| 1 | import 'package:cake_wallet/generated/i18n.dart'; |
| 2 | import 'package:cake_wallet/new-ui/widgets/new_primary_button.dart'; |
| 3 | import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart'; |
| 4 | import 'package:cake_wallet/new-ui/widgets/send_page/send_address_input.dart'; |
| 5 | import 'package:cake_wallet/src/widgets/cake_image_widget.dart'; |
| 6 | import 'package:cw_core/crypto_currency.dart'; |
| 7 | import 'package:flutter/material.dart'; |
| 8 | import 'package:flutter_svg/flutter_svg.dart'; |
| 9 | |
| 10 | class RefundAddressModal extends StatefulWidget { |
| 11 | const RefundAddressModal( |
| 12 | {super.key, this.isFromWalletSelection = false, required this.selectedCurrency}); |
| 13 | |
| 14 | final bool isFromWalletSelection; |
| 15 | final CryptoCurrency selectedCurrency; |
| 16 | |
| 17 | @override |
| 18 | State<RefundAddressModal> createState() => _RefundAddressModalState(); |
| 19 | } |
| 20 | |
| 21 | class _RefundAddressModalState extends State<RefundAddressModal> { |
| 22 | final addressController = TextEditingController(); |
| 23 | bool _textEntered = false; |
| 24 | |
| 25 | @override |
| 26 | void initState() { |
| 27 | super.initState(); |
| 28 | addressController.addListener(() { |
| 29 | setState(() { |
| 30 | _textEntered = addressController.text.isNotEmpty; |
| 31 | }); |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | @override |
| 36 | Widget build(BuildContext context) { |
| 37 | return Container( |
| 38 | decoration: BoxDecoration( |
| 39 | color: Theme.of(context).colorScheme.surface, |
| 40 | borderRadius: BorderRadius.vertical(top: Radius.circular(16))), |
| 41 | child: Column( |
| 42 | mainAxisSize: MainAxisSize.min, |
| 43 | children: [ |
| 44 | ModalTopBar( |
| 45 | title: S.of(context).set_refund_address, |
| 46 | trailingIcon: Icon(Icons.close), |
| 47 | trailingSemanticLabel: S.of(context).close, |
| 48 | onTrailingPressed: Navigator.of(context).pop, |
| 49 | ), |
| 50 | SafeArea( |
| 51 | child: Padding( |
| 52 | padding: const EdgeInsets.symmetric(horizontal: 16.0), |
| 53 | child: Column( |
| 54 | spacing: 24, |
| 55 | children: [ |
| 56 | CakeImageWidget( |
| 57 | imageUrl: "assets/new-ui/refund_address.svg", |
| 58 | colorFilter: |
| 59 | ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn), |
| 60 | ), |
| 61 | Text( |
| 62 | S.of(context).return_address_desc + |
| 63 | (widget.isFromWalletSelection |
| 64 | ? "\n\n${S.of(context).return_address_desc_external}" |
| 65 | : ""), |
| 66 | textAlign: TextAlign.center, |
| 67 | style: TextStyle( |
| 68 | color: Theme.of(context).colorScheme.onSurfaceVariant, |
| 69 | fontSize: 14, |
| 70 | fontWeight: FontWeight.w400), |
| 71 | ), |
| 72 | Column( |
| 73 | spacing: 12, |
| 74 | children: [ |
| 75 | NewSendAddressInput( |
| 76 | bottomPadding: true, |
| 77 | addressController: addressController, |
| 78 | selectedCurrency: widget.selectedCurrency, |
| 79 | onEditingComplete: () {}), |
| 80 | if (widget.isFromWalletSelection || _textEntered) |
| 81 | NewPrimaryButton( |
| 82 | onPressed: () { |
| 83 | Navigator.of(context).pop(addressController.text); |
| 84 | }, |
| 85 | text: !_textEntered |
| 86 | ? S.of(context).skip_set_later |
| 87 | : S.of(context).continue_text, |
| 88 | color: addressController.text.isEmpty |
| 89 | ? Theme.of(context).colorScheme.surfaceContainer |
| 90 | : Theme.of(context).colorScheme.primary, |
| 91 | textColor: addressController.text.isEmpty |
| 92 | ? Theme.of(context).colorScheme.primary |
| 93 | : Theme.of(context).colorScheme.onPrimary) |
| 94 | ], |
| 95 | ), |
| 96 | SizedBox() |
| 97 | ], |
| 98 | ), |
| 99 | ), |
| 100 | ) |
| 101 | ], |
| 102 | ), |
| 103 | ); |
| 104 | } |
| 105 | } |