Skip to content

Commit f9b6aab

Browse files
author
Lockie Richter
committed
Add background color parameter for options
1 parent c8bf4cc commit f9b6aab

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/src/_paint_over_image.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class ImagePainter extends StatefulWidget {
4949
this.optionColor,
5050
this.onUndo,
5151
this.onClear,
52+
this.optionSelectedBackgroundColor,
53+
this.optionUnselectedBackgroundColor,
5254
}) : super(key: key);
5355

5456
///Constructor for loading image from network url.
@@ -77,6 +79,8 @@ class ImagePainter extends StatefulWidget {
7779
Color? optionColor,
7880
VoidCallback? onUndo,
7981
VoidCallback? onClear,
82+
Color? selectedBackgroundColor,
83+
Color? unselectedBackgroundColor,
8084
}) {
8185
return ImagePainter._(
8286
key: key,
@@ -103,6 +107,8 @@ class ImagePainter extends StatefulWidget {
103107
optionColor: optionColor,
104108
onUndo: onUndo,
105109
onClear: onClear,
110+
optionSelectedBackgroundColor: selectedBackgroundColor,
111+
optionUnselectedBackgroundColor: unselectedBackgroundColor,
106112
);
107113
}
108114

@@ -132,6 +138,8 @@ class ImagePainter extends StatefulWidget {
132138
Color? optionColor,
133139
VoidCallback? onUndo,
134140
VoidCallback? onClear,
141+
Color? selectedBackgroundColor,
142+
Color? unselectedBackgroundColor,
135143
}) {
136144
return ImagePainter._(
137145
controller: controller,
@@ -158,6 +166,8 @@ class ImagePainter extends StatefulWidget {
158166
optionColor: optionColor,
159167
onUndo: onUndo,
160168
onClear: onClear,
169+
optionSelectedBackgroundColor: selectedBackgroundColor,
170+
optionUnselectedBackgroundColor: unselectedBackgroundColor,
161171
);
162172
}
163173

@@ -187,6 +197,8 @@ class ImagePainter extends StatefulWidget {
187197
Color? optionColor,
188198
VoidCallback? onUndo,
189199
VoidCallback? onClear,
200+
Color? selectedBackgroundColor,
201+
Color? unselectedBackgroundColor,
190202
}) {
191203
return ImagePainter._(
192204
controller: controller,
@@ -213,6 +225,8 @@ class ImagePainter extends StatefulWidget {
213225
optionColor: optionColor,
214226
onUndo: onUndo,
215227
onClear: onClear,
228+
optionSelectedBackgroundColor: selectedBackgroundColor,
229+
optionUnselectedBackgroundColor: unselectedBackgroundColor,
216230
);
217231
}
218232

@@ -242,6 +256,8 @@ class ImagePainter extends StatefulWidget {
242256
Color? optionColor,
243257
VoidCallback? onUndo,
244258
VoidCallback? onClear,
259+
Color? selectedBackgroundColor,
260+
Color? unselectedBackgroundColor,
245261
}) {
246262
return ImagePainter._(
247263
controller: controller,
@@ -268,6 +284,8 @@ class ImagePainter extends StatefulWidget {
268284
optionColor: optionColor,
269285
onUndo: onUndo,
270286
onClear: onClear,
287+
optionSelectedBackgroundColor: selectedBackgroundColor,
288+
optionUnselectedBackgroundColor: unselectedBackgroundColor,
271289
);
272290
}
273291

@@ -393,8 +411,12 @@ class ImagePainter extends StatefulWidget {
393411

394412
final Color? optionSelectedColor;
395413

414+
final Color? optionSelectedBackgroundColor;
415+
396416
final Color? optionUnselectedColor;
397417

418+
final Color? optionUnselectedBackgroundColor;
419+
398420
final Color? optionColor;
399421

400422
final VoidCallback? onUndo;
@@ -718,7 +740,11 @@ class ImagePainterState extends State<ImagePainter> {
718740
data: item,
719741
isSelected: _controller.mode == item.mode,
720742
selectedColor: widget.optionSelectedColor,
743+
selectedBackgroundColor:
744+
widget.optionSelectedBackgroundColor,
721745
unselectedColor: widget.optionUnselectedColor,
746+
unselectedBackgroundColor:
747+
widget.optionUnselectedBackgroundColor,
722748
onTap: () {
723749
if (widget.onPaintModeChanged != null) {
724750
widget.onPaintModeChanged!(item.mode);

lib/src/widgets/_mode_widget.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class SelectionItems extends StatelessWidget {
88
final VoidCallback? onTap;
99
final Color? selectedColor;
1010
final Color? unselectedColor;
11+
final Color? selectedBackgroundColor;
12+
final Color? unselectedBackgroundColor;
1113

1214
const SelectionItems({
1315
required this.data,
@@ -16,6 +18,8 @@ class SelectionItems extends StatelessWidget {
1618
this.onTap,
1719
this.selectedColor,
1820
this.unselectedColor,
21+
this.selectedBackgroundColor,
22+
this.unselectedBackgroundColor,
1923
}) : super(key: key);
2024

2125
@override
@@ -24,7 +28,9 @@ class SelectionItems extends StatelessWidget {
2428
margin: const EdgeInsets.symmetric(vertical: 2.0),
2529
decoration: BoxDecoration(
2630
borderRadius: BorderRadius.circular(4.0),
27-
color: isSelected ? Colors.blue : Colors.transparent),
31+
color: isSelected
32+
? selectedBackgroundColor ?? Colors.blue
33+
: unselectedBackgroundColor ?? Colors.transparent),
2834
child: ListTile(
2935
leading: IconTheme(
3036
data: const IconThemeData(opacity: 1.0),

0 commit comments

Comments
 (0)