123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- 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';
- import 'package:photos/ui/exif_info_dialog.dart';
- import 'package:photos/utils/date_time_util.dart';
- class FileInfoWidget extends StatelessWidget {
- final File file;
- final AssetEntity entity;
- final int fileSize;
- const FileInfoWidget(
- this.file,
- this.entity,
- this.fileSize, {
- Key key,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- var items = <Widget>[
- Row(
- children: [
- Icon(Icons.calendar_today_outlined),
- Padding(padding: EdgeInsets.all(4)),
- Text(getFormattedTime(
- DateTime.fromMicrosecondsSinceEpoch(file.creationTime))),
- ],
- ),
- Padding(padding: EdgeInsets.all(4)),
- Row(
- children: [
- Icon(Icons.folder_outlined),
- Padding(padding: EdgeInsets.all(4)),
- Text(file.deviceFolder ??
- CollectionsService.instance
- .getCollectionByID(file.collectionID)
- .name),
- ],
- ),
- Padding(padding: EdgeInsets.all(4)),
- ];
- if (file.localID != null) {
- items.add(
- Row(
- children: [
- Icon(Icons.sd_storage_outlined),
- Padding(padding: EdgeInsets.all(4)),
- Text((fileSize / (1024 * 1024)).toStringAsFixed(2) + " MB"),
- ],
- ),
- );
- items.add(
- Padding(padding: EdgeInsets.all(4)),
- );
- if (file.fileType == FileType.image) {
- items.add(
- Row(
- children: [
- Icon(Icons.photo_size_select_actual_outlined),
- Padding(padding: EdgeInsets.all(4)),
- Text(entity.width.toString() + " x " + entity.height.toString()),
- ],
- ),
- );
- } else {
- items.add(
- Row(
- children: [
- Icon(Icons.timer_outlined),
- Padding(padding: EdgeInsets.all(4)),
- Text(entity.videoDuration.toString().split(".")[0]),
- ],
- ),
- );
- }
- items.add(
- Padding(padding: EdgeInsets.all(4)),
- );
- }
- if (file.uploadedFileID != null) {
- items.add(
- Row(
- children: [
- Icon(Icons.cloud_upload_outlined),
- Padding(padding: EdgeInsets.all(4)),
- Text(getFormattedTime(
- DateTime.fromMicrosecondsSinceEpoch(file.updationTime))),
- ],
- ),
- );
- }
- items.add(
- Padding(padding: EdgeInsets.all(12)),
- );
- final List<Widget> actions = [];
- if (file.fileType == FileType.image) {
- actions.add(
- 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: () {
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return ExifInfoDialog(file);
- },
- barrierColor: Colors.black87,
- );
- },
- ),
- );
- }
- actions.add(
- TextButton(
- child: Text(
- "close",
- style: TextStyle(
- color: Colors.white.withOpacity(0.8),
- ),
- ),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop('dialog');
- },
- ),
- );
- items.add(
- Row(
- mainAxisAlignment: file.fileType == FileType.image
- ? MainAxisAlignment.spaceBetween
- : MainAxisAlignment.end,
- children: actions,
- ),
- );
- return AlertDialog(
- title: Text(file.title),
- content: SingleChildScrollView(
- child: ListBody(
- children: items,
- ),
- ),
- );
- }
- }
|