Files
honeyDueKMP/composeApp/src/commonMain/kotlin/com/tt/honeyDue/data/IDataManager.kt
Trey T 98b775d335 P0.1: extract IDataManager interface + LocalDataManager ambient
Adds a narrow IDataManager contract covering the 5 DataManager members
referenced from ui/screens/** (currentUser, residences, totalSummary,
featureBenefits, subscription) and a staticCompositionLocalOf ambient
(LocalDataManager) that defaults to the DataManager singleton.

No screen call-sites change in this commit — screens migrate in P0.2.
ViewModels, APILayer, and PersistenceManager continue to depend on the
concrete DataManager singleton directly; the interface is deliberately
scoped to the screen surface the parity-gallery needs to substitute.

Includes IDataManagerTest (DataManager is IDataManager) and
LocalDataManagerTest (ambient val is exposed + default type-checks to the
real singleton). runComposeUiTest intentionally avoided — consistent with
ThemeSelectionScreenTest's convention, since commonTest composition
runtime is flaky on iosSimulator.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 19:06:16 -05:00

38 lines
1.7 KiB
Kotlin

package com.tt.honeyDue.data
import com.tt.honeyDue.models.FeatureBenefit
import com.tt.honeyDue.models.Residence
import com.tt.honeyDue.models.SubscriptionStatus
import com.tt.honeyDue.models.TotalSummary
import com.tt.honeyDue.models.User
import kotlinx.coroutines.flow.StateFlow
/**
* Minimal contract covering the [DataManager] surface consumed by Compose screens.
*
* This interface exists solely so screens can depend on an abstraction that tests,
* previews, and the parity-gallery can substitute via [LocalDataManager]. It is
* deliberately narrow — only members referenced from the ui/screens package tree
* are included.
*
* ViewModels, [com.tt.honeyDue.network.APILayer], and [PersistenceManager] continue
* to use the concrete [DataManager] singleton directly; widening this interface to
* cover their surface is explicitly out of scope for the ambient refactor.
*/
interface IDataManager {
/** Observed by [com.tt.honeyDue.ui.screens.ProfileScreen], [com.tt.honeyDue.ui.screens.ResidenceDetailScreen], [com.tt.honeyDue.ui.screens.ResidenceFormScreen]. */
val currentUser: StateFlow<User?>
/** Observed by [com.tt.honeyDue.ui.screens.ContractorDetailScreen] and the onboarding first-task screen. */
val residences: StateFlow<List<Residence>>
/** Observed by [com.tt.honeyDue.ui.screens.HomeScreen] and [com.tt.honeyDue.ui.screens.ResidencesScreen]. */
val totalSummary: StateFlow<TotalSummary?>
/** Observed by [com.tt.honeyDue.ui.screens.subscription.FeatureComparisonScreen]. */
val featureBenefits: StateFlow<List<FeatureBenefit>>
/** Observed by [com.tt.honeyDue.ui.screens.ProfileScreen]. */
val subscription: StateFlow<SubscriptionStatus?>
}