Unverified Commit 472bbccf authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Fix both platform system chrome definitions (#18808)

parent 43e63721
......@@ -184,7 +184,7 @@ class ContactsDemoState extends State<ContactsDemo> {
new SliverList(
delegate: new SliverChildListDelegate(<Widget>[
new AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
value: SystemUiOverlayStyle.dark,
child: new _ContactCategory(
icon: Icons.call,
children: <Widget>[
......
......@@ -402,7 +402,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
}
home = new AnnotatedRegion<SystemUiOverlayStyle>(
child: home,
value: SystemUiOverlayStyle.dark
value: SystemUiOverlayStyle.light
);
return home;
......
......@@ -478,8 +478,8 @@ class _AppBarState extends State<AppBar> {
}
final Brightness brightness = widget.brightness ?? themeData.primaryColorBrightness;
final SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
? SystemUiOverlayStyle.dark
: SystemUiOverlayStyle.light;
? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark;
return new Semantics(
container: true,
......
......@@ -100,12 +100,12 @@ class SystemUiOverlayStyle {
/// System overlays should be drawn with a light color. Intended for
/// applications with a dark background.
static const SystemUiOverlayStyle light = const SystemUiOverlayStyle(
systemNavigationBarColor: const Color(0xFFFFFFFF),
systemNavigationBarColor: const Color(0xFF000000),
systemNavigationBarDividerColor: null,
statusBarColor: null,
systemNavigationBarIconBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.dark,
);
/// System overlays should be drawn with a dark color. Intended for
......@@ -115,8 +115,8 @@ class SystemUiOverlayStyle {
systemNavigationBarDividerColor: null,
statusBarColor: null,
systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
);
/// Creates a new [SystemUiOverlayStyle].
......@@ -330,5 +330,9 @@ class SystemChrome {
}
static SystemUiOverlayStyle _pendingStyle;
/// The last style that was set using [SystemChrome.setSystemUIOverlayStyle].
@visibleForTesting
static SystemUiOverlayStyle get latestStyle => _latestStyle;
static SystemUiOverlayStyle _latestStyle;
}
......@@ -6,6 +6,7 @@ import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';
......@@ -752,6 +753,47 @@ void main() {
// is fixed.
skip: !Platform.isLinux,
);
testWidgets('NavBar draws a light system bar for a dark background', (WidgetTester tester) async {
await tester.pumpWidget(
new WidgetsApp(
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>(
settings: settings,
builder: (BuildContext context) {
return const CupertinoNavigationBar(
middle: const Text('Test'),
backgroundColor: const Color(0xFF000000),
);
},
);
},
),
);
expect(SystemChrome.latestStyle, SystemUiOverlayStyle.light);
});
testWidgets('NavBar draws a dark system bar for a light background', (WidgetTester tester) async {
await tester.pumpWidget(
new WidgetsApp(
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>(
settings: settings,
builder: (BuildContext context) {
return const CupertinoNavigationBar(
middle: const Text('Test'),
backgroundColor: const Color(0xFFFFFFFF),
);
},
);
},
),
);
expect(SystemChrome.latestStyle, SystemUiOverlayStyle.dark);
});
}
class _ExpectStyles extends StatelessWidget {
......
......@@ -4,6 +4,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';
......@@ -1340,4 +1341,36 @@ void main() {
semantics.dispose();
});
testWidgets('AppBar draws a light system bar for a dark background', (WidgetTester tester) async {
final ThemeData darkTheme = new ThemeData.dark();
await tester.pumpWidget(new MaterialApp(
theme: darkTheme,
home: Scaffold(
appBar: new AppBar(title: const Text('test'))
),
));
expect(darkTheme.primaryColorBrightness, Brightness.dark);
expect(SystemChrome.latestStyle, const SystemUiOverlayStyle(
statusBarBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.light,
));
});
testWidgets('AppBar draws a dark system bar for a light background', (WidgetTester tester) async {
final ThemeData lightTheme = new ThemeData(primaryColor: Colors.white);
await tester.pumpWidget(new MaterialApp(
theme: lightTheme,
home: Scaffold(
appBar: new AppBar(title: const Text('test'))
),
));
expect(lightTheme.primaryColorBrightness, Brightness.light);
expect(SystemChrome.latestStyle, const SystemUiOverlayStyle(
statusBarBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark,
));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment