111 lines
3.4 KiB
Dart
111 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
enum AppThemePreset {
|
|
ember,
|
|
graphite,
|
|
moss;
|
|
|
|
static const AppThemePreset fallback = AppThemePreset.ember;
|
|
|
|
String get storageValue => switch (this) {
|
|
AppThemePreset.ember => 'ember',
|
|
AppThemePreset.graphite => 'graphite',
|
|
AppThemePreset.moss => 'moss',
|
|
};
|
|
|
|
String get title => switch (this) {
|
|
AppThemePreset.ember => 'Ember',
|
|
AppThemePreset.graphite => 'Graphite',
|
|
AppThemePreset.moss => 'Moss',
|
|
};
|
|
|
|
String get subtitle => switch (this) {
|
|
AppThemePreset.ember => 'Тёплая тёмная тема по умолчанию',
|
|
AppThemePreset.graphite => 'Холодная тёмная тема для пульта',
|
|
AppThemePreset.moss => 'Тёмная зелёная тема для спокойного режима',
|
|
};
|
|
|
|
Color get accentColor => switch (this) {
|
|
AppThemePreset.ember => const Color(0xFFFF6B2C),
|
|
AppThemePreset.graphite => const Color(0xFF5BC0BE),
|
|
AppThemePreset.moss => const Color(0xFF8AA05A),
|
|
};
|
|
|
|
ThemeData get themeData => switch (this) {
|
|
AppThemePreset.ember => _buildDarkTheme(
|
|
seedColor: const Color(0xFFFF6B2C),
|
|
scaffoldBackgroundColor: const Color(0xFF0E0E0E),
|
|
surfaceColor: const Color(0xFF1C1A18),
|
|
appBarColor: const Color(0xFF191715),
|
|
),
|
|
AppThemePreset.graphite => _buildDarkTheme(
|
|
seedColor: const Color(0xFF5BC0BE),
|
|
scaffoldBackgroundColor: const Color(0xFF0C1217),
|
|
surfaceColor: const Color(0xFF151D24),
|
|
appBarColor: const Color(0xFF121920),
|
|
),
|
|
AppThemePreset.moss => _buildDarkTheme(
|
|
seedColor: const Color(0xFF8AA05A),
|
|
scaffoldBackgroundColor: const Color(0xFF10140F),
|
|
surfaceColor: const Color(0xFF1A2118),
|
|
appBarColor: const Color(0xFF161C15),
|
|
),
|
|
};
|
|
|
|
static AppThemePreset fromStorageValue(String? value) {
|
|
for (final preset in AppThemePreset.values) {
|
|
if (preset.storageValue == value) {
|
|
return preset;
|
|
}
|
|
}
|
|
return fallback;
|
|
}
|
|
}
|
|
|
|
ThemeData _buildDarkTheme({
|
|
required Color seedColor,
|
|
required Color scaffoldBackgroundColor,
|
|
required Color surfaceColor,
|
|
required Color appBarColor,
|
|
}) {
|
|
final scheme = ColorScheme.fromSeed(
|
|
seedColor: seedColor,
|
|
brightness: Brightness.dark,
|
|
);
|
|
return ThemeData(
|
|
useMaterial3: true,
|
|
colorScheme: scheme,
|
|
scaffoldBackgroundColor: scaffoldBackgroundColor,
|
|
appBarTheme: AppBarTheme(
|
|
backgroundColor: appBarColor,
|
|
foregroundColor: Colors.white,
|
|
elevation: 0,
|
|
centerTitle: true,
|
|
),
|
|
cardTheme: CardThemeData(
|
|
color: surfaceColor,
|
|
elevation: 1.5,
|
|
margin: EdgeInsets.zero,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
|
|
),
|
|
listTileTheme: const ListTileThemeData(iconColor: Colors.white70),
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
filled: true,
|
|
fillColor: surfaceColor,
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(14)),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
borderSide: BorderSide(color: Colors.white.withValues(alpha: 0.08)),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
borderSide: BorderSide(color: scheme.primary, width: 1.4),
|
|
),
|
|
),
|
|
sliderTheme: const SliderThemeData(
|
|
trackHeight: 4,
|
|
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 8),
|
|
),
|
|
);
|
|
}
|