ente/lib/ui/image_info_dialog.dart

153 lines
4.1 KiB
Dart
Raw Normal View History

2021-07-06 11:50:35 +00:00
import 'package:flutter/material.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:photos/models/file.dart';
import 'package:photos/models/file_type.dart';
import 'package:photos/services/collections_service.dart';
2021-07-06 16:03:39 +00:00
import 'package:photos/ui/exif_info_dialog.dart';
2021-07-06 11:50:35 +00:00
import 'package:photos/utils/date_time_util.dart';
2021-07-06 16:03:39 +00:00
class FileInfoWidget extends StatelessWidget {
2021-07-06 11:50:35 +00:00
final File file;
final AssetEntity entity;
final int fileSize;
2021-07-06 11:51:51 +00:00
const FileInfoWidget(
this.file,
this.entity,
this.fileSize, {
Key key,
}) : super(key: key);
2021-07-06 11:50:35 +00:00
@override
Widget build(BuildContext context) {
var items = <Widget>[
Row(
children: [
Icon(Icons.calendar_today_outlined),
Padding(padding: EdgeInsets.all(4)),
Text(getFormattedTime(
2021-07-06 16:03:39 +00:00
DateTime.fromMicrosecondsSinceEpoch(file.creationTime))),
2021-07-06 11:50:35 +00:00
],
),
Padding(padding: EdgeInsets.all(4)),
Row(
children: [
Icon(Icons.folder_outlined),
Padding(padding: EdgeInsets.all(4)),
2021-07-06 16:03:39 +00:00
Text(file.deviceFolder ??
2021-07-06 11:50:35 +00:00
CollectionsService.instance
2021-07-06 16:03:39 +00:00
.getCollectionByID(file.collectionID)
2021-07-06 11:50:35 +00:00
.name),
],
),
Padding(padding: EdgeInsets.all(4)),
];
2021-07-06 16:03:39 +00:00
if (file.localID != null) {
2021-07-06 11:50:35 +00:00
items.add(
2021-07-06 12:18:39 +00:00
Row(
2021-07-06 11:50:35 +00:00
children: [
2021-07-06 12:18:39 +00:00
Icon(Icons.sd_storage_outlined),
2021-07-06 11:50:35 +00:00
Padding(padding: EdgeInsets.all(4)),
2021-07-06 16:03:39 +00:00
Text((fileSize / (1024 * 1024)).toStringAsFixed(2) + " MB"),
2021-07-06 11:50:35 +00:00
],
2021-07-06 12:18:39 +00:00
),
);
items.add(
Padding(padding: EdgeInsets.all(4)),
);
2021-07-06 16:03:39 +00:00
if (file.fileType == FileType.image) {
2021-07-06 12:18:39 +00:00
items.add(
Row(
children: [
Icon(Icons.photo_size_select_actual_outlined),
Padding(padding: EdgeInsets.all(4)),
2021-07-06 16:03:39 +00:00
Text(entity.width.toString() + " x " + entity.height.toString()),
2021-07-06 12:18:39 +00:00
],
),
);
2021-07-06 11:50:35 +00:00
} else {
2021-07-06 12:02:45 +00:00
items.add(
Row(
children: [
Icon(Icons.timer_outlined),
Padding(padding: EdgeInsets.all(4)),
2021-07-06 16:03:39 +00:00
Text(entity.videoDuration.toString().split(".")[0]),
2021-07-06 12:02:45 +00:00
],
),
);
2021-07-06 11:50:35 +00:00
}
items.add(
Padding(padding: EdgeInsets.all(4)),
);
}
2021-07-06 16:03:39 +00:00
if (file.uploadedFileID != null) {
2021-07-06 12:18:39 +00:00
items.add(
Row(
children: [
Icon(Icons.cloud_upload_outlined),
Padding(padding: EdgeInsets.all(4)),
Text(getFormattedTime(
2021-07-06 16:03:39 +00:00
DateTime.fromMicrosecondsSinceEpoch(file.updationTime))),
2021-07-06 12:18:39 +00:00
],
),
);
}
items.add(
Padding(padding: EdgeInsets.all(12)),
);
items.add(
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
2021-07-06 11:50:35 +00:00
children: [
2021-07-06 12:18:39 +00:00
TextButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Icon(
Icons.camera_outlined,
color: Colors.white,
),
Padding(padding: EdgeInsets.all(4)),
Text(
"view exif",
style: TextStyle(
color: Colors.white.withOpacity(0.8),
),
),
],
),
onPressed: () {
2021-07-06 16:03:39 +00:00
showDialog(
context: context,
builder: (BuildContext context) {
return ExifInfoDialog(file);
},
barrierColor: Colors.black87,
);
2021-07-06 12:18:39 +00:00
},
),
TextButton(
child: Text(
"close",
style: TextStyle(
color: Colors.white.withOpacity(0.8),
),
),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
),
2021-07-06 11:50:35 +00:00
],
2021-07-06 12:18:39 +00:00
),
);
2021-07-06 11:50:35 +00:00
return AlertDialog(
2021-07-06 16:03:39 +00:00
title: Text(file.title),
2021-07-06 11:50:35 +00:00
content: SingleChildScrollView(
child: ListBody(
children: items,
),
),
);
}
}