| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import 'package:flutter/material.dart';
- import '../../core/theme/app_colors.dart';
- /// Shared Settings switch styling so each card matches the rest of the page.
- class SettingsSwitch extends StatelessWidget {
- const SettingsSwitch({
- super.key,
- required this.value,
- required this.onChanged,
- required this.semanticsLabel,
- });
- final bool value;
- final ValueChanged<bool> onChanged;
- final String semanticsLabel;
- @override
- Widget build(BuildContext context) {
- final colors = context.colors;
- return Semantics(
- label: semanticsLabel,
- child: Switch(
- value: value,
- onChanged: onChanged,
- thumbColor: WidgetStateProperty.resolveWith<Color?>(
- (states) => states.contains(WidgetState.selected)
- ? colors.accentInk
- : colors.inkFaint,
- ),
- trackColor: WidgetStateProperty.resolveWith<Color?>(
- (states) => states.contains(WidgetState.selected)
- ? colors.accent
- : colors.surfaceStrong,
- ),
- trackOutlineColor: WidgetStatePropertyAll(colors.border),
- ),
- );
- }
- }
|