Browse Source

Update copies and hook for import & faq on Empty home page (#179)

Neeraj Gupta 1 year ago
parent
commit
dc5cb41f95

+ 1 - 1
lib/l10n/arb/app_en.arb

@@ -77,7 +77,7 @@
   "passwordForDecryptingExport": "Password to decrypt export",
   "passwordForDecryptingExport": "Password to decrypt export",
   "passwordEmptyError": "Password can not be empty",
   "passwordEmptyError": "Password can not be empty",
   "importFromApp": "Import codes from {appName}",
   "importFromApp": "Import codes from {appName}",
-  "importGoogleAuthGuide": "Export your accounts from Google Authenticator to a QR code using the \"Transfer Accounts\" option. Then using another device, scan the QR code.",
+  "importGoogleAuthGuide": "Export your accounts from Google Authenticator to a QR code using the \"Transfer Accounts\" option. Then using another device, scan the QR code.\n\nTip: You can use your laptop's webcam to take a picture of the QR code.",
   "importSelectJsonFile": "Select JSON file",
   "importSelectJsonFile": "Select JSON file",
   "importEnteEncGuide": "Select the encrypted JSON file exported from ente",
   "importEnteEncGuide": "Select the encrypted JSON file exported from ente",
   "importRaivoGuide": "Use the \"Export OTPs to Zip archive\" option in Raivo's Settings.\n\nExtract the zip file and import the JSON file.",
   "importRaivoGuide": "Use the \"Export OTPs to Zip archive\" option in Raivo's Settings.\n\nExtract the zip file and import the JSON file.",

+ 10 - 42
lib/ui/code_widget.dart

@@ -7,6 +7,7 @@ import 'package:ente_auth/models/code.dart';
 import 'package:ente_auth/onboarding/view/setup_enter_secret_key_page.dart';
 import 'package:ente_auth/onboarding/view/setup_enter_secret_key_page.dart';
 import 'package:ente_auth/store/code_store.dart';
 import 'package:ente_auth/store/code_store.dart';
 import 'package:ente_auth/ui/code_timer_progress.dart';
 import 'package:ente_auth/ui/code_timer_progress.dart';
+import 'package:ente_auth/utils/dialog_util.dart';
 import 'package:ente_auth/utils/toast_util.dart';
 import 'package:ente_auth/utils/toast_util.dart';
 import 'package:ente_auth/utils/totp_util.dart';
 import 'package:ente_auth/utils/totp_util.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
@@ -261,50 +262,17 @@ class _CodeWidgetState extends State<CodeWidget> {
     }
     }
   }
   }
 
 
-  void _onDeletePressed(_) {
+  void _onDeletePressed(_) async {
     final l10n = context.l10n;
     final l10n = context.l10n;
-    final AlertDialog alert = AlertDialog(
-      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
-      title: Text(
-        l10n.deleteCodeTitle,
-        style: Theme.of(context).textTheme.headline6,
-      ),
-      content: Text(
-        l10n.deleteCodeMessage,
-      ),
-      actions: [
-        TextButton(
-          child: Text(
-            l10n.delete,
-            style: const TextStyle(
-              color: Colors.red,
-            ),
-          ),
-          onPressed: () {
-            CodeStore.instance.removeCode(widget.code);
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-          },
-        ),
-        TextButton(
-          child: Text(
-            l10n.cancel,
-            style: TextStyle(
-              color: Theme.of(context).colorScheme.onSurface,
-            ),
-          ),
-          onPressed: () {
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-          },
-        ),
-      ],
-    );
-
-    showDialog(
-      context: context,
-      builder: (BuildContext context) {
-        return alert;
+    await showChoiceActionSheet(
+      context,
+      title: l10n.deleteCodeTitle,
+      body: l10n.deleteCodeMessage,
+      firstButtonLabel: l10n.delete,
+      isCritical: true,
+      firstButtonOnTap: () async {
+        await CodeStore.instance.removeCode(widget.code);
       },
       },
-      barrierColor: Colors.black12,
     );
     );
   }
   }
 
 

+ 31 - 0
lib/ui/home/home_empty_state.dart

@@ -1,4 +1,8 @@
 import 'package:ente_auth/l10n/l10n.dart';
 import 'package:ente_auth/l10n/l10n.dart';
+import 'package:ente_auth/theme/ente_theme.dart';
+import 'package:ente_auth/ui/settings/data/import_page.dart';
+import 'package:ente_auth/ui/settings/faq.dart';
+import 'package:ente_auth/utils/navigation_util.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 
 
 class HomeEmptyStateWidget extends StatelessWidget {
 class HomeEmptyStateWidget extends StatelessWidget {
@@ -50,6 +54,33 @@ class HomeEmptyStateWidget extends StatelessWidget {
                       child: Text(l10n.importEnterSetupKey),
                       child: Text(l10n.importEnterSetupKey),
                     ),
                     ),
                   ),
                   ),
+                  const SizedBox(height: 54),
+                  InkWell(
+                    onTap: () {
+                      routeToPage(context, ImportCodePage());
+                    },
+                    child: Text(
+                      l10n.importCodes,
+                      textAlign: TextAlign.center,
+                      style: getEnteTextTheme(context).bodyFaint.copyWith(decoration: TextDecoration.underline),
+                    ),),
+                  const SizedBox(height: 18),
+                  InkWell(
+                    onTap: () {
+                      showModalBottomSheet<void>(
+                        backgroundColor: Theme.of(context).colorScheme.background,
+                        barrierColor: Colors.black87,
+                        context: context,
+                        builder: (context) {
+                          return const FAQQuestionsWidget();
+                        },
+                      );
+                    },
+                    child: Text(
+                      l10n.faq,
+                      textAlign: TextAlign.center,
+                      style: getEnteTextTheme(context).bodyFaint.copyWith(decoration: TextDecoration.underline),
+                    ),),
                 ],
                 ],
               ),
               ),
             ],
             ],

+ 0 - 1
lib/ui/settings/data/data_section_widget.dart

@@ -40,7 +40,6 @@ class DataSectionWidget extends StatelessWidget {
         trailingIconIsMuted: true,
         trailingIconIsMuted: true,
         onTap: () async {
         onTap: () async {
           routeToPage(context, ImportCodePage());
           routeToPage(context, ImportCodePage());
-          // _showImportInstructionDialog(context);
         },
         },
       ),
       ),
       sectionOptionSpacing,
       sectionOptionSpacing,

+ 3 - 1
lib/ui/settings/data/import_page.dart

@@ -59,7 +59,9 @@ class ImportCodePage extends StatelessWidget {
                   iconButtonType: IconButtonType.secondary,
                   iconButtonType: IconButtonType.secondary,
                   onTap: () {
                   onTap: () {
                     Navigator.pop(context);
                     Navigator.pop(context);
-                    Navigator.pop(context);
+                    if(Navigator.canPop(context)) {
+                      Navigator.pop(context);
+                    }
                   },
                   },
                 ),
                 ),
               ],
               ],

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: ente_auth
 name: ente_auth
 description: ente two-factor authenticator
 description: ente two-factor authenticator
-version: 1.0.50+50
+version: 1.0.51+51
 publish_to: none
 publish_to: none
 
 
 environment:
 environment: