mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
Update Branch to null safety
Add deep linking to iOS
This commit is contained in:
parent
7c7de65cdf
commit
f078457c7b
8 changed files with 74 additions and 36 deletions
|
@ -38,7 +38,7 @@
|
||||||
android:scheme="cakewallet"
|
android:scheme="cakewallet"
|
||||||
android:host="y.at" />
|
android:host="y.at" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- bitcoin qr code scheme -->
|
<!-- currencies qr code scheme -->
|
||||||
<intent-filter android:autoVerify="true">
|
<intent-filter android:autoVerify="true">
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
|
@ -21,18 +21,48 @@
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleURLTypes</key>
|
<key>CFBundleURLTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Editor</string>
|
<string>Editor</string>
|
||||||
<key>CFBundleURLName</key>
|
<key>CFBundleURLName</key>
|
||||||
<string>y.at</string>
|
<string>y.at</string>
|
||||||
<key>CFBundleURLSchemes</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>cakewallet</string>
|
<string>cakewallet</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>bitcoin</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>bitcoin</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>monero</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>monero</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>litecoin</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>litecoin</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
|
|
@ -377,8 +377,8 @@ Future setup(
|
||||||
getIt.get<BalanceViewModel>(),
|
getIt.get<BalanceViewModel>(),
|
||||||
_transactionDescriptionBox));
|
_transactionDescriptionBox));
|
||||||
|
|
||||||
getIt.registerFactoryParam<SendPage, PaymentRequest, void>(
|
getIt.registerFactoryParam<SendPage, PaymentRequest?, void>(
|
||||||
(PaymentRequest initialPaymentRequest, _) => SendPage(
|
(PaymentRequest? initialPaymentRequest, _) => SendPage(
|
||||||
sendViewModel: getIt.get<SendViewModel>(),
|
sendViewModel: getIt.get<SendViewModel>(),
|
||||||
settingsViewModel: getIt.get<SettingsViewModel>(),
|
settingsViewModel: getIt.get<SettingsViewModel>(),
|
||||||
initialPaymentRequest: initialPaymentRequest,
|
initialPaymentRequest: initialPaymentRequest,
|
||||||
|
|
|
@ -39,6 +39,8 @@ import 'package:cw_core/unspent_coins_info.dart';
|
||||||
import 'package:cake_wallet/monero/monero.dart';
|
import 'package:cake_wallet/monero/monero.dart';
|
||||||
import 'package:cake_wallet/wallet_type_utils.dart';
|
import 'package:cake_wallet/wallet_type_utils.dart';
|
||||||
|
|
||||||
|
import 'src/screens/auth/auth_page.dart';
|
||||||
|
|
||||||
final navigatorKey = GlobalKey<NavigatorState>();
|
final navigatorKey = GlobalKey<NavigatorState>();
|
||||||
final rootKey = GlobalKey<RootState>();
|
final rootKey = GlobalKey<RootState>();
|
||||||
|
|
||||||
|
@ -213,15 +215,15 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// handle app links while the app is already started - be it in
|
/// handle app links while the app is already started
|
||||||
/// the foreground or in the background.
|
/// whether its in the foreground or in the background.
|
||||||
Future<void> initUniLinks() async {
|
Future<void> initUniLinks() async {
|
||||||
try {
|
try {
|
||||||
stream = getUriLinksStream().listen((Uri uri) {
|
stream = uriLinkStream.listen((Uri? uri) {
|
||||||
handleDeepLinking(uri);
|
handleDeepLinking(uri);
|
||||||
});
|
});
|
||||||
|
|
||||||
final Uri initialUri = await getInitialUri();
|
final Uri? initialUri = await getInitialUri();
|
||||||
|
|
||||||
handleDeepLinking(initialUri);
|
handleDeepLinking(initialUri);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -229,14 +231,21 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDeepLinking(Uri uri) {
|
void handleDeepLinking(Uri? uri) {
|
||||||
if (uri == null || !mounted) return;
|
if (uri == null || !mounted) return;
|
||||||
|
|
||||||
Navigator.pushNamed(
|
Navigator.of(navigatorKey.currentContext!).pushNamed(Routes.auth,
|
||||||
navigatorKey.currentContext,
|
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
|
||||||
Routes.send,
|
if (isAuthenticatedSuccessfully) {
|
||||||
arguments: PaymentRequest.fromUri(uri),
|
auth.close(route: Routes.send, arguments: PaymentRequest.fromUri(uri));
|
||||||
);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigator.pushNamed(
|
||||||
|
// navigatorKey.currentContext!,
|
||||||
|
// Routes.send,
|
||||||
|
// arguments: PaymentRequest.fromUri(uri),
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _handleInitialUri() async {
|
Future<void> _handleInitialUri() async {
|
||||||
|
|
|
@ -210,7 +210,7 @@ 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;
|
final initialPaymentRequest = settings.arguments as PaymentRequest?;
|
||||||
|
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>(
|
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:ui';
|
|
||||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||||
import 'package:cake_wallet/utils/payment_request.dart';
|
import 'package:cake_wallet/utils/payment_request.dart';
|
||||||
import 'package:cw_core/transaction_priority.dart';
|
import 'package:cw_core/transaction_priority.dart';
|
||||||
|
@ -44,7 +43,7 @@ class SendCardState extends State<SendCard>
|
||||||
required this.output,
|
required this.output,
|
||||||
required this.sendViewModel,
|
required this.sendViewModel,
|
||||||
this.initialPaymentRequest})
|
this.initialPaymentRequest})
|
||||||
: addressController = TextEditingController(text: initialPaymentRequest?.address?.toLowerCase()),
|
: addressController = TextEditingController(text: initialPaymentRequest?.address.toLowerCase()),
|
||||||
cryptoAmountController = TextEditingController(text: initialPaymentRequest?.amount),
|
cryptoAmountController = TextEditingController(text: initialPaymentRequest?.amount),
|
||||||
fiatAmountController = TextEditingController(),
|
fiatAmountController = TextEditingController(),
|
||||||
noteController = TextEditingController(),
|
noteController = TextEditingController(),
|
||||||
|
@ -77,8 +76,8 @@ class SendCardState extends State<SendCard>
|
||||||
|
|
||||||
/// if the current wallet doesn't match the one in the qr code
|
/// if the current wallet doesn't match the one in the qr code
|
||||||
if (initialPaymentRequest != null &&
|
if (initialPaymentRequest != null &&
|
||||||
sendViewModel.walletCurrencyName != initialPaymentRequest.scheme?.toLowerCase()) {
|
sendViewModel.walletCurrencyName != initialPaymentRequest!.scheme.toLowerCase()) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
showPopUp<void>(
|
showPopUp<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
@ -544,7 +543,7 @@ class SendCardState extends State<SendCard>
|
||||||
addressController.text = output.address;
|
addressController.text = output.address;
|
||||||
}
|
}
|
||||||
if (output.cryptoAmount.isNotEmpty ||
|
if (output.cryptoAmount.isNotEmpty ||
|
||||||
sendViewModel.walletCurrencyName != initialPaymentRequest?.scheme?.toLowerCase()) {
|
sendViewModel.walletCurrencyName != initialPaymentRequest?.scheme.toLowerCase()) {
|
||||||
cryptoAmountController.text = output.cryptoAmount;
|
cryptoAmountController.text = output.cryptoAmount;
|
||||||
}
|
}
|
||||||
fiatAmountController.text = output.fiatAmount;
|
fiatAmountController.text = output.fiatAmount;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class PaymentRequest {
|
class PaymentRequest {
|
||||||
PaymentRequest(this.address, this.amount, this.note, {this.scheme});
|
PaymentRequest(this.address, this.amount, this.note, this.scheme);
|
||||||
|
|
||||||
factory PaymentRequest.fromUri(Uri uri) {
|
factory PaymentRequest.fromUri(Uri? uri) {
|
||||||
var address = "";
|
var address = "";
|
||||||
var amount = "";
|
var amount = "";
|
||||||
var note = "";
|
var note = "";
|
||||||
|
@ -15,7 +15,7 @@ class PaymentRequest {
|
||||||
scheme = uri.scheme;
|
scheme = uri.scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PaymentRequest(address, amount, note, scheme: scheme);
|
return PaymentRequest(address, amount, note, scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String address;
|
final String address;
|
||||||
|
|
|
@ -137,7 +137,7 @@ abstract class SendViewModelBase with Store {
|
||||||
PendingTransaction? pendingTransaction;
|
PendingTransaction? pendingTransaction;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
String get balance => balanceViewModel.availableBalance ?? '0.0';
|
String get balance => balanceViewModel.availableBalance;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
||||||
|
@ -164,7 +164,7 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
WalletType get walletType => _wallet.type;
|
WalletType get walletType => _wallet.type;
|
||||||
|
|
||||||
String get walletCurrencyName => _wallet.currency.name.toLowerCase();
|
String? get walletCurrencyName => _wallet.currency.name?.toLowerCase();
|
||||||
|
|
||||||
bool get hasCurrecyChanger => walletType == WalletType.haven;
|
bool get hasCurrecyChanger => walletType == WalletType.haven;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue