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 a2b3f87
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 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
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

0 comments on commit a2b3f87

Please sign in to comment.