mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
experimental navigation
This commit is contained in:
parent
06b7332e7d
commit
65941478b8
13 changed files with 66 additions and 133 deletions
|
@ -39,8 +39,8 @@ final pFrostScaffoldArgs = StateProvider<
|
|||
({String walletName, FrostCurrency frostCurrency}) info,
|
||||
String? walletId,
|
||||
List<FrostStepRoute> stepRoutes,
|
||||
VoidCallback onSuccess,
|
||||
FrostInterruptionDialogType frostInterruptionDialogType,
|
||||
NavigatorState parentNav,
|
||||
})?>((ref) => null);
|
||||
|
||||
abstract class FrostRouteGenerator {
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/frost_route_generator.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart';
|
||||
import 'package:stackwallet/services/frost.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart';
|
||||
|
@ -415,39 +409,9 @@ class _NewFrostMsWalletViewState
|
|||
),
|
||||
walletId: null,
|
||||
stepRoutes: FrostRouteGenerator.createNewConfigStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
if (Util.isDesktop) {
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
DesktopHomeView.routeName,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
HomeView.routeName,
|
||||
(route) => false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ref.read(pFrostMultisigConfig.state).state = null;
|
||||
ref.read(pFrostStartKeyGenData.state).state = null;
|
||||
ref.read(pFrostSecretSharesData.state).state = null;
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.success,
|
||||
message: "Your wallet is set up.",
|
||||
iconAsset: Assets.svg.check,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.walletCreation,
|
||||
parentNav: Navigator.of(context),
|
||||
);
|
||||
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:stackwallet/frost_route_generator.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
@ -147,37 +141,7 @@ class _SelectNewFrostImportTypeViewState
|
|||
),
|
||||
walletId: null, // no wallet id yet
|
||||
stepRoutes: FrostRouteGenerator.importNewConfigStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
if (Util.isDesktop) {
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
DesktopHomeView.routeName,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
HomeView.routeName,
|
||||
(route) => false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ref.read(pFrostMultisigConfig.state).state = null;
|
||||
ref.read(pFrostStartKeyGenData.state).state = null;
|
||||
ref.read(pFrostSecretSharesData.state).state = null;
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.success,
|
||||
message: "Your wallet is set up.",
|
||||
iconAsset: Assets.svg.check,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.walletCreation,
|
||||
);
|
||||
|
@ -191,13 +155,7 @@ class _SelectNewFrostImportTypeViewState
|
|||
),
|
||||
walletId: null, // no wallet id yet
|
||||
stepRoutes: FrostRouteGenerator.joinReshareStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
ref.read(pFrostMultisigConfig.state).state = null;
|
||||
ref.read(pFrostStartKeyGenData.state).state = null;
|
||||
ref.read(pFrostSecretSharesData.state).state = null;
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
|
|
|
@ -4,7 +4,10 @@ import 'dart:typed_data';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/frost_route_generator.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart';
|
||||
import 'package:stackwallet/providers/global/node_service_provider.dart';
|
||||
|
@ -13,6 +16,7 @@ import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
|||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/frost.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
|
@ -181,7 +185,36 @@ class _FrostCreateStep5State extends ConsumerState<FrostCreateStep5> {
|
|||
|
||||
if (mounted) {
|
||||
ref.read(pFrostScaffoldCanPopDesktop.notifier).state = true;
|
||||
ref.read(pFrostScaffoldArgs)!.onSuccess();
|
||||
final nav = ref.read(pFrostScaffoldArgs)!.parentNav;
|
||||
|
||||
if (Util.isDesktop) {
|
||||
nav.popUntil(
|
||||
ModalRoute.withName(
|
||||
DesktopHomeView.routeName,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
nav.pushNamedAndRemoveUntil(
|
||||
HomeView.routeName,
|
||||
(route) => false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ref.read(pFrostMultisigConfig.state).state = null;
|
||||
ref.read(pFrostStartKeyGenData.state).state = null;
|
||||
ref.read(pFrostSecretSharesData.state).state = null;
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.success,
|
||||
message: "Your wallet is set up.",
|
||||
iconAsset: Assets.svg.check,
|
||||
context: nav.context,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
|
|
|
@ -187,7 +187,7 @@ class _FrostReshareStep1cState extends ConsumerState<FrostReshareStep1c> {
|
|||
info: data.info,
|
||||
walletId: wallet.walletId,
|
||||
stepRoutes: data.stepRoutes,
|
||||
onSuccess: data.onSuccess,
|
||||
parentNav: data.parentNav,
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
|
|
|
@ -56,12 +56,14 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
|
|||
try {
|
||||
if (amOutgoingParticipant) {
|
||||
ref.read(pFrostResharingData).reset();
|
||||
// nav broken on desktop
|
||||
Navigator.of(context, rootNavigator: !Util.isDesktop).popUntil(
|
||||
ModalRoute.withName(
|
||||
Util.isDesktop ? DesktopWalletView.routeName : WalletView.routeName,
|
||||
),
|
||||
);
|
||||
ref.read(pFrostScaffoldCanPopDesktop.notifier).state = true;
|
||||
ref.read(pFrostScaffoldArgs)?.parentNav.popUntil(
|
||||
ModalRoute.withName(
|
||||
Util.isDesktop
|
||||
? DesktopWalletView.routeName
|
||||
: WalletView.routeName,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// collect resharer completes strings and insert my own at the correct index
|
||||
final resharerCompletes = controllers.map((e) => e.text).toList();
|
||||
|
|
|
@ -94,12 +94,12 @@ class _FrostReshareStep5State extends ConsumerState<FrostReshareStep5> {
|
|||
|
||||
if (mounted) {
|
||||
ref.read(pFrostResharingData).reset();
|
||||
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
_popUntilPath,
|
||||
),
|
||||
);
|
||||
ref.read(pFrostScaffoldCanPopDesktop.notifier).state = true;
|
||||
ref.read(pFrostScaffoldArgs)?.parentNav.popUntil(
|
||||
ModalRoute.withName(
|
||||
_popUntilPath,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e, s) {
|
||||
|
|
|
@ -136,12 +136,7 @@ class _FrostSendViewState extends ConsumerState<FrostSendView> {
|
|||
),
|
||||
walletId: walletId,
|
||||
stepRoutes: FrostRouteGenerator.sendFrostTxStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
// TODO ?
|
||||
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.transactionCreation,
|
||||
);
|
||||
|
|
|
@ -224,14 +224,15 @@ class _FrostSendStep4State extends ConsumerState<FrostSendStep4> {
|
|||
|
||||
if (context.mounted) {
|
||||
if (txData != null) {
|
||||
ref.read(pFrostScaffoldCanPopDesktop.notifier).state = true;
|
||||
ref.read(pFrostTxData.state).state = txData;
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
Util.isDesktop
|
||||
? MyStackView.routeName
|
||||
: WalletView.routeName,
|
||||
),
|
||||
);
|
||||
ref.read(pFrostScaffoldArgs)!.parentNav.popUntil(
|
||||
ModalRoute.withName(
|
||||
Util.isDesktop
|
||||
? MyStackView.routeName
|
||||
: WalletView.routeName,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e, s) {
|
||||
|
|
|
@ -159,12 +159,7 @@ class FrostMSWalletOptionsView extends ConsumerWidget {
|
|||
),
|
||||
walletId: wallet.walletId,
|
||||
stepRoutes: FrostRouteGenerator.importReshareStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
// TODO
|
||||
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
|
|
|
@ -136,10 +136,7 @@ class _CompleteReshareConfigViewState
|
|||
),
|
||||
walletId: wallet.walletId,
|
||||
stepRoutes: FrostRouteGenerator.initiateReshareStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
// TODO
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType: FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
|
||||
|
|
|
@ -368,12 +368,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
),
|
||||
walletId: walletId,
|
||||
stepRoutes: FrostRouteGenerator.signFrostTxStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
// TODO ?
|
||||
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.transactionCreation,
|
||||
);
|
||||
|
|
|
@ -100,14 +100,7 @@ class _MyWalletState extends ConsumerState<MyWallet> {
|
|||
walletId: widget.walletId,
|
||||
stepRoutes: FrostRouteGenerator
|
||||
.signFrostTxStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
// TODO ?
|
||||
|
||||
ref
|
||||
.read(pFrostScaffoldArgs.state)
|
||||
.state = null;
|
||||
},
|
||||
parentNav: Navigator.of(context),
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType
|
||||
.transactionCreation,
|
||||
|
|
Loading…
Reference in a new issue