mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Send data from URI to send screen
This commit is contained in:
parent
01adf863d0
commit
7bccf46832
5 changed files with 64 additions and 28 deletions
10
lib/di.dart
10
lib/di.dart
|
@ -5,6 +5,7 @@ import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
|||
import 'package:cake_wallet/ionia/ionia_category.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_gift_card_detail_page.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_auth_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_buy_card_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_filter_view_model.dart';
|
||||
|
@ -372,9 +373,12 @@ Future setup(
|
|||
getIt.get<BalanceViewModel>(),
|
||||
_transactionDescriptionBox));
|
||||
|
||||
getIt.registerFactory(
|
||||
() => SendPage(sendViewModel: getIt.get<SendViewModel>(),
|
||||
settingsViewModel: getIt.get<SettingsViewModel>()));
|
||||
getIt.registerFactoryParam<SendPage, PaymentRequest, void>(
|
||||
(PaymentRequest initialPaymentRequest, _) => SendPage(
|
||||
sendViewModel: getIt.get<SendViewModel>(),
|
||||
settingsViewModel: getIt.get<SettingsViewModel>(),
|
||||
initialPaymentRequest: initialPaymentRequest,
|
||||
));
|
||||
|
||||
getIt.registerFactory(() => SendTemplatePage(
|
||||
sendTemplateViewModel: getIt.get<SendTemplateViewModel>()));
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:cake_wallet/buy/order.dart';
|
|||
import 'package:cake_wallet/ionia/ionia_category.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -216,34 +217,32 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
|||
/// the foreground or in the background.
|
||||
Future<void> initUniLinks() async {
|
||||
try {
|
||||
stream = getLinksStream().listen((String link) {
|
||||
handleDeepLinking(link);
|
||||
stream = getUriLinksStream().listen((Uri uri) {
|
||||
handleDeepLinking(uri);
|
||||
});
|
||||
|
||||
final String initialLink = await getInitialLink();
|
||||
final Uri initialUri = await getInitialUri();
|
||||
|
||||
handleDeepLinking(initialLink);
|
||||
handleDeepLinking(initialUri);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
void handleDeepLinking(String link) async {
|
||||
if (link == null || !mounted) return;
|
||||
void handleDeepLinking(Uri uri) {
|
||||
if (uri == null || !mounted) return;
|
||||
|
||||
final List<String> urlComponents = link.split(":");
|
||||
|
||||
switch (urlComponents.first) {
|
||||
switch (uri.scheme) {
|
||||
case "bitcoin":
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||
print("Bitcoin QR Code: \n${link}");
|
||||
break;
|
||||
case "litecoin":
|
||||
case "haven":
|
||||
case "monero":
|
||||
default:
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||
print(link);
|
||||
Navigator.pushNamed(
|
||||
navigatorKey.currentContext,
|
||||
Routes.send,
|
||||
arguments: PaymentRequest.fromUri(uri),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart';
|
|||
import 'package:cake_wallet/src/screens/support/support_page.dart';
|
||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_details_page.dart';
|
||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -207,8 +208,12 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
builder: (_) => getIt.get<DashboardPage>());
|
||||
|
||||
case Routes.send:
|
||||
final initialPaymentRequest = settings.arguments as PaymentRequest;
|
||||
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>());
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>(
|
||||
param1: initialPaymentRequest,
|
||||
));
|
||||
|
||||
case Routes.sendTemplate:
|
||||
return CupertinoPageRoute<void>(
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue