restucturization of recipients payment methods
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/payment/methods/card.dart';
|
||||
import 'package:pshared/models/payment/methods/crypto_address.dart';
|
||||
import 'package:pshared/models/payment/methods/iban.dart';
|
||||
import 'package:pshared/models/payment/methods/russian_bank.dart';
|
||||
import 'package:pshared/models/payment/methods/wallet.dart';
|
||||
@@ -46,6 +47,7 @@ class _AdressBookRecipientFormState extends State<AdressBookRecipientForm> {
|
||||
if (r?.iban != null) _methods[PaymentType.iban] = r!.iban;
|
||||
if (r?.wallet != null) _methods[PaymentType.wallet] = r!.wallet;
|
||||
if (r?.bank != null) _methods[PaymentType.bankAccount] = r!.bank;
|
||||
if (r?.cryptoAddress != null) _methods[PaymentType.cryptoAddress] = r!.cryptoAddress;
|
||||
}
|
||||
|
||||
//TODO Change when registration is ready
|
||||
@@ -74,6 +76,7 @@ class _AdressBookRecipientFormState extends State<AdressBookRecipientForm> {
|
||||
iban: _methods[PaymentType.iban] as IbanPaymentMethod?,
|
||||
wallet: _methods[PaymentType.wallet] as WalletPaymentMethod?,
|
||||
bank: _methods[PaymentType.bankAccount] as RussianBankAccountPaymentMethod?,
|
||||
cryptoAddress: _methods[PaymentType.cryptoAddress] as CryptoAddressPaymentMethod?,
|
||||
);
|
||||
|
||||
widget.onSaved?.call(recipient);
|
||||
@@ -106,4 +109,4 @@ class _AdressBookRecipientFormState extends State<AdressBookRecipientForm> {
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,12 @@ class RecipientPaymentRow extends StatelessWidget {
|
||||
type: PaymentType.wallet,
|
||||
value: recipient.wallet!.walletId
|
||||
),
|
||||
if (recipient.cryptoAddress?.address.isNotEmpty ?? false)
|
||||
RecipientAddressBookInfoRow(
|
||||
type: PaymentType.cryptoAddress,
|
||||
value: recipient.cryptoAddress!.address,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,11 @@ class RecipientItem extends StatelessWidget {
|
||||
label: getPaymentTypeLabel(context, PaymentType.wallet),
|
||||
value: recipient.wallet!.walletId,
|
||||
),
|
||||
if (recipient.cryptoAddress?.address.isNotEmpty == true)
|
||||
PaymentInfoRow(
|
||||
label: getPaymentTypeLabel(context, PaymentType.cryptoAddress),
|
||||
value: recipient.cryptoAddress!.address,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
101
frontend/pweb/lib/pages/payment_methods/add/crypto_address.dart
Normal file
101
frontend/pweb/lib/pages/payment_methods/add/crypto_address.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/payment/methods/crypto_address.dart';
|
||||
|
||||
import 'package:pweb/utils/text_field_styles.dart';
|
||||
|
||||
|
||||
class CryptoAddressForm extends StatefulWidget {
|
||||
final void Function(CryptoAddressPaymentMethod) onChanged;
|
||||
final CryptoAddressPaymentMethod? initialData;
|
||||
final bool isEditable;
|
||||
|
||||
const CryptoAddressForm({
|
||||
super.key,
|
||||
required this.onChanged,
|
||||
this.initialData,
|
||||
required this.isEditable,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CryptoAddressForm> createState() => _CryptoAddressFormState();
|
||||
}
|
||||
|
||||
class _CryptoAddressFormState extends State<CryptoAddressForm> {
|
||||
late TextEditingController _addressCtrl;
|
||||
late TextEditingController _networkCtrl;
|
||||
late TextEditingController _destinationTagCtrl;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_addressCtrl = TextEditingController(text: widget.initialData?.address);
|
||||
_networkCtrl = TextEditingController(text: widget.initialData?.network);
|
||||
_destinationTagCtrl = TextEditingController(text: widget.initialData?.destinationTag);
|
||||
}
|
||||
|
||||
void _emit() {
|
||||
if (_addressCtrl.text.isNotEmpty && _networkCtrl.text.isNotEmpty) {
|
||||
widget.onChanged(
|
||||
CryptoAddressPaymentMethod(
|
||||
address: _addressCtrl.text,
|
||||
network: _networkCtrl.text,
|
||||
destinationTag: _destinationTagCtrl.text.isNotEmpty ? _destinationTagCtrl.text : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant CryptoAddressForm oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
final newData = widget.initialData;
|
||||
final oldData = oldWidget.initialData;
|
||||
|
||||
if (newData == null && oldData != null) {
|
||||
_addressCtrl.clear();
|
||||
_networkCtrl.clear();
|
||||
_destinationTagCtrl.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (newData != null && newData != oldData) {
|
||||
_addressCtrl.text = newData.address;
|
||||
_networkCtrl.text = newData.network;
|
||||
_destinationTagCtrl.text = newData.destinationTag ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
readOnly: !widget.isEditable,
|
||||
controller: _addressCtrl,
|
||||
decoration: getInputDecoration(context, 'Crypto address', widget.isEditable),
|
||||
style: getTextFieldStyle(context, widget.isEditable),
|
||||
onChanged: (_) => _emit(),
|
||||
validator: (val) => (val?.isEmpty ?? true) ? 'Enter crypto address' : null,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
readOnly: !widget.isEditable,
|
||||
controller: _networkCtrl,
|
||||
decoration: getInputDecoration(context, 'Network', widget.isEditable),
|
||||
style: getTextFieldStyle(context, widget.isEditable),
|
||||
onChanged: (_) => _emit(),
|
||||
validator: (val) => (val?.isEmpty ?? true) ? 'Enter network' : null,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
readOnly: !widget.isEditable,
|
||||
controller: _destinationTagCtrl,
|
||||
decoration: getInputDecoration(context, 'Destination tag / memo (optional)', widget.isEditable),
|
||||
style: getTextFieldStyle(context, widget.isEditable),
|
||||
onChanged: (_) => _emit(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/payment/methods/card.dart';
|
||||
import 'package:pshared/models/payment/methods/crypto_address.dart';
|
||||
import 'package:pshared/models/payment/methods/iban.dart';
|
||||
import 'package:pshared/models/payment/methods/russian_bank.dart';
|
||||
import 'package:pshared/models/payment/methods/wallet.dart';
|
||||
import 'package:pshared/models/payment/type.dart';
|
||||
|
||||
import 'package:pweb/pages/payment_methods/add/card.dart';
|
||||
import 'package:pweb/pages/payment_methods/add/crypto_address.dart';
|
||||
import 'package:pweb/pages/payment_methods/add/iban.dart';
|
||||
import 'package:pweb/pages/payment_methods/add/russian_bank.dart';
|
||||
import 'package:pweb/pages/payment_methods/add/wallet.dart';
|
||||
@@ -49,6 +51,11 @@ class PaymentMethodForm extends StatelessWidget {
|
||||
initialData: initialData as RussianBankAccountPaymentMethod?,
|
||||
isEditable: isEditable,
|
||||
),
|
||||
PaymentType.cryptoAddress => CryptoAddressForm(
|
||||
onChanged: onChanged,
|
||||
initialData: initialData as CryptoAddressPaymentMethod?,
|
||||
isEditable: isEditable,
|
||||
),
|
||||
_ => const SizedBox.shrink(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ IconData iconForPaymentType(PaymentType type) {
|
||||
return Icons.account_balance_wallet;
|
||||
case PaymentType.card:
|
||||
return Icons.credit_card;
|
||||
case PaymentType.cryptoAddress:
|
||||
return Icons.currency_bitcoin;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user