From 459b50d6289ff4b95ef6c3133765bb8ff8f60a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 29 Jan 2024 22:41:05 +0100 Subject: [PATCH] fix: disable import/export on iOS No local storage access right now --- lib/views/settings/settings.dart | 326 ++++++++++++++++--------------- 1 file changed, 164 insertions(+), 162 deletions(-) diff --git a/lib/views/settings/settings.dart b/lib/views/settings/settings.dart index 92e0ba0..47ea3d1 100644 --- a/lib/views/settings/settings.dart +++ b/lib/views/settings/settings.dart @@ -107,190 +107,192 @@ class _SettingsViewState extends State { ), ], ), - SettingsSection( - title: Text(AppLocalizations.of(context).settingsData), - tiles: [ - SettingsTile.navigation( - title: Text(AppLocalizations.of(context).exportSingle), - description: - Text(AppLocalizations.of(context).exportSingleDesc), - onPressed: (ctx) async { - final all = await WalletManager.listWallets(); - if (!ctx.mounted) return; - final w = await showAdaptiveDialog( - context: ctx, - builder: (ctx) => AlertDialog.adaptive( - title: Text( - AppLocalizations.of(context).selectExportWallet, - ), - actions: [ - PlatformButton( - text: AppLocalizations.of(context).cancel, - onPressed: () => Navigator.of(ctx).pop(), + if (!Platform.isIOS) + SettingsSection( + //! TODO: Find a replacement for iOS + title: Text(AppLocalizations.of(context).settingsData), + tiles: [ + SettingsTile.navigation( + title: Text(AppLocalizations.of(context).exportSingle), + description: + Text(AppLocalizations.of(context).exportSingleDesc), + onPressed: (ctx) async { + final all = await WalletManager.listWallets(); + if (!ctx.mounted) return; + final w = await showAdaptiveDialog( + context: ctx, + builder: (ctx) => AlertDialog.adaptive( + title: Text( + AppLocalizations.of(context).selectExportWallet, ), - ], - content: SizedBox( - width: MediaQuery.of(context).size.width * 0.7, - height: MediaQuery.of(context).size.height * 0.3, - child: ListView.builder( - itemBuilder: (con, i) => InkWell( - onTap: () => Navigator.of(ctx).pop(all[i].name), - child: Padding( - padding: const EdgeInsets.all(8), - child: Text( - all[i].name, - textAlign: TextAlign.center, + actions: [ + PlatformButton( + text: AppLocalizations.of(context).cancel, + onPressed: () => Navigator.of(ctx).pop(), + ), + ], + content: SizedBox( + width: MediaQuery.of(context).size.width * 0.7, + height: MediaQuery.of(context).size.height * 0.3, + child: ListView.builder( + itemBuilder: (con, i) => InkWell( + onTap: () => Navigator.of(ctx).pop(all[i].name), + child: Padding( + padding: const EdgeInsets.all(8), + child: Text( + all[i].name, + textAlign: TextAlign.center, + ), + ), + ), + shrinkWrap: true, + itemCount: all.length, + ), + ), + ), + ); + if (w == null) return; + try { + await WalletManager.exportWallet(name: w); + } catch (e) { + if (!context.mounted) return; + unawaited( + showAdaptiveDialog( + context: context, + builder: (ctx) => AlertDialog.adaptive( + title: Text( + AppLocalizations.of(context).exportError, + ), + content: SingleChildScrollView( + child: Flexible( + child: Text(e.toString()), ), ), ), - shrinkWrap: true, - itemCount: all.length, ), - ), - ), - ); - if (w == null) return; - try { - await WalletManager.exportWallet(name: w); - } catch (e) { - if (!context.mounted) return; - unawaited( - showAdaptiveDialog( - context: context, - builder: (ctx) => AlertDialog.adaptive( - title: Text( - AppLocalizations.of(context).exportError, - ), - content: SingleChildScrollView( - child: Flexible( - child: Text(e.toString()), - ), - ), - ), - ), - ); - logger.e(e); - return; - } - if (!ctx.mounted) return; - unawaited( - showMessage( - AppLocalizations.of(ctx).exportCompleted, - ctx, - ), - ); - }, - ), - SettingsTile.navigation( - title: Text(AppLocalizations.of(context).exportArchive), - description: - Text(AppLocalizations.of(context).exportArchiveDesc), - onPressed: (ctx) async { - try { - await WalletManager.exportAllWallets(); - } catch (e) { + ); + logger.e(e); + return; + } if (!ctx.mounted) return; unawaited( - showAdaptiveDialog( - context: context, - builder: (ctx) => AlertDialog.adaptive( - title: Text( - AppLocalizations.of(context).exportError, - ), - content: SingleChildScrollView( - child: Flexible( - child: Text(e.toString()), + showMessage( + AppLocalizations.of(ctx).exportCompleted, + ctx, + ), + ); + }, + ), + SettingsTile.navigation( + title: Text(AppLocalizations.of(context).exportArchive), + description: + Text(AppLocalizations.of(context).exportArchiveDesc), + onPressed: (ctx) async { + try { + await WalletManager.exportAllWallets(); + } catch (e) { + if (!ctx.mounted) return; + unawaited( + showAdaptiveDialog( + context: context, + builder: (ctx) => AlertDialog.adaptive( + title: Text( + AppLocalizations.of(context).exportError, + ), + content: SingleChildScrollView( + child: Flexible( + child: Text(e.toString()), + ), ), ), ), - ), - ); - logger.e(e); - return; - } - if (!ctx.mounted) return; - unawaited( - showMessage( - AppLocalizations.of(ctx).exportCompleted, - context, - ), - ); - }, - ), - SettingsTile.navigation( - title: Text(AppLocalizations.of(context).importSingle), - description: - Text(AppLocalizations.of(context).importSingleDesc), - onPressed: (ctx) async { - try { - await WalletManager.importWallet(); - } catch (e) { + ); + logger.e(e); + return; + } if (!ctx.mounted) return; unawaited( - showAdaptiveDialog( - context: context, - builder: (ctx) => AlertDialog.adaptive( - title: Text( - AppLocalizations.of(context).exportError, - ), - content: SingleChildScrollView( - child: Flexible( - child: Text(e.toString()), + showMessage( + AppLocalizations.of(ctx).exportCompleted, + context, + ), + ); + }, + ), + SettingsTile.navigation( + title: Text(AppLocalizations.of(context).importSingle), + description: + Text(AppLocalizations.of(context).importSingleDesc), + onPressed: (ctx) async { + try { + await WalletManager.importWallet(); + } catch (e) { + if (!ctx.mounted) return; + unawaited( + showAdaptiveDialog( + context: context, + builder: (ctx) => AlertDialog.adaptive( + title: Text( + AppLocalizations.of(context).exportError, + ), + content: SingleChildScrollView( + child: Flexible( + child: Text(e.toString()), + ), ), ), ), - ), - ); - logger.e(e); - return; - } - if (!ctx.mounted) return; - unawaited( - showMessage( - AppLocalizations.of(ctx).importCompleted, - context, - ), - ); - }, - ), - SettingsTile.navigation( - title: Text(AppLocalizations.of(context).importArchive), - description: - Text(AppLocalizations.of(context).importArchiveDesc), - onPressed: (ctx) async { - try { - await WalletManager.importArchive(); - } catch (e) { + ); + logger.e(e); + return; + } if (!ctx.mounted) return; unawaited( - showAdaptiveDialog( - context: context, - builder: (ctx) => AlertDialog.adaptive( - title: Text( - AppLocalizations.of(context).exportError, - ), - content: SingleChildScrollView( - child: Flexible( - child: Text(e.toString()), + showMessage( + AppLocalizations.of(ctx).importCompleted, + context, + ), + ); + }, + ), + SettingsTile.navigation( + title: Text(AppLocalizations.of(context).importArchive), + description: + Text(AppLocalizations.of(context).importArchiveDesc), + onPressed: (ctx) async { + try { + await WalletManager.importArchive(); + } catch (e) { + if (!ctx.mounted) return; + unawaited( + showAdaptiveDialog( + context: context, + builder: (ctx) => AlertDialog.adaptive( + title: Text( + AppLocalizations.of(context).exportError, + ), + content: SingleChildScrollView( + child: Flexible( + child: Text(e.toString()), + ), ), ), ), + ); + logger.e(e); + return; + } + if (!ctx.mounted) return; + unawaited( + showMessage( + AppLocalizations.of(ctx).importCompleted, + context, ), ); - logger.e(e); - return; - } - if (!ctx.mounted) return; - unawaited( - showMessage( - AppLocalizations.of(ctx).importCompleted, - context, - ), - ); - }, - ), - ], - ), + }, + ), + ], + ), ], ), );