mirror of
https://github.com/immich-app/immich.git
synced 2024-11-24 08:52:28 +02:00
feat(mobile): launch map app from exif info (#3626)
This commit is contained in:
parent
23b836ffbb
commit
57a7103d75
@ -70,5 +70,9 @@
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="https" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="geo" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
@ -17,6 +19,33 @@ class ExifBottomSheet extends HookConsumerWidget {
|
||||
bool get showMap =>
|
||||
asset.exifInfo?.latitude != null && asset.exifInfo?.longitude != null;
|
||||
|
||||
Future<Uri> _createCoordinatesUri(double latitude, double longitude) async {
|
||||
const zoomLevel = 5;
|
||||
if (Platform.isAndroid) {
|
||||
Uri uri = Uri(
|
||||
scheme: 'geo',
|
||||
host: '$latitude,$longitude',
|
||||
queryParameters: {'z': '$zoomLevel', 'q': '$latitude,$longitude'},
|
||||
);
|
||||
if (await canLaunchUrl(uri)) {
|
||||
return uri;
|
||||
}
|
||||
} else if (Platform.isIOS) {
|
||||
var params = {
|
||||
'll': '$latitude,$longitude',
|
||||
'q': '$latitude, $longitude',
|
||||
};
|
||||
Uri uri = Uri.https('maps.apple.com', '/', params);
|
||||
if (!await canLaunchUrl(uri)) {
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
return Uri.https(
|
||||
'www.google.com',
|
||||
'/maps/place/$latitude,$longitude/@$latitude,$longitude,${zoomLevel}z',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final exifInfo = asset.exifInfo;
|
||||
@ -42,6 +71,18 @@ class ExifBottomSheet extends HookConsumerWidget {
|
||||
exifInfo?.longitude ?? 0,
|
||||
),
|
||||
zoom: 16.0,
|
||||
onTap: (tapPosition, latLong) async {
|
||||
if (exifInfo != null &&
|
||||
exifInfo.latitude != null &&
|
||||
exifInfo.longitude != null) {
|
||||
launchUrl(
|
||||
await _createCoordinatesUri(
|
||||
exifInfo.latitude!,
|
||||
exifInfo.longitude!,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
nonRotatedChildren: [
|
||||
RichAttributionWidget(
|
||||
|
Loading…
Reference in New Issue
Block a user