mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Enforce theme colors on switches
This commit is contained in:
@@ -774,7 +774,7 @@ class SensorMetricSelectorItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Switch.adaptive(value: visible, onChanged: onToggle),
|
Switch(value: visible, onChanged: onToggle),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
|
|||||||
@@ -1875,7 +1875,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Switch.adaptive(
|
Switch(
|
||||||
value: _showCurrentImagePreview,
|
value: _showCurrentImagePreview,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() => _showCurrentImagePreview = value);
|
setState(() => _showCurrentImagePreview = value);
|
||||||
|
|||||||
@@ -1,27 +1,50 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
enum AppThemeMode {
|
enum AppThemeMode { light, dark, sarRed, sarGreen, sarNavyBlue, system }
|
||||||
light,
|
|
||||||
dark,
|
|
||||||
sarRed,
|
|
||||||
sarGreen,
|
|
||||||
sarNavyBlue,
|
|
||||||
system,
|
|
||||||
}
|
|
||||||
|
|
||||||
class AppTheme {
|
class AppTheme {
|
||||||
|
static ThemeData _withSharedControls(ThemeData theme) {
|
||||||
|
final colorScheme = theme.colorScheme;
|
||||||
|
return theme.copyWith(
|
||||||
|
switchTheme: SwitchThemeData(
|
||||||
|
thumbColor: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.disabled)) {
|
||||||
|
return colorScheme.onSurface.withValues(alpha: 0.38);
|
||||||
|
}
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return colorScheme.onPrimary;
|
||||||
|
}
|
||||||
|
return colorScheme.outline;
|
||||||
|
}),
|
||||||
|
trackColor: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.disabled)) {
|
||||||
|
return colorScheme.onSurface.withValues(alpha: 0.12);
|
||||||
|
}
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return colorScheme.primary;
|
||||||
|
}
|
||||||
|
return colorScheme.surfaceContainerHighest;
|
||||||
|
}),
|
||||||
|
trackOutlineColor: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return colorScheme.primary;
|
||||||
|
}
|
||||||
|
return colorScheme.outlineVariant;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Light theme (Blue)
|
// Light theme (Blue)
|
||||||
static ThemeData get lightTheme {
|
static ThemeData get lightTheme {
|
||||||
return ThemeData(
|
return _withSharedControls(
|
||||||
|
ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: ColorScheme.fromSeed(
|
colorScheme: ColorScheme.fromSeed(
|
||||||
seedColor: Colors.blue,
|
seedColor: Colors.blue,
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
),
|
),
|
||||||
appBarTheme: const AppBarTheme(
|
appBarTheme: const AppBarTheme(centerTitle: true, elevation: 0),
|
||||||
centerTitle: true,
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
cardTheme: CardThemeData(
|
cardTheme: CardThemeData(
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
@@ -29,26 +52,23 @@ class AppTheme {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
filled: true,
|
filled: true,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dark theme (Blue)
|
// Dark theme (Blue)
|
||||||
static ThemeData get darkTheme {
|
static ThemeData get darkTheme {
|
||||||
return ThemeData(
|
return _withSharedControls(
|
||||||
|
ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: ColorScheme.fromSeed(
|
colorScheme: ColorScheme.fromSeed(
|
||||||
seedColor: Colors.blue,
|
seedColor: Colors.blue,
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
),
|
),
|
||||||
appBarTheme: const AppBarTheme(
|
appBarTheme: const AppBarTheme(centerTitle: true, elevation: 0),
|
||||||
centerTitle: true,
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
cardTheme: CardThemeData(
|
cardTheme: CardThemeData(
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
@@ -56,17 +76,17 @@ class AppTheme {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
filled: true,
|
filled: true,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAR Red theme (Emergency/Alert tones)
|
// SAR Red theme (Emergency/Alert tones)
|
||||||
static ThemeData get sarRedTheme {
|
static ThemeData get sarRedTheme {
|
||||||
return ThemeData(
|
return _withSharedControls(
|
||||||
|
ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: const ColorScheme.dark(
|
colorScheme: const ColorScheme.dark(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
@@ -100,10 +120,7 @@ class AppTheme {
|
|||||||
color: const Color(0xFF2D0000),
|
color: const Color(0xFF2D0000),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
side: const BorderSide(
|
side: const BorderSide(color: Color(0xFFFF5252), width: 1),
|
||||||
color: Color(0xFFFF5252),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
@@ -120,12 +137,14 @@ class AppTheme {
|
|||||||
foregroundColor: const Color(0xFF000000),
|
foregroundColor: const Color(0xFF000000),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAR Green theme (All Clear/Safe tones)
|
// SAR Green theme (All Clear/Safe tones)
|
||||||
static ThemeData get sarGreenTheme {
|
static ThemeData get sarGreenTheme {
|
||||||
return ThemeData(
|
return _withSharedControls(
|
||||||
|
ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: const ColorScheme.dark(
|
colorScheme: const ColorScheme.dark(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
@@ -159,10 +178,7 @@ class AppTheme {
|
|||||||
color: const Color(0xFF002D1F),
|
color: const Color(0xFF002D1F),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
side: const BorderSide(
|
side: const BorderSide(color: Color(0xFF69F0AE), width: 1),
|
||||||
color: Color(0xFF69F0AE),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
@@ -179,12 +195,14 @@ class AppTheme {
|
|||||||
foregroundColor: const Color(0xFF000000),
|
foregroundColor: const Color(0xFF000000),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAR Navy Blue theme (Professional/Operations tones)
|
// SAR Navy Blue theme (Professional/Operations tones)
|
||||||
static ThemeData get sarNavyBlueTheme {
|
static ThemeData get sarNavyBlueTheme {
|
||||||
return ThemeData(
|
return _withSharedControls(
|
||||||
|
ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: const ColorScheme.dark(
|
colorScheme: const ColorScheme.dark(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
@@ -218,10 +236,7 @@ class AppTheme {
|
|||||||
color: const Color(0xFF001A2D),
|
color: const Color(0xFF001A2D),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
side: const BorderSide(
|
side: const BorderSide(color: Color(0xFF5C9FFF), width: 1),
|
||||||
color: Color(0xFF5C9FFF),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
@@ -238,6 +253,7 @@ class AppTheme {
|
|||||||
foregroundColor: const Color(0xFF000000),
|
foregroundColor: const Color(0xFF000000),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user