From 0d3ae2a635e7e1cdf0a02a4992abc022e368321b Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 3 May 2024 12:22:19 -0600 Subject: [PATCH] various frost ui flow tweaks and fixes --- .../reshare/frost_reshare_step_1c.dart | 4 ++- .../reshare/frost_reshare_step_3abd.dart | 26 +++++++------- .../reshare/frost_reshare_step_4.dart | 34 +++++++++++-------- .../reshare/frost_reshare_step_5.dart | 2 +- .../restore/restore_frost_ms_wallet_view.dart | 2 +- .../cashfusion/fusion_progress_view.dart | 2 +- lib/pages/monkey/monkey_view.dart | 6 ++-- lib/pages/ordinals/ordinal_details_view.dart | 2 +- .../send_view/frost_ms/frost_send_view.dart | 2 +- .../send_steps/frost_send_step_4.dart | 2 +- .../change_representative_view.dart | 2 +- .../sub_widgets/my_token_select_item.dart | 2 +- .../sub_widgets/favorite_card.dart | 2 +- .../sub_widgets/wallet_list_item.dart | 2 +- .../cashfusion/sub_widgets/fusion_dialog.dart | 2 +- .../my_stack_view/coin_wallets_table.dart | 2 +- .../desktop_ordinal_details_view.dart | 2 +- .../ordinals/desktop_ordinals_view.dart | 2 +- lib/utilities/show_loading.dart | 4 +-- .../models/incomplete_frost_wallet.dart | 4 ++- lib/widgets/wallet_card.dart | 4 +-- 21 files changed, 60 insertions(+), 50 deletions(-) diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart index a0e39221d..c7690c45b 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart @@ -172,7 +172,7 @@ class _FrostReshareStep1cState extends ConsumerState { whileFuture: _createWallet(), context: context, message: "Setting up wallet", - isDesktop: Util.isDesktop, + rootNavigator: true, onException: (e) => ex = e, ); @@ -191,6 +191,8 @@ class _FrostReshareStep1cState extends ConsumerState { frostInterruptionDialogType: FrostInterruptionDialogType.resharing, ); + ref.read(pFrostMyName.state).state = + ref.read(pFrostResharingData).myName!; ref.read(pFrostCreateCurrentStep.state).state = 2; await Navigator.of(context).pushNamed( ref diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart index 050baa3e8..5bccf7756 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart @@ -179,23 +179,25 @@ class _FrostReshareStep3abdState extends ConsumerState { ], ), if (!Util.isDesktop) const Spacer(), - const SizedBox( - height: 12, - ), - CheckboxTextButton( - label: "I have verified that everyone has my encryption key", - onChanged: (value) { - setState(() { - _userVerifyContinue = value; - }); - }, - ), + if (!amOutgoingParticipant) + const SizedBox( + height: 12, + ), + if (!amOutgoingParticipant) + CheckboxTextButton( + label: "I have verified that everyone has my encryption key", + onChanged: (value) { + setState(() { + _userVerifyContinue = value; + }); + }, + ), const SizedBox( height: 16, ), PrimaryButton( label: "Continue", - enabled: _userVerifyContinue && + enabled: (amOutgoingParticipant || _userVerifyContinue) && !fieldIsEmptyFlags.reduce((v, e) => v |= e), onPressed: _onPressed, ), diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart index 973dc99d7..02530f8e4 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart @@ -40,6 +40,7 @@ class _FrostReshareStep4State extends ConsumerState { late final int? myResharerIndexIndex; late final String? myResharerComplete; late final bool amOutgoingParticipant; + late final bool amNewParticipant; final List fieldIsEmptyFlags = []; @@ -55,7 +56,8 @@ class _FrostReshareStep4State extends ConsumerState { try { if (amOutgoingParticipant) { ref.read(pFrostResharingData).reset(); - Navigator.of(context).popUntil( + // nav broken on desktop + Navigator.of(context, rootNavigator: !Util.isDesktop).popUntil( ModalRoute.withName( Util.isDesktop ? DesktopWalletView.routeName : WalletView.routeName, ), @@ -104,7 +106,7 @@ class _FrostReshareStep4State extends ConsumerState { @override void initState() { - final amNewParticipant = + amNewParticipant = ref.read(pFrostResharingData).startResharerData == null && ref.read(pFrostResharingData).incompleteWallet != null && ref.read(pFrostResharingData).incompleteWallet?.walletId == @@ -217,20 +219,22 @@ class _FrostReshareStep4State extends ConsumerState { const SizedBox( height: 16, ), - CheckboxTextButton( - label: "I have verified that everyone has my resharer complete", - onChanged: (value) { - setState(() { - _userVerifyContinue = value; - }); - }, - ), - const SizedBox( - height: 16, - ), + if (!amNewParticipant) + CheckboxTextButton( + label: "I have verified that everyone has my resharer complete", + onChanged: (value) { + setState(() { + _userVerifyContinue = value; + }); + }, + ), + if (!amNewParticipant) + const SizedBox( + height: 16, + ), PrimaryButton( - label: amOutgoingParticipant ? "Exit" : "Complete", - enabled: _userVerifyContinue && + label: amOutgoingParticipant ? "Done" : "Complete", + enabled: (amNewParticipant || _userVerifyContinue) && (amOutgoingParticipant || !fieldIsEmptyFlags.reduce((v, e) => v |= e)), onPressed: _onPressed, diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart index 10c7a6a24..b044b1d93 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart @@ -84,7 +84,7 @@ class _FrostReshareStep5State extends ConsumerState { ), context: context, message: isNew ? "Creating wallet" : "Updating wallet data", - isDesktop: Util.isDesktop, + rootNavigator: true, onException: (e) => ex = e, ); diff --git a/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart b/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart index 2d4846289..68c220c1f 100644 --- a/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart +++ b/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart @@ -130,7 +130,7 @@ class _RestoreFrostMsWalletViewState whileFuture: _createWalletAndRecover(), context: context, message: "Restoring wallet...", - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, onException: (e) { ex = e; }, diff --git a/lib/pages/cashfusion/fusion_progress_view.dart b/lib/pages/cashfusion/fusion_progress_view.dart index 746825d36..78bc9ccc7 100644 --- a/lib/pages/cashfusion/fusion_progress_view.dart +++ b/lib/pages/cashfusion/fusion_progress_view.dart @@ -79,7 +79,7 @@ class _FusionProgressViewState extends ConsumerState { Future.delayed(const Duration(seconds: 2)), ]), context: context, - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, message: "Stopping fusion", ); diff --git a/lib/pages/monkey/monkey_view.dart b/lib/pages/monkey/monkey_view.dart index a747011ee..9e8bdb090 100644 --- a/lib/pages/monkey/monkey_view.dart +++ b/lib/pages/monkey/monkey_view.dart @@ -349,7 +349,7 @@ class _MonkeyViewState extends ConsumerState { ), ]), context: context, - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, message: "Saving MonKey svg", onException: (e) { didError = true; @@ -402,7 +402,7 @@ class _MonkeyViewState extends ConsumerState { const Duration(seconds: 2)), ]), context: context, - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, message: "Downloading MonKey png", onException: (e) { didError = true; @@ -500,7 +500,7 @@ class _MonkeyViewState extends ConsumerState { Future.delayed(const Duration(seconds: 2)), ]), context: context, - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, message: "Fetching MonKey", subMessage: "We are fetching your MonKey", onException: (e) { diff --git a/lib/pages/ordinals/ordinal_details_view.dart b/lib/pages/ordinals/ordinal_details_view.dart index d15523e10..590bca266 100644 --- a/lib/pages/ordinals/ordinal_details_view.dart +++ b/lib/pages/ordinals/ordinal_details_view.dart @@ -321,7 +321,7 @@ class _OrdinalImageGroup extends ConsumerWidget { final filePath = await showLoading( whileFuture: _savePngToFile(ref), context: context, - isDesktop: true, + rootNavigator: true, message: "Saving ordinal image", onException: (e) { didError = true; diff --git a/lib/pages/send_view/frost_ms/frost_send_view.dart b/lib/pages/send_view/frost_ms/frost_send_view.dart index d6cfc505c..a79ee0e6e 100644 --- a/lib/pages/send_view/frost_ms/frost_send_view.dart +++ b/lib/pages/send_view/frost_ms/frost_send_view.dart @@ -116,7 +116,7 @@ class _FrostSendViewState extends ConsumerState { whileFuture: _loadingFuture(), context: context, message: "Generating sign config", - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, onException: (e) { throw e; }, diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart index 7ad7bfcdd..2906af589 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart @@ -212,7 +212,7 @@ class _FrostSendStep4State extends ConsumerState { ), context: context, message: "Broadcasting transaction to network", - isDesktop: true, // used to pop using root nav + rootNavigator: true, // used to pop using root nav onException: (e) { ex = e; }, diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart index 0876c92e0..03b131993 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart @@ -83,7 +83,7 @@ class _ChangeRepresentativeViewState whileFuture: changeFuture(_textController.text), context: context, message: "Updating representative...", - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, onException: (ex) { String msg = ex.toString(); while (msg.isNotEmpty && msg.startsWith("Exception:")) { diff --git a/lib/pages/token_view/sub_widgets/my_token_select_item.dart b/lib/pages/token_view/sub_widgets/my_token_select_item.dart index 003fd515a..2fd42300d 100644 --- a/lib/pages/token_view/sub_widgets/my_token_select_item.dart +++ b/lib/pages/token_view/sub_widgets/my_token_select_item.dart @@ -98,7 +98,7 @@ class _MyTokenSelectItemState extends ConsumerState { final success = await showLoading( whileFuture: _loadTokenWallet(context, ref), context: context, - isDesktop: isDesktop, + rootNavigator: isDesktop, message: "Loading ${widget.token.name}", ); diff --git a/lib/pages/wallets_view/sub_widgets/favorite_card.dart b/lib/pages/wallets_view/sub_widgets/favorite_card.dart index 8aafe8e30..4ef59bf0b 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_card.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_card.dart @@ -127,7 +127,7 @@ class _FavoriteCardState extends ConsumerState { whileFuture: loadFuture, context: context, message: 'Opening ${wallet.info.name}', - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, ); if (mounted) { diff --git a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart index 2099b05e9..fada0b998 100644 --- a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart +++ b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart @@ -95,7 +95,7 @@ class WalletListItem extends ConsumerWidget { whileFuture: loadFuture, context: context, message: 'Opening ${wallet.info.name}', - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, ); if (context.mounted) { unawaited( diff --git a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart index 2e02aeef9..6d4225fab 100644 --- a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart +++ b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart @@ -132,7 +132,7 @@ class _FusionDialogViewState extends ConsumerState { Future.delayed(const Duration(seconds: 2)), ]), context: context, - isDesktop: true, + rootNavigator: true, message: "Stopping fusion", ); diff --git a/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart b/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart index 7f138509f..94cdf75f8 100644 --- a/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart +++ b/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart @@ -92,7 +92,7 @@ class CoinWalletsTable extends ConsumerWidget { whileFuture: loadFuture, context: context, message: 'Opening ${wallet.info.name}', - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, ); if (context.mounted) { diff --git a/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart b/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart index c28524635..b258d0a5e 100644 --- a/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart +++ b/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart @@ -234,7 +234,7 @@ class _DesktopOrdinalDetailsViewState final path = await showLoading( whileFuture: _savePngToFile(), context: context, - isDesktop: true, + rootNavigator: true, message: "Saving ordinal image", onException: (e) { didError = true; diff --git a/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart b/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart index 1fb4f29af..c710a4d10 100644 --- a/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart +++ b/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart @@ -210,7 +210,7 @@ class _DesktopOrdinals extends ConsumerState { onPressed: () async { // show loading for a minimum of 2 seconds on refreshing await showLoading( - isDesktop: true, + rootNavigator: true, whileFuture: Future.wait([ Future.delayed(const Duration(seconds: 2)), (ref.read(pWallets).getWallet(widget.walletId) diff --git a/lib/utilities/show_loading.dart b/lib/utilities/show_loading.dart index 759eaa05c..e01a86441 100644 --- a/lib/utilities/show_loading.dart +++ b/lib/utilities/show_loading.dart @@ -20,7 +20,7 @@ Future showLoading({ required BuildContext context, required String message, String? subMessage, - bool isDesktop = false, + bool rootNavigator = false, bool opaqueBG = false, void Function(Exception)? onException, }) async { @@ -59,7 +59,7 @@ Future showLoading({ } if (context.mounted) { - Navigator.of(context, rootNavigator: isDesktop).pop(); + Navigator.of(context, rootNavigator: rootNavigator).pop(); if (ex != null) { onException?.call(ex); } diff --git a/lib/wallets/models/incomplete_frost_wallet.dart b/lib/wallets/models/incomplete_frost_wallet.dart index e5075da63..015ca9fb9 100644 --- a/lib/wallets/models/incomplete_frost_wallet.dart +++ b/lib/wallets/models/incomplete_frost_wallet.dart @@ -35,7 +35,9 @@ class IncompleteFrostWallet { threshold: -1, ); - await mainDB.isar.frostWalletInfo.put(frostInfo); + await mainDB.isar.writeTxn(() async { + await mainDB.isar.frostWalletInfo.put(frostInfo); + }); return wallet as BitcoinFrostWallet; } diff --git a/lib/widgets/wallet_card.dart b/lib/widgets/wallet_card.dart index 31a29fb68..6387b8ccb 100644 --- a/lib/widgets/wallet_card.dart +++ b/lib/widgets/wallet_card.dart @@ -137,7 +137,7 @@ class SimpleWalletCard extends ConsumerWidget { whileFuture: loadFuture, context: context, message: 'Opening ${wallet.info.name}', - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, ); if (popPrevious) nav.pop(); @@ -167,7 +167,7 @@ class SimpleWalletCard extends ConsumerWidget { context: desktopNavigatorState?.context ?? context, opaqueBG: true, message: "Loading ${contract.name}", - isDesktop: Util.isDesktop, + rootNavigator: Util.isDesktop, ); if (!success!) {