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';
|
2023-02-04 22:42:42 +02:00
|
|
|
import 'package:immich_mobile/shared/models/exif_info.dart';
|
2023-01-11 22:54:12 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/drag_sheet.dart';
|
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
|
|
|
|
2023-01-11 22:54:12 +02:00
|
|
|
class ExifBottomSheet extends HookConsumerWidget {
|
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
|
|
|
}
|
|
|
|
|
2023-01-11 22:54:12 +02:00
|
|
|
final textColor = Theme.of(context).primaryColor;
|
|
|
|
|
2023-02-04 22:42:42 +02:00
|
|
|
ExifInfo? exifInfo = assetDetail.exifInfo;
|
2022-11-08 19:00:24 +02:00
|
|
|
|
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,
|
|
|
|
fontWeight: FontWeight.bold,
|
2023-01-11 22:54:12 +02:00
|
|
|
color: textColor,
|
2022-07-13 14:23:48 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
);
|
2022-03-11 00:09:03 +02:00
|
|
|
}
|
|
|
|
|
2023-02-04 22:42:42 +02:00
|
|
|
buildSizeText(Asset a) {
|
|
|
|
String resolution = a.width != null && a.height != null
|
|
|
|
? "${a.height} x ${a.width} "
|
|
|
|
: "";
|
|
|
|
String fileSize = a.exifInfo?.fileSize != null
|
|
|
|
? formatBytes(a.exifInfo!.fileSize!)
|
|
|
|
: "";
|
|
|
|
String text = resolution + fileSize;
|
|
|
|
return text.isEmpty ? null : Text(text);
|
|
|
|
}
|
|
|
|
|
2023-01-11 22:54:12 +02:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Card(
|
2023-01-18 17:59:23 +02:00
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(15),
|
|
|
|
topRight: Radius.circular(15),
|
|
|
|
),
|
|
|
|
),
|
2023-01-11 22:54:12 +02:00
|
|
|
margin: const EdgeInsets.all(0),
|
|
|
|
child: Container(
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
const Align(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: CustomDraggingHandle(),
|
2022-07-01 03:08:49 +02:00
|
|
|
),
|
2023-01-11 22:54:12 +02:00
|
|
|
const SizedBox(height: 12),
|
2023-02-04 22:42:42 +02:00
|
|
|
Text(
|
|
|
|
DateFormat('date_format'.tr()).format(
|
|
|
|
assetDetail.createdAt.toLocal(),
|
2023-01-11 22:54:12 +02:00
|
|
|
),
|
2023-02-04 22:42:42 +02:00
|
|
|
style: const TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 14,
|
|
|
|
),
|
|
|
|
),
|
2023-01-11 22:54:12 +02:00
|
|
|
|
|
|
|
// Location
|
2023-02-04 22:42:42 +02:00
|
|
|
if (assetDetail.latitude != null && assetDetail.longitude != null)
|
2023-01-11 22:54:12 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 32.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
const Divider(
|
|
|
|
thickness: 1,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"exif_bottom_sheet_location",
|
|
|
|
style: TextStyle(fontSize: 11, color: textColor),
|
|
|
|
).tr(),
|
2023-02-04 22:42:42 +02:00
|
|
|
buildMap(),
|
2023-01-11 22:54:12 +02:00
|
|
|
if (exifInfo != null &&
|
|
|
|
exifInfo.city != null &&
|
|
|
|
exifInfo.state != null)
|
|
|
|
buildLocationText(),
|
|
|
|
Text(
|
2023-02-04 22:42:42 +02:00
|
|
|
"${assetDetail.latitude!.toStringAsFixed(4)}, ${assetDetail.longitude!.toStringAsFixed(4)}",
|
2023-01-11 22:54:12 +02:00
|
|
|
style: const TextStyle(fontSize: 12),
|
|
|
|
)
|
|
|
|
],
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
2023-01-11 22:54:12 +02:00
|
|
|
),
|
|
|
|
// Detail
|
2023-02-04 22:42:42 +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(
|
|
|
|
"exif_bottom_sheet_details",
|
|
|
|
style: TextStyle(fontSize: 11, color: textColor),
|
|
|
|
).tr(),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.all(0),
|
|
|
|
dense: true,
|
|
|
|
leading: const Icon(Icons.image),
|
|
|
|
title: Text(
|
|
|
|
assetDetail.fileName,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: textColor,
|
|
|
|
),
|
2022-07-13 14:23:48 +02:00
|
|
|
),
|
2023-02-04 22:42:42 +02:00
|
|
|
subtitle: buildSizeText(assetDetail),
|
|
|
|
),
|
|
|
|
if (exifInfo?.make != null)
|
2023-01-11 22:54:12 +02:00
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.all(0),
|
|
|
|
dense: true,
|
2023-02-04 22:42:42 +02:00
|
|
|
leading: const Icon(Icons.camera),
|
2023-01-11 22:54:12 +02:00
|
|
|
title: Text(
|
2023-02-04 22:42:42 +02:00
|
|
|
"${exifInfo!.make} ${exifInfo.model}",
|
2023-01-11 22:54:12 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: textColor,
|
2023-02-04 22:42:42 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
2023-01-11 22:54:12 +02:00
|
|
|
),
|
|
|
|
),
|
2023-02-04 22:42:42 +02:00
|
|
|
subtitle: Text(
|
|
|
|
"ƒ/${exifInfo.fNumber} ${exifInfo.exposureTime} ${exifInfo.focalLength} mm ISO${exifInfo.iso} ",
|
2023-01-11 22:54:12 +02:00
|
|
|
),
|
2023-02-04 22:42:42 +02:00
|
|
|
),
|
|
|
|
],
|
2023-01-11 22:54:12 +02:00
|
|
|
),
|
2023-02-04 22:42:42 +02:00
|
|
|
),
|
2023-01-11 22:54:12 +02:00
|
|
|
const SizedBox(
|
|
|
|
height: 50,
|
2022-07-01 03:08:49 +02:00
|
|
|
),
|
2023-01-11 22:54:12 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|