✨ Better EXIF overlay
This commit is contained in:
@@ -852,7 +852,12 @@ class ChatRoomScreen extends HookConsumerWidget {
|
|||||||
top: 8,
|
top: 8,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8 + MediaQuery.of(context).padding.bottom,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
@@ -914,74 +919,68 @@ class ChatRoomScreen extends HookConsumerWidget {
|
|||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0, // At the very bottom, above gradient
|
bottom: MediaQuery.of(
|
||||||
|
context,
|
||||||
|
).padding.bottom, // At the very bottom, above gradient
|
||||||
child: chatRoom.when(
|
child: chatRoom.when(
|
||||||
data: (room) => Column(
|
data: (room) => ChatInput(
|
||||||
key: inputKey,
|
key: inputKey,
|
||||||
mainAxisSize: MainAxisSize.min,
|
messageController: messageController,
|
||||||
children: [
|
chatRoom: room!,
|
||||||
ChatInput(
|
onSend: sendMessage,
|
||||||
messageController: messageController,
|
onClear: () {
|
||||||
chatRoom: room!,
|
if (messageEditingTo.value != null) {
|
||||||
onSend: sendMessage,
|
attachments.value.clear();
|
||||||
onClear: () {
|
messageController.clear();
|
||||||
if (messageEditingTo.value != null) {
|
}
|
||||||
attachments.value.clear();
|
messageEditingTo.value = null;
|
||||||
messageController.clear();
|
messageReplyingTo.value = null;
|
||||||
}
|
messageForwardingTo.value = null;
|
||||||
messageEditingTo.value = null;
|
selectedPoll.value = null;
|
||||||
messageReplyingTo.value = null;
|
selectedFund.value = null;
|
||||||
messageForwardingTo.value = null;
|
},
|
||||||
selectedPoll.value = null;
|
messageEditingTo: messageEditingTo.value,
|
||||||
selectedFund.value = null;
|
messageReplyingTo: messageReplyingTo.value,
|
||||||
},
|
messageForwardingTo: messageForwardingTo.value,
|
||||||
messageEditingTo: messageEditingTo.value,
|
selectedPoll: selectedPoll.value,
|
||||||
messageReplyingTo: messageReplyingTo.value,
|
onPollSelected: (poll) => selectedPoll.value = poll,
|
||||||
messageForwardingTo: messageForwardingTo.value,
|
selectedFund: selectedFund.value,
|
||||||
selectedPoll: selectedPoll.value,
|
onFundSelected: (fund) => selectedFund.value = fund,
|
||||||
onPollSelected: (poll) => selectedPoll.value = poll,
|
onPickFile: (bool isPhoto) {
|
||||||
selectedFund: selectedFund.value,
|
if (isPhoto) {
|
||||||
onFundSelected: (fund) => selectedFund.value = fund,
|
pickPhotoMedia();
|
||||||
onPickFile: (bool isPhoto) {
|
} else {
|
||||||
if (isPhoto) {
|
pickVideoMedia();
|
||||||
pickPhotoMedia();
|
}
|
||||||
} else {
|
},
|
||||||
pickVideoMedia();
|
onPickAudio: pickAudioMedia,
|
||||||
}
|
onPickGeneralFile: pickGeneralFile,
|
||||||
},
|
onLinkAttachment: linkAttachment,
|
||||||
onPickAudio: pickAudioMedia,
|
attachments: attachments.value,
|
||||||
onPickGeneralFile: pickGeneralFile,
|
onUploadAttachment: uploadAttachment,
|
||||||
onLinkAttachment: linkAttachment,
|
onDeleteAttachment: (index) async {
|
||||||
attachments: attachments.value,
|
final attachment = attachments.value[index];
|
||||||
onUploadAttachment: uploadAttachment,
|
if (attachment.isOnCloud && !attachment.isLink) {
|
||||||
onDeleteAttachment: (index) async {
|
final client = ref.watch(apiClientProvider);
|
||||||
final attachment = attachments.value[index];
|
await client.delete('/drive/files/${attachment.data.id}');
|
||||||
if (attachment.isOnCloud && !attachment.isLink) {
|
}
|
||||||
final client = ref.watch(apiClientProvider);
|
final clone = List.of(attachments.value);
|
||||||
await client.delete(
|
clone.removeAt(index);
|
||||||
'/drive/files/${attachment.data.id}',
|
attachments.value = clone;
|
||||||
);
|
},
|
||||||
}
|
onMoveAttachment: (idx, delta) {
|
||||||
final clone = List.of(attachments.value);
|
if (idx + delta < 0 ||
|
||||||
clone.removeAt(index);
|
idx + delta >= attachments.value.length) {
|
||||||
attachments.value = clone;
|
return;
|
||||||
},
|
}
|
||||||
onMoveAttachment: (idx, delta) {
|
final clone = List.of(attachments.value);
|
||||||
if (idx + delta < 0 ||
|
clone.insert(idx + delta, clone.removeAt(idx));
|
||||||
idx + delta >= attachments.value.length) {
|
attachments.value = clone;
|
||||||
return;
|
},
|
||||||
}
|
onAttachmentsChanged: (newAttachments) {
|
||||||
final clone = List.of(attachments.value);
|
attachments.value = newAttachments;
|
||||||
clone.insert(idx + delta, clone.removeAt(idx));
|
},
|
||||||
attachments.value = clone;
|
attachmentProgress: attachmentProgress.value,
|
||||||
},
|
|
||||||
onAttachmentsChanged: (newAttachments) {
|
|
||||||
attachments.value = newAttachments;
|
|
||||||
},
|
|
||||||
attachmentProgress: attachmentProgress.value,
|
|
||||||
),
|
|
||||||
Gap(MediaQuery.of(context).padding.bottom),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
error: (_, _) => const SizedBox.shrink(),
|
error: (_, _) => const SizedBox.shrink(),
|
||||||
loading: () => const SizedBox.shrink(),
|
loading: () => const SizedBox.shrink(),
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
import 'package:island/pods/config.dart';
|
import 'package:island/pods/config.dart';
|
||||||
import 'package:island/services/file_download.dart';
|
import 'package:island/services/file_download.dart';
|
||||||
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/exif_info_overlay.dart';
|
||||||
import 'package:island/widgets/content/file_action_button.dart';
|
import 'package:island/widgets/content/file_action_button.dart';
|
||||||
import 'package:island/widgets/content/file_info_sheet.dart';
|
import 'package:island/widgets/content/file_info_sheet.dart';
|
||||||
import 'package:island/widgets/content/image_control_overlay.dart';
|
import 'package:island/widgets/content/image_control_overlay.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:photo_view/photo_view.dart';
|
import 'package:photo_view/photo_view.dart';
|
||||||
|
|
||||||
import 'cloud_files.dart';
|
|
||||||
|
|
||||||
class CloudFileLightbox extends HookConsumerWidget {
|
class CloudFileLightbox extends HookConsumerWidget {
|
||||||
final SnCloudFile item;
|
final SnCloudFile item;
|
||||||
final String heroTag;
|
final String heroTag;
|
||||||
@@ -30,7 +30,9 @@ class CloudFileLightbox extends HookConsumerWidget {
|
|||||||
final photoViewController = useMemoized(() => PhotoViewController(), []);
|
final photoViewController = useMemoized(() => PhotoViewController(), []);
|
||||||
final rotation = useState(0);
|
final rotation = useState(0);
|
||||||
|
|
||||||
|
final hasExifData = ExifInfoOverlay.precheck(item);
|
||||||
final showOriginal = useState(false);
|
final showOriginal = useState(false);
|
||||||
|
final showExif = useState(hasExifData);
|
||||||
|
|
||||||
void saveToGallery() {
|
void saveToGallery() {
|
||||||
FileDownloadService(ref).saveToGallery(item);
|
FileDownloadService(ref).saveToGallery(item);
|
||||||
@@ -106,6 +108,14 @@ class CloudFileLightbox extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// EXIF Info Overlay (positioned below the top buttons)
|
||||||
|
if (showExif.value)
|
||||||
|
Positioned(
|
||||||
|
bottom: MediaQuery.of(context).padding.bottom + 60,
|
||||||
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
child: ExifInfoOverlay(item: item),
|
||||||
|
),
|
||||||
ImageControlOverlay(
|
ImageControlOverlay(
|
||||||
photoViewController: photoViewController,
|
photoViewController: photoViewController,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
@@ -113,6 +123,11 @@ class CloudFileLightbox extends HookConsumerWidget {
|
|||||||
onToggleQuality: () {
|
onToggleQuality: () {
|
||||||
showOriginal.value = !showOriginal.value;
|
showOriginal.value = !showOriginal.value;
|
||||||
},
|
},
|
||||||
|
showExifInfo: showExif.value,
|
||||||
|
onToggleExif: () {
|
||||||
|
showExif.value = !showExif.value;
|
||||||
|
},
|
||||||
|
hasExifData: hasExifData,
|
||||||
extraButtons: [
|
extraButtons: [
|
||||||
FileActionButton.info(
|
FileActionButton.info(
|
||||||
onPressed: showInfoSheet,
|
onPressed: showInfoSheet,
|
||||||
|
|||||||
163
lib/widgets/content/exif_info_overlay.dart
Normal file
163
lib/widgets/content/exif_info_overlay.dart
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:island/models/file.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
|
||||||
|
class ExifInfoOverlay extends StatelessWidget {
|
||||||
|
final SnCloudFile item;
|
||||||
|
|
||||||
|
const ExifInfoOverlay({super.key, required this.item});
|
||||||
|
|
||||||
|
static bool precheck(SnCloudFile item) {
|
||||||
|
final exifData = item.fileMeta?['exif'] as Map<String, dynamic>? ?? {};
|
||||||
|
|
||||||
|
if (exifData.isEmpty) return false;
|
||||||
|
|
||||||
|
final dateTime = exifData['ifd0-DateTime'];
|
||||||
|
final model = exifData['ifd0-Model'];
|
||||||
|
final iso = exifData['ifd2-ISOSpeedRatings'];
|
||||||
|
final fnumber = exifData['ifd2-FNumber'];
|
||||||
|
final exposureTime = exifData['ifd2-ExposureTime'];
|
||||||
|
final focalLength = exifData['ifd2-FocalLength'];
|
||||||
|
|
||||||
|
return (dateTime != null && dateTime.isNotEmpty) ||
|
||||||
|
(model != null && model.isNotEmpty) ||
|
||||||
|
iso != null ||
|
||||||
|
fnumber != null ||
|
||||||
|
exposureTime != null ||
|
||||||
|
focalLength != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isPreferredValue(String key, String value) {
|
||||||
|
if ([
|
||||||
|
'ExposureTime',
|
||||||
|
'FNumber',
|
||||||
|
'FocalLength',
|
||||||
|
'ApertureValue',
|
||||||
|
'DateTime',
|
||||||
|
].contains(key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatExifValue(String key, String value) {
|
||||||
|
final lastOpen = value.lastIndexOf('(');
|
||||||
|
final lastClose = value.endsWith(')') ? value.length - 1 : -1;
|
||||||
|
|
||||||
|
if (lastOpen == -1 || lastClose == -1 || lastOpen > lastClose) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
final inside = value.substring(lastOpen + 1, lastClose);
|
||||||
|
final commaIndex = inside.indexOf(',');
|
||||||
|
|
||||||
|
if (commaIndex != -1) {
|
||||||
|
final candidate = inside.substring(0, commaIndex).trim();
|
||||||
|
|
||||||
|
if (_isPreferredValue(key, candidate)) {
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastOpen == -1) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.substring(0, lastOpen).trimRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final exifData = item.fileMeta?['exif'] as Map<String, dynamic>? ?? {};
|
||||||
|
|
||||||
|
if (exifData.isEmpty) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
final dateTime = exifData['ifd0-DateTime'];
|
||||||
|
final model = exifData['ifd0-Model'];
|
||||||
|
final iso = exifData['ifd2-ISOSpeedRatings'];
|
||||||
|
final fnumber = exifData['ifd2-FNumber'];
|
||||||
|
final exposureTime = exifData['ifd2-ExposureTime'];
|
||||||
|
final focalLength = exifData['ifd2-FocalLength'];
|
||||||
|
|
||||||
|
final items = <Widget>[];
|
||||||
|
|
||||||
|
if (dateTime != null && dateTime.isNotEmpty) {
|
||||||
|
items.add(_buildExifItem('DateTime', dateTime, Symbols.calendar_check));
|
||||||
|
}
|
||||||
|
if (model != null && model.isNotEmpty) {
|
||||||
|
items.add(_buildExifItem('Model', model, Symbols.camera_alt));
|
||||||
|
}
|
||||||
|
if (iso != null) {
|
||||||
|
items.add(_buildExifItem('ISO', iso, Icons.iso));
|
||||||
|
}
|
||||||
|
if (fnumber != null) {
|
||||||
|
items.add(_buildExifItem('FNumber', fnumber, Symbols.camera_enhance));
|
||||||
|
}
|
||||||
|
if (exposureTime != null) {
|
||||||
|
items.add(
|
||||||
|
_buildExifItem('ExposureTime', exposureTime, Icons.shutter_speed),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (focalLength != null) {
|
||||||
|
items.add(
|
||||||
|
_buildExifItem(
|
||||||
|
'FocalLength',
|
||||||
|
focalLength,
|
||||||
|
Symbols.photo_size_select_large,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items.isEmpty) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
return Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
|
child: Wrap(
|
||||||
|
alignment: WrapAlignment.start,
|
||||||
|
children: items
|
||||||
|
.map(
|
||||||
|
(item) => Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: item,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildExifItem(String key, String value, IconData icon) {
|
||||||
|
final formattedValue = _formatExifValue(key, value);
|
||||||
|
final shadow = [
|
||||||
|
Shadow(
|
||||||
|
color: Colors.black54,
|
||||||
|
blurRadius: 5.0,
|
||||||
|
offset: const Offset(1.0, 1.0),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 16, color: Colors.white70, shadows: shadow),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
formattedValue,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
shadows: shadow,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import 'package:island/services/file_download.dart';
|
|||||||
import 'package:island/utils/format.dart';
|
import 'package:island/utils/format.dart';
|
||||||
import 'package:island/widgets/content/audio.dart';
|
import 'package:island/widgets/content/audio.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/exif_info_overlay.dart';
|
||||||
import 'package:island/widgets/content/file_info_sheet.dart';
|
import 'package:island/widgets/content/file_info_sheet.dart';
|
||||||
import 'package:island/widgets/content/image_control_overlay.dart';
|
import 'package:island/widgets/content/image_control_overlay.dart';
|
||||||
import 'package:island/widgets/content/video.dart';
|
import 'package:island/widgets/content/video.dart';
|
||||||
@@ -136,7 +137,10 @@ class ImageFileContent extends HookConsumerWidget {
|
|||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final photoViewController = useMemoized(() => PhotoViewController(), []);
|
final photoViewController = useMemoized(() => PhotoViewController(), []);
|
||||||
final rotation = useState(0);
|
final rotation = useState(0);
|
||||||
|
|
||||||
|
final hasExifData = ExifInfoOverlay.precheck(item);
|
||||||
final showOriginal = useState(false);
|
final showOriginal = useState(false);
|
||||||
|
final showExif = useState(hasExifData);
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
@@ -177,6 +181,13 @@ class ImageFileContent extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (showExif.value)
|
||||||
|
Positioned(
|
||||||
|
bottom: MediaQuery.of(context).padding.bottom + 60,
|
||||||
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
child: ExifInfoOverlay(item: item),
|
||||||
|
),
|
||||||
ImageControlOverlay(
|
ImageControlOverlay(
|
||||||
photoViewController: photoViewController,
|
photoViewController: photoViewController,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
@@ -184,6 +195,11 @@ class ImageFileContent extends HookConsumerWidget {
|
|||||||
onToggleQuality: () {
|
onToggleQuality: () {
|
||||||
showOriginal.value = !showOriginal.value;
|
showOriginal.value = !showOriginal.value;
|
||||||
},
|
},
|
||||||
|
showExifInfo: showExif.value,
|
||||||
|
onToggleExif: () {
|
||||||
|
showExif.value = !showExif.value;
|
||||||
|
},
|
||||||
|
hasExifData: hasExifData,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class ImageControlOverlay extends HookWidget {
|
|||||||
final VoidCallback onToggleQuality;
|
final VoidCallback onToggleQuality;
|
||||||
final List<Widget>? extraButtons;
|
final List<Widget>? extraButtons;
|
||||||
final bool showExtraOnLeft;
|
final bool showExtraOnLeft;
|
||||||
|
final bool showExifInfo;
|
||||||
|
final VoidCallback onToggleExif;
|
||||||
|
final bool hasExifData;
|
||||||
|
|
||||||
const ImageControlOverlay({
|
const ImageControlOverlay({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -22,12 +25,19 @@ class ImageControlOverlay extends HookWidget {
|
|||||||
required this.onToggleQuality,
|
required this.onToggleQuality,
|
||||||
this.extraButtons,
|
this.extraButtons,
|
||||||
this.showExtraOnLeft = false,
|
this.showExtraOnLeft = false,
|
||||||
|
this.showExifInfo = false,
|
||||||
|
required this.onToggleExif,
|
||||||
|
this.hasExifData = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final shadow = [
|
final shadow = [
|
||||||
Shadow(color: Colors.black54, blurRadius: 5.0, offset: Offset(1.0, 1.0)),
|
Shadow(
|
||||||
|
color: Colors.black54,
|
||||||
|
blurRadius: 5.0,
|
||||||
|
offset: const Offset(1.0, 1.0),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
final controlButtons = [
|
final controlButtons = [
|
||||||
@@ -58,6 +68,17 @@ class ImageControlOverlay extends HookWidget {
|
|||||||
photoViewController.rotation = rotation.value * -math.pi / 2;
|
photoViewController.rotation = rotation.value * -math.pi / 2;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (hasExifData) ...[
|
||||||
|
const Gap(8),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
showExifInfo ? Icons.visibility : Icons.visibility_off,
|
||||||
|
color: Colors.white,
|
||||||
|
shadows: shadow,
|
||||||
|
),
|
||||||
|
onPressed: onToggleExif,
|
||||||
|
),
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return Positioned(
|
return Positioned(
|
||||||
|
|||||||
Reference in New Issue
Block a user