feat: Add location sharing

This commit is contained in:
Sorunome 2021-08-01 09:53:43 +02:00 committed by Christian Pauly
commit 5d0967ecda
11 changed files with 425 additions and 1 deletions

View file

@ -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;
}