From c902d7ca2027cb089c2ee09e0ea4c731c6ab1370 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sun, 11 Apr 2021 17:57:08 +0800 Subject: [PATCH] Manually refresh photos page --- lib/l10n/app_en.arb | 4 ++++ lib/widget/home_photos.dart | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index a8a4f816..a17fcf78 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -16,6 +16,10 @@ "@zoomTooltip": { "description": "Tooltip of the zoom button" }, + "refreshMenuLabel": "Refresh", + "@refreshMenuLabel": { + "description": "Label of the refresh entry in menu" + }, "settingsMenuLabel": "Settings", "@settingsMenuLabel": { "description": "Label of the settings entry in menu" diff --git a/lib/widget/home_photos.dart b/lib/widget/home_photos.dart index 07de8498..039802b9 100644 --- a/lib/widget/home_photos.dart +++ b/lib/widget/home_photos.dart @@ -16,6 +16,7 @@ import 'package:nc_photos/entity/file_util.dart' as file_util; import 'package:nc_photos/exception_util.dart' as exception_util; import 'package:nc_photos/iterable_extension.dart'; import 'package:nc_photos/k.dart' as k; +import 'package:nc_photos/metadata_task_manager.dart'; import 'package:nc_photos/pref.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; @@ -189,6 +190,19 @@ class _HomePhotosState extends State { ], ), ], + menuActions: [ + PopupMenuItem( + value: _menuValueRefresh, + child: Text(AppLocalizations.of(context).refreshMenuLabel), + ), + ], + onSelectedMenuActions: (option) { + switch (option) { + case _menuValueRefresh: + _onRefreshSelected(); + break; + } + }, ); } @@ -389,6 +403,15 @@ class _HomePhotosState extends State { } } + void _onRefreshSelected() { + _reqQuery(); + if (Pref.inst().isEnableExif()) { + KiwiContainer() + .resolve() + .addTask(MetadataTask(widget.account)); + } + } + /// Transform a File list to grid items void _transformItems(List files) { _backingFiles = files @@ -490,6 +513,7 @@ class _HomePhotosState extends State { final _selectedItems = <_GridFileItem>[]; static final _log = Logger("widget.home_photos._HomePhotosState"); + static const _menuValueRefresh = 0; } abstract class _GridItem {