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({ const TokenView({
Key? key, Key? key,
required this.walletId, required this.walletId,
this.popPrevious = false,
this.eventBus, this.eventBus,
}) : super(key: key); }) : super(key: key);
static const String routeName = "/token"; static const String routeName = "/token";
final String walletId; final String walletId;
final bool popPrevious;
final EventBus? eventBus; final EventBus? eventBus;
@override @override
@ -69,157 +71,172 @@ class _TokenViewState extends ConsumerState<TokenView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType"); debugPrint("BUILD: $runtimeType");
return Background( return WillPopScope(
child: Scaffold( onWillPop: () async {
backgroundColor: Theme.of(context).extension<StackColors>()!.background, final nav = Navigator.of(context);
appBar: AppBar( if (widget.popPrevious) {
leading: AppBarBackButton( nav.pop();
onPressed: () { }
Navigator.of(context).pop(); nav.pop();
}, return false;
), },
centerTitle: true, child: Background(
title: Row( child: Scaffold(
mainAxisAlignment: MainAxisAlignment.center, backgroundColor:
mainAxisSize: MainAxisSize.min, Theme.of(context).extension<StackColors>()!.background,
children: [ appBar: AppBar(
Expanded( leading: AppBarBackButton(
child: Row( onPressed: () {
mainAxisAlignment: MainAxisAlignment.center, final nav = Navigator.of(context);
children: [ if (widget.popPrevious) {
EthTokenIcon( nav.pop();
contractAddress: ref.watch( }
tokenServiceProvider.select( nav.pop();
(value) => value!.tokenContract.address, },
),
centerTitle: true,
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
EthTokenIcon(
contractAddress: ref.watch(
tokenServiceProvider.select(
(value) => value!.tokenContract.address,
),
),
size: 24,
),
const SizedBox(
width: 10,
),
Flexible(
child: Text(
ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.name)),
style: STextStyles.navBarTitle(context),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
), ),
), ),
size: 24, ],
),
),
],
),
actions: [
Padding(
padding: const EdgeInsets.only(right: 2),
child: AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
icon: SvgPicture.asset(
Assets.svg.verticalEllipsis,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
), ),
const SizedBox( onPressed: () {
width: 10, // todo: context menu
), Navigator.of(context).pushNamed(
Flexible( TokenContractDetailsView.routeName,
child: Text( arguments: Tuple2(
ref.watch(tokenServiceProvider ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.name)), .select((value) => value!.tokenContract.address)),
style: STextStyles.navBarTitle(context), widget.walletId,
overflow: TextOverflow.ellipsis, ),
textAlign: TextAlign.center, );
), },
), ),
],
), ),
), ),
], ],
), ),
actions: [ body: Container(
Padding( color: Theme.of(context).extension<StackColors>()!.background,
padding: const EdgeInsets.only(right: 2), child: Column(
child: AspectRatio( children: [
aspectRatio: 1, const SizedBox(
child: AppBarIconButton( height: 10,
icon: SvgPicture.asset(
Assets.svg.verticalEllipsis,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
),
onPressed: () {
// todo: context menu
Navigator.of(context).pushNamed(
TokenContractDetailsView.routeName,
arguments: Tuple2(
ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.address)),
widget.walletId,
),
);
},
), ),
), Padding(
),
],
),
body: Container(
color: Theme.of(context).extension<StackColors>()!.background,
child: Column(
children: [
const SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TokenSummary(
walletId: widget.walletId,
initialSyncStatus: initialSyncStatus,
),
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Transactions",
style: STextStyles.itemSubtitle(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
),
),
CustomTextButton(
text: "See all",
onTap: () {
Navigator.of(context).pushNamed(
AllTransactionsView.routeName,
arguments: widget.walletId,
);
},
),
],
),
),
const SizedBox(
height: 12,
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: ClipRRect( child: TokenSummary(
borderRadius: BorderRadius.vertical( walletId: widget.walletId,
top: Radius.circular( initialSyncStatus: initialSyncStatus,
Constants.size.circularBorderRadius, ),
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Transactions",
style: STextStyles.itemSubtitle(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
),
), ),
bottom: Radius.circular( CustomTextButton(
// TokenView.navBarHeight / 2.0, text: "See all",
Constants.size.circularBorderRadius, onTap: () {
Navigator.of(context).pushNamed(
AllTransactionsView.routeName,
arguments: widget.walletId,
);
},
), ),
), ],
child: Container( ),
decoration: BoxDecoration( ),
color: Colors.transparent, const SizedBox(
borderRadius: BorderRadius.circular( height: 12,
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ClipRRect(
borderRadius: BorderRadius.vertical(
top: Radius.circular(
Constants.size.circularBorderRadius,
),
bottom: Radius.circular(
// TokenView.navBarHeight / 2.0,
Constants.size.circularBorderRadius, Constants.size.circularBorderRadius,
), ),
), ),
child: Column( child: Container(
crossAxisAlignment: CrossAxisAlignment.stretch, decoration: BoxDecoration(
children: [ color: Colors.transparent,
Expanded( borderRadius: BorderRadius.circular(
child: TokenTransactionsList( Constants.size.circularBorderRadius,
walletId: widget.walletId,
),
), ),
], ),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: TokenTransactionsList(
walletId: widget.walletId,
),
),
],
),
), ),
), ),
), ),
), ),
), ],
], ),
), ),
), ),
), ),

View file

@ -1992,6 +1992,17 @@ class RouteGenerator {
name: settings.name, 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()}"); 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/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.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/animated_widgets/rotate_icon.dart';
import 'package:stackwallet/widgets/expandable.dart'; import 'package:stackwallet/widgets/expandable.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -141,7 +142,7 @@ class _MasterWalletCardState extends ConsumerState<MasterWalletCard> {
child: SimpleWalletCard( child: SimpleWalletCard(
walletId: widget.walletId, walletId: widget.walletId,
contractAddress: e, contractAddress: e,
popPrevious: true, popPrevious: Util.isDesktop,
), ),
), ),
), ),

View file

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