@@ -790,48 +790,55 @@ class DefaultAssetPickerViewerBuilderDelegate
790
790
'Viewer provider must not be null '
791
791
'when the special type is not WeChat moment.' ,
792
792
);
793
+ Future <void > onPressed () async {
794
+ if (isWeChatMoment && hasVideo) {
795
+ Navigator .of (context).pop (< AssetEntity > [currentAsset]);
796
+ return ;
797
+ }
798
+ if (provider! .isSelectedNotEmpty) {
799
+ Navigator .of (context).pop (provider.currentlySelectedAssets);
800
+ return ;
801
+ }
802
+ if (await onChangingSelected (context, currentAsset, false )) {
803
+ Navigator .of (context).pop (
804
+ selectedAssets ?? < AssetEntity > [currentAsset],
805
+ );
806
+ }
807
+ }
808
+
809
+ String buildText () {
810
+ if (isWeChatMoment && hasVideo) {
811
+ return textDelegate.confirm;
812
+ }
813
+ if (provider! .isSelectedNotEmpty) {
814
+ return '${textDelegate .confirm }'
815
+ ' (${provider .currentlySelectedAssets .length }'
816
+ '/'
817
+ '${selectorProvider !.maxAssets })' ;
818
+ }
819
+ return textDelegate.confirm;
820
+ }
821
+
822
+ final bool isButtonEnabled = provider == null ||
823
+ provider.currentlySelectedAssets.isNotEmpty ||
824
+ previewAssets.isEmpty ||
825
+ selectedNotifier.value == 0 ;
793
826
return MaterialButton (
794
- minWidth: () {
795
- if (isWeChatMoment && hasVideo) {
796
- return 48.0 ;
797
- }
798
- return provider! .isSelectedNotEmpty ? 48.0 : 20.0 ;
799
- }(),
800
- height: 32.0 ,
801
- padding: const EdgeInsets .symmetric (horizontal: 12.0 ),
827
+ minWidth:
828
+ (isWeChatMoment && hasVideo) || provider! .isSelectedNotEmpty
829
+ ? 48
830
+ : 20 ,
831
+ height: 32 ,
832
+ padding: const EdgeInsets .symmetric (horizontal: 12 ),
802
833
color: themeData.colorScheme.secondary,
834
+ disabledColor: themeData.dividerColor,
803
835
shape: RoundedRectangleBorder (
804
- borderRadius: BorderRadius .circular (3.0 ),
836
+ borderRadius: BorderRadius .circular (3 ),
805
837
),
806
- onPressed: () async {
807
- if (isWeChatMoment && hasVideo) {
808
- Navigator .of (context).pop (< AssetEntity > [currentAsset]);
809
- return ;
810
- }
811
- if (provider! .isSelectedNotEmpty) {
812
- Navigator .of (context).pop (provider.currentlySelectedAssets);
813
- return ;
814
- }
815
- if (await onChangingSelected (context, currentAsset, false )) {
816
- Navigator .of (context).pop (
817
- selectedAssets ?? < AssetEntity > [currentAsset],
818
- );
819
- }
820
- },
838
+ onPressed: isButtonEnabled ? onPressed : null ,
821
839
materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
822
840
child: ScaleText (
823
- () {
824
- if (isWeChatMoment && hasVideo) {
825
- return textDelegate.confirm;
826
- }
827
- if (provider! .isSelectedNotEmpty) {
828
- return '${textDelegate .confirm }'
829
- ' (${provider .currentlySelectedAssets .length }'
830
- '/'
831
- '${selectorProvider !.maxAssets })' ;
832
- }
833
- return textDelegate.confirm;
834
- }(),
841
+ buildText (),
835
842
style: TextStyle (
836
843
color: themeData.textTheme.bodyText1? .color,
837
844
fontSize: 17 ,
0 commit comments