Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
57322195
Unverified
Commit
57322195
authored
May 10, 2018
by
Jonah Williams
Committed by
GitHub
May 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend SystemUiOverlayStyle with additonal values for each platform (#17171)
parent
f48dec57
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
29 deletions
+155
-29
nav_bar.dart
packages/flutter/lib/src/cupertino/nav_bar.dart
+12
-3
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+11
-3
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+2
-14
system_chrome.dart
packages/flutter/lib/src/services/system_chrome.dart
+130
-9
No files found.
packages/flutter/lib/src/cupertino/nav_bar.dart
View file @
57322195
...
...
@@ -294,9 +294,18 @@ Widget _wrapWithBackground({
);
final
bool
darkBackground
=
backgroundColor
.
computeLuminance
()
<
0.179
;
SystemChrome
.
setSystemUIOverlayStyle
(
darkBackground
?
SystemUiOverlayStyle
.
light
:
SystemUiOverlayStyle
.
dark
);
// TODO(jonahwilliams): remove once we have platform themes.
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
SystemChrome
.
setSystemUIOverlayStyle
(
darkBackground
?
SystemUiOverlayStyle
.
light
:
SystemUiOverlayStyle
.
dark
);
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
SystemChrome
.
setSystemUIOverlayStyle
(
SystemUiOverlayStyle
.
dark
);
}
if
(
backgroundColor
.
alpha
==
0xFF
)
return
childWithBackground
;
...
...
packages/flutter/lib/src/material/app_bar.dart
View file @
57322195
...
...
@@ -346,9 +346,17 @@ class _AppBarState extends State<AppBar> {
TextStyle
sideStyle
=
widget
.
textTheme
?.
body1
??
themeData
.
primaryTextTheme
.
body1
;
final
Brightness
brightness
=
widget
.
brightness
??
themeData
.
primaryColorBrightness
;
SystemChrome
.
setSystemUIOverlayStyle
(
brightness
==
Brightness
.
dark
?
SystemUiOverlayStyle
.
light
:
SystemUiOverlayStyle
.
dark
);
// TODO(jonahwilliams): remove once we have platform themes.
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
SystemChrome
.
setSystemUIOverlayStyle
(
brightness
==
Brightness
.
dark
?
SystemUiOverlayStyle
.
light
:
SystemUiOverlayStyle
.
dark
);
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
SystemChrome
.
setSystemUIOverlayStyle
(
SystemUiOverlayStyle
.
dark
);
}
if
(
widget
.
toolbarOpacity
!=
1.0
)
{
final
double
opacity
=
const
Interval
(
0.25
,
1.0
,
curve:
Curves
.
fastOutSlowIn
).
transform
(
widget
.
toolbarOpacity
);
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
57322195
...
...
@@ -5,6 +5,7 @@
import
'dart:ui'
show
Color
,
hashValues
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button_theme.dart'
;
...
...
@@ -16,20 +17,7 @@ import 'input_decorator.dart';
import
'slider_theme.dart'
;
import
'typography.dart'
;
/// Describes the contrast needs of a color.
enum
Brightness
{
/// The color is dark and will require a light text color to achieve readable
/// contrast.
///
/// For example, the color might be dark grey, requiring white text.
dark
,
/// The color is light and will require a dark text color to achieve readable
/// contrast.
///
/// For example, the color might be bright white, requiring black text.
light
,
}
export
'package:flutter/services.dart'
show
Brightness
;
// Deriving these values is black magic. The spec claims that pressed buttons
// have a highlight of 0x66999999, but that's clearly wrong. The videos in the
...
...
packages/flutter/lib/src/services/system_chrome.dart
View file @
57322195
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:ui'
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -77,17 +78,142 @@ enum SystemUiOverlay {
bottom
,
}
/// Describes the contrast needs of a color.
enum
Brightness
{
/// The color is dark and will require a light text color to achieve readable
/// contrast.
///
/// For example, the color might be dark grey, requiring white text.
dark
,
/// The color is light and will require a dark text color to achieve readable
/// contrast.
///
/// For example, the color might be bright white, requiring black text.
light
,
}
/// Specifies a preference for the style of the system overlays.
///
/// Used by [SystemChrome.setSystemUIOverlayStyle].
enum
SystemUiOverlayStyle
{
class
SystemUiOverlayStyle
{
/// System overlays should be drawn with a light color. Intended for
/// applications with a dark background.
light
,
static
const
SystemUiOverlayStyle
light
=
const
SystemUiOverlayStyle
(
systemNavigationBarColor:
const
Color
(
0xFFFFFFFF
),
systemNavigationBarDividerColor:
null
,
statusBarColor:
null
,
systemNavigationBarIconBrightness:
Brightness
.
dark
,
statusBarIconBrightness:
Brightness
.
dark
,
statusBarBrightness:
Brightness
.
dark
,
);
/// System overlays should be drawn with a dark color. Intended for
/// applications with a light background.
dark
,
static
const
SystemUiOverlayStyle
dark
=
const
SystemUiOverlayStyle
(
systemNavigationBarColor:
const
Color
(
0xFF000000
),
systemNavigationBarDividerColor:
null
,
statusBarColor:
null
,
systemNavigationBarIconBrightness:
Brightness
.
light
,
statusBarIconBrightness:
Brightness
.
light
,
statusBarBrightness:
Brightness
.
light
,
);
/// Creates a new [SystemUiOverlayStyle].
const
SystemUiOverlayStyle
({
this
.
systemNavigationBarColor
,
this
.
systemNavigationBarDividerColor
,
this
.
systemNavigationBarIconBrightness
,
this
.
statusBarColor
,
this
.
statusBarBrightness
,
this
.
statusBarIconBrightness
,
});
/// The color of the system bottom navigation bar.
///
/// Only honored in Android versions O and greater.
final
Color
systemNavigationBarColor
;
/// The color of the divider between the system's bottom navigation bar and the app's content.
///
/// Only honored in Android versions P and greater.
final
Color
systemNavigationBarDividerColor
;
/// The brightness of the system navigation bar icons.
///
/// Only honored in Android versions O and greater.
final
Brightness
systemNavigationBarIconBrightness
;
/// The color of top status bar.
///
/// Only honored in Android version M and greater.
final
Color
statusBarColor
;
/// The brightness of top status bar.
///
/// Only honored in iOS .
final
Brightness
statusBarBrightness
;
/// The brightness of the top status bar icons.
///
/// Only honored in Android version M and greater.
final
Brightness
statusBarIconBrightness
;
/// Convert this event to a map for serialization.
Map
<
String
,
dynamic
>
_toMap
()
{
return
<
String
,
dynamic
>{
'systemNavigationBarColor'
:
systemNavigationBarColor
?.
value
,
'systemNavigationBarDividerColor'
:
systemNavigationBarDividerColor
?.
value
,
'statusBarColor'
:
statusBarColor
?.
value
,
'statusBarBrightness'
:
statusBarBrightness
?.
toString
(),
'statusBarIconBrightness'
:
statusBarIconBrightness
?.
toString
(),
'systemNavigationBarIconBrightness'
:
systemNavigationBarIconBrightness
?.
toString
(),
};
}
/// Creates a copy of this theme with the given fields replaced with new values.
SystemUiOverlayStyle
copyWith
({
Color
systemNavigationBarColor
,
Color
systemNavigationBarDividerColor
,
Color
statusBarColor
,
Brightness
statusBarBrightness
,
Brightness
statusBarIconBrightness
,
Brightness
systemNavigationBarIconBrightness
,
})
{
return
new
SystemUiOverlayStyle
(
systemNavigationBarColor:
systemNavigationBarColor
??
this
.
systemNavigationBarColor
,
systemNavigationBarDividerColor:
systemNavigationBarDividerColor
??
this
.
systemNavigationBarDividerColor
,
statusBarColor:
statusBarColor
??
this
.
statusBarColor
,
statusBarIconBrightness:
statusBarIconBrightness
??
this
.
statusBarIconBrightness
,
statusBarBrightness:
statusBarBrightness
??
this
.
statusBarBrightness
,
systemNavigationBarIconBrightness:
systemNavigationBarIconBrightness
??
this
.
systemNavigationBarIconBrightness
,
);
}
@override
int
get
hashCode
{
return
hashValues
(
systemNavigationBarColor
,
systemNavigationBarDividerColor
,
statusBarColor
,
statusBarBrightness
,
statusBarIconBrightness
,
systemNavigationBarIconBrightness
,
);
}
@override
bool
operator
==(
dynamic
other
)
{
if
(
other
.
runtimeType
!=
runtimeType
)
return
false
;
final
SystemUiOverlayStyle
typedOther
=
other
;
return
typedOther
.
systemNavigationBarColor
==
systemNavigationBarColor
&&
typedOther
.
systemNavigationBarDividerColor
==
systemNavigationBarDividerColor
&&
typedOther
.
statusBarColor
==
statusBarColor
&&
typedOther
.
statusBarIconBrightness
==
statusBarIconBrightness
&&
typedOther
.
statusBarBrightness
==
statusBarBrightness
&&
typedOther
.
systemNavigationBarIconBrightness
==
systemNavigationBarIconBrightness
;
}
}
List
<
String
>
_stringify
(
List
<
dynamic
>
list
)
{
...
...
@@ -193,14 +319,9 @@ class SystemChrome {
scheduleMicrotask
(()
{
assert
(
_pendingStyle
!=
null
);
if
(
_pendingStyle
!=
_latestStyle
)
{
// TODO(jonahwilliams): remove when rolling chrome change.
SystemChannels
.
platform
.
invokeMethod
(
'SystemChrome.setSystemUIOverlayStyle'
,
<
String
,
dynamic
>{
'statusBarBrightness'
:
_pendingStyle
==
SystemUiOverlayStyle
.
light
?
'Brightness.light'
:
'Brightness.dark'
,
}
_pendingStyle
.
_toMap
(),
);
_latestStyle
=
_pendingStyle
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment