Skip to content

feat(config): configurable Firebase + external config injection for embedding#1440

Closed
SERDUN wants to merge 5 commits into
developfrom
feat/embedded-host-support
Closed

feat(config): configurable Firebase + external config injection for embedding#1440
SERDUN wants to merge 5 commits into
developfrom
feat/embedded-host-support

Conversation

@SERDUN

@SERDUN SERDUN commented Jun 23, 2026

Copy link
Copy Markdown
Member

Overview

Let webtrit_phone run inside another Flutter host (the theme configurator's realtime preview) purely through configuration — the app never has an "embedded" flag and never branches on "am I embedded".

  • WEBTRIT_APP_FIREBASE_ENABLED config (default true). bootstrap gates Firebase app/messaging/local-push init, the app-id provider (FirebaseAppIdProviderSharedPreferencesAppIdProvider) and Remote Config on it. The analytics navigator observer is attached only when it is true, and the analytics provider is now lazy, so a Firebase-free run never touches FirebaseAnalytics.instance. A host disables Firebase via the existing dart-define override mechanism — no embeddedPreview flag anywhere.
  • External config injection. RootApp/App accept optional external ThemeSettings / ThemeMode / FeatureAccess streams (+ initial seeds) so a host drives the live appearance and feature/login config. Theme is applied via AppThemeSettingsChanged / AppThemeModeChanged (no prefs write); the FeatureAccess StreamProvider source is swapped to the external stream when provided.

Why

Replaces the closed #1437/#1438/#1439 attempts with a single, cleaner design: the app is configured (Firebase on/off + config sources), never aware of embedding. This is the phone-side support for the configurator realtime-preview epic.

Notes

  • Standalone behaviour byte-identical: FIREBASE_ENABLED defaults true, external streams default null.
  • flutter analyze lib green; test/environment_config_test.dart (8 tests incl. FIREBASE_ENABLED default/override) passes.

SERDUN added 5 commits June 23, 2026 20:50
…mbedding

Let webtrit_phone run inside another Flutter host (the theme configurator's
realtime preview) purely through configuration — the app never knows it is
"embedded".

- Add the WEBTRIT_APP_FIREBASE_ENABLED config (default true). bootstrap gates
  Firebase app/messaging/local-push, the app-id provider (Installations vs
  shared-preferences) and Remote Config on it; the analytics navigator observer
  is attached only when it is true, and the analytics provider is lazy so a
  Firebase-free run never touches FirebaseAnalytics.instance. A host configures
  this off via the existing dart-define override mechanism — no embedded flag.
- RootApp/App accept optional external ThemeSettings/ThemeMode/FeatureAccess
  streams (+ initial seeds) so a host can drive the live appearance and
  feature/login config; theme is applied via AppThemeSettingsChanged/
  AppThemeModeChanged (no prefs write), and the FeatureAccess StreamProvider
  source is swapped to the external stream when provided.

Standalone behaviour is unchanged: FIREBASE_ENABLED defaults to true and all
external streams default to null.
Replace the four external Theme/ThemeMode/FeatureAccess stream params spread
across RootApp and App with a single AppConfigSource value object threaded
RootApp -> App. RootApp/App now take one optional `configSource` instead of
several scattered stream fields. No behaviour change.
AppConfigSource now carries plain values (ThemeSettings/ThemeMode/FeatureAccess)
instead of streams. The app renders them directly through the widget tree the
same way it renders everything else - App reads the theme from configSource (or
its AppBloc), and RootApp provides the FeatureAccess value (or the normal
StreamProvider). A host re-supplies a fresh AppConfigSource on each edit, so
reactivity comes from the normal rebuild; no stream subscriptions, no
AppThemeSettingsChanged/AppThemeModeChanged plumbing, no initial-seed field.
…tree

Remove the AppConfigSource wrapper. RootApp now takes plain optional
themeSettings/themeMode/featureAccess values and provides each down the widget
tree (Provider.value for the theme + the FeatureAccess override), exactly like
the app provides everything else. App reads the theme via context.watch (falling
back to its AppBloc theme) and FeatureAccess via the existing provider. No
wrapper object, no constructor config on App.
…source

Stop overriding the theme in build (`hostThemeSettings ?? state.themeSettings`).
The app renders only `state.themeSettings`; when a host (the configurator's
realtime preview) supplies a theme through the tree, App pushes it into the
AppBloc via AppThemeSettingsChanged/AppThemeModeChanged in didChangeDependencies
(same place it reacts to FeatureAccess). No streams, no build-time fallback —
AppState stays the single source of truth.
@SERDUN

SERDUN commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

Splitting into two independent PRs: (A) configurable Firebase, (B) host theme/feature-config injection.

@SERDUN SERDUN closed this Jun 24, 2026
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.

1 participant