Skip to content

Commit f63a0e5

Browse files
authored
🐛 Fix bottom actions bar display conditions (#627)
1 parent 9ac6ef8 commit f63a0e5

File tree

4 files changed

+120
-58
lines changed

4 files changed

+120
-58
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ that can be found in the LICENSE file. -->
99
1010
## Unreleased
1111

12-
*None.*
12+
### Fixes
13+
14+
- Fix bottom actions bar display conditions.
1315

1416
## 9.2.2
1517

example/lib/customs/pickers/directory_file_asset_picker.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,7 @@ class FileAssetPickerBuilder
485485
child: Column(
486486
children: <Widget>[
487487
Expanded(child: assetsGridBuilder(context)),
488-
if (!isAppleOS(context))
489-
bottomActionBar(context),
488+
bottomActionBar(context),
490489
],
491490
),
492491
),
@@ -537,11 +536,10 @@ class FileAssetPickerBuilder
537536
Positioned.fill(
538537
child: assetsGridBuilder(context),
539538
),
540-
if (!isSingleAssetMode || isAppleOS(context))
541-
PositionedDirectional(
542-
bottom: 0.0,
543-
child: bottomActionBar(context),
544-
),
539+
PositionedDirectional(
540+
bottom: 0.0,
541+
child: bottomActionBar(context),
542+
),
545543
],
546544
),
547545
),

