Skip to content

Commit

Permalink
Set the default background color of the text to white
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed May 31, 2023
1 parent dc173ea commit c2988da
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/src/widgets/toolbar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
Color _foreColorSelected = Colors.black;

/// Sets the selected item for the background color dialog
Color _backColorSelected = Colors.yellow;
Color _backColorSelected = Colors.white;

/// Sets the selected item for the list style dropdown
String? _listStyleSelectedItem;
Expand Down Expand Up @@ -131,6 +131,7 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
/// Updates the toolbar from the JS handler on mobile and the onMessage
/// listener on web
void updateToolbar(Map<String, dynamic> json) {
debugPrint('ToolbarWidget::updateToolbar::json: $json');
//get parent element
String parentElem = json['style'] ?? '';
//get font name
Expand Down Expand Up @@ -174,6 +175,7 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
_fontNameSelectedItem = 'sans-serif';
});
}
debugPrint('ToolbarWidget::updateToolbar::colorList: $colorList');
//update the fore/back selected color if necessary
if (colorList[0] != null && colorList[0]!.isNotEmpty) {
setState(mounted, this.setState, () {
Expand All @@ -189,12 +191,18 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
}
if (colorList[1] != null && colorList[1]!.isNotEmpty) {
setState(mounted, this.setState, () {
_backColorSelected =
Color(int.parse(colorList[1]!, radix: 16) + 0xFF000000);
var rgb = colorList[1]!.replaceAll('rgb(', '').replaceAll(')', '');
var rgbList = rgb.split(', ');
_backColorSelected = Color.fromRGBO(
int.parse(rgbList[0]),
int.parse(rgbList[1]),
int.parse(rgbList[2]),
1
);
});
} else {
setState(mounted, this.setState, () {
_backColorSelected = Colors.yellow;
_backColorSelected = Colors.white;
});
}
//check the list style if it matches one of the predetermined styles and update the toolbar
Expand Down Expand Up @@ -1092,7 +1100,7 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
true;
if (proceed) {
widget.controller.execCommand('hiliteColor',
argument: (Colors.yellow.value & 0xFFFFFF)
argument: (Colors.white.value & 0xFFFFFF)
.toRadixString(16)
.padLeft(6, '0')
.toUpperCase());
Expand Down Expand Up @@ -1180,7 +1188,7 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
if (t.getIcons()[index].icon ==
Icons.format_color_fill) {
setState(mounted, this.setState, () {
_backColorSelected = Colors.yellow;
_backColorSelected = Colors.white;
});
widget.controller.execCommand(
'removeFormat',
Expand Down

0 comments on commit c2988da

Please sign in to comment.