Skip to content

Commit f1e7c06

Browse files
committed
Switch improvements
- Add `trackOutlineColor`, 'trackOutlineWidth' and `useMaterial3` properties for SwitchNode.
1 parent a79f074 commit f1e7c06

File tree

2 files changed

+64
-11
lines changed

2 files changed

+64
-11
lines changed

lib/src/api/nodes/switch_node.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ class SwitchProperties with SerializableMixin, EquatableMixin {
131131
/// Whether to focus on the switch automatically.
132132
late bool autofocus;
133133

134+
late ColorRGBA? activeTrackBorderColor;
135+
136+
late ColorRGBA? inactiveTrackBorderColor;
137+
138+
late double trackOutlineWidth;
139+
140+
late bool useMaterial3;
141+
134142
/// Creates a [SwitchProperties] instance with the given data.
135143
SwitchProperties({
136144
this.activeTrackColor = ColorRGBA.black,
@@ -141,6 +149,10 @@ class SwitchProperties with SerializableMixin, EquatableMixin {
141149
this.focusColor = ColorRGBA.grey10,
142150
this.splashRadius = kRadialReactionRadius,
143151
this.autofocus = false,
152+
this.activeTrackBorderColor = ColorRGBA.transparent,
153+
this.inactiveTrackBorderColor = ColorRGBA.transparent,
154+
this.trackOutlineWidth = 2,
155+
this.useMaterial3 = false,
144156
});
145157

146158
/// Duplicates this [SwitchProperties] instance with the given data
@@ -154,6 +166,12 @@ class SwitchProperties with SerializableMixin, EquatableMixin {
154166
ColorRGBA? focusColor,
155167
double? splashRadius,
156168
bool? autofocus,
169+
ColorRGBA? activeTrackBorderColor,
170+
ColorRGBA? inactiveTrackBorderColor,
171+
bool forceActiveTrackBorderColor = false,
172+
bool forceInactiveTrackBorderColor = false,
173+
double? trackOutlineWidth,
174+
bool? useMaterial3,
157175
}) {
158176
return SwitchProperties(
159177
activeTrackColor: activeTrackColor ?? this.activeTrackColor,
@@ -164,6 +182,14 @@ class SwitchProperties with SerializableMixin, EquatableMixin {
164182
focusColor: focusColor ?? this.focusColor,
165183
splashRadius: splashRadius ?? this.splashRadius,
166184
autofocus: autofocus ?? this.autofocus,
185+
activeTrackBorderColor: forceActiveTrackBorderColor
186+
? activeTrackBorderColor
187+
: activeTrackBorderColor ?? this.activeTrackBorderColor,
188+
inactiveTrackBorderColor: forceInactiveTrackBorderColor
189+
? inactiveTrackBorderColor
190+
: inactiveTrackBorderColor ?? this.inactiveTrackBorderColor,
191+
trackOutlineWidth: trackOutlineWidth ?? this.trackOutlineWidth,
192+
useMaterial3: useMaterial3 ?? this.useMaterial3,
167193
);
168194
}
169195

@@ -177,6 +203,10 @@ class SwitchProperties with SerializableMixin, EquatableMixin {
177203
focusColor,
178204
splashRadius,
179205
autofocus,
206+
activeTrackBorderColor,
207+
inactiveTrackBorderColor,
208+
trackOutlineWidth,
209+
useMaterial3,
180210
];
181211

182212
/// Creates a [SwitchProperties] instance from a JSON object.

lib/src/api/nodes/switch_node.g.dart

Lines changed: 34 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)