refactor(android): add generic shared/UiState<T> sealed type

This commit is contained in:
2026-05-30 11:33:42 -04:00
parent 730176b1ed
commit 587baf4a79
@@ -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<PlaylistRef>`, etc.), so a single
* generic replaces the per-screen sealed interface declarations.
*/
sealed interface UiState<out T> {
data object Loading : UiState<Nothing>
data object Empty : UiState<Nothing>
data class Success<T>(val data: T) : UiState<T>
data class Error(val message: String) : UiState<Nothing>
}