eth token wallet navigation fixes

This commit is contained in:
julian 2023-10-17 11:21:53 -06:00
parent 122430f03c
commit 9c4ccfa7ad
4 changed files with 163 additions and 134 deletions

View file

@ -37,12 +37,14 @@ class TokenView extends ConsumerStatefulWidget {
const TokenView({
Key? key,
required this.walletId,
this.popPrevious = false,
this.eventBus,
}) : super(key: key);
static const String routeName = "/token";
final String walletId;
final bool popPrevious;
final EventBus? eventBus;
@override
@ -69,13 +71,27 @@ class _TokenViewState extends ConsumerState<TokenView> {
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
return Background(
return WillPopScope(
onWillPop: () async {
final nav = Navigator.of(context);
if (widget.popPrevious) {
nav.pop();
}
nav.pop();
return false;
},
child: Background(
child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
Navigator.of(context).pop();
final nav = Navigator.of(context);
if (widget.popPrevious) {
nav.pop();
}
nav.pop();
},
),
centerTitle: true,
@ -223,6 +239,7 @@ class _TokenViewState extends ConsumerState<TokenView> {
),
),
),
),
);
}
}

View file

@ -1992,6 +1992,17 @@ class RouteGenerator {
name: settings.name,
),
);
} else if (args is ({String walletId, bool popPrevious})) {
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => TokenView(
walletId: args.walletId,
popPrevious: args.popPrevious,
),
settings: RouteSettings(
name: settings.name,
),
);
}
return _routeError("${settings.name} invalid args: ${args.toString()}");

View file

@ -16,6 +16,7 @@ import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
import 'package:stackwallet/widgets/expandable.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -141,7 +142,7 @@ class _MasterWalletCardState extends ConsumerState<MasterWalletCard> {
child: SimpleWalletCard(
walletId: widget.walletId,
contractAddress: e,
popPrevious: true,
popPrevious: Util.isDesktop,
),
),
),

View file

@ -157,7 +157,7 @@ class SimpleWalletCard extends ConsumerWidget {
} else {
await nav.pushNamed(
TokenView.routeName,
arguments: walletId,
arguments: (walletId: walletId, popPrevious: !Util.isDesktop),
);
}
}