fix: disable import/export on iOS

No local storage access right now
This commit is contained in:
Matyáš Caras 2024-01-29 22:41:05 +01:00
parent 943bf15aab
commit 459b50d628
Signed by untrusted user who does not match committer: hernik
GPG key ID: 2A3175F98820C5C6

View file

@ -107,190 +107,192 @@ class _SettingsViewState extends State<SettingsView> {
), ),
], ],
), ),
SettingsSection( if (!Platform.isIOS)
title: Text(AppLocalizations.of(context).settingsData), SettingsSection(
tiles: [ //! TODO: Find a replacement for iOS
SettingsTile.navigation( title: Text(AppLocalizations.of(context).settingsData),
title: Text(AppLocalizations.of(context).exportSingle), tiles: [
description: SettingsTile.navigation(
Text(AppLocalizations.of(context).exportSingleDesc), title: Text(AppLocalizations.of(context).exportSingle),
onPressed: (ctx) async { description:
final all = await WalletManager.listWallets(); Text(AppLocalizations.of(context).exportSingleDesc),
if (!ctx.mounted) return; onPressed: (ctx) async {
final w = await showAdaptiveDialog<String>( final all = await WalletManager.listWallets();
context: ctx, if (!ctx.mounted) return;
builder: (ctx) => AlertDialog.adaptive( final w = await showAdaptiveDialog<String>(
title: Text( context: ctx,
AppLocalizations.of(context).selectExportWallet, builder: (ctx) => AlertDialog.adaptive(
), title: Text(
actions: [ AppLocalizations.of(context).selectExportWallet,
PlatformButton(
text: AppLocalizations.of(context).cancel,
onPressed: () => Navigator.of(ctx).pop(),
), ),
], actions: [
content: SizedBox( PlatformButton(
width: MediaQuery.of(context).size.width * 0.7, text: AppLocalizations.of(context).cancel,
height: MediaQuery.of(context).size.height * 0.3, onPressed: () => Navigator.of(ctx).pop(),
child: ListView.builder( ),
itemBuilder: (con, i) => InkWell( ],
onTap: () => Navigator.of(ctx).pop(all[i].name), content: SizedBox(
child: Padding( width: MediaQuery.of(context).size.width * 0.7,
padding: const EdgeInsets.all(8), height: MediaQuery.of(context).size.height * 0.3,
child: Text( child: ListView.builder(
all[i].name, itemBuilder: (con, i) => InkWell(
textAlign: TextAlign.center, 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,
), ),
), );
), logger.e(e);
); return;
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) {
if (!ctx.mounted) return; if (!ctx.mounted) return;
unawaited( unawaited(
showAdaptiveDialog( showMessage(
context: context, AppLocalizations.of(ctx).exportCompleted,
builder: (ctx) => AlertDialog.adaptive( ctx,
title: Text( ),
AppLocalizations.of(context).exportError, );
), },
content: SingleChildScrollView( ),
child: Flexible( SettingsTile.navigation(
child: Text(e.toString()), 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);
logger.e(e); return;
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) {
if (!ctx.mounted) return; if (!ctx.mounted) return;
unawaited( unawaited(
showAdaptiveDialog( showMessage(
context: context, AppLocalizations.of(ctx).exportCompleted,
builder: (ctx) => AlertDialog.adaptive( context,
title: Text( ),
AppLocalizations.of(context).exportError, );
), },
content: SingleChildScrollView( ),
child: Flexible( SettingsTile.navigation(
child: Text(e.toString()), 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);
logger.e(e); return;
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) {
if (!ctx.mounted) return; if (!ctx.mounted) return;
unawaited( unawaited(
showAdaptiveDialog( showMessage(
context: context, AppLocalizations.of(ctx).importCompleted,
builder: (ctx) => AlertDialog.adaptive( context,
title: Text( ),
AppLocalizations.of(context).exportError, );
), },
content: SingleChildScrollView( ),
child: Flexible( SettingsTile.navigation(
child: Text(e.toString()), 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,
),
);
},
),
],
),
], ],
), ),
); );