diff --git a/assets/translations/en.json b/assets/translations/en.json index 0cca1e45d0b08a1eb9df2dedd5f43ae098f9c854..7d390b09c7c839446afa95344a53f0e2dfa634cb 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -200,5 +200,14 @@ "share_export_desc": "Your wallet has been exported locally. Would you like to additionally share it with yourself via email/chat/etc. for safekeeping?", "share_export_subject": "My Äž1nkgo Wallet", "share_export_button": "SHARE", - "pay_with_nfc_tooltip": "To receive a payment, simply bring this device close to the other wallet with NFC activated." + "pay_with_nfc_tooltip": "To receive a payment, simply bring this device close to the other wallet with NFC activated.", + "import_wallet_from_clipboard": "Import Wallet from Clipboard", + "import_wallet_from_clipboard_desc": "Please paste a previously exported wallet text to import it", + "paste_here": "Paste here your wallet", + "paste": "PASTE", + "import": "IMPORT", + "select_import_method": "Select Import Method", + "select_import_method_desc": "Please choose where to import the text from", + "file_import": "Import from File", + "clipboard_import": "Import from Clipboard" } diff --git a/assets/translations/es.json b/assets/translations/es.json index 872bd12a6491ae9e7520df132afe7956d6381927..977a729ced3192f6a98f26a13a73deada172cf98 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -7,7 +7,7 @@ "bottom_nav_second": "Recibir", "bottom_nav_trd": "Contactos", "bottom_nav_frd": "Saldo", - "bottom_nav_fifth": "Información", + "bottom_nav_fifth": "Info", "send_g1": "Enviar Äž1", "g1_amount": "Monto a enviar", "g1_amount_hint": "Monto a enviar en {currency}", @@ -202,5 +202,14 @@ "share_export_desc": "Tu monedero ha sido exportado localmente. ¿Te gustarÃa compartirlo adicionalmente contigo mismo vÃa email/chat/etc. para su resguardo?", "share_export_subject": "Mi monedero Äž1nkgo", "share_export_button": "COMPARTIR", - "pay_with_nfc_tooltip": "Para recibir un pago, simplemente acerca este dispositivo al otro monedero con NFC activado." + "pay_with_nfc_tooltip": "Para recibir un pago, simplemente acerca este dispositivo al otro monedero con NFC activado.", + "import_wallet_from_clipboard": "Importar monedero desde el portapapeles", + "import_wallet_from_clipboard_desc": "Por favor, pega aquà el textod del backup previo de tu monedero", + "paste_here": "Pega aquà tu monedero", + "paste": "PEGAR", + "import": "IMPORTAR", + "select_import_method": "Selecciona el método de importación", + "select_import_method_desc": "Por favor, selecciona el método de importación de tu monedero", + "file_import": "Importar desde archivo", + "clipboard_import": "Importar desde portapapeles" } diff --git a/lib/ui/screens/fifth_screen.dart b/lib/ui/screens/fifth_screen.dart index 5a75b11cb50e2ff3f62996b03fefbdd569b21db6..5ccd2aa44a2bc931e93f743668fae9edfe45ab0b 100644 --- a/lib/ui/screens/fifth_screen.dart +++ b/lib/ui/screens/fifth_screen.dart @@ -19,6 +19,7 @@ import '../widgets/faq.dart'; import '../widgets/fifth_screen/export_dialog.dart'; import '../widgets/fifth_screen/fifth_tutorial.dart'; import '../widgets/fifth_screen/grid_item.dart'; +import '../widgets/fifth_screen/import_clipboard_dialog.dart'; import '../widgets/fifth_screen/import_dialog.dart'; import '../widgets/fifth_screen/link_card.dart'; import '../widgets/fifth_screen/node_info.dart'; @@ -190,12 +191,7 @@ class _FifthScreenState extends State<FifthScreen> { title: 'import_key', icon: Icons.upload, onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return const ImportDialog(); - }, - ); + _showSelectImportMethodDialog(); }), ]), const TextDivider(text: 'faq_title'), @@ -235,4 +231,53 @@ class _FifthScreenState extends State<FifthScreen> { ]), )); } + + Future<void> _showSelectImportMethodDialog() async { + final String? method = await showDialog<String>( + context: context, + builder: (BuildContext context) => const SelectImportMethodDialog(), + ); + if (method != null) { + if (!mounted) { + return; + } + showDialog( + context: context, + builder: (BuildContext context) { + if (method == 'file') { + return const ImportDialog(); + } else { + // if (method == 'clipboard') { + return ImportClipboardDialog(onImport: (String wallet) { + showDialog( + context: context, + builder: (BuildContext context) { + return ImportDialog(wallet: wallet); + }); + }); + } + }, + ); + } + } +} + +class SelectImportMethodDialog extends StatelessWidget { + const SelectImportMethodDialog({super.key}); + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: Text(tr('select_import_method')), + content: Text(tr('select_import_method_desc')), + actions: <Widget>[ + TextButton( + child: Text(tr('file_import')), + onPressed: () => Navigator.of(context).pop('file')), + TextButton( + child: Text(tr('clipboard_import')), + onPressed: () => Navigator.of(context).pop('clipboard')), + ], + ); + } } diff --git a/lib/ui/widgets/fifth_screen/import_dialog.dart b/lib/ui/widgets/fifth_screen/import_dialog.dart index 408b220e1fbfdcbd257e03a9274b2664f6ba9c05..a0f6e6cf38503879f2a0992e8b76d83a30dd0769 100644 --- a/lib/ui/widgets/fifth_screen/import_dialog.dart +++ b/lib/ui/widgets/fifth_screen/import_dialog.dart @@ -20,7 +20,9 @@ import '../custom_error_widget.dart'; import 'pattern_util.dart'; class ImportDialog extends StatefulWidget { - const ImportDialog({super.key}); + const ImportDialog({super.key, this.wallet}); + + final String? wallet; @override State<ImportDialog> createState() => _ImportDialogState(); @@ -32,7 +34,9 @@ class _ImportDialogState extends State<ImportDialog> { @override Widget build(BuildContext c) { return FutureBuilder<String>( - future: kIsWeb ? _importWalletWeb(c) : _importWallet(c), + future: widget.wallet == null + ? (kIsWeb ? _importWalletWeb(c) : _importWallet(c)) + : Future<String>.value(widget.wallet), builder: (BuildContext context, AsyncSnapshot<String> snapshot) { if (snapshot.hasData && snapshot.data != null &&