mirror of
https://github.com/immich-app/immich.git
synced 2025-01-21 00:52:43 -05:00
feat(mobile): launch map app from exif info (#3626)
This commit is contained in:
parent
23b836ffbb
commit
57a7103d75
2 changed files with 45 additions and 0 deletions
|
@ -70,5 +70,9 @@
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<data android:scheme="https" />
|
<data android:scheme="https" />
|
||||||
</intent>
|
</intent>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<data android:scheme="geo" />
|
||||||
|
</intent>
|
||||||
</queries>
|
</queries>
|
||||||
</manifest>
|
</manifest>
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
|
@ -17,6 +19,33 @@ class ExifBottomSheet extends HookConsumerWidget {
|
||||||
bool get showMap =>
|
bool get showMap =>
|
||||||
asset.exifInfo?.latitude != null && asset.exifInfo?.longitude != null;
|
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
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final exifInfo = asset.exifInfo;
|
final exifInfo = asset.exifInfo;
|
||||||
|
@ -42,6 +71,18 @@ class ExifBottomSheet extends HookConsumerWidget {
|
||||||
exifInfo?.longitude ?? 0,
|
exifInfo?.longitude ?? 0,
|
||||||
),
|
),
|
||||||
zoom: 16.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: [
|
nonRotatedChildren: [
|
||||||
RichAttributionWidget(
|
RichAttributionWidget(
|
||||||
|
|
Loading…
Add table
Reference in a new issue