From 7c848251d836b754dc204f534b77437359c1eebf Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 26 Jul 2022 16:18:07 +0700 Subject: [PATCH] TF-738 Create ParagraphType --- .../presentation/model/paragraph_type.dart | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 lib/features/composer/presentation/model/paragraph_type.dart diff --git a/lib/features/composer/presentation/model/paragraph_type.dart b/lib/features/composer/presentation/model/paragraph_type.dart new file mode 100644 index 000000000..927fe8138 --- /dev/null +++ b/lib/features/composer/presentation/model/paragraph_type.dart @@ -0,0 +1,79 @@ + +import 'package:core/core.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; + +enum ParagraphType { + alignLeft, + alignRight, + alignCenter, + justify, + indent, + outdent; + + String get commandAction { + switch(this) { + case ParagraphType.alignLeft: + return 'justifyLeft'; + case ParagraphType.alignRight: + return 'justifyRight'; + case ParagraphType.alignCenter: + return 'justifyCenter'; + case ParagraphType.justify: + return 'justifyFull'; + case ParagraphType.indent: + return 'indent'; + case ParagraphType.outdent: + return 'outdent'; + } + } + + String getIcon(ImagePaths imagePaths) { + switch (this) { + case ParagraphType.alignLeft: + return imagePaths.icAlignLeft; + case ParagraphType.alignRight: + return imagePaths.icAlignRight; + case ParagraphType.alignCenter: + return imagePaths.icAlignCenter; + case ParagraphType.justify: + return imagePaths.icAlignJustify; + case ParagraphType.indent: + return imagePaths.icAlignIndent; + case ParagraphType.outdent: + return imagePaths.icAlignOutdent; + } + } + + String getTooltipButton(BuildContext context) { + switch (this) { + case ParagraphType.alignLeft: + return AppLocalizations.of(context).alignLeft; + case ParagraphType.alignRight: + return AppLocalizations.of(context).alignRight; + case ParagraphType.alignCenter: + return AppLocalizations.of(context).alignCenter; + case ParagraphType.justify: + return AppLocalizations.of(context).justifyFull; + case ParagraphType.indent: + return AppLocalizations.of(context).indent; + case ParagraphType.outdent: + return AppLocalizations.of(context).outdent; + } + } + + Widget buildButtonWidget( + BuildContext context, + ImagePaths imagePaths, + Function(ParagraphType paragraph) onActionCallback + ) { + return buildIconWeb( + icon: SvgPicture.asset(getIcon(imagePaths)), + iconPadding: const EdgeInsets.symmetric(vertical: 8, horizontal: 5), + minSize: 30, + iconSize: 30, + tooltip: getTooltipButton(context), + onTap: () => onActionCallback.call(this)); + } +} \ No newline at end of file