Skip to content

Commit 4d3ea45

Browse files
💄 Use SystemUiOverlayStyle from the provided theme first (#138)
Co-authored-by: Alex Li <[email protected]>
1 parent fef574b commit 4d3ea45

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

lib/src/constants/extensions.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ import 'package:flutter/material.dart';
66

77
extension BuildContextExtension on BuildContext {
88
MediaQueryData get mediaQuery => MediaQuery.of(this);
9+
910
ThemeData get themeData => Theme.of(this);
1011
}
1112

1213
extension BrightnessExtension on Brightness {
1314
bool get isDark => this == Brightness.dark;
15+
1416
bool get isLight => this == Brightness.light;
1517
}
1618

1719
extension ColorExtension on Color {
1820
bool get isTransparent => this == Colors.transparent;
1921
}
22+
23+
extension ThemeDataExtension on ThemeData {
24+
Brightness get effectiveBrightness => appBarTheme.brightness ?? brightness;
25+
}

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ abstract class AssetPickerBuilderDelegate<A, P> {
9292
/// Return a system ui overlay style according to
9393
/// the brightness of the theme data.
9494
/// 根据主题返回状态栏的明暗样式
95-
SystemUiOverlayStyle get overlayStyle => theme.brightness == Brightness.light
96-
? SystemUiOverlayStyle.dark
97-
: SystemUiOverlayStyle.light;
95+
SystemUiOverlayStyle get overlayStyle =>
96+
theme.appBarTheme.systemOverlayStyle ??
97+
(theme.effectiveBrightness.isDark
98+
? SystemUiOverlayStyle.light
99+
: SystemUiOverlayStyle.dark);
98100

99101
/// Whether the current platform is Apple OS.
100102
/// 当前平台是否苹果系列系统 (iOS & MacOS)

lib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,10 @@ class DefaultAssetPickerViewerBuilderDelegate
756756
child: Theme(
757757
data: themeData,
758758
child: AnnotatedRegion<SystemUiOverlayStyle>(
759-
value: themeData.brightness.isDark
760-
? SystemUiOverlayStyle.light
761-
: SystemUiOverlayStyle.dark,
759+
value: themeData.appBarTheme.systemOverlayStyle ??
760+
(themeData.effectiveBrightness.isDark
761+
? SystemUiOverlayStyle.light
762+
: SystemUiOverlayStyle.dark),
762763
child: Material(
763764
color: Colors.black,
764765
child: Stack(

lib/src/widget/fixed_appbar.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ class FixedAppBar extends StatelessWidget implements PreferredSizeWidget {
146146
);
147147
}
148148

149+
final ThemeData themeData = Theme.of(context);
149150
return AnnotatedRegion<SystemUiOverlayStyle>(
150-
value:
151-
(Theme.of(context).appBarTheme.brightness ?? Brightness.dark).isDark
151+
value: themeData.appBarTheme.systemOverlayStyle ??
152+
(themeData.effectiveBrightness.isDark
152153
? SystemUiOverlayStyle.light
153-
: SystemUiOverlayStyle.dark,
154+
: SystemUiOverlayStyle.dark),
154155
child: Material(
155156
type: color.isTransparent
156157
? MaterialType.transparency

0 commit comments

Comments
 (0)