2024-03-21 04:51:57 +02:00
|
|
|
import 'package:cake_wallet/core/amount_validator.dart';
|
2021-07-23 14:05:33 +03:00
|
|
|
import 'package:cake_wallet/entities/contact_base.dart';
|
2024-08-10 00:48:36 +03:00
|
|
|
import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
|
2021-07-23 14:05:33 +03:00
|
|
|
import 'package:cake_wallet/routes.dart';
|
2022-03-31 19:54:45 +02:00
|
|
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart';
|
2020-09-30 21:23:15 +03:00
|
|
|
import 'package:cake_wallet/utils/show_bar.dart';
|
2020-09-25 18:32:44 +03:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
2022-03-31 19:54:45 +02:00
|
|
|
import 'package:cake_wallet/utils/payment_request.dart';
|
2023-03-24 17:26:42 +02:00
|
|
|
import 'package:cw_core/currency.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2021-12-24 14:37:24 +02:00
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
2020-05-12 20:46:42 +03:00
|
|
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
2020-05-13 21:26:15 +03:00
|
|
|
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2024-11-09 21:00:56 +02:00
|
|
|
class ExchangeCard<T extends Currency> extends StatefulWidget {
|
2024-09-22 03:46:51 +01:00
|
|
|
ExchangeCard({
|
|
|
|
Key? key,
|
|
|
|
required this.initialCurrency,
|
|
|
|
required this.initialAddress,
|
|
|
|
required this.initialWalletName,
|
|
|
|
required this.initialIsAmountEditable,
|
|
|
|
required this.isAmountEstimated,
|
|
|
|
required this.currencies,
|
|
|
|
required this.onCurrencySelected,
|
|
|
|
this.imageArrow,
|
|
|
|
this.currencyValueValidator,
|
|
|
|
this.addressTextFieldValidator,
|
|
|
|
this.title = '',
|
|
|
|
this.initialIsAddressEditable = true,
|
|
|
|
this.hasRefundAddress = false,
|
|
|
|
this.isMoneroWallet = false,
|
|
|
|
this.currencyButtonColor = Colors.transparent,
|
|
|
|
this.addressButtonsColor = Colors.transparent,
|
|
|
|
this.borderColor = Colors.transparent,
|
|
|
|
this.hasAllAmount = false,
|
|
|
|
this.isAllAmountEnabled = false,
|
2024-11-09 21:00:56 +02:00
|
|
|
this.showAddressField = true,
|
|
|
|
this.showLimitsField = true,
|
2024-09-22 03:46:51 +01:00
|
|
|
this.amountFocusNode,
|
|
|
|
this.addressFocusNode,
|
|
|
|
this.allAmount,
|
2024-11-09 21:00:56 +02:00
|
|
|
this.currencyRowPadding,
|
|
|
|
this.addressRowPadding,
|
2024-09-22 03:46:51 +01:00
|
|
|
this.onPushPasteButton,
|
|
|
|
this.onPushAddressBookButton,
|
|
|
|
this.onDispose,
|
|
|
|
required this.cardInstanceName,
|
|
|
|
}) : super(key: key);
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2024-11-09 21:00:56 +02:00
|
|
|
final List<T> currencies;
|
|
|
|
final Function(T) onCurrencySelected;
|
2020-05-12 20:46:42 +03:00
|
|
|
final String title;
|
2024-11-09 21:00:56 +02:00
|
|
|
final T initialCurrency;
|
2020-01-08 14:26:34 +02:00
|
|
|
final String initialWalletName;
|
|
|
|
final String initialAddress;
|
|
|
|
final bool initialIsAmountEditable;
|
|
|
|
final bool initialIsAddressEditable;
|
|
|
|
final bool isAmountEstimated;
|
2020-10-02 18:49:45 +03:00
|
|
|
final bool hasRefundAddress;
|
2021-07-23 14:05:33 +03:00
|
|
|
final bool isMoneroWallet;
|
2024-08-10 00:48:36 +03:00
|
|
|
final Image? imageArrow;
|
2020-05-12 20:46:42 +03:00
|
|
|
final Color currencyButtonColor;
|
2022-10-12 13:09:57 -04:00
|
|
|
final Color? addressButtonsColor;
|
2020-08-21 23:26:23 +03:00
|
|
|
final Color borderColor;
|
2022-10-12 13:09:57 -04:00
|
|
|
final FormFieldValidator<String>? currencyValueValidator;
|
|
|
|
final FormFieldValidator<String>? addressTextFieldValidator;
|
2024-03-21 04:51:57 +02:00
|
|
|
final FormFieldValidator<String> allAmountValidator = AllAmountValidator();
|
2022-10-12 13:09:57 -04:00
|
|
|
final FocusNode? amountFocusNode;
|
|
|
|
final FocusNode? addressFocusNode;
|
2021-01-05 20:31:03 +02:00
|
|
|
final bool hasAllAmount;
|
2024-11-09 21:00:56 +02:00
|
|
|
final bool showAddressField;
|
|
|
|
final bool showLimitsField;
|
2024-03-21 04:51:57 +02:00
|
|
|
final bool isAllAmountEnabled;
|
2022-10-12 13:09:57 -04:00
|
|
|
final VoidCallback? allAmount;
|
2024-11-09 21:00:56 +02:00
|
|
|
final EdgeInsets? currencyRowPadding;
|
|
|
|
final EdgeInsets? addressRowPadding;
|
2022-10-12 13:09:57 -04:00
|
|
|
final void Function(BuildContext context)? onPushPasteButton;
|
|
|
|
final void Function(BuildContext context)? onPushAddressBookButton;
|
2022-10-20 19:47:36 +02:00
|
|
|
final Function()? onDispose;
|
2024-09-22 03:46:51 +01:00
|
|
|
final String cardInstanceName;
|
2020-01-08 14:26:34 +02:00
|
|
|
|
2020-01-04 21:31:52 +02:00
|
|
|
@override
|
2024-11-09 21:00:56 +02:00
|
|
|
ExchangeCardState<T> createState() => ExchangeCardState<T>();
|
2020-01-04 21:31:52 +02:00
|
|
|
}
|
|
|
|
|
2024-11-09 21:00:56 +02:00
|
|
|
class ExchangeCardState<T extends Currency> extends State<ExchangeCard<T>> {
|
2022-10-12 13:09:57 -04:00
|
|
|
ExchangeCardState()
|
2024-03-21 04:51:57 +02:00
|
|
|
: _title = '',
|
|
|
|
_min = '',
|
|
|
|
_max = '',
|
|
|
|
_isAmountEditable = false,
|
|
|
|
_isAddressEditable = false,
|
|
|
|
_walletName = '',
|
|
|
|
_isAmountEstimated = false,
|
2024-09-22 03:46:51 +01:00
|
|
|
_isMoneroWallet = false,
|
|
|
|
_cardInstanceName = '';
|
2022-10-12 13:09:57 -04:00
|
|
|
|
2020-01-04 21:31:52 +02:00
|
|
|
final addressController = TextEditingController();
|
|
|
|
final amountController = TextEditingController();
|
|
|
|
|
2024-09-22 03:46:51 +01:00
|
|
|
String _cardInstanceName;
|
2020-05-12 20:46:42 +03:00
|
|
|
String _title;
|
2022-10-12 13:09:57 -04:00
|
|
|
String? _min;
|
|
|
|
String? _max;
|
2024-11-09 21:00:56 +02:00
|
|
|
late T _selectedCurrency;
|
2020-01-04 21:31:52 +02:00
|
|
|
String _walletName;
|
|
|
|
bool _isAmountEditable;
|
|
|
|
bool _isAddressEditable;
|
|
|
|
bool _isAmountEstimated;
|
2021-07-23 14:05:33 +03:00
|
|
|
bool _isMoneroWallet;
|
2020-01-04 21:31:52 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
2024-09-22 03:46:51 +01:00
|
|
|
_cardInstanceName = widget.cardInstanceName;
|
2020-05-12 20:46:42 +03:00
|
|
|
_title = widget.title;
|
2020-01-04 21:31:52 +02:00
|
|
|
_isAmountEditable = widget.initialIsAmountEditable;
|
|
|
|
_isAddressEditable = widget.initialIsAddressEditable;
|
|
|
|
_walletName = widget.initialWalletName;
|
|
|
|
_selectedCurrency = widget.initialCurrency;
|
|
|
|
_isAmountEstimated = widget.isAmountEstimated;
|
2021-07-23 14:05:33 +03:00
|
|
|
_isMoneroWallet = widget.isMoneroWallet;
|
2024-11-09 21:00:56 +02:00
|
|
|
addressController.text = _normalizeAddressFormat(widget.initialAddress);
|
|
|
|
|
2020-01-04 21:31:52 +02:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2022-10-20 19:47:36 +02:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
widget.onDispose?.call();
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2022-10-12 13:09:57 -04:00
|
|
|
void changeLimits({String? min, String? max}) {
|
2020-01-04 21:31:52 +02:00
|
|
|
setState(() {
|
|
|
|
_min = min;
|
|
|
|
_max = max;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-11-09 21:00:56 +02:00
|
|
|
void changeSelectedCurrency(T currency) {
|
2020-01-04 21:31:52 +02:00
|
|
|
setState(() => _selectedCurrency = currency);
|
|
|
|
}
|
|
|
|
|
|
|
|
void changeWalletName(String walletName) {
|
|
|
|
setState(() => _walletName = walletName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void changeIsAction(bool isActive) {
|
|
|
|
setState(() => _isAmountEditable = isActive);
|
|
|
|
}
|
|
|
|
|
|
|
|
void isAmountEditable({bool isEditable = true}) {
|
|
|
|
setState(() => _isAmountEditable = isEditable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void isAddressEditable({bool isEditable = true}) {
|
|
|
|
setState(() => _isAddressEditable = isEditable);
|
|
|
|
}
|
|
|
|
|
2022-10-12 13:09:57 -04:00
|
|
|
void changeAddress({required String address}) {
|
2024-11-09 21:00:56 +02:00
|
|
|
setState(() => addressController.text = _normalizeAddressFormat(address));
|
2020-01-04 21:31:52 +02:00
|
|
|
}
|
|
|
|
|
2022-10-12 13:09:57 -04:00
|
|
|
void changeAmount({required String amount}) {
|
2020-01-04 21:31:52 +02:00
|
|
|
setState(() => amountController.text = amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
void changeIsAmountEstimated(bool isEstimated) {
|
|
|
|
setState(() => _isAmountEstimated = isEstimated);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-03-21 04:51:57 +02:00
|
|
|
if (widget.isAllAmountEnabled) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
amountController.text = S.of(context).all;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-08-21 23:26:23 +03:00
|
|
|
final copyImage = Image.asset('assets/images/copy_content.png',
|
2020-09-29 20:56:11 +03:00
|
|
|
height: 16,
|
|
|
|
width: 16,
|
2023-08-17 12:28:31 -03:00
|
|
|
color: Theme.of(context).extension<SendPageTheme>()!.estimatedFeeColor);
|
2020-08-21 23:26:23 +03:00
|
|
|
|
2020-01-04 21:31:52 +02:00
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
2020-05-12 20:46:42 +03:00
|
|
|
color: Colors.transparent,
|
2024-03-21 04:51:57 +02:00
|
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
|
2020-05-12 20:46:42 +03:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
2024-09-22 03:46:51 +01:00
|
|
|
key: ValueKey('${_cardInstanceName}_title_key'),
|
2020-05-12 20:46:42 +03:00
|
|
|
_title,
|
|
|
|
style: TextStyle(
|
2020-09-29 20:56:11 +03:00
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w600,
|
2023-08-17 12:28:31 -03:00
|
|
|
color: Theme.of(context).extension<QRCodeTheme>()!.qrCodeColor),
|
2020-05-12 20:46:42 +03:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2024-08-10 00:48:36 +03:00
|
|
|
CurrencyAmountTextField(
|
2024-09-22 03:46:51 +01:00
|
|
|
currencyPickerButtonKey: ValueKey('${_cardInstanceName}_currency_picker_button_key'),
|
|
|
|
selectedCurrencyTextKey: ValueKey('${_cardInstanceName}_selected_currency_text_key'),
|
|
|
|
selectedCurrencyTagTextKey:
|
|
|
|
ValueKey('${_cardInstanceName}_selected_currency_tag_text_key'),
|
|
|
|
amountTextfieldKey: ValueKey('${_cardInstanceName}_amount_textfield_key'),
|
|
|
|
sendAllButtonKey: ValueKey('${_cardInstanceName}_send_all_button_key'),
|
|
|
|
currencyAmountTextFieldWidgetKey:
|
|
|
|
ValueKey('${_cardInstanceName}_currency_amount_textfield_widget_key'),
|
|
|
|
imageArrow: widget.imageArrow,
|
|
|
|
selectedCurrency: _selectedCurrency.toString(),
|
|
|
|
amountFocusNode: widget.amountFocusNode,
|
|
|
|
amountController: amountController,
|
|
|
|
onTapPicker: () => _presentPicker(context),
|
|
|
|
isAmountEditable: _isAmountEditable,
|
|
|
|
isPickerEnable: true,
|
|
|
|
allAmountButton: widget.hasAllAmount,
|
|
|
|
currencyValueValidator: widget.currencyValueValidator,
|
|
|
|
tag: _selectedCurrency.tag,
|
|
|
|
allAmountCallback: widget.allAmount,
|
|
|
|
),
|
2024-03-21 04:51:57 +02:00
|
|
|
Divider(height: 1, color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor),
|
2020-05-12 20:46:42 +03:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
2024-11-09 21:00:56 +02:00
|
|
|
child: widget.showLimitsField ? Container(
|
2021-01-11 19:15:27 +02:00
|
|
|
height: 15,
|
2024-03-21 04:51:57 +02:00
|
|
|
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[
|
|
|
|
_min != null
|
|
|
|
? Text(
|
2024-09-22 03:46:51 +01:00
|
|
|
key: ValueKey('${_cardInstanceName}_min_limit_text_key'),
|
2024-03-21 04:51:57 +02:00
|
|
|
S.of(context).min_value(_min ?? '', _selectedCurrency.toString()),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10,
|
|
|
|
height: 1.2,
|
|
|
|
color: Theme.of(context).extension<ExchangePageTheme>()!.hintTextColor),
|
|
|
|
)
|
|
|
|
: Offstage(),
|
|
|
|
_min != null ? SizedBox(width: 10) : Offstage(),
|
|
|
|
_max != null
|
2024-09-22 03:46:51 +01:00
|
|
|
? Text(
|
|
|
|
key: ValueKey('${_cardInstanceName}_max_limit_text_key'),
|
|
|
|
S.of(context).max_value(_max ?? '', _selectedCurrency.toString()),
|
2024-03-21 04:51:57 +02:00
|
|
|
style: TextStyle(
|
2024-09-22 03:46:51 +01:00
|
|
|
fontSize: 10,
|
|
|
|
height: 1.2,
|
|
|
|
color: Theme.of(context).extension<ExchangePageTheme>()!.hintTextColor,
|
|
|
|
),
|
|
|
|
)
|
2024-03-21 04:51:57 +02:00
|
|
|
: Offstage(),
|
2024-11-09 21:00:56 +02:00
|
|
|
])) : Offstage(),
|
2020-05-12 20:46:42 +03:00
|
|
|
),
|
2020-10-02 18:49:45 +03:00
|
|
|
!_isAddressEditable && widget.hasRefundAddress
|
|
|
|
? Padding(
|
2021-01-05 20:31:03 +02:00
|
|
|
padding: EdgeInsets.only(top: 20),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).refund_address,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
2023-08-17 12:28:31 -03:00
|
|
|
color: Theme.of(context).extension<ExchangePageTheme>()!.hintTextColor),
|
2021-01-05 20:31:03 +02:00
|
|
|
))
|
2020-10-02 18:49:45 +03:00
|
|
|
: Offstage(),
|
2020-07-31 18:29:21 +03:00
|
|
|
_isAddressEditable
|
2024-11-09 21:00:56 +02:00
|
|
|
? widget.showAddressField
|
2023-04-14 06:39:08 +02:00
|
|
|
? FocusTraversalOrder(
|
2024-03-21 04:51:57 +02:00
|
|
|
order: NumericFocusOrder(2),
|
2023-04-14 06:39:08 +02:00
|
|
|
child: Padding(
|
2024-11-09 21:00:56 +02:00
|
|
|
padding: widget.addressRowPadding ?? EdgeInsets.only(top: 20),
|
2023-04-14 06:39:08 +02:00
|
|
|
child: AddressTextField(
|
2024-09-22 03:46:51 +01:00
|
|
|
addressKey: ValueKey('${_cardInstanceName}_editable_address_textfield_key'),
|
2023-04-14 06:39:08 +02:00
|
|
|
focusNode: widget.addressFocusNode,
|
|
|
|
controller: addressController,
|
|
|
|
onURIScanned: (uri) {
|
|
|
|
final paymentRequest = PaymentRequest.fromUri(uri);
|
|
|
|
addressController.text = paymentRequest.address;
|
2024-03-21 04:51:57 +02:00
|
|
|
|
2023-04-14 06:39:08 +02:00
|
|
|
if (amountController.text.isNotEmpty) {
|
|
|
|
_showAmountPopup(context, paymentRequest);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
widget.amountFocusNode?.requestFocus();
|
2024-03-21 04:51:57 +02:00
|
|
|
amountController.text = paymentRequest.amount;
|
2023-04-14 06:39:08 +02:00
|
|
|
},
|
2024-11-09 21:00:56 +02:00
|
|
|
placeholder:
|
|
|
|
widget.hasRefundAddress ? S.of(context).refund_address : null,
|
2023-04-14 06:39:08 +02:00
|
|
|
options: [
|
|
|
|
AddressTextFieldOption.paste,
|
|
|
|
AddressTextFieldOption.qrCode,
|
|
|
|
AddressTextFieldOption.addressBook,
|
|
|
|
],
|
|
|
|
isBorderExist: false,
|
2024-11-09 21:00:56 +02:00
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white),
|
2023-04-14 06:39:08 +02:00
|
|
|
hintStyle: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
2024-11-09 21:00:56 +02:00
|
|
|
color:
|
|
|
|
Theme.of(context).extension<ExchangePageTheme>()!.hintTextColor),
|
2023-04-14 06:39:08 +02:00
|
|
|
buttonColor: widget.addressButtonsColor,
|
|
|
|
validator: widget.addressTextFieldValidator,
|
|
|
|
onPushPasteButton: widget.onPushPasteButton,
|
|
|
|
onPushAddressBookButton: widget.onPushAddressBookButton,
|
2024-03-21 04:51:57 +02:00
|
|
|
selectedCurrency: _selectedCurrency),
|
2022-03-31 19:54:45 +02:00
|
|
|
),
|
2024-11-09 21:00:56 +02:00
|
|
|
)
|
|
|
|
: Offstage()
|
2020-09-29 20:56:11 +03:00
|
|
|
: Padding(
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
child: Builder(
|
2022-03-31 17:16:42 +03:00
|
|
|
builder: (context) => Stack(children: <Widget>[
|
2024-03-21 04:51:57 +02:00
|
|
|
FocusTraversalOrder(
|
|
|
|
order: NumericFocusOrder(3),
|
|
|
|
child: BaseTextFormField(
|
2024-09-22 03:46:51 +01:00
|
|
|
key: ValueKey(
|
|
|
|
'${_cardInstanceName}_non_editable_address_textfield_key'),
|
2024-03-21 04:51:57 +02:00
|
|
|
controller: addressController,
|
|
|
|
borderColor: Colors.transparent,
|
|
|
|
suffixIcon: SizedBox(width: _isMoneroWallet ? 80 : 36),
|
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white),
|
|
|
|
validator: widget.addressTextFieldValidator),
|
2023-04-14 06:39:08 +02:00
|
|
|
),
|
2022-03-31 17:16:42 +03:00
|
|
|
Positioned(
|
|
|
|
top: 2,
|
|
|
|
right: 0,
|
|
|
|
child: SizedBox(
|
|
|
|
width: _isMoneroWallet ? 80 : 36,
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
if (_isMoneroWallet)
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 10),
|
|
|
|
child: Container(
|
|
|
|
width: 34,
|
|
|
|
height: 34,
|
|
|
|
padding: EdgeInsets.only(top: 0),
|
2023-10-19 01:08:29 +03:00
|
|
|
child: Semantics(
|
|
|
|
label: S.of(context).address_book,
|
|
|
|
child: InkWell(
|
2024-09-22 03:46:51 +01:00
|
|
|
key: ValueKey(
|
|
|
|
'${_cardInstanceName}_address_book_button_key'),
|
2023-10-19 01:08:29 +03:00
|
|
|
onTap: () async {
|
|
|
|
final contact =
|
2024-03-21 04:51:57 +02:00
|
|
|
await Navigator.of(context).pushNamed(
|
2023-10-19 01:08:29 +03:00
|
|
|
Routes.pickerAddressBook,
|
|
|
|
arguments: widget.initialCurrency,
|
|
|
|
);
|
2021-07-23 14:05:33 +03:00
|
|
|
|
2024-03-21 04:51:57 +02:00
|
|
|
if (contact is ContactBase) {
|
2023-10-19 01:08:29 +03:00
|
|
|
setState(() =>
|
2024-03-21 04:51:57 +02:00
|
|
|
addressController.text = contact.address);
|
|
|
|
widget.onPushAddressBookButton?.call(context);
|
2023-10-19 01:08:29 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
decoration: BoxDecoration(
|
2024-03-21 04:51:57 +02:00
|
|
|
color: widget.addressButtonsColor,
|
2023-10-19 01:08:29 +03:00
|
|
|
borderRadius:
|
2024-03-21 04:51:57 +02:00
|
|
|
BorderRadius.all(Radius.circular(6))),
|
2023-10-19 01:08:29 +03:00
|
|
|
child: Image.asset(
|
|
|
|
'assets/images/open_book.png',
|
2024-03-21 04:51:57 +02:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<SendPageTheme>()!
|
|
|
|
.textFieldButtonIconColor,
|
2023-10-19 01:08:29 +03:00
|
|
|
)),
|
|
|
|
),
|
2022-03-31 17:16:42 +03:00
|
|
|
)),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 2),
|
|
|
|
child: Container(
|
|
|
|
width: 34,
|
|
|
|
height: 34,
|
|
|
|
padding: EdgeInsets.only(top: 0),
|
2023-10-19 01:08:29 +03:00
|
|
|
child: Semantics(
|
|
|
|
label: S.of(context).copy_address,
|
|
|
|
child: InkWell(
|
2024-09-22 03:46:51 +01:00
|
|
|
key: ValueKey(
|
|
|
|
'${_cardInstanceName}_copy_refund_address_button_key'),
|
2023-10-19 01:08:29 +03:00
|
|
|
onTap: () {
|
2024-03-21 04:51:57 +02:00
|
|
|
Clipboard.setData(
|
|
|
|
ClipboardData(text: addressController.text));
|
2023-10-19 01:08:29 +03:00
|
|
|
showBar<void>(
|
2024-03-21 04:51:57 +02:00
|
|
|
context, S.of(context).copied_to_clipboard);
|
2023-10-19 01:08:29 +03:00
|
|
|
},
|
|
|
|
child: Container(
|
2024-03-21 04:51:57 +02:00
|
|
|
padding: EdgeInsets.fromLTRB(8, 8, 0, 8),
|
2023-10-19 01:08:29 +03:00
|
|
|
color: Colors.transparent,
|
|
|
|
child: copyImage),
|
|
|
|
),
|
2022-03-31 17:16:42 +03:00
|
|
|
)))
|
|
|
|
])))
|
|
|
|
])),
|
2020-09-29 20:56:11 +03:00
|
|
|
),
|
2020-01-04 21:31:52 +02:00
|
|
|
]),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _presentPicker(BuildContext context) {
|
2020-09-25 18:32:44 +03:00
|
|
|
showPopUp<void>(
|
2023-08-04 20:01:49 +03:00
|
|
|
context: context,
|
|
|
|
builder: (_) => CurrencyPicker(
|
2024-09-22 03:46:51 +01:00
|
|
|
key: ValueKey('${_cardInstanceName}_currency_picker_dialog_button_key'),
|
2023-08-04 20:01:49 +03:00
|
|
|
selectedAtIndex: widget.currencies.indexOf(_selectedCurrency),
|
|
|
|
items: widget.currencies,
|
|
|
|
hintText: S.of(context).search_currency,
|
|
|
|
isMoneroWallet: _isMoneroWallet,
|
|
|
|
isConvertFrom: widget.hasRefundAddress,
|
2024-11-09 21:00:56 +02:00
|
|
|
onItemSelected: (Currency item) => widget.onCurrencySelected(item as T),
|
2023-08-04 20:01:49 +03:00
|
|
|
),
|
|
|
|
);
|
2020-01-04 21:31:52 +02:00
|
|
|
}
|
2022-03-31 19:54:45 +02:00
|
|
|
|
|
|
|
void _showAmountPopup(BuildContext context, PaymentRequest paymentRequest) {
|
|
|
|
showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (dialogContext) {
|
|
|
|
return AlertWithTwoActions(
|
2024-03-29 20:54:59 +02:00
|
|
|
alertTitle: S.of(dialogContext).overwrite_amount,
|
|
|
|
alertContent: S.of(dialogContext).qr_payment_amount,
|
|
|
|
rightButtonText: S.of(dialogContext).ok,
|
|
|
|
leftButtonText: S.of(dialogContext).cancel,
|
2022-03-31 19:54:45 +02:00
|
|
|
actionRightButton: () {
|
2022-10-12 13:09:57 -04:00
|
|
|
widget.amountFocusNode?.requestFocus();
|
2022-03-31 19:54:45 +02:00
|
|
|
amountController.text = paymentRequest.amount;
|
2024-03-29 20:54:59 +02:00
|
|
|
Navigator.of(dialogContext).pop();
|
2022-03-31 19:54:45 +02:00
|
|
|
},
|
|
|
|
actionLeftButton: () => Navigator.of(dialogContext).pop());
|
2024-03-21 04:51:57 +02:00
|
|
|
});
|
2022-03-31 19:54:45 +02:00
|
|
|
}
|
2024-11-09 21:00:56 +02:00
|
|
|
|
|
|
|
String _normalizeAddressFormat(String address) {
|
|
|
|
if (address.startsWith('bitcoincash:')) address = address.substring(12);
|
|
|
|
return address;
|
|
|
|
}
|
2020-01-04 21:31:52 +02:00
|
|
|
}
|
2024-11-09 21:00:56 +02:00
|
|
|
|