2022-07-07 20:40:54 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-03-13 17:28:09 +02:00
|
|
|
import 'package:flutter_map/flutter_map.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2022-11-08 19:00:24 +02:00
|
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
2022-07-13 14:23:48 +02:00
|
|
|
import 'package:openapi/api.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
import 'package:path/path.dart' as p;
|
2022-03-13 17:28:09 +02:00
|
|
|
import 'package:latlong2/latlong.dart';
|
2022-11-24 19:39:27 +02:00
|
|
|
import 'package:immich_mobile/utils/bytes_units.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
|
|
|
|
class ExifBottomSheet extends ConsumerWidget {
|
2022-11-08 19:00:24 +02:00
|
|
|
final Asset assetDetail;
|
2022-02-11 04:40:11 +02:00
|
|
|
|
2022-06-22 07:23:35 +02:00
|
|
|
const ExifBottomSheet({Key? key, required this.assetDetail})
|
|
|
|
: super(key: key);
|
2022-02-11 04:40:11 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-11-21 14:13:14 +02:00
|
|
|
buildMap() {
|
2022-07-01 03:08:49 +02:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
child: Container(
|
|
|
|
height: 150,
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(15)),
|
|
|
|
),
|
|
|
|
child: FlutterMap(
|
|
|
|
options: MapOptions(
|
2022-07-13 14:23:48 +02:00
|
|
|
center: LatLng(
|
2022-11-08 19:00:24 +02:00
|
|
|
assetDetail.latitude ?? 0,
|
|
|
|
assetDetail.longitude ?? 0,
|
2022-07-13 14:23:48 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
zoom: 16.0,
|
|
|
|
),
|
|
|
|
layers: [
|
|
|
|
TileLayerOptions(
|
|
|
|
urlTemplate:
|
|
|
|
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
|
|
subdomains: ['a', 'b', 'c'],
|
|
|
|
attributionBuilder: (_) {
|
|
|
|
return const Text(
|
|
|
|
"© OpenStreetMap",
|
|
|
|
style: TextStyle(fontSize: 10),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
MarkerLayerOptions(
|
|
|
|
markers: [
|
|
|
|
Marker(
|
|
|
|
anchorPos: AnchorPos.align(AnchorAlign.top),
|
2022-07-13 14:23:48 +02:00
|
|
|
point: LatLng(
|
2022-11-08 19:00:24 +02:00
|
|
|
assetDetail.latitude ?? 0,
|
|
|
|
assetDetail.longitude ?? 0,
|
2022-07-13 14:23:48 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
builder: (ctx) => const Image(
|
2022-07-13 14:23:48 +02:00
|
|
|
image: AssetImage('assets/location-pin.png'),
|
|
|
|
),
|
2022-03-11 00:09:03 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
],
|
2022-03-11 00:09:03 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2022-03-11 00:09:03 +02:00
|
|
|
}
|
|
|
|
|
2022-11-08 19:00:24 +02:00
|
|
|
ExifResponseDto? exifInfo = assetDetail.remote?.exifInfo;
|
|
|
|
|
2022-11-21 14:13:14 +02:00
|
|
|
buildLocationText() {
|
2022-07-01 03:08:49 +02:00
|
|
|
return Text(
|
2022-11-08 19:00:24 +02:00
|
|
|
"${exifInfo?.city}, ${exifInfo?.state}",
|
2022-07-01 03:08:49 +02:00
|
|
|
style: TextStyle(
|
2022-07-13 14:23:48 +02:00
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.grey[200],
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
);
|
2022-03-11 00:09:03 +02:00
|
|
|
}
|
|
|
|
|
2022-02-11 04:40:11 +02:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 8),
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
2022-11-08 19:00:24 +02:00
|
|
|
if (exifInfo?.dateTimeOriginal != null)
|
2022-07-01 03:08:49 +02:00
|
|
|
Text(
|
2022-07-07 20:40:54 +02:00
|
|
|
DateFormat('date_format'.tr()).format(
|
2022-11-08 19:00:24 +02:00
|
|
|
exifInfo!.dateTimeOriginal!.toLocal(),
|
2022-07-01 03:08:49 +02:00
|
|
|
),
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.grey[400],
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 14,
|
|
|
|
),
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 16.0),
|
|
|
|
child: Text(
|
2022-07-07 20:40:54 +02:00
|
|
|
"exif_bottom_sheet_description",
|
2022-02-11 04:40:11 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.grey[500],
|
|
|
|
fontSize: 11,
|
|
|
|
),
|
2022-07-07 20:40:54 +02:00
|
|
|
).tr(),
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
// Location
|
2022-11-08 19:00:24 +02:00
|
|
|
if (assetDetail.latitude != null)
|
2022-07-01 03:08:49 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 32.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Divider(
|
|
|
|
thickness: 1,
|
|
|
|
color: Colors.grey[600],
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
Text(
|
2022-07-07 20:40:54 +02:00
|
|
|
"exif_bottom_sheet_location",
|
2022-07-01 03:08:49 +02:00
|
|
|
style: TextStyle(fontSize: 11, color: Colors.grey[400]),
|
2022-07-07 20:40:54 +02:00
|
|
|
).tr(),
|
2022-11-08 19:00:24 +02:00
|
|
|
if (assetDetail.latitude != null &&
|
|
|
|
assetDetail.longitude != null)
|
2022-11-21 14:13:14 +02:00
|
|
|
buildMap(),
|
2022-11-08 19:00:24 +02:00
|
|
|
if (exifInfo != null &&
|
|
|
|
exifInfo.city != null &&
|
|
|
|
exifInfo.state != null)
|
2022-11-21 14:13:14 +02:00
|
|
|
buildLocationText(),
|
2022-07-01 03:08:49 +02:00
|
|
|
Text(
|
2022-11-08 19:00:24 +02:00
|
|
|
"${assetDetail.latitude?.toStringAsFixed(4)}, ${assetDetail.longitude?.toStringAsFixed(4)}",
|
2022-07-01 03:08:49 +02:00
|
|
|
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
// Detail
|
2022-11-08 19:00:24 +02:00
|
|
|
if (exifInfo != null)
|
2022-07-01 03:08:49 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 32.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Divider(
|
|
|
|
thickness: 1,
|
|
|
|
color: Colors.grey[600],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
|
|
child: Text(
|
2022-07-07 20:40:54 +02:00
|
|
|
"exif_bottom_sheet_details",
|
2022-07-01 03:08:49 +02:00
|
|
|
style: TextStyle(fontSize: 11, color: Colors.grey[400]),
|
2022-07-07 20:40:54 +02:00
|
|
|
).tr(),
|
2022-07-01 03:08:49 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.all(0),
|
|
|
|
dense: true,
|
|
|
|
textColor: Colors.grey[300],
|
|
|
|
iconColor: Colors.grey[300],
|
|
|
|
leading: const Icon(Icons.image),
|
|
|
|
title: Text(
|
2022-11-08 19:00:24 +02:00
|
|
|
"${exifInfo.imageName!}${p.extension(assetDetail.remote!.originalPath)}",
|
2022-07-01 03:08:49 +02:00
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
2022-11-08 19:00:24 +02:00
|
|
|
subtitle: exifInfo.exifImageHeight != null
|
2022-07-01 03:08:49 +02:00
|
|
|
? Text(
|
2022-11-24 19:39:27 +02:00
|
|
|
"${exifInfo.exifImageHeight} x ${exifInfo.exifImageWidth} ${formatBytes(exifInfo.fileSizeInByte!)} ",
|
2022-07-13 14:23:48 +02:00
|
|
|
)
|
2022-07-01 03:08:49 +02:00
|
|
|
: null,
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
2022-11-08 19:00:24 +02:00
|
|
|
if (exifInfo.make != null)
|
2022-07-01 03:08:49 +02:00
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.all(0),
|
|
|
|
dense: true,
|
|
|
|
textColor: Colors.grey[300],
|
|
|
|
iconColor: Colors.grey[300],
|
|
|
|
leading: const Icon(Icons.camera),
|
|
|
|
title: Text(
|
2022-11-08 19:00:24 +02:00
|
|
|
"${exifInfo.make} ${exifInfo.model}",
|
2022-07-01 03:08:49 +02:00
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
2022-11-24 19:39:27 +02:00
|
|
|
"ƒ/${exifInfo.fNumber} 1/${(1 / (exifInfo.exposureTime ?? 1)).toStringAsFixed(0)} ${exifInfo.focalLength} mm ISO${exifInfo.iso} ",
|
2022-07-13 14:23:48 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|