first commit
This commit is contained in:
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