diff --git a/lib/ui/viewer/file/file_details_widget.dart b/lib/ui/viewer/file/file_details_widget.dart index f3e3baeb8..bce1c981c 100644 --- a/lib/ui/viewer/file/file_details_widget.dart +++ b/lib/ui/viewer/file/file_details_widget.dart @@ -12,7 +12,6 @@ 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/services/object_detection/object_detection_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'; @@ -23,11 +22,11 @@ import 'package:photos/ui/viewer/file/file_caption_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/date_time_util.dart"; import "package:photos/utils/exif_util.dart"; import "package:photos/utils/navigation_util.dart"; -import "package:photos/utils/thumbnail_util.dart"; class FileDetailsWidget extends StatefulWidget { final File file; @@ -115,13 +114,7 @@ class _FileDetailsWidgetState extends State { showExifListTile ? BasicExifItemWidget(_exifData) : null, _isImage ? AllExifItemWidget(file, _exif) : null, FeatureFlagService.instance.isInternalUserOrDebugBuild() - ? InfoItemWidget( - key: const ValueKey("Objects"), - leadingIcon: Icons.image_search_outlined, - title: "Objects", - subtitleSection: _objectTags(file), - hasChipButtons: true, - ) + ? ObjectsItemWidget(file) : null, (file.uploadedFileID != null && file.updationTime != null) ? InfoItemWidget( @@ -207,30 +200,6 @@ class _FileDetailsWidgetState extends State { ); } - Future> _objectTags(File file) async { - try { - final chipButtons = []; - final objectTags = await getThumbnail(file).then((data) { - return ObjectDetectionService.instance.predict(data!); - }); - for (String objectTag in objectTags) { - chipButtons.add(ChipButtonWidget(objectTag)); - } - if (chipButtons.isEmpty) { - return const [ - ChipButtonWidget( - "No results", - noChips: true, - ) - ]; - } - return chipButtons; - } catch (e, s) { - Logger("FileInfoWidget").info(e, s); - return []; - } - } - Future> _deviceFoldersListOfFile( Future> allDeviceFoldersOfFile, ) async { diff --git a/lib/ui/viewer/file_details/objects_item_widget.dart b/lib/ui/viewer/file_details/objects_item_widget.dart new file mode 100644 index 000000000..3c332578c --- /dev/null +++ b/lib/ui/viewer/file_details/objects_item_widget.dart @@ -0,0 +1,47 @@ +import "package:flutter/material.dart"; +import "package:logging/logging.dart"; +import "package:photos/models/file.dart"; +import "package:photos/services/object_detection/object_detection_service.dart"; +import "package:photos/ui/components/buttons/chip_button_widget.dart"; +import "package:photos/ui/components/info_item_widget.dart"; +import "package:photos/utils/thumbnail_util.dart"; + +class ObjectsItemWidget extends StatelessWidget { + final File file; + const ObjectsItemWidget(this.file, {super.key}); + + @override + Widget build(BuildContext context) { + return InfoItemWidget( + key: const ValueKey("Objects"), + leadingIcon: Icons.image_search_outlined, + title: "Objects", + subtitleSection: _objectTags(file), + hasChipButtons: true, + ); + } + + Future> _objectTags(File file) async { + try { + final chipButtons = []; + final objectTags = await getThumbnail(file).then((data) { + return ObjectDetectionService.instance.predict(data!); + }); + for (String objectTag in objectTags) { + chipButtons.add(ChipButtonWidget(objectTag)); + } + if (chipButtons.isEmpty) { + return const [ + ChipButtonWidget( + "No results", + noChips: true, + ) + ]; + } + return chipButtons; + } catch (e, s) { + Logger("ObjctsItemWidget").info(e, s); + return []; + } + } +}