show contract symbol on mobile token receive page

This commit is contained in:
julian 2023-04-10 14:23:52 -06:00
parent 051eb6c924
commit 1268278adf
4 changed files with 22 additions and 12 deletions

View file

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:qr_flutter/qr_flutter.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/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/receive_view/addresses/wallet_addresses_view.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'; 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 { class ReceiveView extends ConsumerStatefulWidget {
const ReceiveView({ const ReceiveView({
Key? key, Key? key,
required this.coin,
required this.walletId, required this.walletId,
this.tokenContract,
this.clipboard = const ClipboardWrapper(), this.clipboard = const ClipboardWrapper(),
}) : super(key: key); }) : super(key: key);
static const String routeName = "/receiveView"; static const String routeName = "/receiveView";
final Coin coin;
final String walletId; final String walletId;
final EthContract? tokenContract;
final ClipboardInterface clipboard; final ClipboardInterface clipboard;
@override @override
@ -86,7 +87,7 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
@override @override
void initState() { void initState() {
walletId = widget.walletId; walletId = widget.walletId;
coin = widget.coin; coin = ref.read(walletsChangeNotifierProvider).getManager(walletId).coin;
clipboard = widget.clipboard; clipboard = widget.clipboard;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
@ -117,6 +118,8 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
} }
}); });
final ticker = widget.tokenContract?.symbol ?? coin.ticker;
return Background( return Background(
child: Scaffold( child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background, backgroundColor: Theme.of(context).extension<StackColors>()!.background,
@ -127,7 +130,7 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
}, },
), ),
title: Text( title: Text(
"Receive ${coin.ticker}", "Receive $ticker",
style: STextStyles.navBarTitle(context), style: STextStyles.navBarTitle(context),
), ),
actions: [ actions: [
@ -245,7 +248,7 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
Row( Row(
children: [ children: [
Text( Text(
"Your ${coin.ticker} address", "Your $ticker address",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
const Spacer(), const Spacer(),

View file

@ -209,7 +209,7 @@ class TokenWalletOptions extends StatelessWidget {
ReceiveView.routeName, ReceiveView.routeName,
arguments: Tuple2( arguments: Tuple2(
walletId, walletId,
Coin.ethereum, tokenContract,
), ),
); );
}, },

View file

@ -800,10 +800,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
unawaited( unawaited(
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
ReceiveView.routeName, ReceiveView.routeName,
arguments: Tuple2( arguments: walletId,
walletId,
coin,
),
), ),
); );
} }

View file

@ -1019,12 +1019,22 @@ class RouteGenerator {
return _routeError("${settings.name} invalid args: ${args.toString()}"); return _routeError("${settings.name} invalid args: ${args.toString()}");
case ReceiveView.routeName: case ReceiveView.routeName:
if (args is Tuple2<String, Coin>) { if (args is String) {
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => ReceiveView(
walletId: args,
),
settings: RouteSettings(
name: settings.name,
),
);
} else if (args is Tuple2<String, EthContract?>) {
return getRoute( return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute, shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => ReceiveView( builder: (_) => ReceiveView(
walletId: args.item1, walletId: args.item1,
coin: args.item2, tokenContract: args.item2,
), ),
settings: RouteSettings( settings: RouteSettings(
name: settings.name, name: settings.name,