example/lib/customs/pickers/multi_tabs_assets_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ class MultiTabAssetPickerBuilder extends DefaultAssetPickerBuilderDelegate {
531531
child: Column(
532532
children: <Widget>[
533533
Expanded(child: assetsGridBuilder(context)),
534-
if (isPreviewEnabled) bottomActionBar(context),
534+
bottomActionBar(context),
535535
],
536536
),
537537
),

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 111 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -538,35 +538,44 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
538538
/// Action bar widget aligned to bottom.
539539
/// 底部操作栏部件
540540
Widget bottomActionBar(BuildContext context) {
541-
Widget child = Container(
542-
height: bottomActionBarHeight + context.bottomPadding,
543-
padding: const EdgeInsets.symmetric(horizontal: 20).copyWith(
544-
bottom: context.bottomPadding,
545-
),
546-
color: theme.primaryColor.withOpacity(isAppleOS(context) ? 0.90 : 1),
547-
child: Row(
548-
children: <Widget>[
549-
previewButton(context),
550-
const Spacer(),
551-
confirmButton(context),
552-
],
541+
final children = <Widget>[
542+
if (isPermissionLimited) accessLimitedBottomTip(context),
543+
Container(
544+
height: bottomActionBarHeight + context.bottomPadding,
545+
padding: const EdgeInsets.symmetric(horizontal: 20).copyWith(
546+
bottom: context.bottomPadding,
547+
),
548+
color: theme.bottomAppBarTheme.color?.withOpacity(
549+
theme.bottomAppBarTheme.color!.opacity *
550+
(isAppleOS(context) ? .9 : 1),
551+
),
552+
child: Row(
553+
children: <Widget>[
554+
previewButton(context),
555+
if (!isSingleAssetMode) const Spacer(),
556+
if (!isSingleAssetMode) confirmButton(context),
557+
],
558+
),
553559
),
560+
];
561+
if (children.isEmpty) {
562+
return const SizedBox.shrink();
563+
}
564+
Widget child = Column(
565+
mainAxisSize: MainAxisSize.min,
566+
children: children,
554567
);
555-
if (isPermissionLimited) {
556-
child = Column(
557-
mainAxisSize: MainAxisSize.min,
558-
children: <Widget>[accessLimitedBottomTip(context), child],
568+
if (isAppleOS(context)) {
569+
child = ClipRect(
570+
child: BackdropFilter(
571+
filter: ui.ImageFilter.blur(
572+
sigmaX: appleOSBlurRadius,
573+
sigmaY: appleOSBlurRadius,
574+
),
575+
child: child,
576+
),
559577
);
560578
}
561-
child = ClipRect(
562-
child: BackdropFilter(
563-
filter: ui.ImageFilter.blur(
564-
sigmaX: appleOSBlurRadius,
565-
sigmaY: appleOSBlurRadius,
566-
),
567-
child: child,
568-
),
569-
);
570579
return child;
571580
}
572581

@@ -800,6 +809,9 @@ class DefaultAssetPickerBuilderDelegate
800809
@override
801810
bool get isSingleAssetMode => provider.maxAssets == 1;
802811

812+
/// Whether the bottom actions bar should display.
813+
bool get hasBottomActions => isPreviewEnabled || !isSingleAssetMode;
814+
803815
/// The listener to track the scroll position of the [gridScrollController]
804816
/// if [keepScrollOffset] is true.
805817
/// 当 [keepScrollOffset] 为 true 时,跟踪 [gridScrollController] 位置的监听。
@@ -1086,8 +1098,7 @@ class DefaultAssetPickerBuilderDelegate
10861098
child: Column(
10871099
children: <Widget>[
10881100
Expanded(child: assetsGridBuilder(context)),
1089-
if (isPreviewEnabled || !isSingleAssetMode)
1090-
bottomActionBar(context),
1101+
bottomActionBar(context),
10911102
],
10921103
),
10931104
),
@@ -1113,8 +1124,7 @@ class DefaultAssetPickerBuilderDelegate
11131124
child: Stack(
11141125
children: <Widget>[
11151126
Positioned.fill(child: assetsGridBuilder(context)),
1116-
if (isPreviewEnabled || !isSingleAssetMode)
1117-
Positioned.fill(top: null, child: bottomActionBar(context)),
1127+
Positioned.fill(top: null, child: bottomActionBar(context)),
11181128
],
11191129
),
11201130
),
@@ -2296,29 +2306,81 @@ class DefaultAssetPickerBuilderDelegate
22962306
}
22972307

22982308
@override
2299-
Widget bottomActionBar(BuildContext context) {
2300-
Widget child = Container(
2301-
height: bottomActionBarHeight + context.bottomPadding,
2302-
padding: const EdgeInsets.symmetric(horizontal: 20).copyWith(
2303-
bottom: context.bottomPadding,
2304-
),
2305-
color: theme.bottomAppBarTheme.color?.withOpacity(
2306-
theme.bottomAppBarTheme.color!.opacity * (isAppleOS(context) ? .9 : 1),
2307-
),
2308-
child: Row(
2309-
children: <Widget>[
2310-
if (isPreviewEnabled) previewButton(context),
2311-
if (isPreviewEnabled || !isSingleAssetMode) const Spacer(),
2312-
if (isPreviewEnabled || !isSingleAssetMode) confirmButton(context),
2313-
],
2309+
Widget accessLimitedBottomTip(BuildContext context) {
2310+
final double bottomPadding;
2311+
if (hasBottomActions) {
2312+
bottomPadding = 0;
2313+
} else {
2314+
bottomPadding = MediaQuery.paddingOf(context).bottom;
2315+
}
2316+
return GestureDetector(
2317+
onTap: () {
2318+
Feedback.forTap(context);
2319+
PhotoManager.openSetting();
2320+
},
2321+
child: Container(
2322+
padding: const EdgeInsets.symmetric(horizontal: 10)
2323+
.add(EdgeInsets.only(bottom: bottomPadding)),
2324+
height: permissionLimitedBarHeight + bottomPadding,
2325+
color: theme.primaryColor.withOpacity(isAppleOS(context) ? 0.90 : 1),
2326+
child: Row(
2327+
children: <Widget>[
2328+
const SizedBox(width: 5),
2329+
Icon(
2330+
Icons.warning,
2331+
color: Colors.orange[400]!.withOpacity(.8),
2332+
),
2333+
const SizedBox(width: 15),
2334+
Expanded(
2335+
child: ScaleText(
2336+
textDelegate.accessAllTip,
2337+
style: context.textTheme.bodySmall?.copyWith(
2338+
fontSize: 14,
2339+
),
2340+
semanticsLabel: semanticsTextDelegate.accessAllTip,
2341+
),
2342+
),
2343+
Icon(
2344+
Icons.keyboard_arrow_right,
2345+
color: context.iconTheme.color?.withOpacity(.5),
2346+
),
2347+
],
2348+
),
23142349
),
23152350
);
2316-
if (isPermissionLimited) {
2317-
child = Column(
2318-
mainAxisSize: MainAxisSize.min,
2319-
children: <Widget>[accessLimitedBottomTip(context), child],
2320-
);
2351+
}
2352+
2353+
@override
2354+
Widget bottomActionBar(BuildContext context) {
2355+
final children = <Widget>[
2356+
if (isPermissionLimited) accessLimitedBottomTip(context),
2357+
if (hasBottomActions)
2358+
Container(
2359+
height: bottomActionBarHeight + context.bottomPadding,
2360+
padding: const EdgeInsets.symmetric(horizontal: 20).copyWith(
2361+
bottom: context.bottomPadding,
2362+
),
2363+
color: theme.bottomAppBarTheme.color?.withOpacity(
2364+
theme.bottomAppBarTheme.color!.opacity *
2365+
(isAppleOS(context) ? .9 : 1),
2366+
),
2367+
child: Row(
2368+
children: <Widget>[
2369+
if (isPreviewEnabled) previewButton(context),
2370+
if (isPreviewEnabled || !isSingleAssetMode) const Spacer(),
2371+
if (isPreviewEnabled || !isSingleAssetMode)
2372+
confirmButton(context),
2373+
],
2374+
),
2375+
),
2376+
];
2377+
if (children.isEmpty) {
2378+
return const SizedBox.shrink();
23212379
}
2380+
Widget child = Column(
2381+
mainAxisSize: MainAxisSize.min,
2382+
children: children,
2383+
);
23222384
if (isAppleOS(context)) {
23232385
child = ClipRect(
23242386
child: BackdropFilter(

0 commit comments

Comments
 (0)