From 78c02fd2804a921d3fb43db419af1404df106a2f Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sun, 27 Oct 2024 01:56:09 +0800 Subject: [PATCH] Warn user when they try to remove a fixed button --- app/lib/l10n/app_en.arb | 4 ++ app/lib/l10n/untranslated-messages.txt | 41 +++++++++++++------ .../settings/collections_nav_bar/buttons.dart | 29 ++++++++++--- .../collections_nav_bar_settings.dart | 1 + .../settings/viewer_app_bar/demo_buttons.dart | 29 +++++++++++++ .../widget/settings/viewer_app_bar/view.dart | 8 +--- .../settings/viewer_app_bar_settings.dart | 1 + 7 files changed, 87 insertions(+), 26 deletions(-) diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index f02db856..bfd3e57d 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -1517,6 +1517,10 @@ "@customizeCollectionsNavBarDescription": { "description": "Instruction to customize navigation bar buttons in the Collections page" }, + "customizeButtonsUnsupportedWarning": "This button cannot be customized", + "@customizeButtonsUnsupportedWarning": { + "description": "Some button can't be removed. This message will be shown instead when user try to do so" + }, "errorUnauthenticated": "Unauthenticated access. Please sign-in again if the problem continues", "@errorUnauthenticated": { diff --git a/app/lib/l10n/untranslated-messages.txt b/app/lib/l10n/untranslated-messages.txt index e0acea0d..04bc7157 100644 --- a/app/lib/l10n/untranslated-messages.txt +++ b/app/lib/l10n/untranslated-messages.txt @@ -267,6 +267,7 @@ "livePhotoTooltip", "dragAndDropRearrangeButtons", "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning", "errorUnauthenticated", "errorDisconnected", "errorLocked", @@ -284,7 +285,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "de": [ @@ -294,7 +296,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "el": [ @@ -449,7 +452,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "es": [ @@ -459,7 +463,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "fi": [ @@ -505,7 +510,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "fr": [ @@ -551,7 +557,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "it": [ @@ -602,7 +609,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "nl": [ @@ -990,6 +998,7 @@ "livePhotoTooltip", "dragAndDropRearrangeButtons", "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning", "errorUnauthenticated", "errorDisconnected", "errorLocked", @@ -1047,7 +1056,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "pt": [ @@ -1113,7 +1123,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "ru": [ @@ -1159,7 +1170,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "tr": [ @@ -1169,7 +1181,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "zh": [ @@ -1246,7 +1259,8 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ], "zh_Hant": [ @@ -1417,6 +1431,7 @@ "alternativeSignIn", "livePhotoTooltip", "dragAndDropRearrangeButtons", - "customizeCollectionsNavBarDescription" + "customizeCollectionsNavBarDescription", + "customizeButtonsUnsupportedWarning" ] } diff --git a/app/lib/widget/settings/collections_nav_bar/buttons.dart b/app/lib/widget/settings/collections_nav_bar/buttons.dart index ca01c239..fa73b040 100644 --- a/app/lib/widget/settings/collections_nav_bar/buttons.dart +++ b/app/lib/widget/settings/collections_nav_bar/buttons.dart @@ -5,12 +5,29 @@ class _NewButton extends StatelessWidget { @override Widget build(BuildContext context) { - return HomeCollectionsNavBarButton( - icon: const Icon(Icons.add_outlined), - label: L10n.global().createCollectionTooltip, - isMinimized: true, - isUseTooltipWhenMinimized: false, - onPressed: () {}, + return GestureDetector( + onTap: () { + SnackBarManager().showSnackBar(SnackBar( + content: Text(L10n.global().customizeButtonsUnsupportedWarning), + duration: k.snackBarDurationNormal, + )); + }, + onLongPress: () { + SnackBarManager().showSnackBar(SnackBar( + content: Text(L10n.global().customizeButtonsUnsupportedWarning), + duration: k.snackBarDurationNormal, + )); + }, + child: AbsorbPointer( + absorbing: true, + child: HomeCollectionsNavBarButton( + icon: const Icon(Icons.add_outlined), + label: L10n.global().createCollectionTooltip, + isMinimized: true, + isUseTooltipWhenMinimized: false, + onPressed: () {}, + ), + ), ); } } diff --git a/app/lib/widget/settings/collections_nav_bar_settings.dart b/app/lib/widget/settings/collections_nav_bar_settings.dart index 75094383..5f64820c 100644 --- a/app/lib/widget/settings/collections_nav_bar_settings.dart +++ b/app/lib/widget/settings/collections_nav_bar_settings.dart @@ -9,6 +9,7 @@ import 'package:nc_photos/app_localizations.dart'; import 'package:nc_photos/bloc_util.dart'; import 'package:nc_photos/controller/pref_controller.dart'; import 'package:nc_photos/exception_event.dart'; +import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/widget/draggable.dart' as my; import 'package:nc_photos/widget/home_collections.dart'; diff --git a/app/lib/widget/settings/viewer_app_bar/demo_buttons.dart b/app/lib/widget/settings/viewer_app_bar/demo_buttons.dart index d01c8cd3..859e7ca9 100644 --- a/app/lib/widget/settings/viewer_app_bar/demo_buttons.dart +++ b/app/lib/widget/settings/viewer_app_bar/demo_buttons.dart @@ -15,6 +15,35 @@ class _DemoButton extends StatelessWidget { final Widget icon; } +class _DemoMoreButton extends StatelessWidget { + const _DemoMoreButton(); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + SnackBarManager().showSnackBar(SnackBar( + content: Text(L10n.global().customizeButtonsUnsupportedWarning), + duration: k.snackBarDurationNormal, + )); + }, + onLongPress: () { + SnackBarManager().showSnackBar(SnackBar( + content: Text(L10n.global().customizeButtonsUnsupportedWarning), + duration: k.snackBarDurationNormal, + )); + }, + child: AbsorbPointer( + absorbing: true, + child: IconButton( + onPressed: () {}, + icon: Icon(Icons.adaptive.more), + ), + ), + ); + } +} + class _DemoLivePhotoButton extends StatelessWidget { const _DemoLivePhotoButton(); diff --git a/app/lib/widget/settings/viewer_app_bar/view.dart b/app/lib/widget/settings/viewer_app_bar/view.dart index 4a704b54..838ece4d 100644 --- a/app/lib/widget/settings/viewer_app_bar/view.dart +++ b/app/lib/widget/settings/viewer_app_bar/view.dart @@ -41,13 +41,7 @@ class _DemoView extends StatelessWidget { child: _DemoButtonDelegate(e), ), )), - IgnorePointer( - ignoring: true, - child: IconButton( - onPressed: () {}, - icon: Icon(Icons.adaptive.more), - ), - ), + const _DemoMoreButton(), ], ); if (buttons.isEmpty) { diff --git a/app/lib/widget/settings/viewer_app_bar_settings.dart b/app/lib/widget/settings/viewer_app_bar_settings.dart index fb386721..311961d2 100644 --- a/app/lib/widget/settings/viewer_app_bar_settings.dart +++ b/app/lib/widget/settings/viewer_app_bar_settings.dart @@ -10,6 +10,7 @@ import 'package:nc_photos/app_localizations.dart'; import 'package:nc_photos/bloc_util.dart'; import 'package:nc_photos/controller/pref_controller.dart'; import 'package:nc_photos/exception_event.dart'; +import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; import 'package:nc_photos/widget/draggable.dart' as my;