From cfa211db104de789afa5987351dfb9014ba30097 Mon Sep 17 00:00:00 2001 From: Niels Rijnberg Date: Thu, 20 Feb 2025 12:26:09 +0100 Subject: [PATCH] Add secondary and tertiary colors to kleurplaat --- lib/style/interface/kleurplaat_interface.dart | 20 +++++++ lib/style/kleurplaat/katjas_kleurplaat.dart | 32 ++++++++++++ .../text_style/text_style_decorator.dart | 52 +++++++++++++++++++ pubspec.lock | 12 ++--- 4 files changed, 110 insertions(+), 6 deletions(-) diff --git a/lib/style/interface/kleurplaat_interface.dart b/lib/style/interface/kleurplaat_interface.dart index 744f9ba..e5a828d 100644 --- a/lib/style/interface/kleurplaat_interface.dart +++ b/lib/style/interface/kleurplaat_interface.dart @@ -16,6 +16,26 @@ abstract interface class KleurplaatInterface { /// {@endtemplate} ColorGroupInterface get primaryFill; + /// {@template secondary} + /// The secondary color group. + /// {@endtemplate} + ColorGroupInterface? get secondary; + + /// {@template secondaryFill} + /// The secondary fill color group. + /// {@endtemplate} + ColorGroupInterface? get secondaryFill; + + /// {@template tertiary} + /// The tertiary color group. + /// {@endtemplate} + ColorGroupInterface? get tertiary; + + /// {@template tertiaryFill} + /// The tertiary fill color group. + /// {@endtemplate} + ColorGroupInterface? get tertiaryFill; + /// {@template content} /// The content color group. /// {@endtemplate} diff --git a/lib/style/kleurplaat/katjas_kleurplaat.dart b/lib/style/kleurplaat/katjas_kleurplaat.dart index c4261d7..bf77669 100644 --- a/lib/style/kleurplaat/katjas_kleurplaat.dart +++ b/lib/style/kleurplaat/katjas_kleurplaat.dart @@ -18,6 +18,10 @@ class KatjasKleurplaat extends ThemeExtension required this.successFill, required this.surface, required this.surfaceInverse, + this.secondary, + this.secondaryFill, + this.tertiary, + this.tertiaryFill, }); @override @@ -26,6 +30,18 @@ class KatjasKleurplaat extends ThemeExtension @override final ColorGroup primaryFill; + @override + final ColorGroup? secondary; + + @override + final ColorGroup? secondaryFill; + + @override + final ColorGroup? tertiary; + + @override + final ColorGroup? tertiaryFill; + @override final ColorGroup content; @@ -54,6 +70,10 @@ class KatjasKleurplaat extends ThemeExtension ThemeExtension copyWith({ ColorGroup? primary, ColorGroup? primaryFill, + ColorGroup? secondary, + ColorGroup? secondaryFill, + ColorGroup? tertiary, + ColorGroup? tertiaryFill, ColorGroup? content, ColorGroup? contentFill, ColorGroup? error, @@ -66,6 +86,10 @@ class KatjasKleurplaat extends ThemeExtension KatjasKleurplaat( primary: primary ?? this.primary, primaryFill: primaryFill ?? this.primaryFill, + secondary: secondary ?? this.secondary, + secondaryFill: secondaryFill ?? this.secondaryFill, + tertiary: tertiary ?? this.tertiary, + tertiaryFill: tertiaryFill ?? this.tertiaryFill, content: content ?? this.content, contentFill: contentFill ?? this.contentFill, error: error ?? this.error, @@ -83,6 +107,10 @@ class KatjasKleurplaat extends ThemeExtension return KatjasKleurplaat( primary: primary.lerp(other.primary, t), primaryFill: primaryFill.lerp(other.primaryFill, t), + secondary: secondary?.lerp(other.secondary, t), + secondaryFill: secondaryFill?.lerp(other.secondaryFill, t), + tertiary: tertiary?.lerp(other.tertiary, t), + tertiaryFill: tertiaryFill?.lerp(other.tertiaryFill, t), content: content.lerp(other.content, t), contentFill: contentFill.lerp(other.contentFill, t), error: error.lerp(other.error, t), @@ -104,6 +132,10 @@ class KatjasKleurplaat extends ThemeExtension onPrimaryContainer: primary.onColorContrast, secondary: content.color, secondaryContainer: content.color, + secondaryFixed: secondary?.color, + secondaryFixedDim: secondaryFill?.color, + tertiaryFixed: tertiary?.color, + tertiaryFixedDim: tertiaryFill?.color, onSecondary: content.onColorContrast, onSecondaryContainer: content.onColorContrast, tertiary: error.color, diff --git a/lib/style/text_style/text_style_decorator.dart b/lib/style/text_style/text_style_decorator.dart index 3159827..b34a1f3 100644 --- a/lib/style/text_style/text_style_decorator.dart +++ b/lib/style/text_style/text_style_decorator.dart @@ -97,6 +97,58 @@ class TextStyleDecorator implements KleurplaatInterface { ), ); + @override + ColorGroupInterface get secondary => TextStyleColorGroup( + color: _textStyle.copyWith( + color: _kleurplaat.secondary?.color, + ), + onColorContrast: _textStyle.copyWith( + color: _kleurplaat.secondary?.onColorContrast, + ), + onColorSubtle: _textStyle.copyWith( + color: _kleurplaat.secondary?.onColorSubtle, + ), + ); + + @override + ColorGroupInterface get secondaryFill => TextStyleColorGroup( + color: _textStyle.copyWith( + color: _kleurplaat.secondaryFill?.color, + ), + onColorContrast: _textStyle.copyWith( + color: _kleurplaat.secondaryFill?.onColorContrast, + ), + onColorSubtle: _textStyle.copyWith( + color: _kleurplaat.secondaryFill?.onColorSubtle, + ), + ); + + @override + ColorGroupInterface get tertiary => TextStyleColorGroup( + color: _textStyle.copyWith( + color: _kleurplaat.tertiary?.color, + ), + onColorContrast: _textStyle.copyWith( + color: _kleurplaat.tertiary?.onColorContrast, + ), + onColorSubtle: _textStyle.copyWith( + color: _kleurplaat.tertiary?.onColorSubtle, + ), + ); + + @override + ColorGroupInterface get tertiaryFill => TextStyleColorGroup( + color: _textStyle.copyWith( + color: _kleurplaat.tertiaryFill?.color, + ), + onColorContrast: _textStyle.copyWith( + color: _kleurplaat.tertiaryFill?.onColorContrast, + ), + onColorSubtle: _textStyle.copyWith( + color: _kleurplaat.tertiaryFill?.onColorSubtle, + ), + ); + @override ColorGroupInterface get success => TextStyleColorGroup( color: _textStyle.copyWith( diff --git a/pubspec.lock b/pubspec.lock index a8e62f2..60c4b48 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -74,10 +74,10 @@ packages: dependency: "direct main" description: name: chopper - sha256: "40899b729fb6d8969d967264b189efaf2452bc3ccf6ed0782d00f1d8a6161c31" + sha256: "8b25abf4dc034b4a81c23a519691eca6bd16b70782969f95344547d1c4faf3e3" url: "https://pub.dev" source: hosted - version: "8.0.3" + version: "8.0.4" clock: dependency: transitive description: @@ -388,10 +388,10 @@ packages: dependency: transitive description: name: qs_dart - sha256: be73d060d29c0716ded88380ba32e87ce8105f0ba234edb3edefa0d74d47d64b + sha256: eec9f5e9695a949efb1487b387256260362308da4e002a9a7637bfa5acc7e049 url: "https://pub.dev" source: hosted - version: "1.2.4" + version: "1.3.1" recursive_regex: dependency: transitive description: @@ -561,10 +561,10 @@ packages: dependency: transitive description: name: weak_map - sha256: "95ca338f0cdf5f0022cc283dfa4d97f6f6b03752f67eca85ebe6d7a679ffe3ed" + sha256: "5f8e5d5ce57dc624db5fae814dd689ccae1f17f92b426e52f0a7cbe7f6f4ab97" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.0.1" web: dependency: transitive description: