Files
umbrix/lib/core/theme/app_theme.dart

116 lines
4.5 KiB
Dart
Raw Permalink Normal View History

2023-07-06 17:18:41 +03:30
import 'package:flutter/material.dart';
import 'package:umbrix/core/theme/app_theme_mode.dart';
import 'package:umbrix/core/theme/theme_extensions.dart';
2023-09-06 12:56:30 +03:30
class AppTheme {
2024-03-19 08:49:04 +00:00
AppTheme(this.mode, this.fontFamily);
final AppThemeMode mode;
2023-09-06 12:56:30 +03:30
final String fontFamily;
2024-03-19 08:49:04 +00:00
ThemeData lightTheme(ColorScheme? lightColorScheme) {
final ColorScheme scheme = lightColorScheme ?? ColorScheme.fromSeed(seedColor: const Color(0xFF293CA0));
2024-03-19 08:49:04 +00:00
return ThemeData(
2023-07-06 17:18:41 +03:30
useMaterial3: true,
2024-03-19 08:49:04 +00:00
colorScheme: scheme,
2023-07-24 18:53:02 +03:30
fontFamily: fontFamily,
2024-03-19 08:49:04 +00:00
extensions: const <ThemeExtension<dynamic>>{
2023-09-06 12:56:30 +03:30
ConnectionButtonTheme.light,
},
2023-07-06 17:18:41 +03:30
);
}
2024-03-19 08:49:04 +00:00
ThemeData darkTheme(ColorScheme? darkColorScheme) {
// Кастомная темная тема с хорошей контрастностью для блоков
const ColorScheme scheme = ColorScheme(
brightness: Brightness.dark,
// Основной цвет Outline - бирюзовый
primary: Color(0xFF2fbea5), // hsl(170, 60%, 46%)
onPrimary: Color(0xFFFFFFFF), // Белый текст на кнопках
primaryContainer: Color(0xFF005048),
onPrimaryContainer: Color(0xFF7df8dd),
// Фон карточек/блоков - заметно светлее фона приложения
surface: Color(0xFF263238), // Светло-серый для карточек
onSurface: Color(0xFFE1E2E6), // Светлый текст на карточках
surfaceContainerHighest: Color(0xFF37474F), // Еще светлее для выделенных элементов
// Дополнительные цвета
secondary: Color(0xFF2fbea5),
onSecondary: Color(0xFFFFFFFF), // Белый текст
secondaryContainer: Color(0xFF005048),
onSecondaryContainer: Color(0xFF7df8dd),
// Ошибки
error: Color(0xFFf44336),
onError: Color(0xFFFFFFFF),
errorContainer: Color(0xFF93000a),
onErrorContainer: Color(0xFFffdad6),
// Контуры и границы - видимые
outline: Color(0xFF4CAF50), // Зеленоватый контур для видимости
outlineVariant: Color(0xFF546E7A),
);
2024-03-19 08:49:04 +00:00
return ThemeData(
2023-07-06 17:18:41 +03:30
useMaterial3: true,
2024-03-19 08:49:04 +00:00
colorScheme: scheme,
scaffoldBackgroundColor: const Color(0xFF191f23), // Очень темный фон
cardTheme: CardTheme(
elevation: 4,
shadowColor: Colors.black45,
surfaceTintColor: const Color(0xFF2fbea5), // Легкий бирюзовый оттенок
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: const BorderSide(
color: Color(0xFF37474F), // Видимая граница карточки
),
),
),
// Настройка текста кнопок
textTheme: const TextTheme(
labelLarge: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
filledButtonTheme: FilledButtonThemeData(
style: ButtonStyle(
foregroundColor: WidgetStateProperty.all(const Color(0xFFFFFFFF)), // Белый текст
backgroundColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.disabled)) {
return const Color(0xFF263238).withOpacity(0.5);
}
return const Color(0xFF263238); // Темно-серый фон
}),
elevation: WidgetStateProperty.all(4),
shadowColor: WidgetStateProperty.all(Colors.black45),
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
textStyle: WidgetStateProperty.all(
const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFF2fbea5), // Бирюзовый текст
side: const BorderSide(color: Color(0xFF2fbea5), width: 1.5),
textStyle: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
),
2023-07-24 18:53:02 +03:30
fontFamily: fontFamily,
2024-03-19 08:49:04 +00:00
extensions: const <ThemeExtension<dynamic>>{
2023-09-06 12:56:30 +03:30
ConnectionButtonTheme.light,
},
);
}
}