dev
dart 83 lines 3.5 KB
Raw
1 import 'package:cake_wallet/entities/fiat_currency.dart';
2 import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
3 import 'package:flutter/material.dart';
4 import 'package:flutter_mobx/flutter_mobx.dart';
5
6 class ReceiveAmountDisplay extends StatelessWidget {
7 const ReceiveAmountDisplay(
8 {super.key, required this.walletAddressListViewModel, required this.largeQrMode});
9
10 final WalletAddressListViewModel walletAddressListViewModel;
11 final bool largeQrMode;
12
13 @override
14 Widget build(BuildContext context) {
15 return Observer(
16 builder: (_) => AnimatedOpacity(
17 duration: Duration(milliseconds: 300),
18 curve: Curves.easeOutCubic,
19 opacity: largeQrMode || walletAddressListViewModel.displayAmount.isEmpty ? 0 : 1,
20 child: AnimatedAlign(
21 duration: Duration(milliseconds: 300),
22 curve: Curves.easeOutCubic,
23 heightFactor: largeQrMode || walletAddressListViewModel.displayAmount.isEmpty ? 0 : 1,
24 alignment: Alignment.topCenter,
25 // Amount, currency symbol and fiat equivalent describe one value, so
26 // they are announced as a single node.
27 child: MergeSemantics(
28 child: Container(
29 width: double.infinity,
30 child: Row(
31 spacing: 4,
32 mainAxisSize: MainAxisSize.min,
33 mainAxisAlignment: MainAxisAlignment.center,
34 children: [
35 Container(
36 decoration: BoxDecoration(
37 borderRadius: BorderRadius.circular(12),
38 color: Theme.of(context).colorScheme.surfaceContainer),
39 child: Padding(
40 padding: const EdgeInsets.all(8.0),
41 child: Row(
42 spacing: 8.0,
43 children: [
44 Text(
45 walletAddressListViewModel.displayAmount,
46 style: TextStyle(
47 color: Theme.of(context).colorScheme.primary,
48 fontSize: 16,
49 fontWeight: FontWeight.w500),
50 ),
51 Text(walletAddressListViewModel.cryptoCurrencySymbol,
52 style: TextStyle(
53 color: Theme.of(context).colorScheme.primary,
54 fontSize: 16,
55 fontWeight: FontWeight.w500))
56 ],
57 ),
58 ),
59 ),
60 if (!walletAddressListViewModel.isFiatDisabled)
61 Padding(
62 padding: const EdgeInsets.all(8.0),
63 child: Text(
64 _getFiatAmount(),
65 style: TextStyle(
66 color: Theme.of(context).colorScheme.onSurfaceVariant,
67 fontSize: 16,
68 fontWeight: FontWeight.w500),
69 ),
70 )
71 ],
72 ),
73 ),
74 ),
75 ),
76 ),
77 );
78 }
79
80 String _getFiatAmount() {
81 return "${walletAddressListViewModel.fiatAmount} ${walletAddressListViewModel.selectedCurrency is FiatCurrency && walletAddressListViewModel.selectedCurrencyFiatAmount.isNotEmpty ? walletAddressListViewModel.selectedCurrency.name : walletAddressListViewModel.fiatCurrency.name}";
82 }
83 }