feat(app): let the caller supply theme and feature config sources#1446
Open
SERDUN wants to merge 3 commits into
Open
feat(app): let the caller supply theme and feature config sources#1446SERDUN wants to merge 3 commits into
SERDUN wants to merge 3 commits into
Conversation
Make RootApp agnostic about where its theme and feature config come from: it
takes a ConfigSource (an {initial, updates} record) for each and wires it into
the inherited StreamProvider, without reaching into the registry or branching on
a host flag.
The composition root decides the source:
- standalone (main) resolves it from the bootstrap registry - the
FeatureAccessStreamFactory stream and the first AppThemes theme (static, so an
empty updates stream);
- a host that embeds this app in-process (the theme configurator's realtime
preview) passes its own streams, so the preview reflects live edits through the
same inherited ThemeSettings / FeatureAccess the app already consumes.
No wrapper class and no imperative relay; standalone behaviour is unchanged.
475dfd5 to
ba5f6cb
Compare
The host (the configurator's realtime preview) needs to drive the displayed light/dark mode, but FeatureAccess.supportedConfig.themeMode is not practically settable from outside (FeatureAccess/SupportedConfig are plain Equatable value objects with no copyWith), and the embedded AppBloc is unreachable. Add an optional ConfigSource<ThemeMode> to RootApp, provided as an inherited ThemeMode? (null in a standalone run). App.build uses it directly when present: finalThemeMode = hostThemeMode ?? <FeatureAccess/AppState mode>. It is read-only - nothing is persisted and AppBloc is untouched - so an ephemeral preview never affects the real saved preference. Standalone behaviour is unchanged.
The theme refactor removed AppState.themeSettings / effectiveThemeMode, but the screenshots package (used by the configurator's static/semi-dynamic preview) still read them, breaking its build. Provide ThemeSettings as an inherited value here too: bootstrap and the configurator's preview builder supply a Provider<ThemeSettings>, ScreenshotApp reads context.watch<ThemeSettings>(), and the effective mode is derived via the ThemeSettings extension from the settings plus AppState.themeMode. MockAppBloc.allScreen no longer takes themeSettings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Makes
RootAppagnostic about where its theme and feature config come from. It takes aConfigSource(an{initial, updates}record) for each and wires it into the inheritedStreamProvider— without reaching into the registry or branching on a host flag. The composition root decides the source.This is the phone-side half of the embedding work (the configurator side comes next). It builds on the inherited-config groundwork already on develop, so the host only supplies a different source; consumers (
App.build,ThemeModeScreen) stay agnostic.Changes
RootApp.buildwires eachConfigSourcestraight into aStreamProvider(initialData: source.initial,create: source.updates) — no registry access, nohost ?? defaultbranch.main) resolves the sources from the bootstrap registry: theFeatureAccessStreamFactorystream, and the firstAppThemestheme (static, soupdates: const Stream.empty()).bootstrap(firebase: const FirebaseIntegrationDisabled())— live edits flow through the same inherited values.It's a record, not a wrapper class; no imperative relay.
Verification
flutter analyze— clean.updatesis empty).