π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Use shared popup menus
aman-pilot9d7005a21e1d
diff --git a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dartindex e69ba716df..9d02e8d558 100644--- a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart+++ b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart@@ -5,7 +5,6 @@ import "package:locker/l10n/l10n.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/collections/models/collection_view_type.dart";import "package:locker/services/configuration.dart";-import "package:locker/ui/components/popup_menu_item_widget.dart";import "package:locker/utils/collection_actions.dart";class CollectionPopupMenuWidget extends StatelessWidget {@@ -22,33 +21,19 @@ class CollectionPopupMenuWidget extends StatelessWidget {Widget build(BuildContext context) {final colors = context.componentColors;- return PopupMenuButton<String>(+ return EntePopupMenuButton<String>(+ optionsBuilder: () => _buildOptions(context),onSelected: (value) => _handleMenuAction(context, value),- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(16),- side: BorderSide(color: colors.strokeFaint),- ),- padding: EdgeInsets.zero,- menuPadding: EdgeInsets.zero,- color: colors.fillLight,- surfaceTintColor: Colors.transparent,- elevation: 15,- offset: const Offset(-24, 24),- shadowColor: colors.specialScrim.withValues(alpha: 0.08),- constraints: const BoxConstraints(minWidth: 120),child:child ??HugeIcon(icon: HugeIcons.strokeRoundedMoreVertical,color: colors.textBase,),- itemBuilder: (BuildContext context) {- return _buildPopupMenuItems(context);- },);}- List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {+ List<EntePopupMenuOption<String>> _buildOptions(BuildContext context) {final colors = context.componentColors;final collectionViewType = getCollectionViewType(@@ -56,44 +41,31 @@ class CollectionPopupMenuWidget extends StatelessWidget {Configuration.instance.getUserID()!,);- final items = <PopupMenuItem<String>>[];+ final options = <EntePopupMenuOption<String>>[];if (collectionViewType == CollectionViewType.ownedCollection ||collectionViewType == CollectionViewType.hiddenOwnedCollection ||collectionViewType == CollectionViewType.quickLink) {- items.add(- PopupMenuItem<String>(+ options.add(+ EntePopupMenuOption(value: 'edit',- padding: EdgeInsets.zero,- height: 0,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedEdit02,- color: colors.textBase,- size: 20,- ),- label: context.l10n.edit,- isFirst: true,- isLast: false,+ label: context.l10n.edit,+ leadingWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedEdit02,+ color: colors.textBase,+ size: IconSizes.small,),),);-- items.add(- PopupMenuItem<String>(+ options.add(+ EntePopupMenuOption(value: 'delete',- padding: EdgeInsets.zero,- height: 0,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedDelete01,- color: colors.warning,- size: 20,- ),- label: context.l10n.delete,- isFirst: false,- isLast: true,- isWarning: true,+ label: context.l10n.delete,+ labelColor: colors.warning,+ leadingWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedDelete01,+ color: colors.warning,+ size: IconSizes.small,),),);@@ -101,27 +73,21 @@ class CollectionPopupMenuWidget extends StatelessWidget {if (collectionViewType == CollectionViewType.sharedCollectionViewer ||collectionViewType == CollectionViewType.sharedCollectionCollaborator) {- items.add(- PopupMenuItem<String>(+ options.add(+ EntePopupMenuOption(value: 'leave_collection',- padding: EdgeInsets.zero,- height: 0,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedLogout02,- color: colors.warning,- size: 20,- ),- label: context.l10n.leaveCollection,- isFirst: true,- isLast: true,- isWarning: true,+ label: context.l10n.leaveCollection,+ labelColor: colors.warning,+ leadingWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedLogout02,+ color: colors.warning,+ size: IconSizes.small,),),);}- return items;+ return options;}void _handleMenuAction(BuildContext context, String action) {diff --git a/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.dart b/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.dartdeleted file mode 100644index e62ccce5b4..0000000000--- a/mobile/apps/locker/lib/ui/components/popup_menu_item_widget.dart+++ /dev/null@@ -1,65 +0,0 @@-import "package:ente_components/ente_components.dart";-import "package:flutter/material.dart";--class PopupMenuItemWidget extends StatelessWidget {- final Widget icon;- final String label;- final bool isFirst;- final bool isLast;- final bool isWarning;- final VoidCallback? onTap;-- const PopupMenuItemWidget({- super.key,- required this.icon,- required this.label,- this.isFirst = false,- this.isLast = false,- this.isWarning = false,- this.onTap,- });-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- final bottomPadding = MediaQuery.of(context).viewPadding.bottom;-- return GestureDetector(- onTap: onTap,- child: Container(- decoration: BoxDecoration(- color: colors.fillLight,- border: !isLast- ? Border(bottom: BorderSide(color: colors.strokeFaint, width: 1))- : null,- borderRadius: BorderRadius.only(- topLeft: isFirst ? const Radius.circular(15) : Radius.zero,- topRight: isFirst ? const Radius.circular(15) : Radius.zero,- bottomLeft: isLast ? const Radius.circular(15) : Radius.zero,- bottomRight: isLast ? const Radius.circular(15) : Radius.zero,- ),- ),- padding: EdgeInsets.only(- left: 16,- right: 16,- top: 16,- bottom: isLast ? 16 + bottomPadding : 16,- ),- child: Row(- children: [- icon,- const SizedBox(width: 12),- Expanded(- child: Text(- label,- style: isWarning- ? TextStyles.body.copyWith(color: colors.warning)- : TextStyles.body,- ),- ),- ],- ),- ),- );- }-}diff --git a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dartindex b934a2ec1d..4586106423 100644--- a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart@@ -15,7 +15,6 @@ import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/configuration.dart";import "package:locker/ui/components/custom_list_scrollbar.dart";-import "package:locker/ui/components/popup_menu_item_widget.dart";import "package:locker/ui/sharing/add_email_bottom_sheet.dart";import "package:locker/ui/sharing/manage_links_widget.dart";import "package:locker/utils/collection_actions.dart";@@ -256,7 +255,19 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {Widget _buildRolePopupMenu(User user) {final colors = context.componentColors;- return PopupMenuButton<String>(+ return EntePopupMenuButton<String>(+ optionsBuilder: () => [+ EntePopupMenuOption(+ value: "remove",+ label: context.l10n.removeAccess,+ labelColor: colors.warning,+ leadingWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedDelete02,+ color: colors.warning,+ size: IconSizes.small,+ ),+ ),+ ],onSelected: (value) {if (value == "viewer") {_setUserRole(user, CollectionParticipantRole.viewer);@@ -266,72 +277,10 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {_removeSharee(user);}},- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(16),- side: BorderSide(color: colors.strokeFaint),- ),- padding: EdgeInsets.zero,- menuPadding: EdgeInsets.zero,- color: colors.fillLight,- surfaceTintColor: Colors.transparent,- elevation: 15,- shadowColor: Colors.black.withValues(alpha: 0.08),- constraints: const BoxConstraints(minWidth: 120),- position: PopupMenuPosition.under,child: HugeIcon(icon: HugeIcons.strokeRoundedMoreVertical,color: colors.textBase,),- itemBuilder: (context) => [- // TODO: Re-enable viewer option when ready- // PopupMenuItem<String>(- // value: "viewer",- // height: 0,- // padding: EdgeInsets.zero,- // child: PopupMenuItemWidget(- // icon: HugeIcon(- // icon: HugeIcons.strokeRoundedView,- // color: colorScheme.textBase,- // size: 20,- // ),- // label: context.l10n.viewer,- // isFirst: true,- // isLast: false,- // ),- // ),- // TODO: Re-enable collaborator option when ready- // PopupMenuItem<String>(- // value: "collaborator",- // height: 0,- // padding: EdgeInsets.zero,- // child: PopupMenuItemWidget(- // icon: HugeIcon(- // icon: HugeIcons.strokeRoundedUserMultiple,- // color: colorScheme.textBase,- // size: 20,- // ),- // label: context.l10n.collaborator,- // isFirst: false,- // isLast: false,- // ),- // ),- PopupMenuItem<String>(- value: "remove",- height: 0,- padding: EdgeInsets.zero,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,- color: colors.warning,- size: 20,- ),- label: context.l10n.removeAccess,- isFirst: true,- isLast: true,- isWarning: true,- ),- ),- ],);}