@@ -583,6 +583,38 @@ class AssetPicker extends StatelessWidget {
583
583
);
584
584
}
585
585
586
+ /// Animated backdrop widget for items.
587
+ /// 部件选中时的动画遮罩部件
588
+ Widget _selectedBackdrop (
589
+ BuildContext context,
590
+ int index,
591
+ AssetEntity asset,
592
+ ) {
593
+ return Selector <AssetPickerProvider , List <AssetEntity >>(
594
+ selector: (BuildContext _, AssetPickerProvider provider) =>
595
+ provider.selectedAssets,
596
+ builder: (BuildContext _, List <AssetEntity > selectedAssets, Widget __) {
597
+ final bool selected = selectedAssets.contains (asset);
598
+ return Positioned .fill (
599
+ child: GestureDetector (
600
+ onTap: () {
601
+ AssetPickerViewer .pushToViewer (
602
+ context,
603
+ currentIndex: index,
604
+ assets: provider.currentAssets,
605
+ themeData: theme,
606
+ );
607
+ },
608
+ child: AnimatedContainer (
609
+ duration: switchingPathDuration,
610
+ color: selected ? Colors .black45 : Colors .black.withOpacity (0.1 ),
611
+ ),
612
+ ), // 点击预览同目录下所有资源
613
+ );
614
+ },
615
+ );
616
+ }
617
+
586
618
/// Indicator for asset selected status.
587
619
/// 资源是否已选的指示器
588
620
Widget _selectIndicator (
@@ -698,25 +730,8 @@ class AssetPicker extends StatelessWidget {
698
730
return Stack (
699
731
children: < Widget > [
700
732
builder,
701
- Positioned .fill (
702
- child: GestureDetector (
703
- onTap: () {
704
- AssetPickerViewer .pushToViewer (
705
- context,
706
- currentIndex: index,
707
- assets: provider.currentAssets,
708
- themeData: theme,
709
- );
710
- },
711
- child: AnimatedContainer (
712
- duration: switchingPathDuration,
713
- color: selected
714
- ? Colors .black45
715
- : Colors .black.withOpacity (0.1 ),
716
- ),
717
- ), // 点击预览同目录下所有资源
718
- ),
719
- _selectIndicator (asset, provider.selectedAssets),
733
+ _selectedBackdrop (context, index, asset),
734
+ _selectIndicator (asset),
720
735
],
721
736
);
722
737
},
0 commit comments