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-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-02-11 04:40:11 +02:00
|
|
|
|
|
|
|
class ExifBottomSheet extends ConsumerWidget {
|
2022-07-13 14:23:48 +02:00
|
|
|
final AssetResponseDto 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-03-11 00:09:03 +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(
|
|
|
|
assetDetail.exifInfo?.latitude?.toDouble() ?? 0,
|
|
|
|
assetDetail.exifInfo?.longitude?.toDouble() ?? 0,
|
|
|
|
),
|
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(
|
|
|
|
assetDetail.exifInfo?.latitude?.toDouble() ?? 0,
|
|
|
|
assetDetail.exifInfo?.longitude?.toDouble() ?? 0,
|
|
|
|
),
|
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
|
|
|
}
|
|
|
|
|
|
|
|
_buildLocationText() {
|
2022-07-01 03:08:49 +02:00
|
|
|
return Text(
|
|
|
|
"${assetDetail.exifInfo!.city}, ${assetDetail.exifInfo!.state}",
|
|
|
|
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-07-01 03:08:49 +02:00
|
|
|
if (assetDetail.exifInfo?.dateTimeOriginal != null)
|
|
|
|
Text(
|
2022-07-07 20:40:54 +02:00
|
|
|
DateFormat('date_format'.tr()).format(
|
2022-07-13 14:23:48 +02:00
|
|
|
assetDetail.exifInfo!.dateTimeOriginal!,
|
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-07-01 03:08:49 +02:00
|
|
|
if (assetDetail.exifInfo?.latitude != null)
|
|
|
|
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-07-01 03:08:49 +02:00
|
|
|
if (assetDetail.exifInfo?.latitude != null &&
|
|
|
|
assetDetail.exifInfo?.longitude != null)
|
|
|
|
_buildMap(),
|
|
|
|
if (assetDetail.exifInfo?.city != null &&
|
|
|
|
assetDetail.exifInfo?.state != null)
|
|
|
|
_buildLocationText(),
|
|
|
|
Text(
|
|
|
|
"${assetDetail.exifInfo?.latitude?.toStringAsFixed(4)}, ${assetDetail.exifInfo?.longitude?.toStringAsFixed(4)}",
|
|
|
|
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
// Detail
|
2022-07-01 03:08:49 +02:00
|
|
|
if (assetDetail.exifInfo != null)
|
|
|
|
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(
|
|
|
|
"${assetDetail.exifInfo?.imageName!}${p.extension(assetDetail.originalPath)}",
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
subtitle: assetDetail.exifInfo?.exifImageHeight != null
|
|
|
|
? Text(
|
2022-07-13 14:23:48 +02:00
|
|
|
"${assetDetail.exifInfo?.exifImageHeight} x ${assetDetail.exifInfo?.exifImageWidth} ${assetDetail.exifInfo?.fileSizeInByte!}B ",
|
|
|
|
)
|
2022-07-01 03:08:49 +02:00
|
|
|
: null,
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
if (assetDetail.exifInfo?.make != null)
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.all(0),
|
|
|
|
dense: true,
|
|
|
|
textColor: Colors.grey[300],
|
|
|
|
iconColor: Colors.grey[300],
|
|
|
|
leading: const Icon(Icons.camera),
|
|
|
|
title: Text(
|
|
|
|
"${assetDetail.exifInfo?.make} ${assetDetail.exifInfo?.model}",
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
2022-07-13 14:23:48 +02:00
|
|
|
"ƒ/${assetDetail.exifInfo?.fNumber} 1/${(1 / (assetDetail.exifInfo?.exposureTime ?? 1)).toStringAsFixed(0)} ${assetDetail.exifInfo?.focalLength}mm ISO${assetDetail.exifInfo?.iso} ",
|
|
|
|
),
|
2022-07-01 03:08:49 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|