settings_widgets.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:flutter/material.dart';
  2. import '../../core/theme/app_colors.dart';
  3. /// Shared Settings switch styling so each card matches the rest of the page.
  4. class SettingsSwitch extends StatelessWidget {
  5. const SettingsSwitch({
  6. super.key,
  7. required this.value,
  8. required this.onChanged,
  9. required this.semanticsLabel,
  10. });
  11. final bool value;
  12. final ValueChanged<bool> onChanged;
  13. final String semanticsLabel;
  14. @override
  15. Widget build(BuildContext context) {
  16. final colors = context.colors;
  17. return Semantics(
  18. label: semanticsLabel,
  19. child: Switch(
  20. value: value,
  21. onChanged: onChanged,
  22. thumbColor: WidgetStateProperty.resolveWith<Color?>(
  23. (states) => states.contains(WidgetState.selected)
  24. ? colors.accentInk
  25. : colors.inkFaint,
  26. ),
  27. trackColor: WidgetStateProperty.resolveWith<Color?>(
  28. (states) => states.contains(WidgetState.selected)
  29. ? colors.accent
  30. : colors.surfaceStrong,
  31. ),
  32. trackOutlineColor: WidgetStatePropertyAll(colors.border),
  33. ),
  34. );
  35. }
  36. }