diff --git a/android/app/src/main/java/com/fabledsword/minstrel/shared/UiState.kt b/android/app/src/main/java/com/fabledsword/minstrel/shared/UiState.kt new file mode 100644 index 00000000..43ee2c44 --- /dev/null +++ b/android/app/src/main/java/com/fabledsword/minstrel/shared/UiState.kt @@ -0,0 +1,22 @@ +package com.fabledsword.minstrel.shared + +/** + * Shared cache-first UI state for a screen / tab that resolves to a + * single payload. Mirrors the shape every screen had reinvented: + * - [Loading] cold start, before either the cache or the refresh + * has emitted anything + * - [Empty] the cache + refresh both succeeded with no data + * - [Success] the cache (or refresh) has a payload — render it + * - [Error] no cached data + the refresh failed; UI surfaces + * [message] from `ErrorCopy.fromThrowable` + * + * Each screen / tab parameterizes [T] with whatever it actually + * renders (`HomeSections`, `List`, etc.), so a single + * generic replaces the per-screen sealed interface declarations. + */ +sealed interface UiState { + data object Loading : UiState + data object Empty : UiState + data class Success(val data: T) : UiState + data class Error(val message: String) : UiState +}