@@ -1101,108 +1101,108 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
11011101 newColor = _backColorSelected;
11021102 }
11031103 await showDialog (
1104- context: context,
1105- builder: (BuildContext context) {
1106- return PointerInterceptor (
1107- child: AlertDialog (
1108- scrollable: true ,
1109- content: ColorPicker (
1110- color: newColor,
1111- onColorChanged: (color) {
1112- newColor = color;
1113- },
1114- title: Text ('Choose a Color' ,
1115- style: Theme .of (context).textTheme.headline6),
1116- width: 40 ,
1117- height: 40 ,
1118- spacing: 0 ,
1119- runSpacing: 0 ,
1120- borderRadius: 0 ,
1121- wheelDiameter: 165 ,
1122- enableOpacity: false ,
1123- showColorCode: true ,
1124- colorCodeHasColor: true ,
1125- pickersEnabled: < ColorPickerType , bool > {
1126- ColorPickerType .wheel: true ,
1127- },
1128- copyPasteBehavior: const ColorPickerCopyPasteBehavior (
1129- parseShortHexCode: true ,
1130- ),
1131- actionButtons: const ColorPickerActionButtons (
1132- dialogActionButtons: true ,
1133- ),
1134- ),
1135- actions: < Widget > [
1136- TextButton (
1137- onPressed: () {
1138- Navigator .of (context).pop ();
1104+ context: context,
1105+ builder: (BuildContext context) {
1106+ return PointerInterceptor (
1107+ child: AlertDialog (
1108+ scrollable: true ,
1109+ content: ColorPicker (
1110+ color: newColor,
1111+ onColorChanged: (color) {
1112+ newColor = color;
11391113 },
1140- child: Text ('Cancel' ),
1114+ title: Text ('Choose a Color' ,
1115+ style: Theme .of (context).textTheme.headline6),
1116+ width: 40 ,
1117+ height: 40 ,
1118+ spacing: 0 ,
1119+ runSpacing: 0 ,
1120+ borderRadius: 0 ,
1121+ wheelDiameter: 165 ,
1122+ enableOpacity: false ,
1123+ showColorCode: true ,
1124+ colorCodeHasColor: true ,
1125+ pickersEnabled: < ColorPickerType , bool > {
1126+ ColorPickerType .wheel: true ,
1127+ },
1128+ copyPasteBehavior:
1129+ const ColorPickerCopyPasteBehavior (
1130+ parseShortHexCode: true ,
1131+ ),
1132+ actionButtons: const ColorPickerActionButtons (
1133+ dialogActionButtons: true ,
1134+ ),
11411135 ),
1142- TextButton (
1136+ actions: < Widget > [
1137+ TextButton (
1138+ onPressed: () {
1139+ Navigator .of (context).pop ();
1140+ },
1141+ child: Text ('Cancel' ),
1142+ ),
1143+ TextButton (
1144+ onPressed: () {
1145+ if (t.getIcons ()[index].icon ==
1146+ Icons .format_color_text) {
1147+ setState (mounted, this .setState, () {
1148+ _foreColorSelected = Colors .black;
1149+ });
1150+ widget.controller.execCommand (
1151+ 'removeFormat' ,
1152+ argument: 'foreColor' );
1153+ widget.controller.execCommand ('foreColor' ,
1154+ argument: 'initial' );
1155+ }
1156+ if (t.getIcons ()[index].icon ==
1157+ Icons .format_color_fill) {
1158+ setState (mounted, this .setState, () {
1159+ _backColorSelected = Colors .yellow;
1160+ });
1161+ widget.controller.execCommand (
1162+ 'removeFormat' ,
1163+ argument: 'hiliteColor' );
1164+ widget.controller.execCommand ('hiliteColor' ,
1165+ argument: 'initial' );
1166+ }
1167+ Navigator .of (context).pop ();
1168+ },
1169+ child: Text ('Reset to default color' )),
1170+ TextButton (
11431171 onPressed: () {
11441172 if (t.getIcons ()[index].icon ==
11451173 Icons .format_color_text) {
1174+ widget.controller.execCommand ('foreColor' ,
1175+ argument: (newColor.value & 0xFFFFFF )
1176+ .toRadixString (16 )
1177+ .padLeft (6 , '0' )
1178+ .toUpperCase ());
11461179 setState (mounted, this .setState, () {
1147- _foreColorSelected = Colors .black ;
1180+ _foreColorSelected = newColor ;
11481181 });
1149- widget.controller.execCommand (
1150- 'removeFormat' ,
1151- argument: 'foreColor' );
1152- widget.controller.execCommand ('foreColor' ,
1153- argument: 'initial' );
11541182 }
11551183 if (t.getIcons ()[index].icon ==
11561184 Icons .format_color_fill) {
1185+ widget.controller.execCommand ('hiliteColor' ,
1186+ argument: (newColor.value & 0xFFFFFF )
1187+ .toRadixString (16 )
1188+ .padLeft (6 , '0' )
1189+ .toUpperCase ());
11571190 setState (mounted, this .setState, () {
1158- _backColorSelected = Colors .yellow ;
1191+ _backColorSelected = newColor ;
11591192 });
1160- widget.controller.execCommand (
1161- 'removeFormat' ,
1162- argument: 'hiliteColor' );
1163- widget.controller.execCommand ('hiliteColor' ,
1164- argument: 'initial' );
11651193 }
1166- Navigator .of (context).pop ();
1167- },
1168- child: Text ('Reset to default color' )),
1169- TextButton (
1170- onPressed: () {
1171- if (t.getIcons ()[index].icon ==
1172- Icons .format_color_text) {
1173- widget.controller.execCommand ('foreColor' ,
1174- argument: (newColor.value & 0xFFFFFF )
1175- .toRadixString (16 )
1176- .padLeft (6 , '0' )
1177- .toUpperCase ());
11781194 setState (mounted, this .setState, () {
1179- _foreColorSelected = newColor;
1195+ _colorSelected[index] =
1196+ ! _colorSelected[index];
11801197 });
1181- }
1182- if (t.getIcons ()[index].icon ==
1183- Icons .format_color_fill) {
1184- widget.controller.execCommand ('hiliteColor' ,
1185- argument: (newColor.value & 0xFFFFFF )
1186- .toRadixString (16 )
1187- .padLeft (6 , '0' )
1188- .toUpperCase ());
1189- setState (mounted, this .setState, () {
1190- _backColorSelected = newColor;
1191- });
1192- }
1193- setState (mounted, this .setState, () {
1194- _colorSelected[index] =
1195- ! _colorSelected[index];
1196- });
1197- Navigator .of (context).pop ();
1198- },
1199- child: Text ('Set color' ),
1200- )
1201- ],
1202- ),
1203- );
1204- }
1205- );
1198+ Navigator .of (context).pop ();
1199+ },
1200+ child: Text ('Set color' ),
1201+ )
1202+ ],
1203+ ),
1204+ );
1205+ });
12061206 }
12071207 }
12081208 },
0 commit comments