|
@@ -1,32 +1,24 @@
|
|
|
import "package:exif/exif.dart";
|
|
|
import "package:flutter/cupertino.dart";
|
|
|
import "package:flutter/material.dart";
|
|
|
-import "package:logging/logging.dart";
|
|
|
import "package:photos/core/configuration.dart";
|
|
|
-import 'package:photos/db/files_db.dart';
|
|
|
import "package:photos/ente_theme_data.dart";
|
|
|
-import "package:photos/models/collection.dart";
|
|
|
-import "package:photos/models/collection_items.dart";
|
|
|
import "package:photos/models/file.dart";
|
|
|
import "package:photos/models/file_type.dart";
|
|
|
-import "package:photos/models/gallery_type.dart";
|
|
|
import 'package:photos/services/collections_service.dart';
|
|
|
import "package:photos/services/feature_flag_service.dart";
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
|
|
-import "package:photos/ui/components/buttons/chip_button_widget.dart";
|
|
|
import 'package:photos/ui/components/buttons/icon_button_widget.dart';
|
|
|
import 'package:photos/ui/components/divider_widget.dart';
|
|
|
-import "package:photos/ui/components/info_item_widget.dart";
|
|
|
import 'package:photos/ui/components/title_bar_widget.dart';
|
|
|
import 'package:photos/ui/viewer/file/file_caption_widget.dart';
|
|
|
+import "package:photos/ui/viewer/file_details/albums_item_widget.dart";
|
|
|
import "package:photos/ui/viewer/file_details/backed_up_date_item_widget.dart";
|
|
|
import "package:photos/ui/viewer/file_details/creation_time_item_widget.dart";
|
|
|
import "package:photos/ui/viewer/file_details/exif_item_widget.dart";
|
|
|
import "package:photos/ui/viewer/file_details/file_properties_item_widget.dart";
|
|
|
import "package:photos/ui/viewer/file_details/objects_item_widget.dart";
|
|
|
-import "package:photos/ui/viewer/gallery/collection_page.dart";
|
|
|
import "package:photos/utils/exif_util.dart";
|
|
|
-import "package:photos/utils/navigation_util.dart";
|
|
|
|
|
|
class FileDetailsWidget extends StatefulWidget {
|
|
|
final File file;
|
|
@@ -74,20 +66,9 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- final subtitleTextTheme = getEnteTextTheme(context).smallMuted;
|
|
|
final file = widget.file;
|
|
|
- final fileIsBackedup = file.uploadedFileID == null ? false : true;
|
|
|
final bool isFileOwner =
|
|
|
file.ownerID == null || file.ownerID == _currentUserID;
|
|
|
- late Future<Set<int>> allCollectionIDsOfFile;
|
|
|
- //Typing this as Future<Set<T>> as it would be easier to implement showing multiple device folders for a file in the future
|
|
|
- final Future<Set<String>> allDeviceFoldersOfFile =
|
|
|
- Future.sync(() => {file.deviceFolder ?? ''});
|
|
|
- if (fileIsBackedup) {
|
|
|
- allCollectionIDsOfFile = FilesDB.instance.getAllCollectionIDsOfFile(
|
|
|
- file.uploadedFileID!,
|
|
|
- );
|
|
|
- }
|
|
|
|
|
|
if (_isImage && _exif != null) {
|
|
|
_generateExifForDetails(_exif!);
|
|
@@ -117,15 +98,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
|
|
|
(file.uploadedFileID != null && file.updationTime != null)
|
|
|
? BackedUpDateItemWidget(file)
|
|
|
: null,
|
|
|
- InfoItemWidget(
|
|
|
- key: const ValueKey("Albums"),
|
|
|
- leadingIcon: Icons.folder_outlined,
|
|
|
- title: "Albums",
|
|
|
- subtitleSection: fileIsBackedup
|
|
|
- ? _collectionsListOfFile(allCollectionIDsOfFile, _currentUserID!)
|
|
|
- : _deviceFoldersListOfFile(allDeviceFoldersOfFile),
|
|
|
- hasChipButtons: true,
|
|
|
- ),
|
|
|
+ AlbumsItemWidget(file, _currentUserID),
|
|
|
];
|
|
|
|
|
|
fileDetailsTiles.removeWhere(
|
|
@@ -184,65 +157,6 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Future<List<ChipButtonWidget>> _deviceFoldersListOfFile(
|
|
|
- Future<Set<String>> allDeviceFoldersOfFile,
|
|
|
- ) async {
|
|
|
- try {
|
|
|
- final chipButtons = <ChipButtonWidget>[];
|
|
|
- final List<String> deviceFolders =
|
|
|
- (await allDeviceFoldersOfFile).toList();
|
|
|
- for (var deviceFolder in deviceFolders) {
|
|
|
- chipButtons.add(
|
|
|
- ChipButtonWidget(
|
|
|
- deviceFolder,
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
- return chipButtons;
|
|
|
- } catch (e, s) {
|
|
|
- Logger("FileInfoWidget").info(e, s);
|
|
|
- return [];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Future<List<ChipButtonWidget>> _collectionsListOfFile(
|
|
|
- Future<Set<int>> allCollectionIDsOfFile,
|
|
|
- int currentUserID,
|
|
|
- ) async {
|
|
|
- try {
|
|
|
- final chipButtons = <ChipButtonWidget>[];
|
|
|
- final Set<int> collectionIDs = await allCollectionIDsOfFile;
|
|
|
- final collections = <Collection>[];
|
|
|
- for (var collectionID in collectionIDs) {
|
|
|
- final c = CollectionsService.instance.getCollectionByID(collectionID);
|
|
|
- collections.add(c!);
|
|
|
- chipButtons.add(
|
|
|
- ChipButtonWidget(
|
|
|
- c.isHidden() ? "Hidden" : c.name,
|
|
|
- onTap: () {
|
|
|
- if (c.isHidden()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- routeToPage(
|
|
|
- context,
|
|
|
- CollectionPage(
|
|
|
- CollectionWithThumbnail(c, null),
|
|
|
- appBarType: c.isOwner(currentUserID)
|
|
|
- ? GalleryType.ownedCollection
|
|
|
- : GalleryType.sharedCollection,
|
|
|
- ),
|
|
|
- );
|
|
|
- },
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
- return chipButtons;
|
|
|
- } catch (e, s) {
|
|
|
- Logger("FileInfoWidget").info(e, s);
|
|
|
- return [];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
Widget addedBy(File file) {
|
|
|
if (file.uploadedFileID == null) {
|
|
|
return const SizedBox.shrink();
|