Skip to content

Commit

Permalink
TF-2084 Hide Forward action
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui committed Sep 28, 2023
1 parent 4337ea3 commit c1bc74d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,17 @@ enum EmailRuleFilterAction {
return AppLocalizations.of(context).forwardTo;
}
}

bool getSupported() {
switch(this) {
case EmailRuleFilterAction.moveMessage:
case EmailRuleFilterAction.maskAsSeen:
case EmailRuleFilterAction.startIt:
case EmailRuleFilterAction.rejectIt:
case EmailRuleFilterAction.markAsSpam:
return true;
case EmailRuleFilterAction.forwardTo:
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RulesFilterCreatorController extends BaseMailboxController {
final TextEditingController forwardEmailController = TextEditingController();
final FocusNode forwardEmailFocusNode = FocusNode();
final listEmailRuleFilterActionSelected = RxList<RuleFilterActionArguments>();
int maxCountAction = EmailRuleFilterAction.values.length - 1;
int maxCountAction = EmailRuleFilterAction.values.where((action) => action.getSupported() == true).length - 1;
final isShowAddAction = Rxn<bool>();

String? _newRuleName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,10 @@ class RuleFilterCreatorView extends GetWidget<RulesFilterCreatorController> {
EmailRuleFilterAction? ruleActionSelected,
int ruleActionIndex,
) {
return EmailRuleFilterAction.values
final supportedAction = EmailRuleFilterAction.values
.where((ruleAction) => ruleAction.getSupported() == true)
.toList();
return supportedAction
.map((ruleAction) =>
_buildRuleActionWidget(context, ruleAction, ruleActionSelected, ruleActionIndex))
.toList();
Expand Down Expand Up @@ -806,12 +809,4 @@ class RuleFilterCreatorView extends GetWidget<RulesFilterCreatorController> {
}))
.build();
}

Color _getBorderColorMailboxSelected() {
if (controller.errorRuleActionValue.value?.isNotEmpty == true) {
return AppColor.colorInputBorderErrorVerifyName;
} else {
return AppColor.colorInputBorderCreateMailbox;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ class RuleFilterActionRow extends StatelessWidget {

@override
Widget build(BuildContext context) {
final supportedAction = actionList.where((action) => action.getSupported() == true).toList();
return Row(
children: [
Expanded(
child: DropDownButtonWidget<EmailRuleFilterAction>(
items: actionList,
items: supportedAction,
itemSelected: actionSelected,
onChanged: (newAction) => onActionChanged!(newAction),
supportSelectionIcon: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:core/core.dart';
import 'package:core/presentation/utils/keyboard_utils.dart';
import 'package:flutter/material.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/email_rule_filter_action.dart';
Expand Down

0 comments on commit c1bc74d

Please sign in to comment.