Skip to content
Snippets Groups Projects
Commit 95cedc3a authored by vjrj's avatar vjrj
Browse files

Import from clipboard

parent d681fb05
No related branches found
No related tags found
No related merge requests found
......@@ -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"
}
......@@ -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"
}
......@@ -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')),
],
);
}
}
......@@ -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 &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment