Skip to content

Commit dfc57d3

Browse files
committed
test: update tests
1 parent 00daa31 commit dfc57d3

File tree

26 files changed

+345
-341
lines changed

26 files changed

+345
-341
lines changed

example/lib/pages/components/list_item_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class _ListItemExampleState extends State<ListItemExample> {
2626
return ExampleScaffold(
2727
name: ListItemExample.name,
2828
child: Container(
29-
color: zetaColors.surface.secondary,
29+
color: zetaColors.surface.warm,
3030
child: SingleChildScrollView(
3131
child: Padding(
3232
padding: const EdgeInsets.all(16),

example/lib/utils/theme_mode_switch.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ class ZetaThemeModeSwitch extends StatelessWidget {
2222
icon: Nothing(),
2323
dropdownColor: zeta.colors.border.disabled,
2424
items: _themes.map((e) {
25-
// final colors = zetaColors(e);
2625
final colors = e == ThemeMode.dark
27-
? ZetaSemanticColorsAA(primitives: ZetaDarkPrimitive())
28-
: ZetaSemanticColorsAA(primitives: ZetaLightPrimitive());
26+
? ZetaSemanticColorsAA(primitives: ZetaPrimitivesDark())
27+
: ZetaSemanticColorsAA(primitives: ZetaPrimitivesLight());
2928
return DropdownMenuItem<ThemeMode>(
3029
value: e,
3130
alignment: Alignment.center,

lib/generated/tokens/primitives.g.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ abstract interface class ZetaPrimitives {
134134
}
135135

136136
/// Light primitives
137-
final class ZetaLightPrimitive implements ZetaPrimitives {
137+
final class ZetaPrimitivesLight implements ZetaPrimitives {
138138
/// Pure
139139
///
140140
/// {@macro zeta-colors-swatch}
@@ -428,7 +428,7 @@ final class ZetaLightPrimitive implements ZetaPrimitives {
428428
}
429429

430430
/// Dark primitives
431-
final class ZetaDarkPrimitive implements ZetaPrimitives {
431+
final class ZetaPrimitivesDark implements ZetaPrimitives {
432432
/// Pure
433433
///
434434
/// {@macro zeta-colors-swatch}
@@ -722,4 +722,4 @@ final class ZetaDarkPrimitive implements ZetaPrimitives {
722722
}
723723

724724
/// All primitives
725-
Map<String, Type> allPrimitives = {'light': ZetaLightPrimitive, 'dark': ZetaDarkPrimitive};
725+
Map<String, Type> allPrimitives = {'light': ZetaPrimitivesLight, 'dark': ZetaPrimitivesDark};

lib/src/components/contact_item/contact_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ZetaContactItem extends ZetaStatelessWidget {
4545
button: true,
4646
child: SelectionContainer.disabled(
4747
child: Material(
48-
color: colors.surface.primary,
48+
color: colors.surface.defaultColor,
4949
child: DecoratedBox(
5050
decoration: BoxDecoration(
5151
border: enabledDivider ? Border(bottom: BorderSide(color: colors.border.disabled)) : null,

lib/src/components/dialog/dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class _ZetaDialog extends ZetaStatelessWidget {
9999
return ZetaRoundedScope(
100100
rounded: context.rounded,
101101
child: AlertDialog(
102-
surfaceTintColor: zeta.colors.surface.primary,
102+
surfaceTintColor: zeta.colors.surface.defaultColor,
103103
shape: RoundedRectangleBorder(borderRadius: Zeta.of(context).radii.large),
104104
title: icon != null || title != null
105105
? Column(

lib/src/components/global_header/global_header.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class _GlobalHeaderState extends State<ZetaGlobalHeader> {
8080
vertical: Zeta.of(context).spacing.medium,
8181
horizontal: Zeta.of(context).spacing.large,
8282
),
83-
decoration: BoxDecoration(color: colors.surface.primary),
83+
decoration: BoxDecoration(color: colors.surface.defaultColor),
8484
child: Column(
8585
crossAxisAlignment: CrossAxisAlignment.start,
8686
children: [

lib/src/components/segmented_control/segmented_control.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class _ZetaSegmentedControlState<T> extends State<ZetaSegmentedControl<T>>
148148
builder: (BuildContext context, Widget? child) {
149149
return _SegmentedControlRenderWidget<T>(
150150
highlightedIndex: highlightedIndex,
151-
thumbColor: colors.surface.primary,
151+
thumbColor: colors.surface.defaultColor,
152152
thumbScale: _thumbScaleAnimation.value,
153153
rounded: rounded,
154154
state: this,

lib/src/theme/colors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class ZetaColors extends Equatable implements ZetaColorSemantics {
661661
ZetaSemanticMainColors get main => ZetaSemanticMainColorsAA(primitives: primitives);
662662

663663
@override
664-
ZetaPrimitives get primitives => brightness == Brightness.dark ? ZetaDarkPrimitive() : ZetaLightPrimitive();
664+
ZetaPrimitives get primitives => brightness == Brightness.dark ? ZetaPrimitivesDark() : ZetaPrimitivesLight();
665665

666666
@override
667667
ZetaSemanticStateColors get state => ZetaSemanticStateColorsAA(primitives: primitives);

lib/src/utils/zeta.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Zeta extends InheritedWidget {
2424
this.rounded = true,
2525
}) : _mediaBrightness = mediaBrightness,
2626
_semantics = contrast == ZetaContrast.aaa
27-
? ZetaSemanticsAAA(primitives: mediaBrightness.isLight ? ZetaLightPrimitive() : ZetaDarkPrimitive())
28-
: ZetaSemanticsAA(primitives: mediaBrightness.isLight ? ZetaLightPrimitive() : ZetaDarkPrimitive());
27+
? ZetaSemanticsAAA(primitives: mediaBrightness.isLight ? ZetaPrimitivesLight() : ZetaPrimitivesDark())
28+
: ZetaSemanticsAA(primitives: mediaBrightness.isLight ? ZetaPrimitivesLight() : ZetaPrimitivesDark());
2929

3030
/// The current contrast setting for the app, which can be one of the predefined
3131
/// values in [ZetaContrast].

lib/src/utils/zeta_provider.dart

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
201201

202202
// Set the initial light [ThemeData].
203203
_darkThemeData = widget.initialDarkThemeData;
204+
205+
if (widget.initialThemeMode != null) {
206+
_themeMode = widget.initialThemeMode!;
207+
}
208+
if (widget.initialContrast != null) {
209+
_contrast = widget.initialContrast!;
210+
_zetaThemeData = widget.initialZetaThemeData.apply(contrast: _contrast);
211+
}
204212
}
205213

206214
/// Retrieves the theme values from the shared preferences.
@@ -264,49 +272,56 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets
264272

265273
@override
266274
Widget build(BuildContext context) {
275+
if (widget.initialContrast != null && widget.initialThemeMode != null) {
276+
return _getChild();
277+
}
267278
return FutureBuilder<dynamic>(
268279
// ignore: discarded_futures
269280
future: getThemeValuesFromPreferences(),
270281
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
271282
if (snapshot.connectionState == ConnectionState.waiting) {
272283
return const Center(child: CircularProgressIndicator());
273284
}
274-
if (widget.baseBuilder != _emptyBase) {
275-
return _InternalProvider(
276-
contrast: _contrast,
277-
themeMode: _themeMode,
278-
zetaThemeData: _zetaThemeData,
279-
rounded: _rounded,
280-
platformBrightness: _platformBrightness,
281-
widget: widget.baseBuilder(
282-
context,
283-
generateZetaTheme(
284-
brightness: Brightness.light,
285-
existingTheme: _lightThemeData,
286-
colorScheme: _lightThemeData?.colorScheme ?? _zetaThemeData.colorsLight.toScheme(),
287-
),
288-
generateZetaTheme(
289-
brightness: Brightness.dark,
290-
existingTheme: _darkThemeData,
291-
colorScheme: _darkThemeData?.colorScheme ?? _zetaThemeData.colorsDark.toScheme(),
292-
),
293-
_themeMode,
294-
),
295-
);
296-
} else {
297-
return _InternalProvider(
298-
contrast: _contrast,
299-
themeMode: _themeMode,
300-
zetaThemeData: _zetaThemeData,
301-
rounded: _rounded,
302-
platformBrightness: _platformBrightness,
303-
widget: widget.builder(context, _zetaThemeData, _themeMode),
304-
);
305-
}
285+
return _getChild();
306286
},
307287
);
308288
}
309289

290+
Widget _getChild() {
291+
if (widget.baseBuilder != _emptyBase) {
292+
return _InternalProvider(
293+
contrast: _contrast,
294+
themeMode: _themeMode,
295+
zetaThemeData: _zetaThemeData,
296+
rounded: _rounded,
297+
platformBrightness: _platformBrightness,
298+
widget: widget.baseBuilder(
299+
context,
300+
generateZetaTheme(
301+
brightness: Brightness.light,
302+
existingTheme: _lightThemeData,
303+
colorScheme: _lightThemeData?.colorScheme ?? _zetaThemeData.colorsLight.toScheme(),
304+
),
305+
generateZetaTheme(
306+
brightness: Brightness.dark,
307+
existingTheme: _darkThemeData,
308+
colorScheme: _darkThemeData?.colorScheme ?? _zetaThemeData.colorsDark.toScheme(),
309+
),
310+
_themeMode,
311+
),
312+
);
313+
} else {
314+
return _InternalProvider(
315+
contrast: _contrast,
316+
themeMode: _themeMode,
317+
zetaThemeData: _zetaThemeData,
318+
rounded: _rounded,
319+
platformBrightness: _platformBrightness,
320+
widget: widget.builder(context, _zetaThemeData, _themeMode),
321+
);
322+
}
323+
}
324+
310325
@override
311326
void didUpdateWidget(ZetaProvider oldWidget) {
312327
super.didUpdateWidget(oldWidget);

0 commit comments

Comments
 (0)