Skip to content

Commit

Permalink
- 100% test coverage for theme, utils, Zeta and ZetaProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
ps9310 committed Jun 10, 2024
1 parent 1d6b080 commit bc7397f
Show file tree
Hide file tree
Showing 15 changed files with 1,119 additions and 281 deletions.
26 changes: 14 additions & 12 deletions lib/src/theme/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class ZetaColors extends Equatable {
/// Defaults to `ZetaColors.cool.90`.
///
/// {@macro zeta-color-dark}
Color get iconDefault => textDefault;
Color get iconDefault => cool.shade90;

/// Subtle icon color.
///
Expand All @@ -315,14 +315,14 @@ class ZetaColors extends Equatable {
/// Maps to [ColorScheme.onSurface].
///
/// {@macro zeta-color-dark}
Color get iconSubtle => textSubtle;
Color get iconSubtle => cool.shade70;

/// Disabled icon color.
///
/// Defaults to `ZetaColors.cool.50`.
///
/// {@macro zeta-color-dark}
Color get iconDisabled => textDisabled;
Color get iconDisabled => cool.shade50;

/// Inverse icon color.
///
Expand All @@ -331,7 +331,7 @@ class ZetaColors extends Equatable {
/// Defaults to `ZetaColors.cool.20`.
///
/// {@macro zeta-color-dark}
Color get iconInverse => textInverse;
Color get iconInverse => cool.shade20;

/// Default Surface Color
///
Expand All @@ -351,12 +351,12 @@ class ZetaColors extends Equatable {
/// Selected Surface Color
///
/// {@macro zeta-color-dark}
Color get surfaceSelected => blue.shade(10);
Color get surfaceSelected => primary.shade(10);

/// Selected-hover Surface Color
///
/// {@macro zeta-color-dark}
Color get surfaceSelectedHover => blue.shade(20);
Color get surfaceSelectedHover => primary.shade(20);

/// Disabled Surface Color
///
Expand All @@ -376,7 +376,7 @@ class ZetaColors extends Equatable {
/// Primary-subtle Surface Color
///
/// {@macro zeta-color-dark}
Color get surfacePrimarySubtle => blue.shade(10);
Color get surfacePrimarySubtle => primary.shade(10);

/// Avatar Avatar Surface Color
///
Expand Down Expand Up @@ -416,7 +416,7 @@ class ZetaColors extends Equatable {
/// Secondary-subtle Surface Color
///
/// {@macro zeta-color-dark}
Color get surfaceSecondarySubtle => yellow.shade(10);
Color get surfaceSecondarySubtle => secondary.shade(10);

/// Positive Surface Color
///
Expand Down Expand Up @@ -491,17 +491,17 @@ class ZetaColors extends Equatable {
/// Primary-main Border Color
///
/// {@macro zeta-color-dark}
ZetaColorSwatch get borderPrimaryMain => blue;
ZetaColorSwatch get borderPrimaryMain => primary;

/// Primary Border Color
///
/// {@macro zeta-color-dark}
Color get borderPrimary => blue.shade(50);
Color get borderPrimary => primary.shade(50);

/// Secondary Border Color
///
/// {@macro zeta-color-dark}
Color get borderSecondary => yellow.shade(50);
Color get borderSecondary => secondary.shade(50);

/// Positive Border Color
///
Expand Down Expand Up @@ -994,11 +994,13 @@ extension ZetaColorGetters on ColorScheme {
T _resolveDefault<T>(_ZetaColorProperties property) {
switch (property) {
case _ZetaColorProperties.primarySwatch:
case _ZetaColorProperties.secondarySwatch:
return ZetaColorBase.blue.apply(brightness: brightness, contrast: contrast) as T;
case _ZetaColorProperties.secondarySwatch:
return ZetaColorBase.yellow.apply(brightness: brightness, contrast: contrast) as T;
case _ZetaColorProperties.cool:
return ZetaColorBase.cool.apply(brightness: brightness, contrast: contrast) as T;
case _ZetaColorProperties.warm:
return ZetaColorBase.warm.apply(brightness: brightness, contrast: contrast) as T;
case _ZetaColorProperties.textDefault:
return ZetaColorBase.cool.apply(brightness: brightness, contrast: contrast).shade90 as T;
case _ZetaColorProperties.textSubtle:
Expand Down
4 changes: 1 addition & 3 deletions lib/src/theme/colors_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import '../../zeta_flutter.dart';
/// * [warm]
/// * [pure]
/// * [cool].
class ZetaColorBase {
ZetaColorBase._();

abstract final class ZetaColorBase {
/// Link color for light mode.
@Deprecated('This color has been deprecated as of v0.10.0')
static const Color linkLight = Color(0xFF0257AC);
Expand Down
20 changes: 8 additions & 12 deletions lib/src/theme/theme_data.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';

import 'color_extensions.dart';
Expand All @@ -14,7 +15,7 @@ export 'constants.dart';
///
/// This class encapsulates the colors and fonts used for the Zeta theme in both light and dark modes.
@immutable
class ZetaThemeData {
class ZetaThemeData extends Equatable {
/// Constructs a [ZetaThemeData].
///
/// If [primary] and/or [secondary] colors are provided, they will be used to create the light and dark Zeta color palettes.
Expand Down Expand Up @@ -83,15 +84,10 @@ class ZetaThemeData {
}

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ZetaThemeData &&
runtimeType == other.runtimeType &&
fontFamily == other.fontFamily &&
identifier == other.identifier &&
_colorsLight == other._colorsLight &&
_colorsDark == other._colorsDark;

@override
int get hashCode => fontFamily.hashCode ^ identifier.hashCode ^ _colorsLight.hashCode ^ _colorsDark.hashCode;
List<Object?> get props => [
fontFamily,
identifier,
_colorsLight,
_colorsDark,
];
}
Loading

0 comments on commit bc7397f

Please sign in to comment.