diff --git a/lib/src/utils/rounded.dart b/lib/src/utils/rounded.dart index 7b096060..78cdd7f4 100644 --- a/lib/src/utils/rounded.dart +++ b/lib/src/utils/rounded.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -68,7 +70,7 @@ extension Rounded on BuildContext { return (widget as dynamic).rounded as bool; } } catch (e) { - debugPrint('Widget does not have rounded'); + log('Widget(${widget.runtimeType}) does not have rounded \n $e'); } return ZetaRoundedScope.of(this)?._rounded ?? Zeta.of(this).rounded; diff --git a/lib/src/zeta_provider.dart b/lib/src/zeta_provider.dart index 4f4cbe97..520418f0 100644 --- a/lib/src/zeta_provider.dart +++ b/lib/src/zeta_provider.dart @@ -150,13 +150,17 @@ class ZetaProviderState extends State with Diagnosticable, Widgets late ThemeMode _themeMode; /// Represents the late initialization of the ZetaThemeData object. - late ZetaThemeData _themeData; + late ZetaThemeData _zetaThemeData; /// Represents the late initialization of the system's current brightness (dark or light mode). late Brightness _platformBrightness; + /// {@macro zeta-component-rounded} late bool _rounded; + /// Represents the late initialization of the ThemeData object. + late ThemeData? _themeData; + /// Represents a nullable brightness value to be used for brightness change debouncing. Brightness? _debounceBrightness; @@ -188,7 +192,10 @@ class ZetaProviderState extends State with Diagnosticable, Widgets _rounded = widget.initialRounded; // Apply the initial contrast to the theme data. - _themeData = widget.initialZetaThemeData.apply(contrast: _contrast); + _zetaThemeData = widget.initialZetaThemeData.apply(contrast: _contrast); + + // Set the initial theme data. + _themeData = widget.initialThemeData; } /// Clean up function to be called when this object is removed from the tree. @@ -241,7 +248,7 @@ class ZetaProviderState extends State with Diagnosticable, Widgets if (widget.baseBuilder != _emptyBase) { return Zeta( themeMode: _themeMode, - themeData: _themeData, + themeData: _zetaThemeData, contrast: _contrast, mediaBrightness: _platformBrightness, rounded: _rounded, @@ -249,11 +256,11 @@ class ZetaProviderState extends State with Diagnosticable, Widgets context, generateZetaTheme( brightness: Brightness.light, - existingTheme: ThemeData(colorScheme: _themeData.colorsLight.toScheme()), + existingTheme: _themeData ?? ThemeData(colorScheme: _zetaThemeData.colorsLight.toScheme()), ), generateZetaTheme( brightness: Brightness.dark, - existingTheme: ThemeData(colorScheme: _themeData.colorsDark.toScheme()), + existingTheme: _themeData ?? ThemeData(colorScheme: _zetaThemeData.colorsDark.toScheme()), ), _themeMode, ), @@ -262,11 +269,11 @@ class ZetaProviderState extends State with Diagnosticable, Widgets return Zeta( themeMode: _themeMode, - themeData: _themeData, + themeData: _zetaThemeData, contrast: _contrast, rounded: _rounded, mediaBrightness: _platformBrightness, - child: widget.builder(context, _themeData, _themeMode), + child: widget.builder(context, _zetaThemeData, _themeMode), ); } @@ -276,11 +283,13 @@ class ZetaProviderState extends State with Diagnosticable, Widgets if (oldWidget.initialContrast != widget.initialContrast || oldWidget.initialThemeMode != widget.initialThemeMode || oldWidget.initialThemeData != widget.initialThemeData || + oldWidget.initialZetaThemeData != widget.initialZetaThemeData || oldWidget.initialRounded != widget.initialRounded) { setState(() { _themeMode = widget.initialThemeMode; _contrast = widget.initialContrast; - _themeData = widget.initialZetaThemeData.apply(contrast: _contrast); + _zetaThemeData = widget.initialZetaThemeData.apply(contrast: _contrast); + _themeData = widget.initialThemeData; _rounded = widget.initialRounded; }); } @@ -297,7 +306,7 @@ class ZetaProviderState extends State with Diagnosticable, Widgets /// Updates the current theme data. void updateThemeData(ZetaThemeData data) { setState(() { - _themeData = data.apply(contrast: _contrast); + _zetaThemeData = data.apply(contrast: _contrast); _saveThemeChange(); }); } @@ -306,7 +315,7 @@ class ZetaProviderState extends State with Diagnosticable, Widgets void updateContrast(ZetaContrast contrast) { setState(() { _contrast = contrast; - _themeData = _themeData.apply(contrast: contrast); + _zetaThemeData = _zetaThemeData.apply(contrast: contrast); _saveThemeChange(); }); } @@ -314,7 +323,6 @@ class ZetaProviderState extends State with Diagnosticable, Widgets /// Updates the current rounded. // ignore: avoid_positional_boolean_parameters void updateRounded(bool rounded) { - //TODO: This is not triggering rebuild setState(() { _rounded = rounded; _saveThemeChange(); @@ -324,7 +332,7 @@ class ZetaProviderState extends State with Diagnosticable, Widgets void _saveThemeChange() { unawaited( widget.themeService?.saveTheme( - themeData: _themeData, + themeData: _zetaThemeData, themeMode: _themeMode, contrast: _contrast, ), @@ -335,7 +343,7 @@ class ZetaProviderState extends State with Diagnosticable, Widgets void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DiagnosticsProperty('themeData', _themeData)) + ..add(DiagnosticsProperty('themeData', _zetaThemeData)) ..add(EnumProperty('contrast', _contrast)) ..add(EnumProperty('themeMode', _themeMode)); } diff --git a/test/src/components/badge/golden/indicator_default.png b/test/src/components/badge/golden/indicator_default.png index 1c0aa6a8..291fd461 100644 Binary files a/test/src/components/badge/golden/indicator_default.png and b/test/src/components/badge/golden/indicator_default.png differ diff --git a/test/src/components/badge/golden/indicator_icon_default.png b/test/src/components/badge/golden/indicator_icon_default.png index 34bf283a..c472cd38 100644 Binary files a/test/src/components/badge/golden/indicator_icon_default.png and b/test/src/components/badge/golden/indicator_icon_default.png differ diff --git a/test/src/components/badge/golden/indicator_icon_values.png b/test/src/components/badge/golden/indicator_icon_values.png index 9e930cb5..96e73834 100644 Binary files a/test/src/components/badge/golden/indicator_icon_values.png and b/test/src/components/badge/golden/indicator_icon_values.png differ diff --git a/test/src/components/badge/golden/indicator_notification_default.png b/test/src/components/badge/golden/indicator_notification_default.png index 1c0aa6a8..291fd461 100644 Binary files a/test/src/components/badge/golden/indicator_notification_default.png and b/test/src/components/badge/golden/indicator_notification_default.png differ diff --git a/test/src/components/badge/golden/indicator_notification_values.png b/test/src/components/badge/golden/indicator_notification_values.png index 5f3eb489..60afdfc9 100644 Binary files a/test/src/components/badge/golden/indicator_notification_values.png and b/test/src/components/badge/golden/indicator_notification_values.png differ diff --git a/test/src/components/badge/golden/label_dark.png b/test/src/components/badge/golden/label_dark.png index 1e514a9b..56650a35 100644 Binary files a/test/src/components/badge/golden/label_dark.png and b/test/src/components/badge/golden/label_dark.png differ diff --git a/test/src/components/badge/golden/label_default.png b/test/src/components/badge/golden/label_default.png index 8f60d7c5..ab898e1a 100644 Binary files a/test/src/components/badge/golden/label_default.png and b/test/src/components/badge/golden/label_default.png differ diff --git a/test/src/components/badge/golden/label_negative.png b/test/src/components/badge/golden/label_negative.png index 045c3ab3..efd6692b 100644 Binary files a/test/src/components/badge/golden/label_negative.png and b/test/src/components/badge/golden/label_negative.png differ diff --git a/test/src/components/badge/golden/label_neutral.png b/test/src/components/badge/golden/label_neutral.png index 24046acd..8dc692ca 100644 Binary files a/test/src/components/badge/golden/label_neutral.png and b/test/src/components/badge/golden/label_neutral.png differ diff --git a/test/src/components/badge/golden/label_positive.png b/test/src/components/badge/golden/label_positive.png index 711c8308..5df40805 100644 Binary files a/test/src/components/badge/golden/label_positive.png and b/test/src/components/badge/golden/label_positive.png differ diff --git a/test/src/components/badge/golden/label_sharp.png b/test/src/components/badge/golden/label_sharp.png index ebfea1a7..3e96a777 100644 Binary files a/test/src/components/badge/golden/label_sharp.png and b/test/src/components/badge/golden/label_sharp.png differ diff --git a/test/src/components/badge/golden/label_warning.png b/test/src/components/badge/golden/label_warning.png index 5b6326c1..b4091b2c 100644 Binary files a/test/src/components/badge/golden/label_warning.png and b/test/src/components/badge/golden/label_warning.png differ diff --git a/test/src/components/badge/golden/priority_pill_default.png b/test/src/components/badge/golden/priority_pill_default.png index 358111a4..3ec6f2a1 100644 Binary files a/test/src/components/badge/golden/priority_pill_default.png and b/test/src/components/badge/golden/priority_pill_default.png differ diff --git a/test/src/components/badge/golden/priority_pill_high.png b/test/src/components/badge/golden/priority_pill_high.png index 11402303..0384a884 100644 Binary files a/test/src/components/badge/golden/priority_pill_high.png and b/test/src/components/badge/golden/priority_pill_high.png differ diff --git a/test/src/components/badge/golden/priority_pill_low.png b/test/src/components/badge/golden/priority_pill_low.png index ebdc35f8..6199e19f 100644 Binary files a/test/src/components/badge/golden/priority_pill_low.png and b/test/src/components/badge/golden/priority_pill_low.png differ diff --git a/test/src/components/badge/golden/priority_pill_medium.png b/test/src/components/badge/golden/priority_pill_medium.png index c56cd408..e5a1ab11 100644 Binary files a/test/src/components/badge/golden/priority_pill_medium.png and b/test/src/components/badge/golden/priority_pill_medium.png differ diff --git a/test/src/components/badge/golden/status_label_custom.png b/test/src/components/badge/golden/status_label_custom.png index 7e5e24da..dd961c4f 100644 Binary files a/test/src/components/badge/golden/status_label_custom.png and b/test/src/components/badge/golden/status_label_custom.png differ diff --git a/test/src/components/badge/golden/status_label_default.png b/test/src/components/badge/golden/status_label_default.png index 2b8606dc..00459554 100644 Binary files a/test/src/components/badge/golden/status_label_default.png and b/test/src/components/badge/golden/status_label_default.png differ diff --git a/test/src/components/badge/golden/tag_left.png b/test/src/components/badge/golden/tag_left.png index 4ac7894a..879b23a6 100644 Binary files a/test/src/components/badge/golden/tag_left.png and b/test/src/components/badge/golden/tag_left.png differ diff --git a/test/src/components/badge/golden/tag_right.png b/test/src/components/badge/golden/tag_right.png index e078c030..2f860de3 100644 Binary files a/test/src/components/badge/golden/tag_right.png and b/test/src/components/badge/golden/tag_right.png differ diff --git a/test/src/components/button/golden/button_disabled.png b/test/src/components/button/golden/button_disabled.png index fd362469..ed2720f9 100644 Binary files a/test/src/components/button/golden/button_disabled.png and b/test/src/components/button/golden/button_disabled.png differ diff --git a/test/src/components/button/golden/button_negative.png b/test/src/components/button/golden/button_negative.png index b0283c1e..aa2882ae 100644 Binary files a/test/src/components/button/golden/button_negative.png and b/test/src/components/button/golden/button_negative.png differ diff --git a/test/src/components/button/golden/button_outline.png b/test/src/components/button/golden/button_outline.png index ce0f9fa6..93145c17 100644 Binary files a/test/src/components/button/golden/button_outline.png and b/test/src/components/button/golden/button_outline.png differ diff --git a/test/src/components/button/golden/button_outline_subtle.png b/test/src/components/button/golden/button_outline_subtle.png index 536c285b..0fa2b83d 100644 Binary files a/test/src/components/button/golden/button_outline_subtle.png and b/test/src/components/button/golden/button_outline_subtle.png differ diff --git a/test/src/components/button/golden/button_positive.png b/test/src/components/button/golden/button_positive.png index ba493d0a..62018a50 100644 Binary files a/test/src/components/button/golden/button_positive.png and b/test/src/components/button/golden/button_positive.png differ diff --git a/test/src/components/button/golden/button_primary.png b/test/src/components/button/golden/button_primary.png index c2dd825e..124eed1b 100644 Binary files a/test/src/components/button/golden/button_primary.png and b/test/src/components/button/golden/button_primary.png differ diff --git a/test/src/components/button/golden/button_secondary.png b/test/src/components/button/golden/button_secondary.png index 22ca2480..984e16f5 100644 Binary files a/test/src/components/button/golden/button_secondary.png and b/test/src/components/button/golden/button_secondary.png differ diff --git a/test/src/components/button/golden/button_text.png b/test/src/components/button/golden/button_text.png index 7276f3b3..36c7c960 100644 Binary files a/test/src/components/button/golden/button_text.png and b/test/src/components/button/golden/button_text.png differ diff --git a/test/src/components/checkbox/golden/checkbox_disabled.png b/test/src/components/checkbox/golden/checkbox_disabled.png index 0ecfd7bf..6dfe17b6 100644 Binary files a/test/src/components/checkbox/golden/checkbox_disabled.png and b/test/src/components/checkbox/golden/checkbox_disabled.png differ diff --git a/test/src/components/checkbox/golden/checkbox_enabled.png b/test/src/components/checkbox/golden/checkbox_enabled.png index eac35ed1..ad258d31 100644 Binary files a/test/src/components/checkbox/golden/checkbox_enabled.png and b/test/src/components/checkbox/golden/checkbox_enabled.png differ diff --git a/test/src/components/dialpad/golden/dialpad_disabled.png b/test/src/components/dialpad/golden/dialpad_disabled.png index e2357d55..5ee42187 100644 Binary files a/test/src/components/dialpad/golden/dialpad_disabled.png and b/test/src/components/dialpad/golden/dialpad_disabled.png differ diff --git a/test/src/components/dialpad/golden/dialpad_enabled.png b/test/src/components/dialpad/golden/dialpad_enabled.png index e2357d55..5ee42187 100644 Binary files a/test/src/components/dialpad/golden/dialpad_enabled.png and b/test/src/components/dialpad/golden/dialpad_enabled.png differ diff --git a/test/src/components/dialpad/golden/dialpadbutton.png b/test/src/components/dialpad/golden/dialpadbutton.png index b7c289fc..7bbc925e 100644 Binary files a/test/src/components/dialpad/golden/dialpadbutton.png and b/test/src/components/dialpad/golden/dialpadbutton.png differ diff --git a/test/src/components/fabs/golden/FAB_default.png b/test/src/components/fabs/golden/FAB_default.png index e9fd5e47..8ab4dac2 100644 Binary files a/test/src/components/fabs/golden/FAB_default.png and b/test/src/components/fabs/golden/FAB_default.png differ diff --git a/test/src/components/fabs/golden/FAB_inverse.png b/test/src/components/fabs/golden/FAB_inverse.png index fed07d53..41bf5c0f 100644 Binary files a/test/src/components/fabs/golden/FAB_inverse.png and b/test/src/components/fabs/golden/FAB_inverse.png differ diff --git a/test/src/components/fabs/golden/FAB_secondary.png b/test/src/components/fabs/golden/FAB_secondary.png index df672743..40f2cf3b 100644 Binary files a/test/src/components/fabs/golden/FAB_secondary.png and b/test/src/components/fabs/golden/FAB_secondary.png differ diff --git a/test/src/components/in_page_banner/golden/in_page_banner_buttons.png b/test/src/components/in_page_banner/golden/in_page_banner_buttons.png index bfc5644e..1b34beed 100644 Binary files a/test/src/components/in_page_banner/golden/in_page_banner_buttons.png and b/test/src/components/in_page_banner/golden/in_page_banner_buttons.png differ diff --git a/test/src/components/in_page_banner/golden/in_page_banner_default.png b/test/src/components/in_page_banner/golden/in_page_banner_default.png index 641ee16b..d1dc47c0 100644 Binary files a/test/src/components/in_page_banner/golden/in_page_banner_default.png and b/test/src/components/in_page_banner/golden/in_page_banner_default.png differ diff --git a/test/src/components/in_page_banner/golden/in_page_banner_negative.png b/test/src/components/in_page_banner/golden/in_page_banner_negative.png index 406c1b0f..5f808d48 100644 Binary files a/test/src/components/in_page_banner/golden/in_page_banner_negative.png and b/test/src/components/in_page_banner/golden/in_page_banner_negative.png differ diff --git a/test/src/components/in_page_banner/golden/in_page_banner_positive.png b/test/src/components/in_page_banner/golden/in_page_banner_positive.png index 7c12198b..2ec287da 100644 Binary files a/test/src/components/in_page_banner/golden/in_page_banner_positive.png and b/test/src/components/in_page_banner/golden/in_page_banner_positive.png differ diff --git a/test/src/components/password/golden/password_default.png b/test/src/components/password/golden/password_default.png index 91231e82..87a49c78 100644 Binary files a/test/src/components/password/golden/password_default.png and b/test/src/components/password/golden/password_default.png differ diff --git a/test/src/components/password/golden/password_error.png b/test/src/components/password/golden/password_error.png index b7ed8586..f2288ab0 100644 Binary files a/test/src/components/password/golden/password_error.png and b/test/src/components/password/golden/password_error.png differ diff --git a/test/src/components/tooltip/golden/arrow_down.png b/test/src/components/tooltip/golden/arrow_down.png index 4635ff7c..f7e97880 100644 Binary files a/test/src/components/tooltip/golden/arrow_down.png and b/test/src/components/tooltip/golden/arrow_down.png differ diff --git a/test/src/components/tooltip/golden/arrow_left.png b/test/src/components/tooltip/golden/arrow_left.png index e15b340e..05f2c4fb 100644 Binary files a/test/src/components/tooltip/golden/arrow_left.png and b/test/src/components/tooltip/golden/arrow_left.png differ diff --git a/test/src/components/tooltip/golden/arrow_right.png b/test/src/components/tooltip/golden/arrow_right.png index 12a63dee..c329440c 100644 Binary files a/test/src/components/tooltip/golden/arrow_right.png and b/test/src/components/tooltip/golden/arrow_right.png differ diff --git a/test/src/components/tooltip/golden/arrow_up.png b/test/src/components/tooltip/golden/arrow_up.png index 6ea5556f..c7f0165b 100644 Binary files a/test/src/components/tooltip/golden/arrow_up.png and b/test/src/components/tooltip/golden/arrow_up.png differ diff --git a/test/src/zeta_provider_test.dart b/test/src/zeta_provider_test.dart index 1d39bcf1..efbe26f9 100644 --- a/test/src/zeta_provider_test.dart +++ b/test/src/zeta_provider_test.dart @@ -25,7 +25,7 @@ void main() { final providerState = tester.state(find.byType(ZetaProvider)); expect(providerState.widget.initialThemeMode, ThemeMode.system); expect(providerState.widget.initialContrast, ZetaContrast.aa); - expect(providerState.widget.initialThemeData, isNotNull); + expect(providerState.widget.initialZetaThemeData, isNotNull); }); testWidgets('initializes with provided values', (WidgetTester tester) async { @@ -42,7 +42,7 @@ void main() { final providerState = tester.state(find.byType(ZetaProvider)); expect(providerState.widget.initialThemeMode, ThemeMode.light); expect(providerState.widget.initialContrast, ZetaContrast.aaa); - expect(providerState.widget.initialThemeData, initialThemeData); + expect(providerState.widget.initialZetaThemeData, initialThemeData); expect(providerState.widget.themeService, mockThemeService); }); @@ -216,7 +216,7 @@ void main() { ), ), ); - +//TODO: This does not work as expected await tester.pumpAndSettle(const Duration(milliseconds: 250)); // Verifying through the public interface of Zeta widget diff --git a/test/test_utils/test_app.dart b/test/test_utils/test_app.dart index a84dc976..97272772 100644 --- a/test/test_utils/test_app.dart +++ b/test/test_utils/test_app.dart @@ -22,6 +22,7 @@ class TestApp extends StatelessWidget { Widget build(BuildContext context) { return ZetaProvider.base( initialThemeMode: themeMode ?? ThemeMode.system, + initialRounded: rounded ?? true, builder: (context, lightTheme, darkTheme, themeMode) { return MaterialApp( theme: lightTheme,