TF-4233 Handle edit label on mobile

This commit is contained in:
dab246
2026-01-05 17:00:28 +07:00
committed by Dat H. Pham
parent bac101021e
commit ac33424c30
8 changed files with 131 additions and 8 deletions
@@ -2,7 +2,9 @@ import 'package:core/presentation/resources/image_paths.dart';
import 'package:flutter/material.dart';
import 'package:labels/model/label.dart';
import 'package:tmail_ui_user/features/base/mixin/popup_context_menu_action_mixin.dart';
import 'package:tmail_ui_user/features/base/widget/context_menu/context_menu_item_action.dart';
import 'package:tmail_ui_user/features/base/widget/popup_menu/popup_menu_item_action_widget.dart';
import 'package:tmail_ui_user/features/labels/presentation/models/context_item_label_action.dart';
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
import 'package:tmail_ui_user/features/labels/presentation/models/popup_menu_item_label_action.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/utils/labels/label_method_action_define.dart';
@@ -10,7 +12,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
mixin LabelContextMenuMixin on PopupContextMenuActionMixin {
Future<void> openLabelContextMenuAction(
Future<void> _openLabelPopupMenuAction(
BuildContext context,
ImagePaths imagePaths,
Label label,
@@ -68,4 +70,67 @@ mixin LabelContextMenuMixin on PopupContextMenuActionMixin {
popBack();
onLabelActionTypeCallback(label, actionType);
}
ContextMenuItemAction _buildLabelContextMenuItem(
LabelActionType actionType,
AppLocalizations appLocalizations,
ImagePaths imagePaths,
) {
return ContextMenuItemLabelAction(
actionType,
appLocalizations,
imagePaths,
);
}
Future<void> _openLabelContextMenuAction(
BuildContext context,
ImagePaths imagePaths,
Label label,
OnLabelActionTypeCallback onLabelActionTypeCallback,
) async {
final listLabelAction = [LabelActionType.edit];
final contextMenuActions = listLabelAction
.map((actionType) => _buildLabelContextMenuItem(
actionType,
AppLocalizations.of(context),
imagePaths,
))
.toList();
return openBottomSheetContextMenuAction(
context: context,
itemActions: contextMenuActions,
onContextMenuActionClick: (menuAction) {
popBack();
onLabelActionTypeCallback(label, menuAction.action);
},
);
}
Future<void> openLabelMenuAction(
BuildContext context,
ImagePaths imagePaths,
Label label,
OnLabelActionTypeCallback onLabelActionTypeCallback,
{RelativeRect? position}
) async {
if (position == null) {
return _openLabelContextMenuAction(
context,
imagePaths,
label,
onLabelActionTypeCallback,
);
} else {
return _openLabelPopupMenuAction(
context,
imagePaths,
label,
position,
onLabelActionTypeCallback,
);
}
}
}
@@ -0,0 +1,29 @@
import 'package:core/presentation/resources/image_paths.dart';
import 'package:flutter/material.dart';
import 'package:tmail_ui_user/features/base/widget/context_menu/context_menu_item_action.dart';
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
class ContextMenuItemLabelAction
extends ContextMenuItemActionRequiredIcon<LabelActionType> {
final AppLocalizations appLocalizations;
final ImagePaths imagePaths;
ContextMenuItemLabelAction(
super.action,
this.appLocalizations,
this.imagePaths,
);
@override
String get actionIcon => action.getContextMenuIcon(imagePaths);
@override
String get actionName => action.getContextMenuTitle(appLocalizations);
@override
Color get actionIconColor => action.getContextMenuIconColor();
@override
Color get actionNameColor => action.getContextMenuTitleColor();
}
@@ -75,7 +75,6 @@ class _CreateNewLabelModalState extends State<CreateNewLabelModal> {
if (selectedLabel != null) {
_nameInputController.text = selectedLabel.safeDisplayName;
_nameInputFocusNode.requestFocus();
_labelSelectedColorNotifier.value = _selectedColor;
_createLabelStateNotifier.value = true;
}
});