TF-733 Apply change text background color to body composer on web
This commit is contained in:
@@ -10,7 +10,10 @@ abstract class BaseRichTextController extends GetxController {
|
||||
void openMenuSelectColor(
|
||||
BuildContext context,
|
||||
Color currentColor,
|
||||
{Function(Color?)? onSelectColor}
|
||||
{
|
||||
Function(Color?)? onSelectColor,
|
||||
VoidCallback? onResetToDefault,
|
||||
}
|
||||
) async {
|
||||
await ColorPickerDialogBuilder(
|
||||
context,
|
||||
@@ -20,6 +23,10 @@ abstract class BaseRichTextController extends GetxController {
|
||||
textActionResetDefault: AppLocalizations.of(context).resetToDefault,
|
||||
textActionCancel: AppLocalizations.of(context).cancel,
|
||||
cancelActionCallback: () => popBack(),
|
||||
resetToDefaultActionCallback: () {
|
||||
onResetToDefault?.call();
|
||||
popBack();
|
||||
},
|
||||
setColorActionCallback: (selectedColor) {
|
||||
onSelectColor?.call(selectedColor);
|
||||
popBack();
|
||||
|
||||
@@ -20,6 +20,7 @@ class RichTextWebController extends BaseRichTextController {
|
||||
|
||||
final listTextStyleApply = RxList<RichTextStyleType>();
|
||||
final selectedTextColor = Colors.black.obs;
|
||||
final selectedTextBackgroundColor = Colors.transparent.obs;
|
||||
|
||||
void onEditorSettingsChange(EditorSettings settings) {
|
||||
log('RichTextWebController::onEditorSettingsChange():');
|
||||
@@ -47,14 +48,23 @@ class RichTextWebController extends BaseRichTextController {
|
||||
openMenuSelectColor(
|
||||
context,
|
||||
selectedTextColor.value,
|
||||
onResetToDefault: () {
|
||||
final colorAsString = (Colors.black.value & 0xFFFFFF)
|
||||
.toRadixString(16)
|
||||
.padLeft(6, '0')
|
||||
.toUpperCase();
|
||||
selectedTextColor.value = Colors.black;
|
||||
editorController.execCommand(
|
||||
textStyleType.commandAction,
|
||||
argument: colorAsString);
|
||||
},
|
||||
onSelectColor: (selectedColor) {
|
||||
final newColor = selectedColor ?? Colors.black;
|
||||
final colorAsString = (newColor.value & 0xFFFFFF)
|
||||
.toRadixString(16)
|
||||
.padLeft(6, '0')
|
||||
.toUpperCase();
|
||||
log('RichTextWebController::applyRichTextStyle(): color: $newColor');
|
||||
log('RichTextWebController::applyRichTextStyle(): colorAsString: $colorAsString');
|
||||
log('RichTextWebController::applyRichTextStyle():selectedTextColor: colorAsString: $colorAsString');
|
||||
selectedTextColor.value = newColor;
|
||||
editorController.execCommand(
|
||||
textStyleType.commandAction,
|
||||
@@ -62,6 +72,34 @@ class RichTextWebController extends BaseRichTextController {
|
||||
}
|
||||
);
|
||||
break;
|
||||
case RichTextStyleType.textBackgroundColor:
|
||||
openMenuSelectColor(
|
||||
context,
|
||||
selectedTextBackgroundColor.value,
|
||||
onResetToDefault: () {
|
||||
final colorAsString = (Colors.transparent.value & 0xFFFFFF)
|
||||
.toRadixString(16)
|
||||
.padLeft(6, '0')
|
||||
.toUpperCase();
|
||||
selectedTextBackgroundColor.value = Colors.transparent;
|
||||
editorController.execCommand(
|
||||
textStyleType.commandAction,
|
||||
argument: colorAsString);
|
||||
},
|
||||
onSelectColor: (selectedColor) {
|
||||
final newColor = selectedColor ?? Colors.transparent;
|
||||
final colorAsString = (newColor.value & 0xFFFFFF)
|
||||
.toRadixString(16)
|
||||
.padLeft(6, '0')
|
||||
.toUpperCase();
|
||||
log('RichTextWebController::applyRichTextStyle():textBackgroundColor: colorAsString: $colorAsString');
|
||||
selectedTextBackgroundColor.value = newColor;
|
||||
editorController.execCommand(
|
||||
textStyleType.commandAction,
|
||||
argument: colorAsString);
|
||||
}
|
||||
);
|
||||
break;
|
||||
default:
|
||||
editorController.execCommand(textStyleType.commandAction);
|
||||
_selectTextStyleType(textStyleType);
|
||||
|
||||
Reference in New Issue
Block a user