Skip to content

Commit d94cecf

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

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/src/_paint_over_image.dart

Lines changed: 27 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.optionsBackgroundColor,
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? optionsSelectedBackgroundColor,
83+
Color? optionsBackgroundColor,
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: optionsSelectedBackgroundColor,
111+
optionsBackgroundColor: optionsBackgroundColor,
106112
);
107113
}
108114

@@ -132,6 +138,8 @@ class ImagePainter extends StatefulWidget {
132138
Color? optionColor,
133139
VoidCallback? onUndo,
134140
VoidCallback? onClear,
141+
Color? optionsSelectedBackgroundColor,
142+
Color? optionsBackgroundColor,
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: optionsSelectedBackgroundColor,
170+
optionsBackgroundColor: optionsBackgroundColor,
161171
);
162172
}
163173

@@ -187,6 +197,8 @@ class ImagePainter extends StatefulWidget {
187197
Color? optionColor,
188198
VoidCallback? onUndo,
189199
VoidCallback? onClear,
200+
Color? optionsSelectedBackgroundColor,
201+
Color? optionsBackgroundColor,
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: optionsSelectedBackgroundColor,
229+
optionsBackgroundColor: optionsBackgroundColor,
216230
);
217231
}
218232

@@ -242,6 +256,8 @@ class ImagePainter extends StatefulWidget {
242256
Color? optionColor,
243257
VoidCallback? onUndo,
244258
VoidCallback? onClear,
259+
Color? optionsSelectedBackgroundColor,
260+
Color? optionsBackgroundColor,
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: optionsSelectedBackgroundColor,
288+
optionsBackgroundColor: optionsBackgroundColor,
271289
);
272290
}
273291

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

394412
final Color? optionSelectedColor;
395413

414+
/// The background color of the selected option in the options list.
415+
final Color? optionSelectedBackgroundColor;
416+
417+
/// The background color of the options list.
418+
final Color? optionsBackgroundColor;
419+
396420
final Color? optionUnselectedColor;
397421

398422
final Color? optionColor;
@@ -718,6 +742,8 @@ class ImagePainterState extends State<ImagePainter> {
718742
data: item,
719743
isSelected: _controller.mode == item.mode,
720744
selectedColor: widget.optionSelectedColor,
745+
selectedBackgroundColor:
746+
widget.optionSelectedBackgroundColor,
721747
unselectedColor: widget.optionUnselectedColor,
722748
onTap: () {
723749
if (widget.onPaintModeChanged != null) {
@@ -834,6 +860,7 @@ class ImagePainterState extends State<ImagePainter> {
834860
.firstWhere((item) => item.mode == _controller.mode)
835861
.icon;
836862
return PopupMenuButton(
863+
color: widget.optionsBackgroundColor,
837864
tooltip: textDelegate.changeMode,
838865
shape: ContinuousRectangleBorder(
839866
borderRadius: BorderRadius.circular(40),

lib/src/widgets/_mode_widget.dart

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

1213
const SelectionItems({
1314
required this.data,
@@ -16,15 +17,19 @@ class SelectionItems extends StatelessWidget {
1617
this.onTap,
1718
this.selectedColor,
1819
this.unselectedColor,
20+
this.selectedBackgroundColor,
1921
}) : super(key: key);
2022

2123
@override
2224
Widget build(BuildContext context) {
2325
return Container(
2426
margin: const EdgeInsets.symmetric(vertical: 2.0),
2527
decoration: BoxDecoration(
26-
borderRadius: BorderRadius.circular(4.0),
27-
color: isSelected ? Colors.blue : Colors.transparent),
28+
borderRadius: BorderRadius.circular(4.0),
29+
color: isSelected
30+
? selectedBackgroundColor ?? Colors.blue
31+
: Colors.transparent,
32+
),
2833
child: ListTile(
2934
leading: IconTheme(
3035
data: const IconThemeData(opacity: 1.0),

0 commit comments

Comments
 (0)