various frost ui flow tweaks and fixes

This commit is contained in:
Julian 2024-05-03 12:22:19 -06:00
parent e2fe526be4
commit 0d3ae2a635
21 changed files with 60 additions and 50 deletions

View file

@ -172,7 +172,7 @@ class _FrostReshareStep1cState extends ConsumerState<FrostReshareStep1c> {
whileFuture: _createWallet(), whileFuture: _createWallet(),
context: context, context: context,
message: "Setting up wallet", message: "Setting up wallet",
isDesktop: Util.isDesktop, rootNavigator: true,
onException: (e) => ex = e, onException: (e) => ex = e,
); );
@ -191,6 +191,8 @@ class _FrostReshareStep1cState extends ConsumerState<FrostReshareStep1c> {
frostInterruptionDialogType: frostInterruptionDialogType:
FrostInterruptionDialogType.resharing, FrostInterruptionDialogType.resharing,
); );
ref.read(pFrostMyName.state).state =
ref.read(pFrostResharingData).myName!;
ref.read(pFrostCreateCurrentStep.state).state = 2; ref.read(pFrostCreateCurrentStep.state).state = 2;
await Navigator.of(context).pushNamed( await Navigator.of(context).pushNamed(
ref ref

View file

@ -179,9 +179,11 @@ class _FrostReshareStep3abdState extends ConsumerState<FrostReshareStep3abd> {
], ],
), ),
if (!Util.isDesktop) const Spacer(), if (!Util.isDesktop) const Spacer(),
if (!amOutgoingParticipant)
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
if (!amOutgoingParticipant)
CheckboxTextButton( CheckboxTextButton(
label: "I have verified that everyone has my encryption key", label: "I have verified that everyone has my encryption key",
onChanged: (value) { onChanged: (value) {
@ -195,7 +197,7 @@ class _FrostReshareStep3abdState extends ConsumerState<FrostReshareStep3abd> {
), ),
PrimaryButton( PrimaryButton(
label: "Continue", label: "Continue",
enabled: _userVerifyContinue && enabled: (amOutgoingParticipant || _userVerifyContinue) &&
!fieldIsEmptyFlags.reduce((v, e) => v |= e), !fieldIsEmptyFlags.reduce((v, e) => v |= e),
onPressed: _onPressed, onPressed: _onPressed,
), ),

View file

@ -40,6 +40,7 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
late final int? myResharerIndexIndex; late final int? myResharerIndexIndex;
late final String? myResharerComplete; late final String? myResharerComplete;
late final bool amOutgoingParticipant; late final bool amOutgoingParticipant;
late final bool amNewParticipant;
final List<bool> fieldIsEmptyFlags = []; final List<bool> fieldIsEmptyFlags = [];
@ -55,7 +56,8 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
try { try {
if (amOutgoingParticipant) { if (amOutgoingParticipant) {
ref.read(pFrostResharingData).reset(); ref.read(pFrostResharingData).reset();
Navigator.of(context).popUntil( // nav broken on desktop
Navigator.of(context, rootNavigator: !Util.isDesktop).popUntil(
ModalRoute.withName( ModalRoute.withName(
Util.isDesktop ? DesktopWalletView.routeName : WalletView.routeName, Util.isDesktop ? DesktopWalletView.routeName : WalletView.routeName,
), ),
@ -104,7 +106,7 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
@override @override
void initState() { void initState() {
final amNewParticipant = amNewParticipant =
ref.read(pFrostResharingData).startResharerData == null && ref.read(pFrostResharingData).startResharerData == null &&
ref.read(pFrostResharingData).incompleteWallet != null && ref.read(pFrostResharingData).incompleteWallet != null &&
ref.read(pFrostResharingData).incompleteWallet?.walletId == ref.read(pFrostResharingData).incompleteWallet?.walletId ==
@ -217,6 +219,7 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
if (!amNewParticipant)
CheckboxTextButton( CheckboxTextButton(
label: "I have verified that everyone has my resharer complete", label: "I have verified that everyone has my resharer complete",
onChanged: (value) { onChanged: (value) {
@ -225,12 +228,13 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
}); });
}, },
), ),
if (!amNewParticipant)
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
PrimaryButton( PrimaryButton(
label: amOutgoingParticipant ? "Exit" : "Complete", label: amOutgoingParticipant ? "Done" : "Complete",
enabled: _userVerifyContinue && enabled: (amNewParticipant || _userVerifyContinue) &&
(amOutgoingParticipant || (amOutgoingParticipant ||
!fieldIsEmptyFlags.reduce((v, e) => v |= e)), !fieldIsEmptyFlags.reduce((v, e) => v |= e)),
onPressed: _onPressed, onPressed: _onPressed,

View file

@ -84,7 +84,7 @@ class _FrostReshareStep5State extends ConsumerState<FrostReshareStep5> {
), ),
context: context, context: context,
message: isNew ? "Creating wallet" : "Updating wallet data", message: isNew ? "Creating wallet" : "Updating wallet data",
isDesktop: Util.isDesktop, rootNavigator: true,
onException: (e) => ex = e, onException: (e) => ex = e,
); );

View file

@ -130,7 +130,7 @@ class _RestoreFrostMsWalletViewState
whileFuture: _createWalletAndRecover(), whileFuture: _createWalletAndRecover(),
context: context, context: context,
message: "Restoring wallet...", message: "Restoring wallet...",
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
onException: (e) { onException: (e) {
ex = e; ex = e;
}, },

View file

@ -79,7 +79,7 @@ class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
Future<void>.delayed(const Duration(seconds: 2)), Future<void>.delayed(const Duration(seconds: 2)),
]), ]),
context: context, context: context,
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
message: "Stopping fusion", message: "Stopping fusion",
); );

