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,157 +71,172 @@ class _TokenViewState extends ConsumerState<TokenView> {
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
return Background(
child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
Navigator.of(context).pop();
},
),
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,
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,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
final nav = Navigator.of(context);
if (widget.popPrevious) {
nav.pop();
}
nav.pop();
},
),
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(
width: 10,
),
Flexible(
child: Text(
ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.name)),
style: STextStyles.navBarTitle(context),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
),
],
onPressed: () {
// todo: context menu
Navigator.of(context).pushNamed(
TokenContractDetailsView.routeName,
arguments: Tuple2(
ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.address)),
widget.walletId,
),
);
},
),
),
),
],
),
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,
),
onPressed: () {
// todo: context menu
Navigator.of(context).pushNamed(
TokenContractDetailsView.routeName,
arguments: Tuple2(
ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.address)),
widget.walletId,
),
);
},
body: Container(
color: Theme.of(context).extension<StackColors>()!.background,
child: Column(
children: [
const SizedBox(
height: 10,
),
),
),
],
),
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(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ClipRRect(
borderRadius: BorderRadius.vertical(
top: Radius.circular(
Constants.size.circularBorderRadius,
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,
),
),
bottom: Radius.circular(
// TokenView.navBarHeight / 2.0,
Constants.size.circularBorderRadius,
CustomTextButton(
text: "See all",
onTap: () {
Navigator.of(context).pushNamed(
AllTransactionsView.routeName,
arguments: widget.walletId,
);
},
),
),
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(
],
),
),
const SizedBox(
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,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: TokenTransactionsList(
walletId: widget.walletId,
),
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: TokenTransactionsList(
walletId: widget.walletId,
),
),
],
),
),
),
),
),
),
],
],
),
),
),
),

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),
);
}
}