reorganize app colors

This commit is contained in:
Fabian Freund
2026-01-11 19:05:18 +01:00
parent edbc157c46
commit 01d145bd72
17 changed files with 152 additions and 62 deletions
+76 -12
View File
@@ -1,21 +1,85 @@
import 'package:flutter/material.dart';
class AppColors {
AppColors._();
@immutable
class AppColors extends ThemeExtension<AppColors> {
const AppColors._({
this.seedColor = const Color(0xFF167C80),
this.privateTabPurple = const Color(0xFF8000D7),
this.privateTabBackground = const Color(0xFF25003E),
this.privateSelectionOverlay = const Color(0x648000D7),
this.torPurple = const Color(0xFF7D4698),
this.torActiveGreen = const Color(0xFF68B030),
this.torBackgroundGrey = const Color(0xFF333A41),
});
static const Color seedColor = Color(0xFF167C80);
final Color seedColor;
final Color privateTabPurple;
final Color privateTabBackground;
final Color privateSelectionOverlay;
final Color torPurple;
final Color torActiveGreen;
final Color torBackgroundGrey;
static const Color privateTabPurple = Color(0xFF8000D7);
static const light = AppColors._();
static const dark = AppColors._();
static const Color privateTabBackground = Color(0xFF25003E);
@override
AppColors copyWith({
Color? seedColor,
Color? privateTabPurple,
Color? privateTabBackground,
Color? privateSelectionOverlay,
Color? torPurple,
Color? torActiveGreen,
Color? torBackgroundGrey,
}) {
return AppColors._(
seedColor: seedColor ?? this.seedColor,
privateTabPurple: privateTabPurple ?? this.privateTabPurple,
privateTabBackground: privateTabBackground ?? this.privateTabBackground,
privateSelectionOverlay:
privateSelectionOverlay ?? this.privateSelectionOverlay,
torPurple: torPurple ?? this.torPurple,
torActiveGreen: torActiveGreen ?? this.torActiveGreen,
torBackgroundGrey: torBackgroundGrey ?? this.torBackgroundGrey,
);
}
static const Color privateSelectionOverlay = Color(0x648000D7);
@override
AppColors lerp(covariant ThemeExtension<AppColors>? other, double t) {
if (other is! AppColors) {
return this;
}
static const Color torPurple = Color(0xFF7D4698);
return AppColors._(
seedColor: Color.lerp(seedColor, other.seedColor, t)!,
privateTabPurple: Color.lerp(
privateTabPurple,
other.privateTabPurple,
t,
)!,
privateTabBackground: Color.lerp(
privateTabBackground,
other.privateTabBackground,
t,
)!,
privateSelectionOverlay: Color.lerp(
privateSelectionOverlay,
other.privateSelectionOverlay,
t,
)!,
torPurple: Color.lerp(torPurple, other.torPurple, t)!,
torActiveGreen: Color.lerp(torActiveGreen, other.torActiveGreen, t)!,
torBackgroundGrey: Color.lerp(
torBackgroundGrey,
other.torBackgroundGrey,
t,
)!,
);
}
static const Color torActiveGreen = Color(0xFF68B030);
static const Color torBackgroundGrey = Color(0xFF333A41);
static const Color dialogOverlay = Color(0x44000000);
/// Get AppColors from the current theme
static AppColors of(BuildContext context) {
return Theme.of(context).extension<AppColors>() ?? light;
}
}
+2 -2
View File
@@ -24,10 +24,10 @@ import 'package:weblibre/core/design/app_colors.dart';
part 'defaults.g.dart';
@Riverpod(keepAlive: true)
Color lightSeedColorFallback(Ref ref) => AppColors.seedColor;
Color lightSeedColorFallback(Ref ref) => AppColors.light.seedColor;
@Riverpod(keepAlive: true)
Color darkSeedColorFallback(Ref ref) => AppColors.seedColor;
Color darkSeedColorFallback(Ref ref) => AppColors.dark.seedColor;
@Riverpod(keepAlive: true)
Uri docsUri(Ref ref) => Uri.parse('https://docs.weblibre.eu/');
+2 -2
View File
@@ -49,7 +49,7 @@ final class LightSeedColorFallbackProvider
}
String _$lightSeedColorFallbackHash() =>
r'd5fb3ead5795c1cadd6c3a5f91ef84c3cbdaa3c1';
r'851efdcb11e4367ea2e54f1884a73fd4cd841d4a';
@ProviderFor(darkSeedColorFallback)
final darkSeedColorFallbackProvider = DarkSeedColorFallbackProvider._();
@@ -91,7 +91,7 @@ final class DarkSeedColorFallbackProvider
}
String _$darkSeedColorFallbackHash() =>
r'a383dbf6edf4fee54a8215bc52a98f26354e4645';
r'161a8c4318108c31d5c300441bc3332d08c24496';
@ProviderFor(docsUri)
final docsUriProvider = DocsUriProvider._();