Skip to content

Commit 0ebd8e0

Browse files
authored
💄 Improve UI details in the AssetPickerAppBar (#400)
Part of #398 is valid, this PR continues from it.
1 parent 596298b commit 0ebd8e0

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ that can be found in the LICENSE file. -->
1010

1111
- Add `index` argument to `selectAsset` in the `AssetPickerBuilderDelegate`. (#399)
1212

13+
### Improvements
14+
15+
- Improve UI details in the `AssetPickerAppBar`. (#400)
16+
1317
## 8.2.0
1418

1519
### New features

lib/src/widget/asset_picker_app_bar.dart

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
9999

100100
@override
101101
Widget build(BuildContext context) {
102-
Widget? titleWidget = title;
102+
final ThemeData theme = Theme.of(context);
103+
final AppBarTheme appBarTheme = theme.appBarTheme;
104+
final IconThemeData iconTheme = this.iconTheme ?? theme.iconTheme;
105+
final Widget? titleWidget;
103106
if (centerTitle) {
104107
titleWidget = Center(child: title);
108+
} else {
109+
titleWidget = title;
105110
}
106111
Widget child = Container(
107112
width: double.maxFinite,
@@ -126,10 +131,7 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
126131
? Alignment.center
127132
: AlignmentDirectional.centerStart,
128133
child: DefaultTextStyle(
129-
style: Theme.of(context)
130-
.textTheme
131-
.headline6!
132-
.copyWith(fontSize: 23.0),
134+
style: theme.textTheme.headline6!.copyWith(fontSize: 23.0),
133135
maxLines: 1,
134136
softWrap: false,
135137
overflow: TextOverflow.ellipsis,
@@ -163,18 +165,26 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
163165
);
164166
}
165167

166-
if (iconTheme != null) {
167-
child = IconTheme.merge(data: iconTheme!, child: child);
168-
}
168+
/// Apply the icon theme data.
169+
child = IconTheme.merge(data: iconTheme, child: child);
170+
171+
final Color effectiveBackgroundColor =
172+
backgroundColor ?? theme.colorScheme.surface;
169173

170174
// Set [SystemUiOverlayStyle] according to the brightness.
171175
final Brightness effectiveBrightness = brightness ??
172-
Theme.of(context).appBarTheme.systemOverlayStyle?.statusBarBrightness ??
173-
Theme.of(context).brightness;
176+
appBarTheme.systemOverlayStyle?.statusBarBrightness ??
177+
theme.brightness;
178+
final bool isDark = effectiveBrightness == Brightness.dark;
179+
final SystemUiOverlayStyle overlayStyle = appBarTheme.systemOverlayStyle ??
180+
SystemUiOverlayStyle(
181+
statusBarColor: effectiveBackgroundColor,
182+
systemNavigationBarIconBrightness: Brightness.light,
183+
statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
184+
statusBarBrightness: isDark ? Brightness.dark : Brightness.light,
185+
);
174186
child = AnnotatedRegion<SystemUiOverlayStyle>(
175-
value: effectiveBrightness == Brightness.dark
176-
? SystemUiOverlayStyle.light
177-
: SystemUiOverlayStyle.dark,
187+
value: overlayStyle,
178188
child: Column(
179189
mainAxisSize: MainAxisSize.min,
180190
children: <Widget>[
@@ -187,7 +197,7 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
187197
final Widget result = Material(
188198
// Wrap to ensure the child rendered correctly
189199
color: Color.lerp(
190-
backgroundColor ?? Theme.of(context).colorScheme.surface,
200+
effectiveBackgroundColor,
191201
Colors.transparent,
192202
blurRadius > 0.0 ? 0.1 : 0.0,
193203
),

0 commit comments

Comments
 (0)