1
1
import 'dart:io' ;
2
2
3
+ import 'package:easy_localization/easy_localization.dart' ;
3
4
import 'package:flutter/material.dart' ;
4
5
import 'package:fluttertoast/fluttertoast.dart' ;
5
6
import 'package:hooks_riverpod/hooks_riverpod.dart' ;
6
7
import 'package:immich_mobile/constants/enums.dart' ;
8
+ import 'package:immich_mobile/extensions/build_context_extensions.dart' ;
7
9
import 'package:immich_mobile/extensions/translate_extensions.dart' ;
8
10
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart' ;
9
11
import 'package:immich_mobile/providers/infrastructure/action.provider.dart' ;
10
12
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart' ;
11
13
import 'package:immich_mobile/widgets/common/immich_toast.dart' ;
12
14
15
+ class _SharePreparingDialog extends StatelessWidget {
16
+ const _SharePreparingDialog ();
17
+
18
+ @override
19
+ Widget build (BuildContext context) {
20
+ return AlertDialog (
21
+ content: Column (
22
+ mainAxisSize: MainAxisSize .min,
23
+ children: [
24
+ const CircularProgressIndicator (),
25
+ Container (margin: const EdgeInsets .only (top: 12 ), child: const Text ('share_dialog_preparing' ).tr ()),
26
+ ],
27
+ ),
28
+ );
29
+ }
30
+ }
31
+
13
32
class ShareActionButton extends ConsumerWidget {
14
33
final ActionSource source;
15
34
@@ -20,28 +39,34 @@ class ShareActionButton extends ConsumerWidget {
20
39
return ;
21
40
}
22
41
23
- final result = await ref.read (actionProvider.notifier).shareAssets (source);
24
- ref.read (multiSelectProvider.notifier).reset ();
42
+ showDialog (
43
+ context: context,
44
+ builder: (BuildContext buildContext) {
45
+ ref.read (actionProvider.notifier).shareAssets (source).then ((ActionResult result) {
46
+ ref.read (multiSelectProvider.notifier).reset ();
25
47
26
- if (! context.mounted) {
27
- return ;
28
- }
48
+ if (! context.mounted) {
49
+ return ;
50
+ }
29
51
30
- if (! result.success) {
31
- ImmichToast .show (
32
- context: context,
33
- msg: 'scaffold_body_error_occurred' .t (context: context),
34
- gravity: ToastGravity .BOTTOM ,
35
- toastType: ToastType .error,
36
- );
37
- } else if (result.count > 0 ) {
38
- ImmichToast .show (
39
- context: context,
40
- msg: 'share_action_prompt' .t (context: context, args: {'count' : result.count.toString ()}),
41
- gravity: ToastGravity .BOTTOM ,
42
- toastType: ToastType .success,
43
- );
44
- }
52
+ if (! result.success) {
53
+ ImmichToast .show (
54
+ context: context,
55
+ msg: 'scaffold_body_error_occurred' .t (context: context),
56
+ gravity: ToastGravity .BOTTOM ,
57
+ toastType: ToastType .error,
58
+ );
59
+ }
60
+
61
+ buildContext.pop ();
62
+ });
63
+
64
+ // show a loading spinner with a "Preparing" message
65
+ return const _SharePreparingDialog ();
66
+ },
67
+ barrierDismissible: false ,
68
+ useRootNavigator: false ,
69
+ );
45
70
}
46
71
47
72
@override
0 commit comments