first commit
This commit is contained in:
91
lib/theme/custom_theme.dart
Normal file
91
lib/theme/custom_theme.dart
Normal file
@@ -0,0 +1,91 @@
|
||||
// Flutter imports:
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remever/common/resources.dart';
|
||||
|
||||
class CustomTheme extends ValueNotifier<ThemeMode> {
|
||||
/// Текущая тема
|
||||
static bool _isDarkTheme = false;
|
||||
|
||||
CustomTheme(super.value);
|
||||
|
||||
@override
|
||||
ThemeMode get value => _isDarkTheme ? ThemeMode.dark : ThemeMode.light;
|
||||
|
||||
bool get isDark => _isDarkTheme;
|
||||
|
||||
///
|
||||
/// Смена темы
|
||||
///
|
||||
void toggleTheme() {
|
||||
_isDarkTheme = !_isDarkTheme;
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
///
|
||||
/// Темная тема
|
||||
///
|
||||
static ThemeData get darkTheme {
|
||||
return ThemeData.dark(useMaterial3: true);
|
||||
}
|
||||
|
||||
///
|
||||
/// Светлая тема
|
||||
///
|
||||
static ThemeData get lightTheme {
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSwatch(backgroundColor: Colors.white),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.black),
|
||||
),
|
||||
filledButtonTheme: FilledButtonThemeData(
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: AppColors.app_blue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
segmentedButtonTheme: SegmentedButtonThemeData(
|
||||
style: SegmentedButton.styleFrom(
|
||||
selectedBackgroundColor: const Color(0xFFF3F3FF),
|
||||
selectedForegroundColor: AppColors.app_blue,
|
||||
overlayColor: AppColors.app_blue,
|
||||
foregroundColor: Colors.black,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: const BorderSide(color: AppColors.app_border, width: 1),
|
||||
),
|
||||
side: const BorderSide(color: AppColors.app_border, width: 1),
|
||||
),
|
||||
),
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppColors.app_blue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: AppColors.app_blue,
|
||||
width: 1.3,
|
||||
style: BorderStyle.solid,
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
||||
selectedItemColor: AppColors.app_blue,
|
||||
unselectedItemColor: Color(0xFF888B98),
|
||||
),
|
||||
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||
color: AppColors.app_blue,
|
||||
),
|
||||
tabBarTheme: const TabBarTheme(
|
||||
labelColor: Colors.black,
|
||||
indicatorColor: AppColors.app_blue,
|
||||
tabAlignment: TabAlignment.start,
|
||||
dividerColor: AppColors.app_border,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
65
lib/theme/extensions/app_theme_extensions.dart
Normal file
65
lib/theme/extensions/app_theme_extensions.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
// Flutter imports:
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
///
|
||||
/// Расширение для темы всего приложения
|
||||
/// Для [Theme]
|
||||
///
|
||||
/// Используется для хранения общих типов цветов
|
||||
///
|
||||
class AppThemeExtension extends ThemeExtension<AppThemeExtension> {
|
||||
AppThemeExtension({
|
||||
required this.background,
|
||||
required this.textColor,
|
||||
required this.appBarBackground,
|
||||
});
|
||||
|
||||
AppThemeExtension.light()
|
||||
: background = Colors.white,
|
||||
textColor = Colors.black,
|
||||
appBarBackground = Colors.indigo;
|
||||
|
||||
AppThemeExtension.dark()
|
||||
: background = Colors.black,
|
||||
textColor = Colors.white,
|
||||
appBarBackground = Colors.lightGreen;
|
||||
|
||||
/// Цвет фона
|
||||
final Color background;
|
||||
|
||||
/// Цвет текста
|
||||
final Color textColor;
|
||||
|
||||
/// Цвет фона [AppBar]
|
||||
final Color appBarBackground;
|
||||
|
||||
@override
|
||||
ThemeExtension<AppThemeExtension> copyWith({
|
||||
Color? background,
|
||||
Color? textColor,
|
||||
Color? appBarBackground,
|
||||
}) {
|
||||
return AppThemeExtension(
|
||||
background: background ?? this.background,
|
||||
textColor: textColor ?? this.textColor,
|
||||
appBarBackground: appBarBackground ?? this.appBarBackground,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ThemeExtension<AppThemeExtension> lerp(
|
||||
ThemeExtension<AppThemeExtension>? other,
|
||||
double t,
|
||||
) {
|
||||
if (other is! AppThemeExtension) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return AppThemeExtension(
|
||||
background: Color.lerp(background, other.background, t)!,
|
||||
textColor: Color.lerp(textColor, other.textColor, t)!,
|
||||
appBarBackground:
|
||||
Color.lerp(appBarBackground, other.appBarBackground, t)!,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user