@@ -24,6 +24,7 @@ abstract class AssetPickerViewerBuilderDelegate<Asset, Path> {
24
24
this .provider,
25
25
this .selectedAssets,
26
26
this .maxAssets,
27
+ this .shouldReversePreview = false ,
27
28
});
28
29
29
30
/// [ChangeNotifier] for photo selector viewer.
@@ -46,6 +47,14 @@ abstract class AssetPickerViewerBuilderDelegate<Asset, Path> {
46
47
/// 资源选择器的状态保持
47
48
final AssetPickerProvider <Asset , Path >? selectorProvider;
48
49
50
+ /// Whether the preview sequence is reversed.
51
+ /// 预览时顺序是否为反向
52
+ ///
53
+ /// Usually this will be true when users are previewing on Apple OS and
54
+ /// clicked one item of the asset grid.
55
+ /// 通常用户使用苹果系统时,点击网格内容进行预览,是反向进行预览。
56
+ final bool shouldReversePreview;
57
+
49
58
/// [StreamController] for viewing page index update.
50
59
/// 用于更新当前正在浏览的资源页码的流控制器
51
60
///
@@ -308,6 +317,7 @@ class DefaultAssetPickerViewerBuilderDelegate
308
317
this .previewThumbSize,
309
318
this .specialPickerType,
310
319
int ? maxAssets,
320
+ bool shouldReversePreview = false ,
311
321
}) : super (
312
322
currentIndex: currentIndex,
313
323
previewAssets: previewAssets,
@@ -316,6 +326,7 @@ class DefaultAssetPickerViewerBuilderDelegate
316
326
selectedAssets: selectedAssets,
317
327
selectorProvider: selectorProvider,
318
328
maxAssets: maxAssets,
329
+ shouldReversePreview: shouldReversePreview,
319
330
);
320
331
321
332
/// Thumb size for the preview of images in the viewer.
@@ -451,57 +462,55 @@ class DefaultAssetPickerViewerBuilderDelegate
451
462
height: context.bottomPadding + bottomDetailHeight,
452
463
child: child! ,
453
464
),
454
- child: Padding (
455
- padding: EdgeInsetsDirectional .only (bottom: context.bottomPadding),
456
- child: ChangeNotifierProvider <
457
- AssetPickerViewerProvider <AssetEntity >?>.value (
458
- value: provider,
459
- child: Column (
460
- mainAxisSize: MainAxisSize .min,
461
- mainAxisAlignment: MainAxisAlignment .end,
462
- children: < Widget > [
463
- if (provider != null )
464
- ValueListenableBuilder <int >(
465
- valueListenable: selectedNotifier,
466
- builder: (_, int count, __) => Container (
467
- width: count > 0 ? double .maxFinite : 0 ,
468
- height: bottomPreviewHeight,
469
- color: _backgroundColor,
470
- child: ListView .builder (
471
- controller: previewingListController,
472
- scrollDirection: Axis .horizontal,
473
- padding: const EdgeInsets .symmetric (horizontal: 5.0 ),
474
- physics: const ClampingScrollPhysics (),
475
- itemCount: count,
476
- itemBuilder: bottomDetailItemBuilder,
477
- ),
465
+ child:
466
+ ChangeNotifierProvider <AssetPickerViewerProvider <AssetEntity >?>.value (
467
+ value: provider,
468
+ child: Column (
469
+ mainAxisSize: MainAxisSize .min,
470
+ mainAxisAlignment: MainAxisAlignment .end,
471
+ children: < Widget > [
472
+ if (provider != null )
473
+ ValueListenableBuilder <int >(
474
+ valueListenable: selectedNotifier,
475
+ builder: (_, int count, __) => Container (
476
+ width: count > 0 ? double .maxFinite : 0 ,
477
+ height: bottomPreviewHeight,
478
+ color: _backgroundColor,
479
+ child: ListView .builder (
480
+ controller: previewingListController,
481
+ scrollDirection: Axis .horizontal,
482
+ padding: const EdgeInsets .symmetric (horizontal: 5.0 ),
483
+ physics: const ClampingScrollPhysics (),
484
+ itemCount: count,
485
+ itemBuilder: bottomDetailItemBuilder,
478
486
),
479
487
),
480
- Container (
481
- height: bottomBarHeight,
482
- padding: const EdgeInsets .symmetric (horizontal: 20.0 ),
483
- decoration: BoxDecoration (
484
- border: Border (
485
- top: BorderSide (
486
- width: 1.0 ,
487
- color: themeData.canvasColor,
488
- ),
488
+ ),
489
+ Container (
490
+ height: bottomBarHeight + context.bottomPadding,
491
+ padding: const EdgeInsets .symmetric (horizontal: 20.0 )
492
+ .copyWith (bottom: context.bottomPadding),
493
+ decoration: BoxDecoration (
494
+ border: Border (
495
+ top: BorderSide (
496
+ width: 1.0 ,
497
+ color: themeData.canvasColor,
489
498
),
490
- color: _backgroundColor,
491
- ),
492
- child: Row (
493
- mainAxisAlignment: MainAxisAlignment .spaceBetween,
494
- children: < Widget > [
495
- const Spacer (),
496
- if (isAppleOS && (provider != null || isWeChatMoment))
497
- confirmButton (context)
498
- else
499
- selectButton (context),
500
- ],
501
499
),
500
+ color: _backgroundColor,
502
501
),
503
- ],
504
- ),
502
+ child: Row (
503
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
504
+ children: < Widget > [
505
+ const Spacer (),
506
+ if (isAppleOS && (provider != null || isWeChatMoment))
507
+ confirmButton (context)
508
+ else
509
+ selectButton (context),
510
+ ],
511
+ ),
512
+ ),
513
+ ],
505
514
),
506
515
),
507
516
);
@@ -837,7 +846,7 @@ class DefaultAssetPickerViewerBuilderDelegate
837
846
controller: pageController,
838
847
itemCount: previewAssets.length,
839
848
itemBuilder: assetPageBuilder,
840
- reverse: isAppleOS ,
849
+ reverse: shouldReversePreview ,
841
850
onPageChanged: (int index) {
842
851
currentIndex = index;
843
852
pageStreamController.add (index);
0 commit comments