Update Branch to null safety

Add deep linking to iOS
This commit is contained in:
OmarHatem 2022-11-08 16:56:27 +02:00
parent 7c7de65cdf
commit f078457c7b
8 changed files with 74 additions and 36 deletions

View file

@ -39,6 +39,8 @@ import 'package:cw_core/unspent_coins_info.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'src/screens/auth/auth_page.dart';
final navigatorKey = GlobalKey<NavigatorState>();
final rootKey = GlobalKey<RootState>();
@ -213,15 +215,15 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
super.dispose();
}
/// handle app links while the app is already started - be it in
/// the foreground or in the background.
/// handle app links while the app is already started
/// whether its in the foreground or in the background.
Future<void> initUniLinks() async {
try {
stream = getUriLinksStream().listen((Uri uri) {
stream = uriLinkStream.listen((Uri? uri) {
handleDeepLinking(uri);
});
final Uri initialUri = await getInitialUri();
final Uri? initialUri = await getInitialUri();
handleDeepLinking(initialUri);
} 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;
Navigator.pushNamed(
navigatorKey.currentContext,
Routes.send,
arguments: PaymentRequest.fromUri(uri),
);
Navigator.of(navigatorKey.currentContext!).pushNamed(Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close(route: Routes.send, arguments: PaymentRequest.fromUri(uri));
}
});
// Navigator.pushNamed(
// navigatorKey.currentContext!,
// Routes.send,
// arguments: PaymentRequest.fromUri(uri),
// );
}
Future<void> _handleInitialUri() async {