Skip to content

Commit

Permalink
test: Fixed component tests, still need to fix color tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Aug 16, 2024
1 parent ee30934 commit e5203da
Show file tree
Hide file tree
Showing 63 changed files with 317 additions and 300 deletions.
2 changes: 1 addition & 1 deletion example/lib/pages/components/list_item_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class _ListItemExampleState extends State<ListItemExample> {
return ExampleScaffold(
name: ListItemExample.name,
child: Container(
color: zetaColors.surface.secondary,
color: zetaColors.surface.warm,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/contact_item/contact_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ZetaContactItem extends ZetaStatelessWidget {
button: true,
child: SelectionContainer.disabled(
child: Material(
color: colors.surface.primary,
color: colors.surface.defaultColor,
child: DecoratedBox(
decoration: BoxDecoration(
border: enabledDivider ? Border(bottom: BorderSide(color: colors.border.disabled)) : null,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/dialog/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _ZetaDialog extends ZetaStatelessWidget {
return ZetaRoundedScope(
rounded: context.rounded,
child: AlertDialog(
surfaceTintColor: zeta.colors.surface.primary,
surfaceTintColor: zeta.colors.surface.defaultColor,
shape: RoundedRectangleBorder(borderRadius: Zeta.of(context).radii.large),
title: icon != null || title != null
? Column(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/global_header/global_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class _GlobalHeaderState extends State<ZetaGlobalHeader> {
vertical: Zeta.of(context).spacing.medium,
horizontal: Zeta.of(context).spacing.large,
),
decoration: BoxDecoration(color: colors.surface.primary),
decoration: BoxDecoration(color: colors.surface.defaultColor),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _ZetaSegmentedControlState<T> extends State<ZetaSegmentedControl<T>>
builder: (BuildContext context, Widget? child) {
return _SegmentedControlRenderWidget<T>(
highlightedIndex: highlightedIndex,
thumbColor: colors.surface.primary,
thumbColor: colors.surface.defaultColor,
thumbScale: _thumbScaleAnimation.value,
rounded: rounded,
state: this,
Expand Down
79 changes: 47 additions & 32 deletions lib/src/utils/zeta_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ class ZetaProviderState extends State<ZetaProvider> with Diagnosticable, Widgets

// Set the initial light [ThemeData].
_darkThemeData = widget.initialDarkThemeData;

if (widget.initialThemeMode != null) {
_themeMode = widget.initialThemeMode!;
}
if (widget.initialContrast != null) {
_contrast = widget.initialContrast!;
_zetaThemeData = widget.initialZetaThemeData.apply(contrast: _contrast);
}
}

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

@override
Widget build(BuildContext context) {
if (widget.initialContrast != null && widget.initialThemeMode != null) {
return _getChild();
}
return FutureBuilder<dynamic>(
// ignore: discarded_futures
future: getThemeValuesFromPreferences(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (widget.baseBuilder != _emptyBase) {
return _InternalProvider(
contrast: _contrast,
themeMode: _themeMode,
zetaThemeData: _zetaThemeData,
rounded: _rounded,
platformBrightness: _platformBrightness,
widget: widget.baseBuilder(
context,
generateZetaTheme(
brightness: Brightness.light,
existingTheme: _lightThemeData,
colorScheme: _lightThemeData?.colorScheme ?? _zetaThemeData.colorsLight.toScheme(),
),
generateZetaTheme(
brightness: Brightness.dark,
existingTheme: _darkThemeData,
colorScheme: _darkThemeData?.colorScheme ?? _zetaThemeData.colorsDark.toScheme(),
),
_themeMode,
),
);
} else {
return _InternalProvider(
contrast: _contrast,
themeMode: _themeMode,
zetaThemeData: _zetaThemeData,
rounded: _rounded,
platformBrightness: _platformBrightness,
widget: widget.builder(context, _zetaThemeData, _themeMode),
);
}
return _getChild();
},
);
}

Widget _getChild() {
if (widget.baseBuilder != _emptyBase) {
return _InternalProvider(
contrast: _contrast,
themeMode: _themeMode,
zetaThemeData: _zetaThemeData,
rounded: _rounded,
platformBrightness: _platformBrightness,
widget: widget.baseBuilder(
context,
generateZetaTheme(
brightness: Brightness.light,
existingTheme: _lightThemeData,
colorScheme: _lightThemeData?.colorScheme ?? _zetaThemeData.colorsLight.toScheme(),
),
generateZetaTheme(
brightness: Brightness.dark,
existingTheme: _darkThemeData,
colorScheme: _darkThemeData?.colorScheme ?? _zetaThemeData.colorsDark.toScheme(),
),
_themeMode,
),
);
} else {
return _InternalProvider(
contrast: _contrast,
themeMode: _themeMode,
zetaThemeData: _zetaThemeData,
rounded: _rounded,
platformBrightness: _platformBrightness,
widget: widget.builder(context, _zetaThemeData, _themeMode),
);
}
}

@override
void didUpdateWidget(ZetaProvider oldWidget) {
super.didUpdateWidget(oldWidget);
Expand Down
2 changes: 1 addition & 1 deletion test/src/components/accordion/accordion_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() {
),
),
);

await tester.pumpAndSettle();
// Verify that the accordion is initially collapsed
final Finder accordionContent = find.byType(SizeTransition);
expect(accordionContent, findsOneWidget);
Expand Down
Binary file modified test/src/components/badge/golden/indicator_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/indicator_icon_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/indicator_icon_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/indicator_notification_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_negative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_neutral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_positive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_sharp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/label_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_high.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/priority_pill_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/status_label_custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/status_label_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/tag_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/badge/golden/tag_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/src/components/button/button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void main() {
expect(button.size, ZetaWidgetSize.medium);
expect(
filledButton.style?.side?.resolve({WidgetState.focused}),
BorderSide(color: ZetaLightPrimitive().blue, width: ZetaBorderTemp.borderWidth),
BorderSide(color: ZetaLightPrimitive().blue.shade50, width: ZetaBorderTemp.borderWidth),
);
});
testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {
Expand Down
Binary file modified test/src/components/button/golden/button_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_negative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_positive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_primary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/src/components/button/golden/button_secondary.png
Binary file modified test/src/components/button/golden/button_text.png
Binary file modified test/src/components/checkbox/golden/checkbox_disabled.png
Binary file modified test/src/components/checkbox/golden/checkbox_enabled.png
Binary file modified test/src/components/checkbox/golden/checkbox_hover.png
Binary file modified test/src/components/dialpad/golden/dialpad_disabled.png
Binary file modified test/src/components/dialpad/golden/dialpad_enabled.png
Binary file modified test/src/components/dialpad/golden/dialpadbutton.png
6 changes: 2 additions & 4 deletions test/src/components/fabs/fab_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'dart:ui';

import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -140,7 +138,7 @@ void main() {
await gesture.moveTo(tester.getCenter(fabFinder));
await tester.pumpAndSettle();

expect(filledButton.style?.backgroundColor?.resolve({WidgetState.hovered}), ZetaColorBase.yellow.shade70);
expect(filledButton.style?.backgroundColor?.resolve({WidgetState.hovered}), ZetaLightPrimitive().yellow.shade30);

await gesture.moveTo(Offset.zero);
await tester.pumpAndSettle();
Expand All @@ -149,7 +147,7 @@ void main() {
await tester.pumpAndSettle();
expect(
filledButton.style?.side?.resolve({WidgetState.focused}),
BorderSide(color: ZetaColorBase.blue[50]!, width: ZetaBorderTemp.borderWidth),
BorderSide(color: ZetaLightPrimitive().blue.shade50, width: ZetaBorderTemp.borderWidth),
);
});

Expand Down
Binary file modified test/src/components/fabs/golden/FAB_default.png
Binary file modified test/src/components/fabs/golden/FAB_disabled.png
Binary file modified test/src/components/fabs/golden/FAB_inverse.png
Binary file modified test/src/components/fabs/golden/FAB_pressed.png
Binary file modified test/src/components/fabs/golden/FAB_secondary.png
Binary file modified test/src/components/password/golden/password_error.png
Binary file modified test/src/components/search_bar/golden/search_bar_default.png
Binary file modified test/src/components/search_bar/golden/search_bar_full.png
Binary file modified test/src/components/search_bar/golden/search_bar_medium.png
Binary file modified test/src/components/search_bar/golden/search_bar_sharp.png
Binary file modified test/src/components/search_bar/golden/search_bar_small.png
Binary file modified test/src/components/tooltip/golden/arrow_down.png
Binary file modified test/src/components/tooltip/golden/arrow_left.png
Binary file modified test/src/components/tooltip/golden/arrow_right.png
Binary file modified test/src/components/tooltip/golden/arrow_up.png
Loading

0 comments on commit e5203da

Please sign in to comment.