Skip to content

Commit d580c6a

Browse files
committed
🎨 Update callers to avoid deprecated usage
1 parent f07fb69 commit d580c6a

File tree

6 files changed

+65
-56
lines changed

6 files changed

+65
-56
lines changed

example/lib/customs/pickers/directory_file_asset_picker.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class FileAssetPickerBuilder
469469
@override
470470
PreferredSizeWidget appBar(BuildContext context) {
471471
return AppBar(
472-
backgroundColor: theme.appBarTheme.color,
472+
backgroundColor: theme.appBarTheme.backgroundColor,
473473
centerTitle: isAppleOS,
474474
title: pathEntitySelector(context),
475475
leading: backButton(context),
@@ -1359,7 +1359,8 @@ class FileAssetPickerViewerBuilderDelegate
13591359
return AnimatedPositioned(
13601360
duration: kThemeAnimationDuration,
13611361
curve: Curves.easeInOut,
1362-
top: _isDisplayingDetail ? 0.0 : -(Screens.topSafeHeight + kToolbarHeight),
1362+
top:
1363+
_isDisplayingDetail ? 0.0 : -(Screens.topSafeHeight + kToolbarHeight),
13631364
left: 0.0,
13641365
right: 0.0,
13651366
height: Screens.topSafeHeight + kToolbarHeight,
@@ -1543,7 +1544,7 @@ class FileAssetPickerViewerBuilderDelegate
15431544
border: !isSelected
15441545
? Border.all(color: themeData.iconTheme.color!)
15451546
: null,
1546-
color: isSelected ? themeData.buttonColor : null,
1547+
color: isSelected ? themeData.colorScheme.secondary : null,
15471548
shape: BoxShape.circle,
15481549
),
15491550
child: Center(

lib/src/constants/extensions.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ extension ColorExtension on Color {
2727
}
2828

2929
extension ThemeDataExtension on ThemeData {
30-
Brightness get effectiveBrightness => appBarTheme.brightness ?? brightness;
30+
Brightness get effectiveBrightness =>
31+
appBarTheme.systemOverlayStyle?.statusBarBrightness ?? brightness;
3132
}

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ class DefaultAssetPickerBuilderDelegate
759759
@override
760760
PreferredSizeWidget appBar(BuildContext context) {
761761
return FixedAppBar(
762-
backgroundColor: theme.appBarTheme.color,
762+
backgroundColor: theme.appBarTheme.backgroundColor,
763763
centerTitle: isAppleOS,
764764
title: pathEntitySelector(context),
765765
leading: backButton(context),
@@ -787,34 +787,38 @@ class DefaultAssetPickerBuilderDelegate
787787
child: Selector<DefaultAssetPickerProvider, bool>(
788788
selector: (_, DefaultAssetPickerProvider p) => p.hasAssetsToDisplay,
789789
builder: (_, bool hasAssetsToDisplay, __) {
790+
final Widget _child;
790791
final bool shouldDisplayAssets = hasAssetsToDisplay ||
791792
(allowSpecialItemWhenEmpty &&
792793
specialItemPosition != SpecialItemPosition.none);
793-
return AnimatedSwitcher(
794-
duration: switchingPathDuration,
795-
child: shouldDisplayAssets
796-
? Stack(
794+
if (shouldDisplayAssets) {
795+
_child = Stack(
796+
children: <Widget>[
797+
RepaintBoundary(
798+
child: Stack(
797799
children: <Widget>[
798-
RepaintBoundary(
799-
child: Stack(
800-
children: <Widget>[
801-
Positioned.fill(
802-
child: assetsGridBuilder(context),
803-
),
804-
if ((!isSingleAssetMode || isAppleOS) &&
805-
isPreviewEnabled)
806-
Positioned.fill(
807-
top: null,
808-
child: bottomActionBar(context),
809-
),
810-
],
811-
),
800+
Positioned.fill(
801+
child: assetsGridBuilder(context),
812802
),
813-
pathEntityListBackdrop(context),
814-
pathEntityListWidget(context),
803+
if ((!isSingleAssetMode || isAppleOS) &&
804+
isPreviewEnabled)
805+
Positioned.fill(
806+
top: null,
807+
child: bottomActionBar(context),
808+
),
815809
],
816-
)
817-
: loadingIndicator(context),
810+
),
811+
),
812+
pathEntityListBackdrop(context),
813+
pathEntityListWidget(context),
814+
],
815+
);
816+
} else {
817+
_child = loadingIndicator(context);
818+
}
819+
return AnimatedSwitcher(
820+
duration: switchingPathDuration,
821+
child: _child,
818822
);
819823
},
820824
),
@@ -926,29 +930,31 @@ class DefaultAssetPickerBuilderDelegate
926930
child: ColoredBox(
927931
color: theme.canvasColor,
928932
child: Selector<DefaultAssetPickerProvider, List<AssetEntity>>(
929-
selector: (_, DefaultAssetPickerProvider provider) =>
930-
provider.currentAssets,
931-
builder: (_, List<AssetEntity> assets, __) =>
932-
CustomScrollView(
933-
physics: const AlwaysScrollableScrollPhysics(),
934-
controller: gridScrollController,
935-
anchor: isAppleOS ? anchor : 0,
936-
center: isAppleOS ? gridRevertKey : null,
937-
slivers: <Widget>[
938-
if (isAppleOS)
939-
SliverGap.v(context.topPadding + kToolbarHeight),
940-
_sliverGrid(_, assets),
941-
// Ignore the gap when the [anchor] is not equal to 1.
942-
if (isAppleOS && anchor == 1)
943-
SliverGap.v(
944-
context.bottomPadding + bottomSectionHeight),
945-
if (isAppleOS)
946-
SliverToBoxAdapter(
947-
key: gridRevertKey,
948-
child: const SizedBox.shrink(),
949-
),
950-
],
951-
),
933+
selector: (_, DefaultAssetPickerProvider p) =>
934+
p.currentAssets,
935+
builder: (_, List<AssetEntity> assets, __) {
936+
return CustomScrollView(
937+
physics: const AlwaysScrollableScrollPhysics(),
938+
controller: gridScrollController,
939+
anchor: isAppleOS ? anchor : 0,
940+
center: isAppleOS ? gridRevertKey : null,
941+
slivers: <Widget>[
942+
if (isAppleOS)
943+
SliverGap.v(context.topPadding + kToolbarHeight),
944+
_sliverGrid(_, assets),
945+
// Ignore the gap when the [anchor] is not equal to 1.
946+
if (isAppleOS && anchor == 1)
947+
SliverGap.v(
948+
context.bottomPadding + bottomSectionHeight,
949+
),
950+
if (isAppleOS)
951+
SliverToBoxAdapter(
952+
key: gridRevertKey,
953+
child: const SizedBox.shrink(),
954+
),
955+
],
956+
);
957+
},
952958
),
953959
),
954960
);

lib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ class DefaultAssetPickerViewerBuilderDelegate
754754
border: !isSelected
755755
? Border.all(color: themeData.iconTheme.color!)
756756
: null,
757-
color: isSelected ? themeData.buttonColor : null,
757+
color: isSelected ? themeData.colorScheme.secondary : null,
758758
shape: BoxShape.circle,
759759
),
760760
child: const Center(child: Icon(Icons.check, size: 20.0)),

lib/src/widget/asset_picker.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,10 @@ class AssetPicker<Asset, Path> extends StatefulWidget {
194194
/// 通过主题色构建一个默认的暗黑主题
195195
static ThemeData themeData(Color themeColor) {
196196
return ThemeData.dark().copyWith(
197-
buttonColor: themeColor,
198197
primaryColor: Colors.grey[900],
199198
primaryColorBrightness: Brightness.dark,
200199
primaryColorLight: Colors.grey[900],
201200
primaryColorDark: Colors.grey[900],
202-
accentColor: themeColor,
203-
accentColorBrightness: Brightness.dark,
204201
canvasColor: Colors.grey[850],
205202
scaffoldBackgroundColor: Colors.grey[900],
206203
bottomAppBarColor: Colors.grey[900],
@@ -214,9 +211,13 @@ class AssetPicker<Asset, Path> extends StatefulWidget {
214211
),
215212
indicatorColor: themeColor,
216213
appBarTheme: const AppBarTheme(
217-
brightness: Brightness.dark,
214+
systemOverlayStyle: SystemUiOverlayStyle(
215+
statusBarBrightness: Brightness.dark,
216+
statusBarIconBrightness: Brightness.light,
217+
),
218218
elevation: 0,
219219
),
220+
buttonTheme: ButtonThemeData(buttonColor: themeColor),
220221
colorScheme: ColorScheme(
221222
primary: Colors.grey[900]!,
222223
primaryVariant: Colors.grey[900]!,

lib/src/widget/fixed_appbar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class FixedAppBar extends StatelessWidget implements PreferredSizeWidget {
157157
? MaterialType.transparency
158158
: MaterialType.canvas,
159159
color: (backgroundColor ??
160-
context.themeData.appBarTheme.color ??
160+
context.themeData.appBarTheme.backgroundColor ??
161161
context.themeData.primaryColor)
162162
.withOpacity(blurRadius > 0.0 ? 0.90 : 1.0),
163163
elevation: elevation ?? context.themeData.appBarTheme.elevation ?? 4.0,

0 commit comments

Comments
 (0)