-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anna Barsukova
authored and
Anna Barsukova
committed
Oct 30, 2024
1 parent
338dd34
commit 2dd5f5c
Showing
9 changed files
with
154 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:every_door/screens/browser.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class NavigationHelper { | ||
static Widget navigateByUri(Uri uri) { | ||
if (uri.scheme == 'geo' && uri.path.isNotEmpty) { | ||
return BrowserPage(); | ||
} | ||
return BrowserPage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:every_door/providers/geolocation.dart'; | ||
import 'package:every_door/providers/location.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:app_links/app_links.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
final appLinksProvider = Provider((ref) => AppLinks()); | ||
|
||
final uriLinkStreamProvider = StreamProvider<Uri?>((ref) async* { | ||
final appLinks = ref.watch(appLinksProvider); | ||
await for (final uri in appLinks.uriLinkStream) { | ||
if (uri.scheme == 'geo' && uri.path.isNotEmpty) { | ||
_handleGeoIntent(uri, ref); | ||
} | ||
|
||
yield uri; | ||
} | ||
}); | ||
|
||
void _handleGeoIntent(Uri uri, StreamProviderRef<Uri?> ref) { | ||
final location = _parseLatLngFromGeoUri(uri); | ||
if (location != null) { | ||
ref.read(geolocationProvider.notifier).disableTracking(); | ||
ref.read(effectiveLocationProvider.notifier).set(location); | ||
} | ||
} | ||
|
||
LatLng? _parseLatLngFromGeoUri(Uri uri) { | ||
try { | ||
final coords = uri.path.split(','); | ||
if (coords.length == 2) { | ||
final lat = double.parse(coords[0]); | ||
final lng = double.parse(coords[1]); | ||
return LatLng(lat, lng); | ||
} | ||
} catch (e) { | ||
Logger('AppLinks').warning('Failed to parse coordinates'); | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
final navigatonKeyProvider = Provider<GlobalKey<NavigatorState>>((ref) { | ||
return GlobalKey<NavigatorState>(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters