diff --git a/lib/widget/album_browser_mixin.dart b/lib/widget/album_browser_mixin.dart index f4f099cf..865c0c43 100644 --- a/lib/widget/album_browser_mixin.dart +++ b/lib/widget/album_browser_mixin.dart @@ -17,6 +17,7 @@ import 'package:nc_photos/use_case/import_pending_shared_album.dart'; import 'package:nc_photos/use_case/update_album.dart'; import 'package:nc_photos/widget/album_browser_app_bar.dart'; import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util; +import 'package:nc_photos/widget/photo_list_util.dart' as photo_list_util; import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart'; import 'package:nc_photos/widget/selection_app_bar.dart'; import 'package:nc_photos/widget/zoom_menu_button.dart'; @@ -163,19 +164,7 @@ mixin AlbumBrowserMixin } @protected - int get thumbSize { - switch (_thumbZoomLevel) { - case 1: - return 176; - - case 2: - return 256; - - case 0: - default: - return 112; - } - } + int get thumbSize => photo_list_util.getThumbSize(_thumbZoomLevel); void _onMenuOptionSelected(int option, Account account, Album album, void Function(int)? onSelectedMenuItem) { diff --git a/lib/widget/archive_browser.dart b/lib/widget/archive_browser.dart index b13f870f..04bc268a 100644 --- a/lib/widget/archive_browser.dart +++ b/lib/widget/archive_browser.dart @@ -20,6 +20,7 @@ import 'package:nc_photos/theme.dart'; import 'package:nc_photos/use_case/update_property.dart'; import 'package:nc_photos/widget/empty_list_indicator.dart'; import 'package:nc_photos/widget/photo_list_item.dart'; +import 'package:nc_photos/widget/photo_list_util.dart' as photo_list_util; import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart'; import 'package:nc_photos/widget/selection_app_bar.dart'; import 'package:nc_photos/widget/viewer.dart'; @@ -294,25 +295,12 @@ class _ArchiveBrowserState extends State _bloc.add(const ScanAccountDirBlocQuery()); } - int get _thumbSize { - switch (_thumbZoomLevel) { - case 1: - return 176; - - case 2: - return 256; - - case 0: - default: - return 112; - } - } - late final _bloc = ScanAccountDirBloc.of(widget.account); var _backingFiles = []; var _thumbZoomLevel = 0; + int get _thumbSize => photo_list_util.getThumbSize(_thumbZoomLevel); static final _log = Logger("widget.archive_browser._ArchiveBrowserState"); } diff --git a/lib/widget/home_photos.dart b/lib/widget/home_photos.dart index 35e00ed8..3ecc915f 100644 --- a/lib/widget/home_photos.dart +++ b/lib/widget/home_photos.dart @@ -612,23 +612,6 @@ class _HomePhotosState extends State return " ($clippedCount/$_metadataTaskProcessTotalCount)"; } - int get _thumbSize { - switch (_thumbZoomLevel) { - case -1: - return 96; - - case 1: - return 176; - - case 2: - return 256; - - case 0: - default: - return 112; - } - } - Primitive get _hasFiredMetadataTask { final blocId = "${widget.account.scheme}://${widget.account.username}@${widget.account.address}"; @@ -651,6 +634,7 @@ class _HomePhotosState extends State var _backingFiles = []; var _thumbZoomLevel = 0; + int get _thumbSize => photo_list_util.getThumbSize(_thumbZoomLevel); final ScrollController _scrollController = ScrollController(); diff --git a/lib/widget/person_browser.dart b/lib/widget/person_browser.dart index 78e0c08e..bd68b8f7 100644 --- a/lib/widget/person_browser.dart +++ b/lib/widget/person_browser.dart @@ -33,6 +33,7 @@ import 'package:nc_photos/use_case/update_property.dart'; import 'package:nc_photos/widget/handler/add_selection_to_album_handler.dart'; import 'package:nc_photos/widget/handler/remove_selection_handler.dart'; import 'package:nc_photos/widget/photo_list_item.dart'; +import 'package:nc_photos/widget/photo_list_util.dart' as photo_list_util; import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart'; import 'package:nc_photos/widget/selection_app_bar.dart'; import 'package:nc_photos/widget/viewer.dart'; @@ -450,24 +451,11 @@ class _PersonBrowserState extends State _bloc.add(ListFaceBlocQuery(widget.account, widget.person)); } - int get _thumbSize { - switch (_thumbZoomLevel) { - case 1: - return 176; - - case 2: - return 256; - - case 0: - default: - return 112; - } - } - final ListFaceBloc _bloc = ListFaceBloc(); List? _backingFiles; var _thumbZoomLevel = 0; + int get _thumbSize => photo_list_util.getThumbSize(_thumbZoomLevel); late final Throttler _refreshThrottler = Throttler( onTriggered: (_) { diff --git a/lib/widget/photo_list_util.dart b/lib/widget/photo_list_util.dart index a10c232a..7cbacdbe 100644 --- a/lib/widget/photo_list_util.dart +++ b/lib/widget/photo_list_util.dart @@ -18,3 +18,20 @@ class DateGroupHelper { final bool isMonthOnly; DateTime? _currentDate; } + +int getThumbSize(int zoomLevel) { + switch (zoomLevel) { + case -1: + return 96; + + case 1: + return 176; + + case 2: + return 256; + + case 0: + default: + return 112; + } +} diff --git a/lib/widget/trashbin_browser.dart b/lib/widget/trashbin_browser.dart index 58443eaa..020c5a9d 100644 --- a/lib/widget/trashbin_browser.dart +++ b/lib/widget/trashbin_browser.dart @@ -21,6 +21,7 @@ import 'package:nc_photos/use_case/restore_trashbin.dart'; import 'package:nc_photos/widget/empty_list_indicator.dart'; import 'package:nc_photos/widget/handler/remove_selection_handler.dart'; import 'package:nc_photos/widget/photo_list_item.dart'; +import 'package:nc_photos/widget/photo_list_util.dart' as photo_list_util; import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart'; import 'package:nc_photos/widget/selection_app_bar.dart'; import 'package:nc_photos/widget/trashbin_viewer.dart'; @@ -404,25 +405,12 @@ class _TrashbinBrowserState extends State _bloc.add(LsTrashbinBlocQuery(widget.account)); } - int get _thumbSize { - switch (_thumbZoomLevel) { - case 1: - return 176; - - case 2: - return 256; - - case 0: - default: - return 112; - } - } - late LsTrashbinBloc _bloc; var _backingFiles = []; var _thumbZoomLevel = 0; + int get _thumbSize => photo_list_util.getThumbSize(_thumbZoomLevel); static final _log = Logger("widget.trashbin_browser._TrashbinBrowserState"); }