Skip to content

refactor(theme): provide ThemeSettings as an inherited value, out of AppState#1444

Merged
SERDUN merged 1 commit into
developfrom
refactor/theme-settings-inherited
Jun 24, 2026
Merged

refactor(theme): provide ThemeSettings as an inherited value, out of AppState#1444
SERDUN merged 1 commit into
developfrom
refactor/theme-settings-inherited

Conversation

@SERDUN

@SERDUN SERDUN commented Jun 24, 2026

Copy link
Copy Markdown
Member

Overview

Moves the active ThemeSettings out of AppState and provides it as an inherited value at the composition root, so the app consumes it directly through the widget tree — the same pattern already used for FeatureAccess.

The theme settings were static for a whole run (seeded once from AppThemes, never changed at runtime), yet lived in AppState; the only code that ever emitted AppThemeSettingsChanged was external. This refactor makes RootApp the single injection boundary for the theme and keeps everything below it consuming via providers — no bloc relay.

This is groundwork for host-driven theming (an embedder overriding the provider); standalone behaviour is unchanged.

Changes

  • RootApp provides Provider<ThemeSettings> (standalone: AppThemes.values.first.settings). An embedder can override this provider to drive the theme.
  • App.build and ThemeModeScreen read context.watch<ThemeSettings>() instead of AppState.themeSettings.
  • isThemeModeSupported / effectiveThemeMode move from AppState getters to a ThemeSettings extension (they depend only on the settings plus the mode).
  • AppState keeps only themeMode (still user-switchable and persisted). Dropped: the themeSettings field, the AppThemeSettingsChanged event + handler, and the now-unused AppThemes dependency of AppBloc.

Verification

  • flutter analyze — clean.
  • Full test suite — 940 pass (theme-mode screen, teardown, version-gate and app-compatibility-gate tests updated to the new shape).
  • ThemeProvider.of consumers (e.g. themed_scaffold) unaffected — the ThemeProvider widget still wraps MaterialApp.

@SERDUN SERDUN marked this pull request as draft June 24, 2026 09:51
@SERDUN SERDUN force-pushed the refactor/theme-settings-inherited branch from b3bd334 to 5f97b55 Compare June 24, 2026 14:12
@SERDUN SERDUN marked this pull request as ready for review June 24, 2026 14:15
@SERDUN SERDUN requested a review from digiboridev June 24, 2026 14:15
…AppState

The active theme settings were static for a whole run (seeded from AppThemes,
never changed at runtime) yet lived in AppState, and the only thing that ever
emitted AppThemeSettingsChanged was external. Move the theme settings out of the
bloc and provide them as an inherited value at the composition root, so the app
consumes them directly via the widget tree - the same pattern already used for
FeatureAccess.

- RootApp provides Provider<ThemeSettings>, derived directly from the registry's
  AppThemes (standalone: the first bootstrap-built theme). A future embedder can
  override this provider to drive the theme.
- App.build and ThemeModeScreen read context.watch<ThemeSettings>() instead of
  AppState.themeSettings.
- isThemeModeSupported / effectiveThemeMode move from AppState getters to a
  ThemeSettings extension (they depend only on the settings plus the mode).
- AppState keeps only themeMode (still user-switchable and persisted); drop the
  themeSettings field, AppThemeSettingsChanged event and its handler, and the
  now-unused AppThemes dependency of AppBloc.
- Drop the widget-tree Provider<AppThemes>: it was consumed only to seed the
  theme, so ThemeSettings now reads AppThemes straight from the registry.

Standalone behaviour is unchanged. Prepares the app for host-driven theming.
@SERDUN SERDUN force-pushed the refactor/theme-settings-inherited branch from 5f97b55 to e8f8c50 Compare June 24, 2026 14:28
@SERDUN SERDUN merged commit a5ab834 into develop Jun 24, 2026
2 checks passed
@SERDUN SERDUN deleted the refactor/theme-settings-inherited branch June 24, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants