ente/lib/ui/viewer/file/file_info_dialog.dart

836 lines
25 KiB
Dart
Raw Normal View History

import "dart:io";
2022-07-02 07:24:36 +00:00
import "package:exif/exif.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
import "package:photos/core/configuration.dart";
import "package:photos/ente_theme_data.dart";
import "package:photos/models/file.dart";
import "package:photos/models/file_type.dart";
import "package:photos/services/collections_service.dart";
import "package:photos/ui/viewer/file/exif_info_dialog.dart";
import "package:photos/utils/date_time_util.dart";
import "package:photos/utils/exif_util.dart";
import "package:photos/utils/file_util.dart";
import "package:photos/utils/magic_util.dart";
import "package:photos/utils/toast_util.dart";
2021-07-06 11:50:35 +00:00
2021-07-10 05:48:00 +00:00
class FileInfoWidget extends StatefulWidget {
2021-07-06 11:50:35 +00:00
final File file;
2021-07-06 11:51:51 +00:00
const FileInfoWidget(
2021-07-07 01:01:14 +00:00
this.file, {
2021-07-06 11:51:51 +00:00
Key key,
}) : super(key: key);
2021-07-06 11:50:35 +00:00
2021-07-10 05:48:00 +00:00
@override
2022-07-03 09:45:00 +00:00
State<FileInfoWidget> createState() => _FileInfoWidgetState();
2021-07-10 05:48:00 +00:00
}
class _FileInfoWidgetState extends State<FileInfoWidget> {
Map<String, IfdTag> _exif;
final Map<String, dynamic> _exifData = {
"focalLength": null,
"fNumber": null,
"resolution": null,
"takenOnDevice": null,
"exposureTime": null,
"ISO": null,
"megaPixels": null
};
2021-07-11 07:54:38 +00:00
bool _isImage = false;
2022-03-05 20:52:00 +00:00
Color infoColor;
2021-07-10 05:48:00 +00:00
@override
void initState() {
2022-07-12 06:18:52 +00:00
debugPrint('file_info_dialog initState');
2021-08-09 06:33:47 +00:00
_isImage = widget.file.fileType == FileType.image ||
widget.file.fileType == FileType.livePhoto;
2021-07-11 07:54:38 +00:00
if (_isImage) {
2021-08-24 07:14:33 +00:00
getExif(widget.file).then((exif) {
2021-07-11 07:54:38 +00:00
setState(() {
_exif = exif;
});
2021-07-10 05:48:00 +00:00
});
2021-07-11 07:54:38 +00:00
}
2021-07-10 05:48:00 +00:00
super.initState();
}
2021-07-06 11:50:35 +00:00
@override
Widget build(BuildContext context) {
2021-11-12 11:36:18 +00:00
final file = widget.file;
2022-07-02 07:24:36 +00:00
final dateTime = DateTime.fromMicrosecondsSinceEpoch(file.creationTime);
final dateTimeForUpdationTime =
DateTime.fromMicrosecondsSinceEpoch(file.updationTime);
infoColor =
Theme.of(context).colorScheme.onSurface.withOpacity(0.85); //remove
if (_isImage && _exif != null) {
_generateExifForDetails(_exif);
}
final bool showExifListTile = _exifData["focalLength"] != null ||
_exifData["fNumber"] != null ||
_exifData["takenOnDevice"] != null ||
_exifData["exposureTime"] != null ||
_exifData["ISO"] != null;
2022-07-02 07:24:36 +00:00
var listTiles = <Widget>[
ListTile(
2022-07-07 05:27:05 +00:00
leading: const Padding(
padding: EdgeInsets.only(top: 8, left: 6),
2022-07-02 07:24:36 +00:00
child: Icon(Icons.calendar_today_rounded),
),
title: Text(
getFullDate(
DateTime.fromMicrosecondsSinceEpoch(file.creationTime),
),
),
subtitle: Text(
getTimeIn12hrFormat(dateTime) + " " + dateTime.timeZoneName,
style: Theme.of(context)
.textTheme
.bodyText2
.copyWith(color: Colors.black.withOpacity(0.5)),
),
trailing: (widget.file.ownerID == null ||
widget.file.ownerID ==
Configuration.instance.getUserID()) &&
widget.file.uploadedFileID != null
? IconButton(
onPressed: () {
PopupMenuItem(
value: 2,
child: Row(
children: [
Icon(
Platform.isAndroid
? Icons.access_time_rounded
: CupertinoIcons.time,
color: Theme.of(context).iconTheme.color,
),
2022-07-07 05:27:05 +00:00
const Padding(
2022-07-02 07:24:36 +00:00
padding: EdgeInsets.all(8),
),
2022-07-07 05:27:05 +00:00
const Text("Edit time"),
2022-07-02 07:24:36 +00:00
],
),
);
},
2022-07-07 05:27:05 +00:00
icon: const Icon(Icons.edit),
2022-07-02 07:24:36 +00:00
)
: const SizedBox.shrink(),
),
2022-07-07 05:27:05 +00:00
const DividerWithPadding(),
ListTile(
leading: _isImage
? const Padding(
padding: EdgeInsets.only(top: 8, left: 6),
child: Icon(
Icons.image,
),
)
: const Padding(
padding: EdgeInsets.only(top: 8, left: 6),
child: Icon(
Icons.video_camera_back,
size: 27,
),
),
title: Text(
file.getDisplayName(),
),
2022-07-07 08:37:14 +00:00
subtitle: Row(
children: [
2022-07-12 06:18:52 +00:00
Padding(
padding: const EdgeInsets.only(right: 10),
child: _getFileSize(),
),
2022-07-12 08:27:58 +00:00
!_isImage ? _getVideoDuration() : const SizedBox.shrink(),
2022-07-07 08:37:14 +00:00
],
),
trailing: file.uploadedFileID == null ||
file.ownerID != Configuration.instance.getUserID()
? const SizedBox.shrink()
: IconButton(
onPressed: () async {
await editFilename(context, file);
setState(() {});
},
2022-07-07 05:27:05 +00:00
icon: const Icon(Icons.edit),
),
),
2022-07-07 05:27:05 +00:00
const DividerWithPadding(),
showExifListTile
? ListTile(
leading: const Padding(
padding: EdgeInsets.only(left: 6),
child: Icon(Icons.camera_rounded),
),
title: Text(_exifData["takenOnDevice"] ?? "--"),
subtitle: Row(
children: [
_exifData["fNumber"] != null
? Padding(
padding: const EdgeInsets.only(right: 10),
child: Text('ƒ/' + _exifData["fNumber"].toString()),
)
: const SizedBox.shrink(),
_exifData["exposureTime"] != null
? Padding(
padding: const EdgeInsets.only(right: 10),
child: Text(_exifData["exposureTime"]),
)
: const SizedBox.shrink(),
_exifData["focalLength"] != null
? Padding(
padding: const EdgeInsets.only(right: 10),
child:
Text(_exifData["focalLength"].toString() + "mm"),
)
: const SizedBox.shrink(),
_exifData["ISO"] != null
? Padding(
padding: const EdgeInsets.only(right: 10),
child: Text("ISO" + _exifData["ISO"].toString()),
)
: const SizedBox.shrink(),
],
),
)
: const SizedBox.shrink(),
showExifListTile ? const DividerWithPadding() : const SizedBox.shrink(),
ListTile(
leading: const Padding(
padding: EdgeInsets.only(left: 6),
child: Icon(Icons.folder_outlined),
),
title: Text(
file.deviceFolder ??
CollectionsService.instance
.getCollectionByID(file.collectionID)
.name,
),
),
const DividerWithPadding(),
(file.uploadedFileID != null && file.updationTime != null)
? ListTile(
leading: const Padding(
padding: EdgeInsets.only(top: 8, left: 6),
child: Icon(Icons.cloud_upload_outlined),
),
title: Text(
getFullDate(
DateTime.fromMicrosecondsSinceEpoch(file.updationTime),
),
),
subtitle: Text(
getTimeIn12hrFormat(dateTimeForUpdationTime) +
" " +
dateTimeForUpdationTime.timeZoneName,
style: Theme.of(context)
.textTheme
.bodyText2
.copyWith(color: Colors.black.withOpacity(0.5)),
),
)
: const SizedBox.shrink(),
_isImage
? Padding(
padding: const EdgeInsets.fromLTRB(0, 24, 0, 16),
child: SafeArea(
child: RawExifButton(_exif),
),
)
: const SizedBox(
height: 12,
)
2022-07-02 07:24:36 +00:00
];
2021-07-06 11:50:35 +00:00
var items = <Widget>[
//remove
2021-07-06 11:50:35 +00:00
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.calendar_today_outlined, color: infoColor),
const SizedBox(height: 8),
Text(
getFormattedTime(
2021-11-12 11:36:18 +00:00
DateTime.fromMicrosecondsSinceEpoch(file.creationTime),
),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
),
2021-07-06 11:50:35 +00:00
],
),
const SizedBox(height: 12),
2021-07-06 11:50:35 +00:00
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.folder_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
Text(
2021-11-12 11:36:18 +00:00
file.deviceFolder ??
CollectionsService.instance
2021-11-12 11:36:18 +00:00
.getCollectionByID(file.collectionID)
.name,
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
),
2021-07-06 11:50:35 +00:00
],
),
const SizedBox(height: 12),
2021-07-06 11:50:35 +00:00
];
2021-07-07 00:57:53 +00:00
items.addAll(
[
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.sd_storage_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-07 00:57:53 +00:00
_getFileSize(),
],
),
const SizedBox(height: 12),
2021-07-07 00:57:53 +00:00
],
);
2021-11-12 11:36:18 +00:00
if (file.localID != null && !_isImage) {
2022-07-12 06:18:52 +00:00
//remove
2021-07-07 00:41:49 +00:00
items.addAll(
[
2021-07-06 12:18:39 +00:00
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.timer_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-07 01:01:14 +00:00
FutureBuilder(
2021-11-12 11:36:18 +00:00
future: file.getAsset(),
2021-07-07 01:01:14 +00:00
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.videoDuration.toString().split(".")[0],
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
2021-07-07 01:01:14 +00:00
);
} else {
return Center(
child: SizedBox.fromSize(
2022-07-04 06:02:17 +00:00
size: const Size.square(24),
child: const CupertinoActivityIndicator(
2021-07-07 01:01:14 +00:00
radius: 8,
),
),
);
}
},
),
2021-07-06 12:18:39 +00:00
],
),
const SizedBox(height: 12),
2021-07-07 00:41:49 +00:00
],
);
2021-07-06 11:50:35 +00:00
}
2021-07-11 07:54:38 +00:00
if (_isImage && _exif != null) {
//remove
// items.add(_getExifWidgets(_exif));
_generateExifForDetails(_exif);
2021-07-06 12:18:39 +00:00
}
2021-11-12 11:36:18 +00:00
if (file.uploadedFileID != null && file.updationTime != null) {
//remove
items.addAll(
[
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.cloud_upload_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
Text(
2021-11-12 11:36:18 +00:00
getFormattedTime(
2022-06-11 08:23:52 +00:00
DateTime.fromMicrosecondsSinceEpoch(file.updationTime),
),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
),
],
),
],
);
}
2021-07-06 12:18:39 +00:00
items.add(
const SizedBox(height: 12),
2021-07-06 12:18:39 +00:00
);
2021-07-10 05:48:00 +00:00
items.add(
Row(
mainAxisAlignment:
2021-07-11 07:54:38 +00:00
_isImage ? MainAxisAlignment.spaceBetween : MainAxisAlignment.end,
children: _getActions(),
2021-07-10 05:48:00 +00:00
),
);
2021-11-12 11:32:43 +00:00
Widget titleContent;
2021-11-12 11:36:18 +00:00
if (file.uploadedFileID == null ||
file.ownerID != Configuration.instance.getUserID()) {
titleContent = Text(file.getDisplayName());
2021-11-12 11:32:43 +00:00
} else {
titleContent = InkWell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2021-11-24 11:33:22 +00:00
Flexible(
child: Text(
file.getDisplayName(),
2022-05-03 10:05:54 +00:00
style: Theme.of(context).textTheme.headline5,
2021-11-24 11:33:22 +00:00
),
2021-11-12 11:32:43 +00:00
),
const SizedBox(width: 16),
2022-05-03 10:05:54 +00:00
Icon(Icons.edit, color: infoColor),
2021-11-12 11:32:43 +00:00
],
),
onTap: () async {
2021-11-12 11:36:18 +00:00
await editFilename(context, file);
setState(() {});
},
2021-11-12 11:32:43 +00:00
);
}
// return AlertDialog(
// title: titleContent,
// content: SingleChildScrollView(
// child: ListBody(
// children: items,
// ),
// ),
// );
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
onPressed: () {
Navigator.pop(context);
},
2022-07-07 05:27:05 +00:00
icon: const Icon(
Icons.close,
),
),
const SizedBox(width: 6),
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Text(
"Details",
style: Theme.of(context).textTheme.bodyText1,
),
),
],
),
2021-07-10 05:48:00 +00:00
),
2022-07-02 07:24:36 +00:00
...listTiles
],
2021-07-10 05:48:00 +00:00
);
}
2021-07-11 07:54:38 +00:00
List<Widget> _getActions() {
2021-07-06 20:49:46 +00:00
final List<Widget> actions = [];
2021-07-11 07:54:38 +00:00
if (_isImage) {
2021-07-10 05:48:00 +00:00
if (_exif == null) {
actions.add(
TextButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Center(
child: SizedBox.fromSize(
2022-07-04 06:02:17 +00:00
size: const Size.square(24),
child: const CupertinoActivityIndicator(
2021-07-10 05:48:00 +00:00
radius: 8,
),
),
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-10 05:48:00 +00:00
Text(
2022-05-03 10:05:54 +00:00
"EXIF",
style: TextStyle(color: infoColor),
2021-07-10 05:48:00 +00:00
),
],
),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return ExifInfoDialog(widget.file);
},
barrierColor: Colors.black87,
);
},
),
);
} else if (_exif.isNotEmpty) {
actions.add(
TextButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.feed_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-10 05:48:00 +00:00
Text(
2022-06-06 16:13:29 +00:00
"View raw EXIF",
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
2021-07-10 05:48:00 +00:00
),
],
),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return ExifInfoDialog(widget.file);
},
barrierColor: Colors.black87,
);
},
2021-07-06 12:18:39 +00:00
),
2021-07-10 05:48:00 +00:00
);
} else {
actions.add(
TextButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Icon(
Icons.feed_outlined,
2022-06-09 05:14:05 +00:00
color: Theme.of(context)
.colorScheme
.defaultTextColor
.withOpacity(0.5),
2021-07-10 05:48:00 +00:00
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-10 05:48:00 +00:00
Text(
2022-06-06 16:13:29 +00:00
"No exif",
2021-07-10 05:48:00 +00:00
style: TextStyle(
2022-06-09 05:14:05 +00:00
color: Theme.of(context)
.colorScheme
.defaultTextColor
.withOpacity(0.5),
2021-07-10 05:48:00 +00:00
),
),
],
),
onPressed: () {
2022-06-10 14:29:56 +00:00
showShortToast(context, "This image has no exif data");
2021-07-10 05:48:00 +00:00
},
),
);
}
2021-07-06 20:49:46 +00:00
}
actions.add(
//remove
2021-07-06 20:49:46 +00:00
TextButton(
child: Text(
2022-06-06 16:13:29 +00:00
"Close",
2021-07-06 20:49:46 +00:00
style: TextStyle(
2022-03-05 20:52:00 +00:00
color: infoColor,
2021-07-06 20:49:46 +00:00
),
),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop("dialog");
2021-07-06 20:49:46 +00:00
},
),
);
2021-07-10 05:48:00 +00:00
return actions;
2021-07-06 11:50:35 +00:00
}
_generateExifForDetails(Map<String, IfdTag> exif) {
if (exif["EXIF FocalLength"] != null) {
_exifData["focalLength"] =
(exif["EXIF FocalLength"].values.toList()[0] as Ratio).numerator /
(exif["EXIF FocalLength"].values.toList()[0] as Ratio)
.denominator;
}
if (exif["EXIF FNumber"] != null) {
_exifData["fNumber"] =
(exif["EXIF FNumber"].values.toList()[0] as Ratio).numerator /
(exif["EXIF FNumber"].values.toList()[0] as Ratio).denominator;
}
if (exif["EXIF ExifImageWidth"] != null &&
exif["EXIF ExifImageLength"] != null) {
_exifData["resolution"] = exif["EXIF ExifImageWidth"].toString() +
" x " +
exif["EXIF ExifImageLength"].toString();
_exifData['megaPixels'] = ((exif["Image ImageWidth"].values.firstAsInt() *
exif["Image ImageLength"].values.firstAsInt()) /
1000000)
.toStringAsFixed(1);
} else if (exif["Image ImageWidth"] != null &&
exif["Image ImageLength"] != null) {
_exifData["resolution"] = exif["Image ImageWidth"].toString() +
" x " +
exif["Image ImageLength"].toString();
}
if (exif["Image Make"] != null && exif["Image Model"] != null) {
_exifData["takenOnDevice"] =
exif["Image Make"].toString() + " " + exif["Image Model"].toString();
}
if (exif["EXIF ExposureTime"] != null) {
_exifData["exposureTime"] = exif["EXIF ExposureTime"].toString();
}
if (exif["EXIF ISOSpeedRatings"] != null) {
_exifData['ISO'] = exif["EXIF ISOSpeedRatings"].toString();
}
}
Widget _getExifWidgets(Map<String, IfdTag> exif) {
final focalLength = exif["EXIF FocalLength"] != null
? (exif["EXIF FocalLength"].values.toList()[0] as Ratio).numerator /
(exif["EXIF FocalLength"].values.toList()[0] as Ratio)
.denominator //to remove
: null;
final fNumber = exif["EXIF FNumber"] != null
? (exif["EXIF FNumber"].values.toList()[0] as Ratio).numerator /
(exif["EXIF FNumber"].values.toList()[0] as Ratio)
.denominator //to remove
: null;
final List<Widget> children = [];
2021-07-07 00:41:49 +00:00
if (exif["EXIF ExifImageWidth"] != null &&
exif["EXIF ExifImageLength"] != null) {
children.addAll([
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.photo_size_select_actual_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-07 00:41:49 +00:00
Text(
exif["EXIF ExifImageWidth"].toString() +
" x " +
exif["EXIF ExifImageLength"].toString(),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
2021-07-07 00:41:49 +00:00
),
],
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(6)),
2021-07-07 00:41:49 +00:00
]);
} else if (exif["Image ImageWidth"] != null &&
exif["Image ImageLength"] != null) {
children.addAll([
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.photo_size_select_actual_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-07 00:41:49 +00:00
Text(
exif["Image ImageWidth"].toString() +
" x " +
exif["Image ImageLength"].toString(),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
2021-07-07 00:41:49 +00:00
),
],
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(6)),
2021-07-07 00:41:49 +00:00
]);
}
if (exif["Image Make"] != null && exif["Image Model"] != null) {
children.addAll(
[
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.camera_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2021-07-23 10:15:54 +00:00
Flexible(
child: Text(
exif["Image Make"].toString() +
" " +
exif["Image Model"].toString(),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
2021-07-23 10:15:54 +00:00
overflow: TextOverflow.clip,
),
),
],
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(6)),
],
);
}
if (fNumber != null) {
children.addAll([
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(CupertinoIcons.f_cursive, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
Text(
fNumber.toString(),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
),
],
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(6)),
]);
}
if (focalLength != null) {
children.addAll([
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.center_focus_strong_outlined, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
2022-06-11 08:23:52 +00:00
Text(
focalLength.toString() + " mm",
style: TextStyle(color: infoColor),
),
],
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(6)),
]);
}
if (exif["EXIF ExposureTime"] != null) {
children.addAll([
Row(
children: [
2022-05-03 10:05:54 +00:00
Icon(Icons.shutter_speed, color: infoColor),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(4)),
Text(
exif["EXIF ExposureTime"].toString(),
2022-05-03 10:05:54 +00:00
style: TextStyle(color: infoColor),
),
],
),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(6)),
]);
}
return Column(
children: children,
);
}
2021-07-07 00:57:53 +00:00
Widget _getFileSize() {
return FutureBuilder(
2021-08-09 06:33:47 +00:00
future: getFile(widget.file).then((f) => f.length()),
2021-07-07 00:57:53 +00:00
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(
(snapshot.data / (1024 * 1024)).toStringAsFixed(2) + " MB",
);
} else {
return Center(
child: SizedBox.fromSize(
2022-07-04 06:02:17 +00:00
size: const Size.square(24),
child: const CupertinoActivityIndicator(
2021-07-07 00:57:53 +00:00
radius: 8,
),
),
);
}
},
);
}
2022-07-12 06:18:52 +00:00
Widget _getVideoDuration() {
2022-07-12 08:27:58 +00:00
if (widget.file.duration != 0) {
return Text(
secondsToHHMMSS(widget.file.duration),
);
}
2022-07-12 06:18:52 +00:00
return FutureBuilder(
future: widget.file.getAsset(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.videoDuration.toString().split(".")[0],
);
} else {
return Center(
child: SizedBox.fromSize(
size: const Size.square(24),
child: const CupertinoActivityIndicator(
radius: 8,
),
),
);
}
},
);
}
2021-07-06 11:50:35 +00:00
}
class DividerWithPadding extends StatelessWidget {
const DividerWithPadding({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.fromLTRB(70, 0, 20, 0),
child: Divider(
thickness: 0.5,
),
);
}
}
enum Status {
loading,
exifIsAvailable,
noExif,
}
class RawExifButton extends StatelessWidget {
final Map<String, IfdTag> exif;
const RawExifButton(this.exif, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
Status exifStatus = Status.loading;
if (exif == null) {
exifStatus = Status.loading;
} else if (exif.isNotEmpty) {
exifStatus = Status.exifIsAvailable;
} else {
exifStatus = Status.noExif;
}
return GestureDetector(
child: Container(
height: 40,
width: 140,
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.inverseBackgroundColor
.withOpacity(0.12),
borderRadius: const BorderRadius.all(
Radius.circular(20),
),
),
child: Center(
child: exifStatus == Status.loading
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CupertinoActivityIndicator(
radius: 8,
),
const SizedBox(
width: 8,
),
Text('EXIF')
],
)
: exifStatus == Status.exifIsAvailable
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.feed_outlined),
SizedBox(
width: 8,
),
Text('Raw EXIF'),
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.feed_outlined),
SizedBox(
width: 8,
),
Text('No EXIF'),
],
),
),
),
onTap: () {},
);
}
}