Skip to content

Commit 4b0380e

Browse files
authored
🐛 Fix AssetPickerAppBar (#520)
- Fix unhandled child semantics with the app bar title. - Fix styles around the app bar and other widgets.
1 parent ec7adc1 commit 4b0380e

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ that can be found in the LICENSE file. -->
44

55
# Changelog
66

7-
See the [Migration Guide](guides/migration_guide.md) for the details of breaking changes between versions.
7+
> [!IMPORTANT]
8+
> See the [Migration Guide](guides/migration_guide.md) for the details of breaking changes between versions.
9+
10+
## 9.0.0-dev.2
11+
12+
### Fixes
13+
14+
- Fix unhandled child semantics with the app bar title.
15+
- Fix styles around the app bar and other widgets.
816

917
## 9.0.0-dev.1
1018

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,6 @@ class DefaultAssetPickerBuilderDelegate
929929
@override
930930
AssetPickerAppBar appBar(BuildContext context) {
931931
final AssetPickerAppBar appBar = AssetPickerAppBar(
932-
backgroundColor: theme.appBarTheme.backgroundColor,
933932
title: Semantics(
934933
onTapHint: semanticsTextDelegate.sActionSwitchPathLabel,
935934
child: pathEntitySelector(context),

lib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ class DefaultAssetPickerViewerBuilderDelegate
948948
? SystemUiOverlayStyle.light
949949
: SystemUiOverlayStyle.dark),
950950
child: Material(
951-
color: themeData.colorScheme.onSecondary,
951+
color: themeData.scaffoldBackgroundColor,
952952
child: Stack(
953953
children: <Widget>[
954954
Positioned.fill(child: _pageViewBuilder(context)),

lib/src/widget/asset_picker_app_bar.dart

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
102102
@override
103103
Widget build(BuildContext context) {
104104
final ThemeData theme = Theme.of(context);
105+
final AppBarTheme appBarTheme = theme.appBarTheme;
106+
105107
final Widget? titleWidget;
106108
if (centerTitle) {
107109
titleWidget = Center(child: title);
@@ -118,7 +120,10 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
118120
PositionedDirectional(
119121
top: 0.0,
120122
bottom: 0.0,
121-
child: leading ?? const BackButton(),
123+
child: IconTheme.merge(
124+
data: appBarTheme.iconTheme ?? theme.iconTheme,
125+
child: leading ?? const BackButton(),
126+
),
122127
),
123128
if (titleWidget != null)
124129
PositionedDirectional(
@@ -131,7 +136,8 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
131136
? Alignment.center
132137
: AlignmentDirectional.centerStart,
133138
child: DefaultTextStyle(
134-
style: theme.textTheme.titleLarge!.copyWith(fontSize: 23.0),
139+
style: appBarTheme.titleTextStyle ??
140+
theme.textTheme.titleLarge!.copyWith(fontSize: 23.0),
135141
maxLines: 1,
136142
softWrap: false,
137143
overflow: TextOverflow.ellipsis,
@@ -146,9 +152,15 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
146152
top: 0.0,
147153
end: 0.0,
148154
height: _barHeight,
149-
child: Padding(
150-
padding: actionsPadding ?? EdgeInsets.zero,
151-
child: Row(mainAxisSize: MainAxisSize.min, children: actions!),
155+
child: IconTheme.merge(
156+
data: appBarTheme.actionsIconTheme ?? theme.iconTheme,
157+
child: Padding(
158+
padding: actionsPadding ?? EdgeInsets.zero,
159+
child: Row(
160+
mainAxisSize: MainAxisSize.min,
161+
children: actions!,
162+
),
163+
),
152164
),
153165
),
154166
],
@@ -172,20 +184,19 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
172184
);
173185
}
174186

175-
final AppBarTheme appBarTheme = theme.appBarTheme;
176-
177187
/// Apply the icon theme data.
178188
child = IconTheme.merge(
179189
data: iconTheme ?? appBarTheme.iconTheme ?? theme.iconTheme,
180190
child: child,
181191
);
182192

183193
// Set [SystemUiOverlayStyle] according to the brightness.
194+
final Color effectiveBackgroundColor = backgroundColor ??
195+
appBarTheme.backgroundColor ??
196+
theme.colorScheme.surface;
184197
final Brightness effectiveBrightness = brightness ??
185198
appBarTheme.systemOverlayStyle?.statusBarBrightness ??
186199
theme.brightness;
187-
final Color effectiveBackgroundColor =
188-
backgroundColor ?? theme.colorScheme.surface;
189200
final SystemUiOverlayStyle overlayStyle = appBarTheme.systemOverlayStyle ??
190201
SystemUiOverlayStyle(
191202
statusBarColor: effectiveBackgroundColor,
@@ -199,7 +210,7 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
199210
);
200211

201212
final Widget result = Material(
202-
// Wrap to ensure the child rendered correctly
213+
// Wrap to ensure the child rendered correctly.
203214
color: Color.lerp(
204215
effectiveBackgroundColor,
205216
Colors.transparent,
@@ -209,7 +220,11 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
209220
child: child,
210221
);
211222
return semanticsBuilder?.call(result) ??
212-
Semantics(sortKey: const OrdinalSortKey(0), child: result);
223+
Semantics(
224+
sortKey: const OrdinalSortKey(0),
225+
explicitChildNodes: true,
226+
child: result,
227+
);
213228
}
214229
}
215230

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: wechat_assets_picker
2-
version: 9.0.0-dev.1
2+
version: 9.0.0-dev.2
33
description: |
44
An image picker (also with videos and audio)
55
for Flutter projects based on WeChat's UI,

0 commit comments

Comments
 (0)