Parcourir la source

Replaced errorDialogs with new errorDialogs

ashilkn il y a 2 ans
Parent
commit
b23f8f06fe

+ 1 - 1
lib/services/local_authentication_service.dart

@@ -3,9 +3,9 @@
 import 'package:flutter/material.dart';
 import 'package:local_auth/local_auth.dart';
 import 'package:photos/core/configuration.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/tools/app_lock.dart';
 import 'package:photos/utils/auth_util.dart';
-import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/toast_util.dart';
 
 class LocalAuthenticationService {

+ 1 - 1
lib/ui/account/change_email_dialog.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:photos/services/user_service.dart';
-import 'package:photos/utils/dialog_util.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/email_util.dart';
 
 class ChangeEmailDialog extends StatefulWidget {

+ 1 - 0
lib/ui/account/recovery_page.dart

@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
 import 'package:photos/core/configuration.dart';
 import 'package:photos/ui/account/password_entry_page.dart';
 import 'package:photos/ui/common/dynamic_fab.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/toast_util.dart';
 

+ 1 - 0
lib/ui/account/sessions_page.dart

@@ -5,6 +5,7 @@ import 'package:photos/ente_theme_data.dart';
 import 'package:photos/models/sessions.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/common/loading_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/toast_util.dart';

+ 1 - 1
lib/ui/account/two_factor_recovery_page.dart

@@ -2,7 +2,7 @@ import 'dart:ui';
 
 import 'package:flutter/material.dart';
 import 'package:photos/services/user_service.dart';
-import 'package:photos/utils/dialog_util.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 
 class TwoFactorRecoveryPage extends StatefulWidget {
   final String sessionID;

+ 1 - 1
lib/ui/common/rename_dialog.dart

@@ -1,7 +1,7 @@
 // @dart=2.9
 
 import 'package:flutter/material.dart';
-import 'package:photos/utils/dialog_util.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 
 class RenameDialog extends StatefulWidget {
   final String name;

+ 22 - 0
lib/ui/components/dialog_widget.dart

@@ -9,6 +9,28 @@ import 'package:photos/ui/components/button_widget.dart';
 import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/utils/separators_util.dart';
 
+Future<ButtonAction?> showErrorDialog(
+  BuildContext context,
+  String title,
+  String body, {
+  bool isDismissable = true,
+}) async {
+  return showDialogWidget(
+    context: context,
+    title: title,
+    body: body,
+    isDismissible: isDismissable,
+    buttons: const [
+      ButtonWidget(
+        buttonType: ButtonType.secondary,
+        labelText: "OK",
+        isInAlert: true,
+        buttonAction: ButtonAction.first,
+      ),
+    ],
+  );
+}
+
 ///Will return null if dismissed by tapping outside
 Future<ButtonAction?> showGenericErrorDialog({
   required BuildContext context,

+ 1 - 0
lib/ui/viewer/file/detail_page.dart

@@ -8,6 +8,7 @@ import 'package:photos/core/configuration.dart';
 import 'package:photos/core/constants.dart';
 import 'package:photos/core/errors.dart';
 import 'package:photos/models/file.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/tools/editor/image_editor_page.dart';
 import 'package:photos/ui/viewer/file/fading_app_bar.dart';
 import 'package:photos/ui/viewer/file/fading_bottom_bar.dart';

+ 0 - 38
lib/utils/dialog_util.dart

@@ -30,44 +30,6 @@ ProgressDialog createProgressDialog(
   return dialog;
 }
 
-Future<dynamic> showErrorDialog(
-  BuildContext context,
-  String title,
-  String content,
-) {
-  final AlertDialog alert = AlertDialog(
-    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
-    title: title.isEmpty
-        ? const SizedBox.shrink()
-        : Text(
-            title,
-            style: Theme.of(context).textTheme.headline6,
-          ),
-    content: Text(content),
-    actions: [
-      TextButton(
-        child: Text(
-          "Ok",
-          style: TextStyle(
-            color: Theme.of(context).colorScheme.onSurface,
-          ),
-        ),
-        onPressed: () {
-          Navigator.of(context, rootNavigator: true).pop('dialog');
-        },
-      ),
-    ],
-  );
-
-  return showDialog(
-    context: context,
-    builder: (BuildContext context) {
-      return alert;
-    },
-    barrierColor: Colors.black12,
-  );
-}
-
 Future<T> showConfettiDialog<T>({
   @required BuildContext context,
   WidgetBuilder builder,