Send data from URI to send screen

This commit is contained in:
OmarHatem28
2022-08-09 15:47:41 +02:00
parent 01adf863d0
commit 7bccf46832
5 changed files with 64 additions and 28 deletions
+9 -2
View File
@@ -5,6 +5,7 @@ import 'package:cake_wallet/src/screens/send/widgets/send_card.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/picker.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/utils/payment_request.dart';
import 'package:cake_wallet/view_model/send/output.dart';
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
import 'package:flutter/cupertino.dart';
@@ -28,13 +29,18 @@ import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:cw_core/crypto_currency.dart';
class SendPage extends BasePage {
SendPage({@required this.sendViewModel,@required this.settingsViewModel }) : _formKey = GlobalKey<FormState>(),fiatFromSettings = settingsViewModel.fiatCurrency;
SendPage({
@required this.sendViewModel,
@required this.settingsViewModel,
this.initialPaymentRequest,
}) : _formKey = GlobalKey<FormState>(),fiatFromSettings = settingsViewModel.fiatCurrency;
final SendViewModel sendViewModel;
final SettingsViewModel settingsViewModel;
final GlobalKey<FormState> _formKey;
final controller = PageController(initialPage: 0);
final FiatCurrency fiatFromSettings ;
final FiatCurrency fiatFromSettings;
final PaymentRequest initialPaymentRequest;
bool _effectsInstalled = false;
@@ -116,6 +122,7 @@ class SendPage extends BasePage {
key: output.key,
output: output,
sendViewModel: sendViewModel,
initialPaymentRequest: initialPaymentRequest,
);
});
},
+29 -8
View File
@@ -19,23 +19,35 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
class SendCard extends StatefulWidget {
SendCard({Key key, @required this.output, @required this.sendViewModel}) : super(key: key);
SendCard({
Key key,
@required this.output,
@required this.sendViewModel,
this.initialPaymentRequest,
}) : super(key: key);
final Output output;
final SendViewModel sendViewModel;
final PaymentRequest initialPaymentRequest;
@override
SendCardState createState() => SendCardState(
SendCardState createState() {
return SendCardState(
output: output,
sendViewModel: sendViewModel
sendViewModel: sendViewModel,
initialPaymentRequest: initialPaymentRequest,
);
}
}
class SendCardState extends State<SendCard>
with AutomaticKeepAliveClientMixin<SendCard> {
SendCardState({@required this.output, @required this.sendViewModel})
: addressController = TextEditingController(),
cryptoAmountController = TextEditingController(),
SendCardState({
@required this.output,
@required this.sendViewModel,
PaymentRequest initialPaymentRequest})
: addressController = TextEditingController(text: initialPaymentRequest?.address),
cryptoAmountController = TextEditingController(text: initialPaymentRequest?.amount),
fiatAmountController = TextEditingController(),
noteController = TextEditingController(),
extractedAddressController = TextEditingController(),
@@ -111,6 +123,11 @@ class SendCardState extends State<SendCard>
? sendViewModel.textValidator
: sendViewModel.addressValidator;
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
print("444444444444444444444444444444");
print(addressController.text);
print(cryptoAmountController.text);
return AddressTextField(
focusNode: addressFocusNode,
controller: addressController,
@@ -509,8 +526,12 @@ class SendCardState extends State<SendCard>
}
void _setEffects(BuildContext context) {
addressController.text = output.address;
cryptoAmountController.text = output.cryptoAmount;
if (output.address.isNotEmpty) {
addressController.text = output.address;
}
if (output.cryptoAmount.isNotEmpty) {
cryptoAmountController.text = output.cryptoAmount;
}
fiatAmountController.text = output.fiatAmount;
noteController.text = output.note;
extractedAddressController.text = output.extractedAddress;