add dialog edit rule for mobile
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:rule_filter/rule_filter/tmail_rule.dart';
|
||||
|
||||
class EmailRuleBottomSheetActionTileBuilder
|
||||
extends CupertinoActionSheetActionBuilder<TMailRule> {
|
||||
final TMailRule emailRule;
|
||||
final SvgPicture? actionSelected;
|
||||
final Color? bgColor;
|
||||
final EdgeInsets? iconLeftPadding;
|
||||
final EdgeInsets? iconRightPadding;
|
||||
final TextStyle? textStyleAction;
|
||||
|
||||
EmailRuleBottomSheetActionTileBuilder(
|
||||
Key key,
|
||||
SvgPicture actionIcon,
|
||||
String actionName,
|
||||
this.emailRule, {
|
||||
this.actionSelected,
|
||||
this.bgColor,
|
||||
this.iconLeftPadding,
|
||||
this.iconRightPadding,
|
||||
this.textStyleAction,
|
||||
}) : super(key, actionIcon, actionName);
|
||||
|
||||
@override
|
||||
Widget build() {
|
||||
return Container(
|
||||
color: bgColor ?? Colors.white,
|
||||
child: MouseRegion(
|
||||
cursor: BuildUtils.isWeb
|
||||
? MaterialStateMouseCursor.clickable
|
||||
: MouseCursor.defer,
|
||||
child: CupertinoActionSheetAction(
|
||||
key: key,
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding(
|
||||
padding: iconLeftPadding ??
|
||||
const EdgeInsets.only(left: 12, right: 16),
|
||||
child: actionIcon),
|
||||
Expanded(
|
||||
child: Text(actionName,
|
||||
textAlign: TextAlign.left,
|
||||
style: actionTextStyle(textStyle: textStyleAction))),
|
||||
]),
|
||||
onPressed: () {
|
||||
if (onCupertinoActionSheetActionClick != null) {
|
||||
onCupertinoActionSheetActionClick!(emailRule);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+35
-21
@@ -6,23 +6,25 @@ import 'package:rule_filter/rule_filter/tmail_rule.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/email_rules/email_rules_controller.dart';
|
||||
|
||||
class EmailRulesItemWidget extends GetWidget<EmailRulesController> {
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
EmailRulesItemWidget({
|
||||
Key? key,
|
||||
required this.editRule,
|
||||
required this.rule,
|
||||
required this.deleteRule,
|
||||
}) : super(key: key);
|
||||
|
||||
final void Function(TMailRule) editRule;
|
||||
final TMailRule rule;
|
||||
final void Function(TMailRule) deleteRule;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24),
|
||||
padding: EdgeInsets.only(
|
||||
top: 15,
|
||||
bottom: 15,
|
||||
left: _responsiveUtils.isMobile(context) ? 16 : 24,
|
||||
right: _responsiveUtils.isMobile(context) ? 0 : 24
|
||||
),
|
||||
color: Colors.white,
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
||||
Text(rule.name,
|
||||
@@ -31,22 +33,34 @@ class EmailRulesItemWidget extends GetWidget<EmailRulesController> {
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black)),
|
||||
const Spacer(),
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icEditRule,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
onTap: () {
|
||||
editRule.call(rule);
|
||||
}),
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icDeleteRule,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
onTap: () {
|
||||
deleteRule.call(rule);
|
||||
}),
|
||||
if (!_responsiveUtils.isMobile(context))
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icEditRule,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
onTap: () {
|
||||
controller.editEmailRule(rule);
|
||||
}),
|
||||
if (!_responsiveUtils.isMobile(context))
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icDeleteRule,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
onTap: () {
|
||||
controller.deleteEmailRule(rule);
|
||||
}),
|
||||
if (_responsiveUtils.isMobile(context))
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icOpenEditRule,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
iconPadding: const EdgeInsets.all(0),
|
||||
onTap: () {
|
||||
controller.openEditRuleMenuAction(context, rule);
|
||||
}),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
+50
-26
@@ -21,31 +21,6 @@ class EmailRulesHeaderWidget extends GetWidget<EmailRulesController> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final buttonAddNewRule = Row(children: [
|
||||
if (!responsiveUtils.isMobile(context))
|
||||
(ButtonBuilder(imagePaths.icAddNewRules)
|
||||
..key(const Key('button_new_rule'))
|
||||
..decoration(BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: AppColor.colorTextButton))
|
||||
..paddingIcon(const EdgeInsets.only(right: 8))
|
||||
..iconColor(Colors.white)
|
||||
..maxWidth(170)
|
||||
..size(20)
|
||||
..radiusSplash(10)
|
||||
..padding(const EdgeInsets.symmetric(vertical: 12))
|
||||
..textStyle(const TextStyle(
|
||||
fontSize: 17,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
))
|
||||
..onPressActionClick(() => controller.goToCreateNewRule())
|
||||
..text(
|
||||
AppLocalizations.of(context).addNewRule,
|
||||
isVertical: false,
|
||||
))
|
||||
.build()
|
||||
]);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
@@ -65,8 +40,57 @@ class EmailRulesHeaderWidget extends GetWidget<EmailRulesController> {
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorTextButtonHeaderThread)),
|
||||
const SizedBox(height: 24),
|
||||
buttonAddNewRule,
|
||||
_buildButtonAddNewRule(context),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildButtonAddNewRule(BuildContext context) {
|
||||
if (!responsiveUtils.isMobile(context)) {
|
||||
return (ButtonBuilder(imagePaths.icAddNewRules)
|
||||
..key(const Key('button_new_rule'))
|
||||
..decoration(BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: AppColor.colorTextButton))
|
||||
..paddingIcon(const EdgeInsets.only(right: 8))
|
||||
..iconColor(Colors.white)
|
||||
..maxWidth(130)
|
||||
..size(20)
|
||||
..radiusSplash(10)
|
||||
..padding(const EdgeInsets.symmetric(vertical: 12))
|
||||
..textStyle(const TextStyle(
|
||||
fontSize: 17,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
))
|
||||
..onPressActionClick(() => controller.goToCreateNewRule())
|
||||
..text(
|
||||
AppLocalizations.of(context).addNewRule,
|
||||
isVertical: false,
|
||||
))
|
||||
.build();
|
||||
} else {
|
||||
return (ButtonBuilder(imagePaths.icAddNewRules)
|
||||
..key(const Key('button_new_rule'))
|
||||
..decoration(BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: AppColor.colorTextButton))
|
||||
..paddingIcon(const EdgeInsets.only(right: 8))
|
||||
..iconColor(Colors.white)
|
||||
..size(20)
|
||||
..radiusSplash(10)
|
||||
..padding(const EdgeInsets.symmetric(vertical: 12))
|
||||
..textStyle(const TextStyle(
|
||||
fontSize: 17,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
))
|
||||
..onPressActionClick(() => controller.goToCreateNewRule())
|
||||
..text(
|
||||
AppLocalizations.of(context).addNewRule,
|
||||
isVertical: false,
|
||||
))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-6
@@ -44,12 +44,6 @@ class ListEmailRulesWidget extends GetWidget<EmailRulesController> {
|
||||
final rule = controller.listEmailRule[index];
|
||||
return EmailRulesItemWidget(
|
||||
rule: rule,
|
||||
editRule: (rule) {
|
||||
controller.editEmailRule(rule);
|
||||
},
|
||||
deleteRule: (rule) {
|
||||
controller.editEmailRule(rule);
|
||||
},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
|
||||
Reference in New Issue
Block a user