diff --git a/forui/lib/src/widgets/switch.dart b/forui/lib/src/widgets/switch.dart index 31b7570b9..e7d71306a 100644 --- a/forui/lib/src/widgets/switch.dart +++ b/forui/lib/src/widgets/switch.dart @@ -77,9 +77,9 @@ class FSwitch extends StatelessWidget { /// Creates a [FSwitch]. const FSwitch({ required this.value, + required this.onChanged, super.key, this.style, - this.onChanged, this.autofocus = false, this.focusNode, this.onFocusChange, @@ -92,14 +92,14 @@ class FSwitch extends StatelessWidget { return CupertinoSwitch( value: value, onChanged: onChanged, - // activeColor: style.checked, - // trackColor: style.unchecked, - // thumbColor: style.thumb, - // focusColor: style.focus, - // autofocus: autofocus, - // focusNode: focusNode, - // onFocusChange: onFocusChange, - // dragStartBehavior: dragStartBehavior, + activeColor: style.checked, + trackColor: style.unchecked, + thumbColor: style.thumb, + focusColor: style.focus, + autofocus: autofocus, + focusNode: focusNode, + onFocusChange: onFocusChange, + dragStartBehavior: dragStartBehavior, ); } diff --git a/forui/test/golden/switch/zinc-dark-checked-disabled.png b/forui/test/golden/switch/zinc-dark-checked-disabled.png new file mode 100644 index 000000000..9edb34764 Binary files /dev/null and b/forui/test/golden/switch/zinc-dark-checked-disabled.png differ diff --git a/forui/test/golden/switch/zinc-dark-checked-focused.png b/forui/test/golden/switch/zinc-dark-checked-focused.png new file mode 100644 index 000000000..6e215403c Binary files /dev/null and b/forui/test/golden/switch/zinc-dark-checked-focused.png differ diff --git a/forui/test/golden/switch/zinc-dark-checked-unfocused.png b/forui/test/golden/switch/zinc-dark-checked-unfocused.png index c427ff84e..6e215403c 100644 Binary files a/forui/test/golden/switch/zinc-dark-checked-unfocused.png and b/forui/test/golden/switch/zinc-dark-checked-unfocused.png differ diff --git a/forui/test/golden/switch/zinc-dark-unchecked-disabled.png b/forui/test/golden/switch/zinc-dark-unchecked-disabled.png new file mode 100644 index 000000000..3c075c60a Binary files /dev/null and b/forui/test/golden/switch/zinc-dark-unchecked-disabled.png differ diff --git a/forui/test/golden/switch/zinc-dark-unchecked-focused.png b/forui/test/golden/switch/zinc-dark-unchecked-focused.png new file mode 100644 index 000000000..c77c254de Binary files /dev/null and b/forui/test/golden/switch/zinc-dark-unchecked-focused.png differ diff --git a/forui/test/golden/switch/zinc-dark-unchecked-unfocused.png b/forui/test/golden/switch/zinc-dark-unchecked-unfocused.png index 3c075c60a..c77c254de 100644 Binary files a/forui/test/golden/switch/zinc-dark-unchecked-unfocused.png and b/forui/test/golden/switch/zinc-dark-unchecked-unfocused.png differ diff --git a/forui/test/golden/switch/zinc-light-checked-disabled.png b/forui/test/golden/switch/zinc-light-checked-disabled.png new file mode 100644 index 000000000..8d161b3b9 Binary files /dev/null and b/forui/test/golden/switch/zinc-light-checked-disabled.png differ diff --git a/forui/test/golden/switch/zinc-light-checked-focused.png b/forui/test/golden/switch/zinc-light-checked-focused.png new file mode 100644 index 000000000..27ef8b8ce Binary files /dev/null and b/forui/test/golden/switch/zinc-light-checked-focused.png differ diff --git a/forui/test/golden/switch/zinc-light-checked-unfocused.png b/forui/test/golden/switch/zinc-light-checked-unfocused.png index 683dbc6eb..27ef8b8ce 100644 Binary files a/forui/test/golden/switch/zinc-light-checked-unfocused.png and b/forui/test/golden/switch/zinc-light-checked-unfocused.png differ diff --git a/forui/test/golden/switch/zinc-light-unchecked-disabled.png b/forui/test/golden/switch/zinc-light-unchecked-disabled.png new file mode 100644 index 000000000..db304ca9b Binary files /dev/null and b/forui/test/golden/switch/zinc-light-unchecked-disabled.png differ diff --git a/forui/test/golden/switch/zinc-light-unchecked-focused.png b/forui/test/golden/switch/zinc-light-unchecked-focused.png new file mode 100644 index 000000000..d952fa6e2 Binary files /dev/null and b/forui/test/golden/switch/zinc-light-unchecked-focused.png differ diff --git a/forui/test/golden/switch/zinc-light-unchecked-unfocused.png b/forui/test/golden/switch/zinc-light-unchecked-unfocused.png index db304ca9b..d952fa6e2 100644 Binary files a/forui/test/golden/switch/zinc-light-unchecked-unfocused.png and b/forui/test/golden/switch/zinc-light-unchecked-unfocused.png differ diff --git a/forui/test/src/widgets/switch_test.dart b/forui/test/src/widgets/switch_test.dart index a29580737..f237459da 100644 --- a/forui/test/src/widgets/switch_test.dart +++ b/forui/test/src/widgets/switch_test.dart @@ -7,13 +7,16 @@ import '../test_scaffold.dart'; void main() { group('FSeparator', () { for (final (name, theme, _) in TestScaffold.themes) { - for (final (checked, value) in [('checked', true)]) { + for (final (checked, value) in [('checked', true), ('unchecked', false)]) { testWidgets('$name - $checked - unfocused', (tester) async { await tester.pumpWidget( TestScaffold( data: theme, child: Center( - child: FSwitch(value: value), + child: FSwitch( + value: value, + onChanged: (_) {}, + ), ), ), ); @@ -23,6 +26,46 @@ void main() { matchesGoldenFile('switch/$name-$checked-unfocused.png'), ); }); + + testWidgets('$name - $checked - focused', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Center( + child: FSwitch( + value: value, + autofocus: true, + onChanged: (_) {}, + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('switch/$name-$checked-focused.png'), + ); + }); + + testWidgets('$name - $checked - disabled', (tester) async { + await tester.pumpWidget( + TestScaffold( + data: theme, + child: Center( + child: FSwitch( + value: value, + autofocus: true, + onChanged: null, + ), + ), + ), + ); + + await expectLater( + find.byType(TestScaffold), + matchesGoldenFile('switch/$name-$checked-disabled.png'), + ); + }); } } });