From 1268278adf6ce0a4ce0bf641aff8b725acf6eeeb Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 10 Apr 2023 14:23:52 -0600 Subject: [PATCH] show contract symbol on mobile token receive page --- lib/pages/receive_view/receive_view.dart | 13 ++++++++----- .../token_view/sub_widgets/token_summary.dart | 2 +- lib/pages/wallet_view/wallet_view.dart | 5 +---- lib/route_generator.dart | 14 ++++++++++++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index 94cec7c14..87587aa46 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/receive_view/addresses/wallet_addresses_view.dart'; import 'package:stackwallet/pages/receive_view/generate_receiving_uri_qr_code_view.dart'; @@ -25,15 +26,15 @@ import 'package:stackwallet/widgets/rounded_white_container.dart'; class ReceiveView extends ConsumerStatefulWidget { const ReceiveView({ Key? key, - required this.coin, required this.walletId, + this.tokenContract, this.clipboard = const ClipboardWrapper(), }) : super(key: key); static const String routeName = "/receiveView"; - final Coin coin; final String walletId; + final EthContract? tokenContract; final ClipboardInterface clipboard; @override @@ -86,7 +87,7 @@ class _ReceiveViewState extends ConsumerState { @override void initState() { walletId = widget.walletId; - coin = widget.coin; + coin = ref.read(walletsChangeNotifierProvider).getManager(walletId).coin; clipboard = widget.clipboard; WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { @@ -117,6 +118,8 @@ class _ReceiveViewState extends ConsumerState { } }); + final ticker = widget.tokenContract?.symbol ?? coin.ticker; + return Background( child: Scaffold( backgroundColor: Theme.of(context).extension()!.background, @@ -127,7 +130,7 @@ class _ReceiveViewState extends ConsumerState { }, ), title: Text( - "Receive ${coin.ticker}", + "Receive $ticker", style: STextStyles.navBarTitle(context), ), actions: [ @@ -245,7 +248,7 @@ class _ReceiveViewState extends ConsumerState { Row( children: [ Text( - "Your ${coin.ticker} address", + "Your $ticker address", style: STextStyles.itemSubtitle(context), ), const Spacer(), diff --git a/lib/pages/token_view/sub_widgets/token_summary.dart b/lib/pages/token_view/sub_widgets/token_summary.dart index d9c62ae66..30b60a885 100644 --- a/lib/pages/token_view/sub_widgets/token_summary.dart +++ b/lib/pages/token_view/sub_widgets/token_summary.dart @@ -209,7 +209,7 @@ class TokenWalletOptions extends StatelessWidget { ReceiveView.routeName, arguments: Tuple2( walletId, - Coin.ethereum, + tokenContract, ), ); }, diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 82adc3b6a..941acd719 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -800,10 +800,7 @@ class _WalletViewState extends ConsumerState { unawaited( Navigator.of(context).pushNamed( ReceiveView.routeName, - arguments: Tuple2( - walletId, - coin, - ), + arguments: walletId, ), ); } diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 4031e425e..340b7803d 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -1019,12 +1019,22 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case ReceiveView.routeName: - if (args is Tuple2) { + if (args is String) { + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => ReceiveView( + walletId: args, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } else if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => ReceiveView( walletId: args.item1, - coin: args.item2, + tokenContract: args.item2, ), settings: RouteSettings( name: settings.name,