Skip to content

Commit d58a588

Browse files
committed
šŸ› Fix wrong position for the confirm button on iOS with WeChat Moment mode
1 parent e16efa8 commit d58a588

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

ā€Žlib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -405,39 +405,39 @@ class DefaultAssetPickerViewerBuilderDelegate
405405
return ValueListenableBuilder2<bool, int>(
406406
firstNotifier: isDisplayingDetail,
407407
secondNotifier: selectedNotifier,
408-
builder: (_, bool value, int count, Widget? child) =>
409-
AnimatedPositionedDirectional(
408+
builder: (_, bool v, __, Widget? child) => AnimatedPositionedDirectional(
410409
duration: kThemeAnimationDuration,
411410
curve: Curves.easeInOut,
412-
bottom: value ? 0.0 : -(Screens.bottomSafeHeight + bottomDetailHeight),
413-
start: 0.0,
414-
end: 0.0,
411+
bottom: v ? 0 : -(Screens.bottomSafeHeight + bottomDetailHeight),
412+
start: 0,
413+
end: 0,
415414
height: Screens.bottomSafeHeight + bottomDetailHeight,
416415
child: child!,
417416
),
418-
child: Container(
417+
child: Padding(
419418
padding: EdgeInsetsDirectional.only(bottom: Screens.bottomSafeHeight),
420419
child: ChangeNotifierProvider<
421-
AssetPickerViewerProvider<AssetEntity>>.value(
422-
value: provider!,
420+
AssetPickerViewerProvider<AssetEntity>?>.value(
421+
value: provider,
423422
child: Column(
424423
mainAxisSize: MainAxisSize.min,
425424
mainAxisAlignment: MainAxisAlignment.end,
426425
children: <Widget>[
427-
ValueListenableBuilder<int>(
428-
valueListenable: selectedNotifier,
429-
builder: (_, int count, __) => Container(
430-
width: count > 0 ? double.maxFinite : 0,
431-
height: 90,
432-
color: _backgroundColor,
433-
child: ListView.builder(
434-
scrollDirection: Axis.horizontal,
435-
padding: const EdgeInsets.symmetric(horizontal: 5.0),
436-
itemCount: count,
437-
itemBuilder: bottomDetailItemBuilder,
426+
if (provider != null)
427+
ValueListenableBuilder<int>(
428+
valueListenable: selectedNotifier,
429+
builder: (_, int count, __) => Container(
430+
width: count > 0 ? double.maxFinite : 0,
431+
height: 90,
432+
color: _backgroundColor,
433+
child: ListView.builder(
434+
scrollDirection: Axis.horizontal,
435+
padding: const EdgeInsets.symmetric(horizontal: 5.0),
436+
itemCount: count,
437+
itemBuilder: bottomDetailItemBuilder,
438+
),
438439
),
439440
),
440-
),
441441
Container(
442442
height: 50,
443443
padding: const EdgeInsets.symmetric(horizontal: 20.0),
@@ -454,7 +454,7 @@ class DefaultAssetPickerViewerBuilderDelegate
454454
mainAxisAlignment: MainAxisAlignment.spaceBetween,
455455
children: <Widget>[
456456
const Spacer(),
457-
if (isAppleOS && provider != null)
457+
if (isAppleOS && (provider != null || isWeChatMoment))
458458
confirmButton(context)
459459
else
460460
selectButton(context),
@@ -498,18 +498,18 @@ class DefaultAssetPickerViewerBuilderDelegate
498498
pageController.jumpToPage(index);
499499
}
500500
},
501-
child: Selector<AssetPickerViewerProvider<AssetEntity>,
502-
List<AssetEntity>>(
503-
selector: (_, AssetPickerViewerProvider<AssetEntity> p) =>
504-
p.currentlySelectedAssets,
501+
child: Selector<AssetPickerViewerProvider<AssetEntity>?,
502+
List<AssetEntity>?>(
503+
selector: (_, AssetPickerViewerProvider<AssetEntity>? p) =>
504+
p?.currentlySelectedAssets,
505505
child: _item,
506506
builder: (
507507
_,
508-
List<AssetEntity> currentlySelectedAssets,
508+
List<AssetEntity>? currentlySelectedAssets,
509509
Widget? w,
510510
) {
511511
final bool isSelected =
512-
currentlySelectedAssets.contains(asset);
512+
currentlySelectedAssets?.contains(asset) ?? false;
513513
return Stack(
514514
children: <Widget>[
515515
w!,
@@ -578,7 +578,7 @@ class DefaultAssetPickerViewerBuilderDelegate
578578
),
579579
const Spacer(),
580580
if (isAppleOS && provider != null) selectButton(context),
581-
if (!isAppleOS && provider != null || isWeChatMoment)
581+
if (!isAppleOS && (provider != null || isWeChatMoment))
582582
confirmButton(context),
583583
],
584584
),

0 commit comments

Comments
Ā (0)