mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
add coin as arg to BuyInWalletView->BuyView->BuyForm
This commit is contained in:
parent
79e1bbf13b
commit
6b6ef179cc
5 changed files with 38 additions and 7 deletions
|
@ -48,10 +48,13 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
|||
class BuyForm extends ConsumerStatefulWidget {
|
||||
const BuyForm({
|
||||
Key? key,
|
||||
this.coin,
|
||||
this.clipboard = const ClipboardWrapper(),
|
||||
this.scanner = const BarcodeScannerWrapper(),
|
||||
}) : super(key: key);
|
||||
|
||||
final Coin? coin;
|
||||
|
||||
final ClipboardInterface clipboard;
|
||||
final BarcodeScannerInterface scanner;
|
||||
|
||||
|
@ -60,6 +63,8 @@ class BuyForm extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _BuyFormState extends ConsumerState<BuyForm> {
|
||||
late final Coin? coin;
|
||||
|
||||
late final ClipboardInterface clipboard;
|
||||
late final BarcodeScannerInterface scanner;
|
||||
|
||||
|
@ -701,7 +706,10 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
// TODO set defaults better; should probably explicitly enumerate the coins & fiats used and pull the specific ones we need rather than generating them as defaults here
|
||||
selectedFiat =
|
||||
Fiat.fromJson({'ticker': 'USD', 'name': 'United States Dollar'});
|
||||
selectedCrypto = Crypto.fromJson({'ticker': 'BTC', 'name': 'Bitcoin'});
|
||||
selectedCrypto = Crypto.fromJson({
|
||||
'ticker': widget.coin?.ticker ?? 'BTC',
|
||||
'name': widget.coin?.prettyName ?? 'Bitcoin'
|
||||
});
|
||||
|
||||
// TODO set initial crypto to open wallet if a wallet is open
|
||||
|
||||
|
|
|
@ -1,20 +1,28 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/pages/buy_view/buy_view.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
||||
class BuyInWalletView extends StatefulWidget {
|
||||
const BuyInWalletView({Key? key}) : super(key: key);
|
||||
const BuyInWalletView({
|
||||
Key? key,
|
||||
required this.coin,
|
||||
}) : super(key: key);
|
||||
|
||||
static const String routeName = "/stackBuyInWalletView";
|
||||
|
||||
final Coin? coin;
|
||||
|
||||
@override
|
||||
State<BuyInWalletView> createState() => _BuyInWalletViewState();
|
||||
}
|
||||
|
||||
class _BuyInWalletViewState extends State<BuyInWalletView> {
|
||||
late final Coin? coin;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
@ -33,7 +41,7 @@ class _BuyInWalletViewState extends State<BuyInWalletView> {
|
|||
style: STextStyles.navBarTitle(context),
|
||||
),
|
||||
),
|
||||
body: const BuyView(),
|
||||
body: BuyView(coin: widget.coin),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
||||
class BuyView extends StatefulWidget {
|
||||
const BuyView({Key? key}) : super(key: key);
|
||||
const BuyView({
|
||||
Key? key,
|
||||
this.coin,
|
||||
}) : super(key: key);
|
||||
|
||||
static const String routeName = "/stackBuyView";
|
||||
|
||||
final Coin? coin;
|
||||
|
||||
@override
|
||||
State<BuyView> createState() => _BuyViewState();
|
||||
}
|
||||
|
||||
class _BuyViewState extends State<BuyView> {
|
||||
late final Coin? coin;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
|
|
@ -779,6 +779,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
|
||||
unawaited(Navigator.of(context).pushNamed(
|
||||
BuyInWalletView.routeName,
|
||||
arguments: coin,
|
||||
));
|
||||
},
|
||||
),
|
||||
|
|
|
@ -1134,10 +1134,16 @@ class RouteGenerator {
|
|||
settings: RouteSettings(name: settings.name));
|
||||
|
||||
case BuyInWalletView.routeName:
|
||||
return getRoute(
|
||||
if (args is Coin) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => const BuyInWalletView(),
|
||||
settings: RouteSettings(name: settings.name));
|
||||
builder: (_) => BuyInWalletView(coin: args),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case DesktopBuyView.routeName:
|
||||
return getRoute(
|
||||
|
|
Loading…
Reference in a new issue