Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theming Slider control #573

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package/lib/src/controls/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../flet_app_services.dart';
import '../models/app_state.dart';
import '../models/control.dart';
import '../protocol/update_control_props_payload.dart';
import '../utils/colors.dart';
import 'create_control.dart';

class SliderControl extends StatefulWidget {
Expand Down Expand Up @@ -108,6 +109,12 @@ class _SliderControlState extends State<SliderControl> {
max: max,
divisions: divisions,
label: label?.replaceAll("{value}", _value.toString()),
activeColor: HexColor.fromString(Theme.of(context),
widget.control.attrString("activeColor", "")!),
inactiveColor: HexColor.fromString(Theme.of(context),
widget.control.attrString("inactiveColor", "")!),
thumbColor: HexColor.fromString(Theme.of(context),
widget.control.attrString("thumbColor", "")!),
onChanged: !disabled
? (double value) {
onChange(value, dispatch);
Expand Down
33 changes: 33 additions & 0 deletions sdk/python/flet/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def __init__(
max: OptionalNumber = None,
divisions: Optional[int] = None,
autofocus: Optional[bool] = None,
active_color: Optional[str] = None,
inactive_color: Optional[str] = None,
thumb_color: Optional[str] = None,
on_change=None,
on_focus=None,
on_blur=None,
Expand Down Expand Up @@ -89,6 +92,9 @@ def __init__(
self.max = max
self.divisions = divisions
self.autofocus = autofocus
self.active_color = active_color
self.inactive_color = inactive_color
self.thumb_color = thumb_color
self.on_change = on_change
self.on_focus = on_focus
self.on_blur = on_blur
Expand Down Expand Up @@ -155,6 +161,33 @@ def autofocus(self) -> Optional[bool]:
def autofocus(self, value: Optional[bool]):
self._set_attr("autofocus", value)

# active_color
@property
def active_color(self):
return self._get_attr("activeColor")

@active_color.setter
def active_color(self, value):
self._set_attr("activeColor", value)

# inactive_color
@property
def inactive_color(self):
return self._get_attr("inactiveColor")

@inactive_color.setter
def inactive_color(self, value):
self._set_attr("inactiveColor", value)

# thumb_color
@property
def thumb_color(self):
return self._get_attr("thumbColor")

@thumb_color.setter
def thumb_color(self, value):
self._set_attr("thumbColor", value)

# on_change
@property
def on_change(self):
Expand Down