TF-1878 Fix font family not changed correctly in composer
(cherry picked from commit a4c72a79abf429aa2938c8218308f1ac16f89d76)
This commit is contained in:
@@ -174,7 +174,7 @@ class DropDownButtonWidget<T> extends StatelessWidget {
|
|||||||
return item.name ?? '';
|
return item.name ?? '';
|
||||||
}
|
}
|
||||||
if (item is FontNameType) {
|
if (item is FontNameType) {
|
||||||
return item.fontFamily;
|
return item.title;
|
||||||
}
|
}
|
||||||
if (item is rich_text_composer.SafeFont) {
|
if (item is rich_text_composer.SafeFont) {
|
||||||
return item.name;
|
return item.name;
|
||||||
|
|||||||
@@ -47,8 +47,16 @@ class RichTextWebController extends BaseRichTextController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void onEditorSettingsChange(EditorSettings settings) async {
|
void onEditorSettingsChange(EditorSettings settings) {
|
||||||
log('RichTextWebController::onEditorSettingsChange():foregroundColor: ${settings.foregroundColor} | backgroundColor: ${settings.backgroundColor}');
|
_updateTextStyle(settings);
|
||||||
|
_updateFontName(settings);
|
||||||
|
_updateTextColor(settings);
|
||||||
|
_updateBackgroundTextColor(settings);
|
||||||
|
_updateOrderList(settings);
|
||||||
|
_updateParagraph(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateTextStyle(EditorSettings settings) {
|
||||||
listTextStyleApply.clear();
|
listTextStyleApply.clear();
|
||||||
|
|
||||||
if (settings.isBold) {
|
if (settings.isBold) {
|
||||||
@@ -67,11 +75,35 @@ class RichTextWebController extends BaseRichTextController {
|
|||||||
listTextStyleApply.add(RichTextStyleType.strikeThrough);
|
listTextStyleApply.add(RichTextStyleType.strikeThrough);
|
||||||
}
|
}
|
||||||
|
|
||||||
log('RichTextWebController::onEditorSettingsChange(): $listTextStyleApply');
|
log('RichTextWebController::_updateTextStyle(): $listTextStyleApply');
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateFontName(EditorSettings settings) {
|
||||||
|
log('RichTextWebController::_updateFontName():fontName: ${settings.fontName}');
|
||||||
|
final matchedFontName = FontNameType.values.firstWhereOrNull((fontName) => fontName.value == settings.fontName);
|
||||||
|
log('RichTextWebController::_updateFontName():matchedFontName: $matchedFontName');
|
||||||
|
if (matchedFontName != null) {
|
||||||
|
selectedFontName.value = matchedFontName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateTextColor(EditorSettings settings) {
|
||||||
selectedTextColor.value = settings.foregroundColor;
|
selectedTextColor.value = settings.foregroundColor;
|
||||||
selectedTextBackgroundColor.value = settings.backgroundColor;
|
}
|
||||||
|
|
||||||
|
void _updateBackgroundTextColor(EditorSettings settings) {
|
||||||
|
selectedTextBackgroundColor.value = settings.backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateOrderList(EditorSettings settings) {
|
||||||
|
if (settings.isOl) {
|
||||||
|
selectedOrderList.value = OrderListType.numberedList;
|
||||||
|
} else if (settings.isUl) {
|
||||||
|
selectedOrderList.value = OrderListType.bulletedList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateParagraph(EditorSettings settings) {
|
||||||
if (settings.isAlignCenter) {
|
if (settings.isAlignCenter) {
|
||||||
selectedParagraph.value = ParagraphType.alignCenter;
|
selectedParagraph.value = ParagraphType.alignCenter;
|
||||||
} else if (settings.isAlignJustify) {
|
} else if (settings.isAlignJustify) {
|
||||||
@@ -81,12 +113,6 @@ class RichTextWebController extends BaseRichTextController {
|
|||||||
} else if (settings.isAlignRight) {
|
} else if (settings.isAlignRight) {
|
||||||
selectedParagraph.value = ParagraphType.alignRight;
|
selectedParagraph.value = ParagraphType.alignRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.isOl) {
|
|
||||||
selectedOrderList.value = OrderListType.numberedList;
|
|
||||||
} else if (settings.isUl) {
|
|
||||||
selectedOrderList.value = OrderListType.bulletedList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyRichTextStyle(BuildContext context, RichTextStyleType textStyleType) {
|
void applyRichTextStyle(BuildContext context, RichTextStyleType textStyleType) {
|
||||||
@@ -157,8 +183,8 @@ class RichTextWebController extends BaseRichTextController {
|
|||||||
final fontSelected = newFont ?? FontNameType.sansSerif;
|
final fontSelected = newFont ?? FontNameType.sansSerif;
|
||||||
selectedFontName.value = fontSelected;
|
selectedFontName.value = fontSelected;
|
||||||
editorController.execCommand(
|
editorController.execCommand(
|
||||||
RichTextStyleType.fontName.commandAction,
|
RichTextStyleType.fontName.commandAction,
|
||||||
argument: fontSelected.fontFamily);
|
argument: fontSelected.value);
|
||||||
editorController.setFocus();
|
editorController.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ enum FontNameType {
|
|||||||
sansSerif,
|
sansSerif,
|
||||||
verdana;
|
verdana;
|
||||||
|
|
||||||
String get fontFamily {
|
String get title {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
case FontNameType.arial:
|
case FontNameType.arial:
|
||||||
return 'Arial';
|
return 'Arial';
|
||||||
@@ -47,4 +47,37 @@ enum FontNameType {
|
|||||||
return 'Verdana';
|
return 'Verdana';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get value {
|
||||||
|
switch(this) {
|
||||||
|
case FontNameType.arial:
|
||||||
|
return 'Arial';
|
||||||
|
case FontNameType.arialBlack:
|
||||||
|
return 'Arial Black';
|
||||||
|
case FontNameType.brushScriptMT:
|
||||||
|
return 'Brush Script MT';
|
||||||
|
case FontNameType.comicSansMS:
|
||||||
|
return 'Comic Sans MS';
|
||||||
|
case FontNameType.courierNew:
|
||||||
|
return 'Courier New';
|
||||||
|
case FontNameType.helveticaNeue:
|
||||||
|
return 'Helvetica Neue';
|
||||||
|
case FontNameType.helvetica:
|
||||||
|
return 'Helvetica';
|
||||||
|
case FontNameType.impact:
|
||||||
|
return 'Impact';
|
||||||
|
case FontNameType.lucidaGrande:
|
||||||
|
return 'Lucida Grande';
|
||||||
|
case FontNameType.tahoma:
|
||||||
|
return 'Tahoma';
|
||||||
|
case FontNameType.timesNewRoman:
|
||||||
|
return 'Times New Roman';
|
||||||
|
case FontNameType.trebuchetMS:
|
||||||
|
return 'Trebuchet MS';
|
||||||
|
case FontNameType.sansSerif:
|
||||||
|
return 'sans-serif';
|
||||||
|
case FontNameType.verdana:
|
||||||
|
return 'Verdana';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user