TF-4233 Fix the response success check to use key presence instead of value nullness.
This commit is contained in:
@@ -48,7 +48,7 @@ extension HandleLabelActionTypeExtension on LabelController {
|
||||
labels: labels,
|
||||
selectedLabel: label,
|
||||
actionType: LabelActionType.edit,
|
||||
onCreateNewLabelCallback: (newLabel) =>
|
||||
onLabelActionCallback: (newLabel) =>
|
||||
editLabel(
|
||||
accountId: accountId,
|
||||
selectedLabel: label,
|
||||
|
||||
@@ -89,7 +89,7 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
||||
await DialogRouter().openDialogModal(
|
||||
child: CreateNewLabelModal(
|
||||
labels: labels,
|
||||
onCreateNewLabelCallback: (label) => _createNewLabel(accountId, label),
|
||||
onLabelActionCallback: (label) => _createNewLabel(accountId, label),
|
||||
),
|
||||
dialogLabel: 'create-new-label-modal',
|
||||
);
|
||||
|
||||
@@ -12,6 +12,8 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
mixin LabelContextMenuMixin on PopupContextMenuActionMixin {
|
||||
static const _labelActions = [LabelActionType.edit];
|
||||
|
||||
Future<void> _openLabelPopupMenuAction(
|
||||
BuildContext context,
|
||||
ImagePaths imagePaths,
|
||||
@@ -19,9 +21,7 @@ mixin LabelContextMenuMixin on PopupContextMenuActionMixin {
|
||||
RelativeRect position,
|
||||
OnLabelActionTypeCallback onLabelActionTypeCallback,
|
||||
) async {
|
||||
final listLabelAction = [LabelActionType.edit];
|
||||
|
||||
final popupMenuItems = listLabelAction
|
||||
final popupMenuItems = _labelActions
|
||||
.map((actionType) => _buildLabelPopupMenuItem(
|
||||
label,
|
||||
actionType,
|
||||
@@ -89,9 +89,7 @@ mixin LabelContextMenuMixin on PopupContextMenuActionMixin {
|
||||
Label label,
|
||||
OnLabelActionTypeCallback onLabelActionTypeCallback,
|
||||
) async {
|
||||
final listLabelAction = [LabelActionType.edit];
|
||||
|
||||
final contextMenuActions = listLabelAction
|
||||
final contextMenuActions = _labelActions
|
||||
.map((actionType) => _buildLabelContextMenuItem(
|
||||
actionType,
|
||||
AppLocalizations.of(context),
|
||||
|
||||
@@ -43,6 +43,15 @@ enum LabelActionType {
|
||||
}
|
||||
}
|
||||
|
||||
Key getModalPositiveActionKey() {
|
||||
switch (this) {
|
||||
case LabelActionType.create:
|
||||
return const Key('create_label_button_action');
|
||||
case LabelActionType.edit:
|
||||
return const Key('save_label_button_action');
|
||||
}
|
||||
}
|
||||
|
||||
String getContextMenuIcon(ImagePaths imagePaths) {
|
||||
switch (this) {
|
||||
case LabelActionType.create:
|
||||
|
||||
@@ -25,18 +25,18 @@ import 'package:tmail_ui_user/features/mailbox_creator/presentation/extensions/v
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
typedef OnCreateNewLabelCallback = Function(Label label);
|
||||
typedef OnLabelActionCallback = Function(Label label);
|
||||
|
||||
class CreateNewLabelModal extends StatefulWidget {
|
||||
final List<Label> labels;
|
||||
final LabelActionType actionType;
|
||||
final OnCreateNewLabelCallback onCreateNewLabelCallback;
|
||||
final OnLabelActionCallback onLabelActionCallback;
|
||||
final Label? selectedLabel;
|
||||
|
||||
const CreateNewLabelModal({
|
||||
super.key,
|
||||
required this.labels,
|
||||
required this.onCreateNewLabelCallback,
|
||||
required this.onLabelActionCallback,
|
||||
this.actionType = LabelActionType.create,
|
||||
this.selectedLabel,
|
||||
});
|
||||
@@ -182,6 +182,7 @@ class _CreateNewLabelModalState extends State<CreateNewLabelModal> {
|
||||
isPositiveActionEnabled: value,
|
||||
onPositiveAction: _onCreateNewLabel,
|
||||
onNegativeAction: _onCloseModal,
|
||||
positiveKey: widget.actionType.getModalPositiveActionKey(),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -338,7 +339,7 @@ class _CreateNewLabelModalState extends State<CreateNewLabelModal> {
|
||||
? HexColor(_selectedColor!.toHexTriplet())
|
||||
: null,
|
||||
);
|
||||
widget.onCreateNewLabelCallback(newLabel);
|
||||
widget.onLabelActionCallback(newLabel);
|
||||
|
||||
popBack();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user