View file

@ -349,7 +349,7 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
), ),
]), ]),
context: context, context: context,
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
message: "Saving MonKey svg", message: "Saving MonKey svg",
onException: (e) { onException: (e) {
didError = true; didError = true;
@ -402,7 +402,7 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
const Duration(seconds: 2)), const Duration(seconds: 2)),
]), ]),
context: context, context: context,
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
message: "Downloading MonKey png", message: "Downloading MonKey png",
onException: (e) { onException: (e) {
didError = true; didError = true;
@ -500,7 +500,7 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
Future<void>.delayed(const Duration(seconds: 2)), Future<void>.delayed(const Duration(seconds: 2)),
]), ]),
context: context, context: context,
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
message: "Fetching MonKey", message: "Fetching MonKey",
subMessage: "We are fetching your MonKey", subMessage: "We are fetching your MonKey",
onException: (e) { onException: (e) {

View file

@ -321,7 +321,7 @@ class _OrdinalImageGroup extends ConsumerWidget {
final filePath = await showLoading<String>( final filePath = await showLoading<String>(
whileFuture: _savePngToFile(ref), whileFuture: _savePngToFile(ref),
context: context, context: context,
isDesktop: true, rootNavigator: true,
message: "Saving ordinal image", message: "Saving ordinal image",
onException: (e) { onException: (e) {
didError = true; didError = true;

View file

@ -116,7 +116,7 @@ class _FrostSendViewState extends ConsumerState<FrostSendView> {
whileFuture: _loadingFuture(), whileFuture: _loadingFuture(),
context: context, context: context,
message: "Generating sign config", message: "Generating sign config",
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
onException: (e) { onException: (e) {
throw e; throw e;
}, },

View file

@ -212,7 +212,7 @@ class _FrostSendStep4State extends ConsumerState<FrostSendStep4> {
), ),
context: context, context: context,
message: "Broadcasting transaction to network", message: "Broadcasting transaction to network",
isDesktop: true, // used to pop using root nav rootNavigator: true, // used to pop using root nav
onException: (e) { onException: (e) {
ex = e; ex = e;
}, },

View file

@ -83,7 +83,7 @@ class _ChangeRepresentativeViewState
whileFuture: changeFuture(_textController.text), whileFuture: changeFuture(_textController.text),
context: context, context: context,
message: "Updating representative...", message: "Updating representative...",
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
onException: (ex) { onException: (ex) {
String msg = ex.toString(); String msg = ex.toString();
while (msg.isNotEmpty && msg.startsWith("Exception:")) { while (msg.isNotEmpty && msg.startsWith("Exception:")) {

View file

@ -98,7 +98,7 @@ class _MyTokenSelectItemState extends ConsumerState<MyTokenSelectItem> {
final success = await showLoading<bool>( final success = await showLoading<bool>(
whileFuture: _loadTokenWallet(context, ref), whileFuture: _loadTokenWallet(context, ref),
context: context, context: context,
isDesktop: isDesktop, rootNavigator: isDesktop,
message: "Loading ${widget.token.name}", message: "Loading ${widget.token.name}",
); );

View file

@ -127,7 +127,7 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
whileFuture: loadFuture, whileFuture: loadFuture,
context: context, context: context,
message: 'Opening ${wallet.info.name}', message: 'Opening ${wallet.info.name}',
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
); );
if (mounted) { if (mounted) {

View file

@ -95,7 +95,7 @@ class WalletListItem extends ConsumerWidget {
whileFuture: loadFuture, whileFuture: loadFuture,
context: context, context: context,
message: 'Opening ${wallet.info.name}', message: 'Opening ${wallet.info.name}',
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
); );
if (context.mounted) { if (context.mounted) {
unawaited( unawaited(

View file

@ -132,7 +132,7 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
Future<void>.delayed(const Duration(seconds: 2)), Future<void>.delayed(const Duration(seconds: 2)),
]), ]),
context: context, context: context,
isDesktop: true, rootNavigator: true,
message: "Stopping fusion", message: "Stopping fusion",
); );

View file

@ -92,7 +92,7 @@ class CoinWalletsTable extends ConsumerWidget {
whileFuture: loadFuture, whileFuture: loadFuture,
context: context, context: context,
message: 'Opening ${wallet.info.name}', message: 'Opening ${wallet.info.name}',
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
); );
if (context.mounted) { if (context.mounted) {

View file

@ -234,7 +234,7 @@ class _DesktopOrdinalDetailsViewState
final path = await showLoading<String>( final path = await showLoading<String>(
whileFuture: _savePngToFile(), whileFuture: _savePngToFile(),
context: context, context: context,
isDesktop: true, rootNavigator: true,
message: "Saving ordinal image", message: "Saving ordinal image",
onException: (e) { onException: (e) {
didError = true; didError = true;

View file

@ -210,7 +210,7 @@ class _DesktopOrdinals extends ConsumerState<DesktopOrdinalsView> {
onPressed: () async { onPressed: () async {
// show loading for a minimum of 2 seconds on refreshing // show loading for a minimum of 2 seconds on refreshing
await showLoading( await showLoading(
isDesktop: true, rootNavigator: true,
whileFuture: Future.wait<void>([ whileFuture: Future.wait<void>([
Future.delayed(const Duration(seconds: 2)), Future.delayed(const Duration(seconds: 2)),
(ref.read(pWallets).getWallet(widget.walletId) (ref.read(pWallets).getWallet(widget.walletId)

View file

@ -20,7 +20,7 @@ Future<T?> showLoading<T>({
required BuildContext context, required BuildContext context,
required String message, required String message,
String? subMessage, String? subMessage,
bool isDesktop = false, bool rootNavigator = false,
bool opaqueBG = false, bool opaqueBG = false,
void Function(Exception)? onException, void Function(Exception)? onException,
}) async { }) async {
@ -59,7 +59,7 @@ Future<T?> showLoading<T>({
} }
if (context.mounted) { if (context.mounted) {
Navigator.of(context, rootNavigator: isDesktop).pop(); Navigator.of(context, rootNavigator: rootNavigator).pop();
if (ex != null) { if (ex != null) {
onException?.call(ex); onException?.call(ex);
} }

View file

@ -35,7 +35,9 @@ class IncompleteFrostWallet {
threshold: -1, threshold: -1,
); );
await mainDB.isar.writeTxn(() async {
await mainDB.isar.frostWalletInfo.put(frostInfo); await mainDB.isar.frostWalletInfo.put(frostInfo);
});
return wallet as BitcoinFrostWallet; return wallet as BitcoinFrostWallet;
} }

View file

@ -137,7 +137,7 @@ class SimpleWalletCard extends ConsumerWidget {
whileFuture: loadFuture, whileFuture: loadFuture,
context: context, context: context,
message: 'Opening ${wallet.info.name}', message: 'Opening ${wallet.info.name}',
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
); );
if (popPrevious) nav.pop(); if (popPrevious) nav.pop();
@ -167,7 +167,7 @@ class SimpleWalletCard extends ConsumerWidget {
context: desktopNavigatorState?.context ?? context, context: desktopNavigatorState?.context ?? context,
opaqueBG: true, opaqueBG: true,
message: "Loading ${contract.name}", message: "Loading ${contract.name}",
isDesktop: Util.isDesktop, rootNavigator: Util.isDesktop,
); );
if (!success!) { if (!success!) {