Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][packages] Add popup menu component

Aman Rajd9f15040cdd5
diff --git a/mobile/apps/photos/assets/icons/guest_view_icon.svg b/mobile/apps/photos/assets/icons/guest_view_icon.svg
deleted file mode 100644
index e03b029b28..0000000000
--- a/mobile/apps/photos/assets/icons/guest_view_icon.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-<svg width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
-<g clip-path="url(#clip0_30549_98929)">
-<path d="M14.9945 11.4609C13.2275 11.4609 11.7455 12.7208 11.3655 14.3975C10.463 14.0091 9.6365 14.1133 9.0095 14.388C8.62 12.7019 7.138 11.4609 5.3805 11.4609C3.319 11.4609 1.6375 13.1565 1.6375 15.25C1.6375 17.3435 3.319 19.0391 5.3805 19.0391C7.3375 19.0391 8.9335 17.5045 9.0855 15.5531C9.4085 15.3258 10.254 14.8995 11.2895 15.5721C11.4605 17.514 13.0375 19.0391 14.9945 19.0391C17.056 19.0391 18.7375 17.3435 18.7375 15.25C18.7375 13.1565 17.056 11.4609 14.9945 11.4609ZM5.3805 17.9592C3.8985 17.9592 2.711 16.7467 2.711 15.25C2.711 13.7533 3.908 12.5408 5.3805 12.5408C6.8625 12.5408 8.05 13.7533 8.05 15.25C8.05 16.7467 6.8625 17.9592 5.3805 17.9592ZM14.9945 17.9592C13.5125 17.9592 12.325 16.7467 12.325 15.25C12.325 13.7533 13.5125 12.5408 14.9945 12.5408C16.4765 12.5408 17.6735 13.7533 17.6735 15.25C17.6735 16.7467 16.467 17.9592 14.9945 17.9592ZM19.6875 9.80323C19.6875 9.41086 19.3694 9.09278 18.9771 9.09278H1.39795C1.00558 9.09278 0.6875 9.41086 0.6875 9.80323V9.80323C0.6875 10.1956 1.00558 10.5137 1.39795 10.5137H18.9771C19.3694 10.5137 19.6875 10.1956 19.6875 9.80323V9.80323ZM13.541 1.6378C13.332 1.17364 12.8 0.927351 12.2965 1.08839L10.1875 1.78936L8.069 1.08839L8.0215 1.07891C7.518 0.936824 6.986 1.20206 6.796 1.68516L4.4875 7.67188H15.8875L13.5695 1.68516L13.541 1.6378Z" fill="black" stroke="black" stroke-width="0.331543"/>
-</g>
-<defs>
-<clipPath id="clip0_30549_98929">
-<rect width="20" height="20" fill="white" transform="translate(0.1875 0.0390625)"/>
-</clipPath>
-</defs>
-</svg>
diff --git a/mobile/apps/photos/changes/popup-menu-component.md b/mobile/apps/photos/changes/popup-menu-component.md
new file mode 100644
index 0000000000..26e507ec08
--- /dev/null
+++ b/mobile/apps/photos/changes/popup-menu-component.md
@@ -0,0 +1 @@
+- Add a popup menu component
diff --git a/mobile/apps/photos/lib/ui/collections/collection_list_page.dart b/mobile/apps/photos/lib/ui/collections/collection_list_page.dart
index c91a293d60..39ab6896a0 100644
--- a/mobile/apps/photos/lib/ui/collections/collection_list_page.dart
+++ b/mobile/apps/photos/lib/ui/collections/collection_list_page.dart
@@ -1,6 +1,7 @@
import "dart:async";
import "package:collection/collection.dart";
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import "package:hugeicons/hugeicons.dart";
import "package:photos/core/constants.dart";
@@ -16,7 +17,6 @@ import "package:photos/services/collections_service.dart";
import "package:photos/settings/local_settings.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/collections/flex_grid_view.dart";
-import "package:photos/ui/components/popup_menu/ente_popup_menu_button.dart";
import "package:photos/ui/components/searchable_appbar.dart";
import "package:photos/ui/viewer/actions/album_selection_overlay_bar.dart";
diff --git a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
index 3dcabf83a4..95ec42f6c4 100644
--- a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
+++ b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
@@ -29,7 +29,6 @@ import "package:photos/ui/collections/device/device_folders_vertical_grid_view.d
import "package:photos/ui/collections/flex_grid_view.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/components/empty_state_component.dart";
-import "package:photos/ui/components/popup_menu/ente_popup_menu_button.dart";
import "package:photos/ui/tabs/albums/albums_manage_sheet.dart";
import "package:photos/ui/tabs/albums/empty_states/on_ente_empty_state.dart";
import "package:photos/ui/tabs/albums/empty_states/shared_empty_state.dart";
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
index be5f299529..6ccb9d1383 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
@@ -1,12 +1,10 @@
import "dart:async";
import 'dart:io';
-import "dart:math" as math;
-import "package:ente_icons/ente_icons.dart";
-import 'package:flutter/cupertino.dart';
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import "package:flutter/services.dart";
-import "package:flutter_svg/flutter_svg.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:local_auth/local_auth.dart";
import 'package:logging/logging.dart';
import 'package:media_extension/media_extension.dart';
@@ -29,11 +27,9 @@ import "package:photos/services/local_authentication_service.dart";
import "package:photos/services/video_preview_service.dart";
import "package:photos/states/detail_page_state.dart";
import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
import "package:photos/ui/actions/file/file_actions.dart";
import 'package:photos/ui/collections/collection_action_sheet.dart';
-import "package:photos/ui/common/popup_item.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/ui/viewer/actions/suggest_delete_sheet.dart';
import "package:photos/ui/viewer/file/detail_page.dart";
@@ -78,8 +74,6 @@ class FileAppBarState extends State<FileAppBar> {
bool isGuestView = false;
bool shouldLoopVideo = localSettings.shouldLoopVideo();
bool _reloadActions = false;
- bool _isMenuOpen = false;
- bool _pendingActionsReload = false;
ValueNotifier<bool>? _isInSharedCollectionNotifier;
ValueNotifier<String?>? _showingThumbnailFallbackNotifier;
@@ -231,28 +225,9 @@ class FileAppBarState extends State<FileAppBar> {
}
void _requestActionsReload() {
- if (_isMenuOpen) {
- _pendingActionsReload = true;
- return;
- }
if (mounted) {
setState(() {
_reloadActions = true;
- _pendingActionsReload = false;
- });
- }
- }
-
- void _handleMenuOpened() {
- _isMenuOpen = true;
- }
-
- void _handleMenuClosed() {
- _isMenuOpen = false;
- if (_pendingActionsReload && mounted) {
- setState(() {
- _reloadActions = true;
- _pendingActionsReload = false;
});
}
}
@@ -334,43 +309,33 @@ class FileAppBarState extends State<FileAppBar> {
);
}
- final List<PopupMenuItem> items = [];
+ final List<EntePopupMenuOption<int>> items = [];
final bool restrictFileActions =
widget.mode == DetailPageMode.minimalistic || widget.file is TrashFile;
if (restrictFileActions) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).info,
value: 12,
- icon: Platform.isAndroid ? Icons.info_outline : CupertinoIcons.info,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedInformationCircle,
),
);
} else {
if (isFileUploaded) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).download,
value: 1,
- icon: Platform.isAndroid
- ? Icons.download
- : Icons.cloud_download_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedDownload01,
),
);
if (isOwnedByUser && !isFileHidden) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).sendLink,
value: 14,
- iconWidget: Transform.rotate(
- angle: math.pi / 2,
- child: Icon(
- Icons.navigation_rounded,
- color: Theme.of(context).iconTheme.color,
- ),
- ),
+ hugeIcon: HugeIcons.strokeRoundedNavigation03,
),
);
}
@@ -381,11 +346,10 @@ class FileAppBarState extends State<FileAppBar> {
widget.file.fileType == FileType.livePhoto ||
widget.file.fileType == FileType.video)) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).edit,
value: 11,
- icon: Icons.tune_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedSlidersHorizontal,
),
);
}
@@ -393,11 +357,10 @@ class FileAppBarState extends State<FileAppBar> {
// (moved from bottom bar to make room for social icons)
if (isInSharedCollection && isFileUploaded && !isFileHidden) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).addToAlbum,
value: 10,
- icon: EnteIcons.addToAlbum,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedImageAdd01,
),
);
}
@@ -406,13 +369,14 @@ class FileAppBarState extends State<FileAppBar> {
final bool isArchived =
widget.file.magicMetadata.visibility == archiveVisibility;
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
isArchived
? AppLocalizations.of(context).unarchive
: AppLocalizations.of(context).archive,
value: 2,
- icon: isArchived ? Icons.unarchive : Icons.archive_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: isArchived
+ ? HugeIcons.strokeRoundedUnarchive03
+ : HugeIcons.strokeRoundedArchive03,
),
);
}
@@ -421,67 +385,56 @@ class FileAppBarState extends State<FileAppBar> {
widget.file.fileType == FileType.livePhoto) &&
Platform.isAndroid) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).setAs,
value: 3,
- icon: Icons.wallpaper_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedImage01,
),
);
}
if (isOwnedByUser && widget.file.isUploaded) {
if (!isFileHidden) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).hide,
value: 4,
- icon: Icons.visibility_off,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedViewOffSlash,
),
);
} else {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).unhide,
value: 5,
- icon: Icons.visibility,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedView,
),
);
}
}
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).guestView,
value: 6,
- iconWidget: SvgPicture.asset(
- "assets/icons/guest_view_icon.svg",
- colorFilter: ColorFilter.mode(
- getEnteColorScheme(context).textBase,
- BlendMode.srcIn,
- ),
- ),
+ hugeIcon: HugeIcons.strokeRoundedIncognito,
),
);
if (canSuggestDeleteAction) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).suggestDeletion,
value: 13,
- icon: Icons.flag_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedFlag01,
),
);
}
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).info,
value: 12,
- icon: Platform.isAndroid ? Icons.info_outline : CupertinoIcons.info,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedInformationCircle,
),
);
}
@@ -490,118 +443,59 @@ class FileAppBarState extends State<FileAppBar> {
// Video streaming options
if (_shouldShowCreateStreamOption()) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).createStream,
value: 8,
- icon: Icons.video_settings_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedVideoReplay,
),
);
}
if (_shouldShowRecreateStreamOption()) {
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
AppLocalizations.of(context).recreateStream,
value: 9,
- icon: Icons.refresh_outlined,
- iconColor: Theme.of(context).iconTheme.color,
+ hugeIcon: HugeIcons.strokeRoundedRefresh,
),
);
}
items.add(
- EntePopupMenuItem(
+ _fileMenuOption(
shouldLoopVideo
? AppLocalizations.of(context).loopVideoOn
: AppLocalizations.of(context).loopVideoOff,
value: 7,
- iconWidget: Stack(
- alignment: Alignment.center,
- children: [
- Icon(
- Icons.loop_rounded,
- color: Theme.of(context).iconTheme.color,
- ),
- shouldLoopVideo
- ? Transform.rotate(
- angle: 3.14 / 4,
- child: Container(
- width: 2,
- height: 24,
- decoration: BoxDecoration(
- color: Theme.of(context).iconTheme.color,
- borderRadius: BorderRadius.circular(1),
- ),
- ),
- )
- : const SizedBox.shrink(),
- ],
- ),
+ hugeIcon: shouldLoopVideo
+ ? HugeIcons.strokeRoundedRepeatOff
+ : HugeIcons.strokeRoundedRepeat,
),
);
}
if (items.isNotEmpty) {
_actions.add(
- PopupMenuButton(
- tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
- onOpened: _handleMenuOpened,
- itemBuilder: (context) {
- return items;
- },
- onCanceled: _handleMenuClosed,
- onSelected: (dynamic value) async {
- _handleMenuClosed();
- if (value == 1) {
- await _download(widget.file);
- } else if (value == 14) {
- await _sendLink(widget.file);
- } else if (value == 2) {
- await _toggleFileArchiveStatus(widget.file);
- } else if (value == 3) {
- await _setAs(widget.file);
- } else if (value == 4) {
- await _handleHideRequest(context);
- } else if (value == 5) {
- await _handleUnHideRequest(context);
- } else if (value == 6) {
- await _onTapGuestView();
- } else if (value == 99) {
- try {
- await VideoPreviewService.instance.chunkAndUploadVideo(
- context,
- widget.file,
- );
- } catch (e) {
- if (mounted) {
- await showGenericErrorDialog(context: context, error: e);
- }
- }
- } else if (value == 7) {
- _onToggleLoopVideo();
- } else if (value == 8) {
- await _handleVideoStream('create');
- } else if (value == 9) {
- await _handleVideoStream('recreate');
- } else if (value == 11) {
- widget.onEditRequested(widget.file);
- } else if (value == 12) {
- await showDetailsSheet(context, widget.file);
- } else if (value == 13) {
- if (collection != null) {
- await _handleSuggestDelete(collection);
- }
- } else if (value == 10) {
- final selectedFiles = SelectedFiles();
- selectedFiles.files.add(widget.file);
- showCollectionActionSheet(
- context,
- selectedFiles: selectedFiles,
- actionType: CollectionActionType.addFiles,
- );
+ EntePopupMenuButton<int>(
+ optionsBuilder: () => items,
+ onSelected: (selected) async {
+ if (!mounted) {
+ return;
}
+ await _handleFileMenuSelection(selected, collection);
},
+ child: Tooltip(
+ message: MaterialLocalizations.of(context).moreButtonTooltip,
+ child: const SizedBox.square(
+ dimension: kMinInteractiveDimension,
+ child: Center(
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedMoreVertical,
+ color: Colors.white,
+ ),
+ ),
+ ),
+ ),
),
);
}
@@ -609,6 +503,76 @@ class FileAppBarState extends State<FileAppBar> {
return _actions;
}
+ EntePopupMenuOption<int> _fileMenuOption(
+ String label, {
+ required int value,
+ required List<List<dynamic>> hugeIcon,
+ }) {
+ return EntePopupMenuOption<int>(
+ value: value,
+ label: label,
+ leadingWidget: HugeIcon(
+ icon: hugeIcon,
+ size: IconSizes.small,
+ color: context.componentColors.textLight,
+ ),
+ );
+ }
+
+ Future<void> _handleFileMenuSelection(
+ int value,
+ Collection? collection,
+ ) async {
+ if (value == 1) {
+ await _download(widget.file);
+ } else if (value == 14) {
+ await _sendLink(widget.file);
+ } else if (value == 2) {
+ await _toggleFileArchiveStatus(widget.file);
+ } else if (value == 3) {
+ await _setAs(widget.file);
+ } else if (value == 4) {
+ await _handleHideRequest(context);
+ } else if (value == 5) {
+ await _handleUnHideRequest(context);
+ } else if (value == 6) {
+ await _onTapGuestView();
+ } else if (value == 99) {
+ try {
+ await VideoPreviewService.instance.chunkAndUploadVideo(
+ context,
+ widget.file,
+ );
+ } catch (e) {
+ if (mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+ } else if (value == 7) {
+ _onToggleLoopVideo();
+ } else if (value == 8) {
+ await _handleVideoStream('create');
+ } else if (value == 9) {
+ await _handleVideoStream('recreate');
+ } else if (value == 11) {
+ widget.onEditRequested(widget.file);
+ } else if (value == 12) {
+ await showDetailsSheet(context, widget.file);
+ } else if (value == 13) {
+ if (collection != null) {
+ await _handleSuggestDelete(collection);
+ }
+ } else if (value == 10) {
+ final selectedFiles = SelectedFiles();
+ selectedFiles.files.add(widget.file);
+ showCollectionActionSheet(
+ context,
+ selectedFiles: selectedFiles,
+ actionType: CollectionActionType.addFiles,
+ );
+ }
+ }
+
Future<void> _handleSuggestDelete(Collection collection) async {
if (widget.file.uploadedFileID == null) {
return;
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart
index b8f91a46fa..6bd207a353 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart
@@ -3,7 +3,6 @@ import "dart:async";
import "package:ente_components/ente_components.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
-import "package:photos/ui/components/popup_menu/ente_popup_menu_button.dart";
/// Shared trailing-action surface for the gallery / people / cluster app bars.
class GalleryAppBarIconButtonSurface extends StatelessWidget {
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 94d4d2926f..c83f2f095e 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -42,7 +42,6 @@ import "package:photos/ui/common/web_page.dart";
import 'package:photos/ui/components/action_sheet_widget.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
-import "package:photos/ui/components/popup_menu/ente_popup_menu_button.dart";
import "package:photos/ui/map/map_screen.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/ui/sharing/album_participants_page.dart';
diff --git a/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart
index df35ece19c..e447cd1b6e 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart
@@ -23,7 +23,6 @@ import "package:photos/services/machine_learning/ml_result.dart";
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
-import "package:photos/ui/components/popup_menu/ente_popup_menu_button.dart";
import "package:photos/ui/viewer/gallery/gallery_app_bar_actions.dart";
import "package:photos/ui/viewer/gallery/gallery_app_bar_config.dart";
import "package:photos/ui/viewer/people/cluster_breakup_page.dart";
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
index b3a7ffc356..a9e2527336 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
@@ -19,7 +19,6 @@ import "package:photos/services/machine_learning/face_ml/person/person_service.d
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import "package:photos/ui/components/buttons/button_widget.dart";
-import "package:photos/ui/components/popup_menu/ente_popup_menu_button.dart";
import "package:photos/ui/notification/toast.dart";
import "package:photos/ui/viewer/gallery/gallery_app_bar_actions.dart";
import "package:photos/ui/viewer/gallery/gallery_app_bar_config.dart";
diff --git a/mobile/packages/ente_components/example/lib/main.dart b/mobile/packages/ente_components/example/lib/main.dart
index 7a13538a8f..6b835c2b93 100644
--- a/mobile/packages/ente_components/example/lib/main.dart
+++ b/mobile/packages/ente_components/example/lib/main.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:ente_components/ente_components.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@@ -203,6 +205,20 @@ class _CatalogHomeState extends State<CatalogHome> {
],
previewBuilder: (_) => const _MenuItemPreview(),
),
+ CatalogSection(
+ title: 'Popup menu',
+ icon: HugeIcons.strokeRoundedMoreVertical,
+ components: const [
+ 'Sort menu',
+ 'Leading icons',
+ 'Trailing icons',
+ 'Label icon',
+ 'Full combo',
+ 'Active state',
+ 'All cases',
+ ],
+ previewBuilder: (_) => const _PopupMenuPreview(),
+ ),
CatalogSection(
title: 'Buttons',
icon: HugeIcons.strokeRoundedCursorPointer02,
@@ -2598,6 +2614,363 @@ class _SelectionPreviewState extends State<_SelectionPreview> {
}
}
+class _PopupMenuPreview extends StatefulWidget {
+ const _PopupMenuPreview();
+
+ @override
+ State<_PopupMenuPreview> createState() => _PopupMenuPreviewState();
+}
+
+class _PopupMenuPreviewState extends State<_PopupMenuPreview> {
+ String _lastSelection = 'None';
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+
+ return _CatalogPreviewList(
+ children: [
+ _CatalogPreviewGroup(
+ title: 'Interactive menu triggers',
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Wrap(
+ spacing: Spacing.md,
+ runSpacing: Spacing.md,
+ children: [
+ _PopupMenuTrigger(
+ optionsBuilder: _sortOptions,
+ onSelected: _handleSelected,
+ ),
+ _PopupMenuTrigger(
+ optionsBuilder: _fileOptions,
+ onSelected: _handleSelected,
+ ),
+ _PopupMenuTrigger(
+ optionsBuilder: _viewOptions,
+ onSelected: _handleSelected,
+ ),
+ _PopupMenuTrigger(
+ optionsBuilder: _fullOptions,
+ onSelected: _handleSelected,
+ ),
+ _PopupMenuTrigger(
+ optionsBuilder: _activeOptions,
+ onSelected: _handleSelected,
+ ),
+ _PopupMenuTrigger(
+ optionsBuilder: _allCasesOptions,
+ onSelected: _handleSelected,
+ ),
+ ],
+ ),
+ const SizedBox(height: Spacing.md),
+ Text(
+ 'Last selected: $_lastSelection',
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+
+ Future<void> _handleSelected(String value) async {
+ setState(() => _lastSelection = value);
+ }
+
+ List<EntePopupMenuOption<String>> _sortOptions(BuildContext context) {
+ final colors = context.componentColors;
+ return [
+ EntePopupMenuOption(
+ value: 'sort-name',
+ label: 'Name',
+ secondaryLabel: 'A-Z',
+ secondaryTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedArrowUp02,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ ),
+ const EntePopupMenuOption(value: 'sort-created', label: 'Created'),
+ const EntePopupMenuOption(value: 'sort-newest', label: 'Newest'),
+ const EntePopupMenuOption(
+ value: 'sort-updated',
+ label: 'Updated',
+ showDivider: false,
+ ),
+ ];
+ }
+
+ List<EntePopupMenuOption<String>> _fileOptions(BuildContext context) {
+ final colors = context.componentColors;
+ return [
+ const EntePopupMenuOption(
+ value: 'download',
+ label: 'Download',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedDownload01,
+ size: IconSizes.small,
+ ),
+ ),
+ const EntePopupMenuOption(
+ value: 'share',
+ label: 'Share',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedShare08,
+ size: IconSizes.small,
+ ),
+ ),
+ const EntePopupMenuOption(
+ value: 'copy-link',
+ label: 'Copy link',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedCopy01,
+ size: IconSizes.small,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'delete',
+ label: 'Delete',
+ labelColor: colors.warning,
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedDelete02,
+ color: colors.warning,
+ size: IconSizes.small,
+ ),
+ showDivider: false,
+ ),
+ ];
+ }
+
+ List<EntePopupMenuOption<String>> _viewOptions(BuildContext context) {
+ final colors = context.componentColors;
+ return [
+ EntePopupMenuOption(
+ value: 'grid',
+ label: 'Grid',
+ trailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedGridView,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'list',
+ label: 'List',
+ trailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedMenu01,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'upload',
+ label: 'Upload',
+ trailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedImageUpload,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ showDivider: false,
+ ),
+ ];
+ }
+
+ List<EntePopupMenuOption<String>> _fullOptions(BuildContext context) {
+ final colors = context.componentColors;
+ return [
+ EntePopupMenuOption(
+ value: 'created-ascending',
+ label: 'Created',
+ secondaryLabel: 'A-Z',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedAdd01,
+ color: colors.textLight,
+ size: IconSizes.small,
+ ),
+ secondaryTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedArrowUp02,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ trailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedAdd01,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'updated-descending',
+ label: 'Updated',
+ secondaryLabel: 'Z-A',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedRefresh,
+ color: colors.textLight,
+ size: IconSizes.small,
+ ),
+ secondaryTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedArrowUp02,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ activeTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedCheckmarkCircle02,
+ color: colors.primary,
+ size: IconSizes.tiny,
+ ),
+ isActive: true,
+ ),
+ EntePopupMenuOption(
+ value: 'storage-info',
+ label: 'Storage',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedDatabase,
+ color: colors.textLight,
+ size: IconSizes.small,
+ ),
+ trailingWidget: Text(
+ '2 TB',
+ style: TextStyles.mini.copyWith(color: colors.textLight),
+ ),
+ showDivider: false,
+ ),
+ ];
+ }
+
+ List<EntePopupMenuOption<String>> _activeOptions(BuildContext context) {
+ final colors = context.componentColors;
+ final activeSortIcon = _CatalogHugeIcon(
+ HugeIcons.strokeRoundedArrowUp02,
+ color: colors.primary,
+ size: IconSizes.tiny,
+ );
+
+ return [
+ EntePopupMenuOption(
+ value: 'active-name',
+ label: 'Name',
+ secondaryLabel: 'A-Z',
+ activeTrailingWidget: activeSortIcon,
+ isActive: true,
+ ),
+ EntePopupMenuOption(
+ value: 'inactive-created',
+ label: 'Created',
+ activeTrailingWidget: activeSortIcon,
+ ),
+ EntePopupMenuOption(
+ value: 'inactive-updated',
+ label: 'Updated',
+ activeTrailingWidget: activeSortIcon,
+ ),
+ EntePopupMenuOption(
+ value: 'inactive-size',
+ label: 'Size',
+ activeTrailingWidget: activeSortIcon,
+ showDivider: false,
+ ),
+ ];
+ }
+
+ List<EntePopupMenuOption<String>> _allCasesOptions(BuildContext context) {
+ final colors = context.componentColors;
+ return [
+ const EntePopupMenuOption(value: 'plain', label: 'Plain label'),
+ const EntePopupMenuOption(
+ value: 'secondary-label',
+ label: 'Name',
+ secondaryLabel: 'A-Z',
+ ),
+ EntePopupMenuOption(
+ value: 'label-icon',
+ label: 'Name',
+ secondaryLabel: 'A-Z',
+ secondaryTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedArrowUp02,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ ),
+ const EntePopupMenuOption(
+ value: 'leading',
+ label: 'Download',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedDownload01,
+ size: IconSizes.small,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'trailing',
+ label: 'Grid',
+ trailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedGridView,
+ color: colors.textLight,
+ size: IconSizes.tiny,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'active',
+ label: 'Updated',
+ secondaryLabel: 'Selected',
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedRefresh,
+ color: colors.textLight,
+ size: IconSizes.small,
+ ),
+ activeTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedCheckmarkCircle02,
+ color: colors.primary,
+ size: IconSizes.tiny,
+ ),
+ isActive: true,
+ ),
+ EntePopupMenuOption(
+ value: 'inactive-reserved',
+ label: 'Created',
+ secondaryLabel: 'Not selected',
+ activeTrailingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedCheckmarkCircle02,
+ color: colors.primary,
+ size: IconSizes.tiny,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: 'destructive',
+ label: 'Delete',
+ labelColor: colors.warning,
+ leadingWidget: _CatalogHugeIcon(
+ HugeIcons.strokeRoundedDelete02,
+ color: colors.warning,
+ size: IconSizes.small,
+ ),
+ showDivider: false,
+ ),
+ ];
+ }
+}
+
+class _PopupMenuTrigger extends StatelessWidget {
+ const _PopupMenuTrigger({
+ required this.optionsBuilder,
+ required this.onSelected,
+ });
+
+ final List<EntePopupMenuOption<String>> Function(BuildContext context)
+ optionsBuilder;
+ final FutureOr<void> Function(String value) onSelected;
+
+ @override
+ Widget build(BuildContext context) {
+ return EntePopupMenuButton<String>(
+ optionsBuilder: () => optionsBuilder(context),
+ onSelected: onSelected,
+ );
+ }
+}
+
enum _MenuItemTrailingKind { icon, toggle, none }
class _MenuItemPreview extends StatefulWidget {
diff --git a/mobile/packages/ente_components/example/test/smoke_test.dart b/mobile/packages/ente_components/example/test/smoke_test.dart
index 8df8a5a0b7..ca8d584a0a 100644
--- a/mobile/packages/ente_components/example/test/smoke_test.dart
+++ b/mobile/packages/ente_components/example/test/smoke_test.dart
@@ -50,7 +50,7 @@ void main() {
expect(find.byKey(const ValueKey('success')), findsOneWidget);
await tester.pump(const Duration(seconds: 2));
- await tester.pump();
+ await tester.pumpAndSettle();
expect(find.text('Continue'), findsOneWidget);
});
diff --git a/mobile/apps/photos/lib/ui/components/popup_menu/ente_popup_menu_button.dart b/mobile/packages/ente_components/lib/components/popup_menu_component.dart
similarity index 62%
rename from mobile/apps/photos/lib/ui/components/popup_menu/ente_popup_menu_button.dart
rename to mobile/packages/ente_components/lib/components/popup_menu_component.dart
index ae42b4ca63..97d3a07b17 100644
--- a/mobile/apps/photos/lib/ui/components/popup_menu/ente_popup_menu_button.dart
+++ b/mobile/packages/ente_components/lib/components/popup_menu_component.dart
@@ -1,15 +1,24 @@
-import "dart:async";
+import 'dart:async';
-import "package:ente_components/ente_components.dart";
-import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
-import "package:photos/theme/ente_theme.dart";
+import 'package:ente_components/components/buttons/icon_button_component.dart';
+import 'package:ente_components/theme/icon_sizes.dart';
+import 'package:ente_components/theme/radii.dart';
+import 'package:ente_components/theme/spacing.dart';
+import 'package:ente_components/theme/text_styles.dart';
+import 'package:ente_components/theme/theme.dart';
+import 'package:flutter/material.dart';
+import 'package:hugeicons/hugeicons.dart';
+/// Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/Ente-Visual-Design?node-id=2513-52763&m=dev
+/// Section: Dropdown menu
+/// Specs: 196px menu, 52px rows, 20px radius, optional leading/trailing icons,
+/// optional secondary label, faint dividers, and Inter mini typography.
class EntePopupMenuOption<T> {
const EntePopupMenuOption({
required this.value,
required this.label,
this.secondaryLabel,
+ this.secondaryTrailingWidget,
this.labelColor,
this.leadingWidget,
this.isActive = false,
@@ -21,6 +30,7 @@ class EntePopupMenuOption<T> {
final T value;
final String label;
final String? secondaryLabel;
+ final Widget? secondaryTrailingWidget;
final Color? labelColor;
final Widget? leadingWidget;
final bool isActive;
@@ -36,9 +46,9 @@ class EntePopupMenuButton<T> extends StatelessWidget {
this.child,
this.menuWidth = 196.0,
this.itemHeight = 52.0,
- this.borderRadius = 20.0,
- this.elevation = 8.0,
- this.itemHorizontalPadding = 16.0,
+ this.borderRadius = Radii.button,
+ this.elevation = 0.0,
+ this.itemHorizontalPadding = Spacing.lg,
super.key,
});
@@ -72,7 +82,7 @@ class EntePopupMenuButton<T> extends StatelessWidget {
Future<void> _showMenu(BuildContext context) async {
final options = await optionsBuilder();
- if (options.isEmpty) {
+ if (!context.mounted || options.isEmpty) {
return;
}
@@ -85,7 +95,7 @@ class EntePopupMenuButton<T> extends StatelessWidget {
elevation: elevation,
itemHorizontalPadding: itemHorizontalPadding,
);
- if (selected == null) return;
+ if (!context.mounted || selected == null) return;
await onSelected(selected);
}
}
@@ -95,16 +105,16 @@ Future<T?> showEntePopupMenu<T>({
required List<EntePopupMenuOption<T>> options,
double menuWidth = 196.0,
double itemHeight = 52.0,
- double borderRadius = 20.0,
+ double borderRadius = Radii.button,
double elevation = 0.0,
- double itemHorizontalPadding = 16.0,
+ double itemHorizontalPadding = Spacing.lg,
}) {
- final colorScheme = getEnteColorScheme(context);
+ final colors = context.componentColors;
+ final menuStrokeColor = colors.strokeFaint;
final button = context.findRenderObject()! as RenderBox;
final overlay = Overlay.of(context).context.findRenderObject()! as RenderBox;
// Anchor the menu to the button's bottom edge so it drops below the button
- // instead of opening on top of it (showMenu flips it upward if there's no
- // room below).
+ // instead of opening on top of it when there is enough room below.
final position = RelativeRect.fromRect(
Rect.fromPoints(
button.localToGlobal(
@@ -121,13 +131,16 @@ Future<T?> showEntePopupMenu<T>({
return showMenu<T>(
context: context,
- color: colorScheme.fill,
+ color: colors.fillLight,
elevation: elevation,
+ surfaceTintColor: Colors.transparent,
+ menuPadding: EdgeInsets.zero,
constraints: BoxConstraints.tightFor(width: menuWidth),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius),
- side: BorderSide(color: colorScheme.strokeFaint),
+ side: BorderSide(color: menuStrokeColor),
),
+ clipBehavior: Clip.antiAlias,
position: position,
items: List.generate(options.length, (index) {
final option = options[index];
@@ -136,11 +149,12 @@ Future<T?> showEntePopupMenu<T>({
padding: EdgeInsets.zero,
height: itemHeight,
child: Container(
+ key: ValueKey('ente-popup-menu-item-$index'),
height: itemHeight,
padding: EdgeInsets.symmetric(horizontal: itemHorizontalPadding),
decoration: BoxDecoration(
border: option.showDivider && index != options.length - 1
- ? Border(bottom: BorderSide(color: colorScheme.strokeFaint))
+ ? Border(bottom: BorderSide(color: menuStrokeColor))
: null,
),
child: _EntePopupMenuRow(option: option),
@@ -157,8 +171,11 @@ class _EntePopupMenuRow<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
- final titleStyle = textTheme.mini.copyWith(color: option.labelColor);
+ final colors = context.componentColors;
+ final mutedStyle = TextStyles.mini.copyWith(color: colors.textLight);
+ final titleStyle = TextStyles.mini.copyWith(
+ color: option.labelColor ?? colors.textBase,
+ );
final title = option.secondaryLabel == null
? Text(
option.label,
@@ -177,14 +194,25 @@ class _EntePopupMenuRow<T> extends StatelessWidget {
),
),
const SizedBox(width: 6),
- Text("β€’", style: textTheme.miniMuted),
+ Text('β€’', style: mutedStyle),
const SizedBox(width: 6),
Flexible(
- child: Text(
- option.secondaryLabel!,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: textTheme.miniMuted,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Flexible(
+ child: Text(
+ option.secondaryLabel!,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: mutedStyle,
+ ),
+ ),
+ if (option.secondaryTrailingWidget != null) ...[
+ const SizedBox(width: Spacing.xs),
+ option.secondaryTrailingWidget!,
+ ],
+ ],
),
),
],
@@ -194,10 +222,18 @@ class _EntePopupMenuRow<T> extends StatelessWidget {
children: [
if (option.leadingWidget != null) ...[
SizedBox.square(
- dimension: 20,
- child: Center(child: option.leadingWidget),
+ dimension: 24,
+ child: Center(
+ child: IconTheme.merge(
+ data: IconThemeData(
+ color: colors.textLight,
+ size: IconSizes.small,
+ ),
+ child: option.leadingWidget!,
+ ),
+ ),
),
- const SizedBox(width: 12),
+ const SizedBox(width: 6),
],
Expanded(child: title),
if (option.trailingWidget != null)
@@ -205,7 +241,7 @@ class _EntePopupMenuRow<T> extends StatelessWidget {
else if (option.activeTrailingWidget != null)
option.isActive
? option.activeTrailingWidget!
- : const SizedBox(width: 12),
+ : const SizedBox(width: Spacing.md),
],
);
}
diff --git a/mobile/packages/ente_components/lib/ente_components.dart b/mobile/packages/ente_components/lib/ente_components.dart
index 5ac8c4d439..02378aa326 100644
--- a/mobile/packages/ente_components/lib/ente_components.dart
+++ b/mobile/packages/ente_components/lib/ente_components.dart
@@ -8,6 +8,7 @@ export 'components/divider_component.dart';
export 'components/filter_chip_component.dart';
export 'components/menu_component.dart';
export 'components/menu_group_component.dart';
+export 'components/popup_menu_component.dart';
export 'components/selection_controls/checkbox_component.dart';
export 'components/selection_controls/labeled_control_component.dart';
export 'components/selection_controls/radio_component.dart';
diff --git a/mobile/packages/ente_components/lib/theme/colors.dart b/mobile/packages/ente_components/lib/theme/colors.dart
index 8c8e9cafcc..1cacf6271b 100644
--- a/mobile/packages/ente_components/lib/theme/colors.dart
+++ b/mobile/packages/ente_components/lib/theme/colors.dart
@@ -567,7 +567,7 @@ const Color strokeDarkLight = Color.fromRGBO(224, 224, 224, 1);
const Color strokeDarkDark = Color.fromRGBO(62, 62, 62, 1);
const Color strokeFaintLight = Color.fromRGBO(235, 235, 235, 1);
-const Color strokeFaintDark = Color.fromRGBO(33, 33, 33, 1);
+const Color strokeFaintDark = Color.fromRGBO(42, 42, 42, 1);
// Accent Colors
const Color accentOrangeLightLight = Color.fromRGBO(255, 247, 244, 1);
diff --git a/mobile/packages/ente_components/test/components/popup_menu_component_test.dart b/mobile/packages/ente_components/test/components/popup_menu_component_test.dart
new file mode 100644
index 0000000000..5b223d0830
--- /dev/null
+++ b/mobile/packages/ente_components/test/components/popup_menu_component_test.dart
@@ -0,0 +1,161 @@
+import 'dart:async';
+
+import 'package:ente_components/ente_components.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+Future<void> pumpPopupMenu(
+ WidgetTester tester,
+ Widget child, {
+ double width = 420,
+ double height = 360,
+}) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: ComponentTheme.lightTheme(),
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: SizedBox(width: width, height: height, child: child),
+ ),
+ ),
+ ),
+ );
+}
+
+void main() {
+ testWidgets(
+ 'EntePopupMenuButton renders Figma-sized rows and selects values',
+ (tester) async {
+ String? selected;
+
+ await pumpPopupMenu(
+ tester,
+ Padding(
+ padding: const EdgeInsets.all(Spacing.xl),
+ child: EntePopupMenuButton<String>(
+ child: const SizedBox.square(
+ key: ValueKey('popup-anchor'),
+ dimension: 48,
+ child: Icon(Icons.more_vert),
+ ),
+ optionsBuilder: () => const [
+ EntePopupMenuOption(
+ value: 'name',
+ label: 'Name',
+ secondaryLabel: 'A-Z',
+ secondaryTrailingWidget: Icon(Icons.north, size: 12),
+ activeTrailingWidget: Icon(Icons.arrow_upward),
+ isActive: true,
+ ),
+ EntePopupMenuOption(value: 'created', label: 'Created'),
+ EntePopupMenuOption(
+ value: 'updated',
+ label: 'Updated',
+ showDivider: false,
+ ),
+ ],
+ onSelected: (value) => selected = value,
+ ),
+ ),
+ );
+
+ await tester.tap(find.byKey(const ValueKey('popup-anchor')));
+ await tester.pumpAndSettle();
+
+ expect(find.text('Name'), findsOneWidget);
+ expect(find.text('A-Z'), findsOneWidget);
+ expect(find.text('Created'), findsOneWidget);
+ expect(find.text('Updated'), findsOneWidget);
+ expect(find.byIcon(Icons.north), findsOneWidget);
+ expect(find.byIcon(Icons.arrow_upward), findsOneWidget);
+
+ final firstItem = tester.widget<Container>(
+ find.byKey(const ValueKey('ente-popup-menu-item-0')),
+ );
+ expect(firstItem.constraints, const BoxConstraints.tightFor(height: 52));
+ expect(firstItem.padding, const EdgeInsets.symmetric(horizontal: 16));
+ final firstDecoration = firstItem.decoration! as BoxDecoration;
+ expect(
+ firstDecoration.border?.bottom.color,
+ ColorTokens.light.strokeFaint,
+ );
+
+ final lastItem = tester.widget<Container>(
+ find.byKey(const ValueKey('ente-popup-menu-item-2')),
+ );
+ final lastDecoration = lastItem.decoration! as BoxDecoration;
+ expect(lastDecoration.border, isNull);
+
+ final nameStyle = tester.widget<Text>(find.text('Name')).style!;
+ expect(nameStyle.fontSize, TextStyles.mini.fontSize);
+ expect(nameStyle.height, TextStyles.mini.height);
+ expect(nameStyle.fontWeight, TextStyles.mini.fontWeight);
+ expect(nameStyle.color, ColorTokens.light.textBase);
+ expect(
+ tester.widget<Text>(find.text('A-Z')).style?.color,
+ ColorTokens.light.textLight,
+ );
+
+ await tester.tap(find.text('Created'));
+ await tester.pumpAndSettle();
+
+ expect(selected, 'created');
+ },
+ );
+
+ testWidgets('EntePopupMenuButton does not open for empty options', (
+ tester,
+ ) async {
+ await pumpPopupMenu(
+ tester,
+ EntePopupMenuButton<String>(
+ child: const SizedBox.square(
+ key: ValueKey('empty-popup-anchor'),
+ dimension: 48,
+ child: Icon(Icons.more_vert),
+ ),
+ optionsBuilder: () => const [],
+ onSelected: (_) {},
+ ),
+ );
+
+ await tester.tap(find.byKey(const ValueKey('empty-popup-anchor')));
+ await tester.pumpAndSettle();
+
+ expect(find.byKey(const ValueKey('ente-popup-menu-item-0')), findsNothing);
+ });
+
+ testWidgets(
+ 'EntePopupMenuButton ignores async options after anchor unmounts',
+ (tester) async {
+ final optionsCompleter = Completer<List<EntePopupMenuOption<String>>>();
+ var selected = false;
+
+ await pumpPopupMenu(
+ tester,
+ EntePopupMenuButton<String>(
+ child: const SizedBox.square(
+ key: ValueKey('async-popup-anchor'),
+ dimension: 48,
+ child: Icon(Icons.more_vert),
+ ),
+ optionsBuilder: () => optionsCompleter.future,
+ onSelected: (_) => selected = true,
+ ),
+ );
+
+ await tester.tap(find.byKey(const ValueKey('async-popup-anchor')));
+ await tester.pump();
+
+ await pumpPopupMenu(tester, const SizedBox.shrink());
+ optionsCompleter.complete(const [
+ EntePopupMenuOption(value: 'late', label: 'Late option'),
+ ]);
+ await tester.pumpAndSettle();
+
+ expect(find.text('Late option'), findsNothing);
+ expect(selected, isFalse);
+ },
+ );
+}
diff --git a/mobile/packages/ente_components/test/theme/theme_tokens_test.dart b/mobile/packages/ente_components/test/theme/theme_tokens_test.dart
index 49bf442094..cf477e64e4 100644
--- a/mobile/packages/ente_components/test/theme/theme_tokens_test.dart
+++ b/mobile/packages/ente_components/test/theme/theme_tokens_test.dart
@@ -217,7 +217,7 @@ void main() {
"special/white": Color.fromRGBO(255, 255, 255, 1),
"special/white-overlay": Color.fromRGBO(255, 255, 255, 0.14),
"stroke/dark": Color.fromRGBO(62, 62, 62, 1),
- "stroke/faint": Color.fromRGBO(33, 33, 33, 1),
+ "stroke/faint": Color.fromRGBO(42, 42, 42, 1),
"text/base": Color.fromRGBO(255, 255, 255, 1),
"text/dark": Color.fromRGBO(229, 229, 229, 1),
"text/darker": Color.fromRGBO(204, 204, 204, 1),