mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +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_category.dart';
|
||||||
import 'package:cake_wallet/ionia/ionia_gift_card.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/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_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_buy_card_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/ionia/ionia_filter_view_model.dart';
|
import 'package:cake_wallet/view_model/ionia/ionia_filter_view_model.dart';
|
||||||
|
@ -372,9 +373,12 @@ Future setup(
|
||||||
getIt.get<BalanceViewModel>(),
|
getIt.get<BalanceViewModel>(),
|
||||||
_transactionDescriptionBox));
|
_transactionDescriptionBox));
|
||||||
|
|
||||||
getIt.registerFactory(
|
getIt.registerFactoryParam<SendPage, PaymentRequest, void>(
|
||||||
() => SendPage(sendViewModel: getIt.get<SendViewModel>(),
|
(PaymentRequest initialPaymentRequest, _) => SendPage(
|
||||||
settingsViewModel: getIt.get<SettingsViewModel>()));
|
sendViewModel: getIt.get<SendViewModel>(),
|
||||||
|
settingsViewModel: getIt.get<SettingsViewModel>(),
|
||||||
|
initialPaymentRequest: initialPaymentRequest,
|
||||||
|
));
|
||||||
|
|
||||||
getIt.registerFactory(() => SendTemplatePage(
|
getIt.registerFactory(() => SendTemplatePage(
|
||||||
sendTemplateViewModel: getIt.get<SendTemplateViewModel>()));
|
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_category.dart';
|
||||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||||
import 'package:cake_wallet/store/yat/yat_store.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/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -216,34 +217,32 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
/// the foreground or in the background.
|
/// the foreground or in the background.
|
||||||
Future<void> initUniLinks() async {
|
Future<void> initUniLinks() async {
|
||||||
try {
|
try {
|
||||||
stream = getLinksStream().listen((String link) {
|
stream = getUriLinksStream().listen((Uri uri) {
|
||||||
handleDeepLinking(link);
|
handleDeepLinking(uri);
|
||||||
});
|
});
|
||||||
|
|
||||||
final String initialLink = await getInitialLink();
|
final Uri initialUri = await getInitialUri();
|
||||||
|
|
||||||
handleDeepLinking(initialLink);
|
handleDeepLinking(initialUri);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeepLinking(String link) async {
|
void handleDeepLinking(Uri uri) {
|
||||||
if (link == null || !mounted) return;
|
if (uri == null || !mounted) return;
|
||||||
|
|
||||||
final List<String> urlComponents = link.split(":");
|
switch (uri.scheme) {
|
||||||
|
|
||||||
switch (urlComponents.first) {
|
|
||||||
case "bitcoin":
|
case "bitcoin":
|
||||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
|
||||||
print("Bitcoin QR Code: \n${link}");
|
|
||||||
break;
|
|
||||||
case "litecoin":
|
case "litecoin":
|
||||||
case "haven":
|
case "haven":
|
||||||
case "monero":
|
case "monero":
|
||||||
default:
|
default:
|
||||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
Navigator.pushNamed(
|
||||||
print(link);
|
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/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_details_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_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:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -207,8 +208,12 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
builder: (_) => getIt.get<DashboardPage>());
|
builder: (_) => getIt.get<DashboardPage>());
|
||||||
|
|
||||||
case Routes.send:
|
case Routes.send:
|
||||||
|
final initialPaymentRequest = settings.arguments as PaymentRequest;
|
||||||
|
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>());
|
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>(
|
||||||
|
param1: initialPaymentRequest,
|
||||||
|
));
|
||||||
|
|
||||||
case Routes.sendTemplate:
|
case Routes.sendTemplate:
|
||||||
return CupertinoPageRoute<void>(
|
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/alert_with_two_actions.dart';
|
||||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||||
import 'package:cake_wallet/src/widgets/template_tile.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/send/output.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
||||||
import 'package:flutter/cupertino.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';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
|
|
||||||
class SendPage extends BasePage {
|
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 SendViewModel sendViewModel;
|
||||||
final SettingsViewModel settingsViewModel;
|
final SettingsViewModel settingsViewModel;
|
||||||
final GlobalKey<FormState> _formKey;
|
final GlobalKey<FormState> _formKey;
|
||||||
final controller = PageController(initialPage: 0);
|
final controller = PageController(initialPage: 0);
|
||||||
final FiatCurrency fiatFromSettings ;
|
final FiatCurrency fiatFromSettings;
|
||||||
|
final PaymentRequest initialPaymentRequest;
|
||||||
|
|
||||||
bool _effectsInstalled = false;
|
bool _effectsInstalled = false;
|
||||||
|
|
||||||
|
@ -116,6 +122,7 @@ class SendPage extends BasePage {
|
||||||
key: output.key,
|
key: output.key,
|
||||||
output: output,
|
output: output,
|
||||||
sendViewModel: sendViewModel,
|
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';
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||||
|
|
||||||
class SendCard extends StatefulWidget {
|
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 Output output;
|
||||||
final SendViewModel sendViewModel;
|
final SendViewModel sendViewModel;
|
||||||
|
final PaymentRequest initialPaymentRequest;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
SendCardState createState() => SendCardState(
|
SendCardState createState() {
|
||||||
|
return SendCardState(
|
||||||
output: output,
|
output: output,
|
||||||
sendViewModel: sendViewModel
|
sendViewModel: sendViewModel,
|
||||||
|
initialPaymentRequest: initialPaymentRequest,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SendCardState extends State<SendCard>
|
class SendCardState extends State<SendCard>
|
||||||
with AutomaticKeepAliveClientMixin<SendCard> {
|
with AutomaticKeepAliveClientMixin<SendCard> {
|
||||||
SendCardState({@required this.output, @required this.sendViewModel})
|
SendCardState({
|
||||||
: addressController = TextEditingController(),
|
@required this.output,
|
||||||
cryptoAmountController = TextEditingController(),
|
@required this.sendViewModel,
|
||||||
|
PaymentRequest initialPaymentRequest})
|
||||||
|
: addressController = TextEditingController(text: initialPaymentRequest?.address),
|
||||||
|
cryptoAmountController = TextEditingController(text: initialPaymentRequest?.amount),
|
||||||
fiatAmountController = TextEditingController(),
|
fiatAmountController = TextEditingController(),
|
||||||
noteController = TextEditingController(),
|
noteController = TextEditingController(),
|
||||||
extractedAddressController = TextEditingController(),
|
extractedAddressController = TextEditingController(),
|
||||||
|
@ -111,6 +123,11 @@ class SendCardState extends State<SendCard>
|
||||||
? sendViewModel.textValidator
|
? sendViewModel.textValidator
|
||||||
: sendViewModel.addressValidator;
|
: sendViewModel.addressValidator;
|
||||||
|
|
||||||
|
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||||
|
print("444444444444444444444444444444");
|
||||||
|
print(addressController.text);
|
||||||
|
print(cryptoAmountController.text);
|
||||||
|
|
||||||
return AddressTextField(
|
return AddressTextField(
|
||||||
focusNode: addressFocusNode,
|
focusNode: addressFocusNode,
|
||||||
controller: addressController,
|
controller: addressController,
|
||||||
|
@ -509,8 +526,12 @@ class SendCardState extends State<SendCard>
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setEffects(BuildContext context) {
|
void _setEffects(BuildContext context) {
|
||||||
addressController.text = output.address;
|
if (output.address.isNotEmpty) {
|
||||||
cryptoAmountController.text = output.cryptoAmount;
|
addressController.text = output.address;
|
||||||
|
}
|
||||||
|
if (output.cryptoAmount.isNotEmpty) {
|
||||||
|
cryptoAmountController.text = output.cryptoAmount;
|
||||||
|
}
|
||||||
fiatAmountController.text = output.fiatAmount;
|
fiatAmountController.text = output.fiatAmount;
|
||||||
noteController.text = output.note;
|
noteController.text = output.note;
|
||||||
extractedAddressController.text = output.extractedAddress;
|
extractedAddressController.text = output.extractedAddress;
|
||||||
|
|
Loading…
Reference in a new issue