Browse Source

Update file-download-disabling flow

vishnukvmd 3 năm trước cách đây
mục cha
commit
e27321115d
2 tập tin đã thay đổi với 24 bổ sung3 xóa
  1. 5 3
      lib/ui/common/dialogs.dart
  2. 19 0
      lib/ui/manage_links_widget.dart

+ 5 - 3
lib/ui/common/dialogs.dart

@@ -13,7 +13,9 @@ Future<T> showChoiceDialog<T>(
   String title,
   String content, {
   String firstAction = 'ok',
+  Color firstActionColor,
   String secondAction = 'cancel',
+  Color secondActionColor,
   ActionType actionType = ActionType.confirm,
 }) {
   AlertDialog alert = AlertDialog(
@@ -34,8 +36,8 @@ Future<T> showChoiceDialog<T>(
         child: Text(
           firstAction,
           style: TextStyle(
-            color:
-                actionType == ActionType.critical ? Colors.red : Colors.white,
+            color: firstActionColor ??
+                (actionType == ActionType.critical ? Colors.red : Colors.white),
           ),
         ),
         onPressed: () {
@@ -47,7 +49,7 @@ Future<T> showChoiceDialog<T>(
         child: Text(
           secondAction,
           style: TextStyle(
-            color: Theme.of(context).buttonColor,
+            color: secondActionColor ?? Theme.of(context).buttonColor,
           ),
         ),
         onPressed: () {

+ 19 - 0
lib/ui/manage_links_widget.dart

@@ -8,6 +8,7 @@ import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
 import 'package:flutter_sodium/flutter_sodium.dart';
 import 'package:photos/models/collection.dart';
 import 'package:photos/services/collections_service.dart';
+import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/widget_theme.dart';
 import 'package:photos/ui/settings/settings_text_item.dart';
 import 'package:photos/utils/crypto_util.dart';
@@ -136,8 +137,26 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                                   ?.enableDownload ??
                               true,
                           onChanged: (value) async {
+                            if (!value) {
+                              final choice = await showChoiceDialog(
+                                context,
+                                'disable downloads',
+                                'are you sure that you want to disable the download button for files?',
+                                firstAction: 'no',
+                                secondAction: 'yes',
+                                firstActionColor: Theme.of(context).buttonColor,
+                                secondActionColor: Colors.white,
+                              );
+                              if (choice != DialogUserChoice.secondChoice) {
+                                return;
+                              }
+                            }
                             await _updateUrlSettings(
                                 context, {'enableDownload': value});
+                            if (!value) {
+                              showErrorDialog(context, "please note",
+                                  "viewers can still take screenshots or save a copy of your photos using external tools");
+                            }
                             setState(() {});
                           },
                         ),