feat: Add location sharing
This commit is contained in:
parent
45a75d4949
commit
5d0967ecda
11 changed files with 425 additions and 1 deletions
|
|
@ -10,6 +10,8 @@ import 'package:vrouter/vrouter.dart';
|
|||
import 'package:punycode/punycode.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import 'platform_infos.dart';
|
||||
|
||||
class UrlLauncher {
|
||||
final String url;
|
||||
final BuildContext context;
|
||||
|
|
@ -30,6 +32,24 @@ class UrlLauncher {
|
|||
}
|
||||
if (!{'https', 'http'}.contains(uri.scheme)) {
|
||||
// just launch non-https / non-http uris directly
|
||||
|
||||
// transmute geo URIs on desktop to openstreetmap links, as those usually can't hanlde
|
||||
// geo URIs
|
||||
if (!PlatformInfos.isMobile && uri.scheme == 'geo' && uri.path != null) {
|
||||
final latlong = uri.path
|
||||
.split(';')
|
||||
.first
|
||||
.split(',')
|
||||
.map((s) => double.tryParse(s))
|
||||
.toList();
|
||||
if (latlong.length == 2 &&
|
||||
latlong.first != null &&
|
||||
latlong.last != null) {
|
||||
launch(
|
||||
'https://www.openstreetmap.org/?mlat=${latlong.first}&mlon=${latlong.last}#map=16/${latlong.first}/${latlong.last}');
|
||||
return;
|
||||
}
|
||||
}
|
||||
launch(url);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue