Yokan / rebuild
Course 1 8624561

AppIconService.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/services/appicons/AppIconService.kt

implementation42 lines
1package eu.friedcutlet.yokan.services.appicons23/** Installation-owned state, deliberately absent from profile settings, sync, and backups. */4enum class AppIconDesign { Default, Torii }5enum class AppIconAppearance { Light, Dark, System }6data class AppIconSelection(7    val design: AppIconDesign = AppIconDesign.Default,8    val appearance: AppIconAppearance = AppIconAppearance.Light,9) {10    companion object { val Default = AppIconSelection() }11}1213val ExplicitAppIcons = listOf(14    AppIconSelection.Default,15    AppIconSelection(AppIconDesign.Torii, AppIconAppearance.Light),16    AppIconSelection(AppIconDesign.Torii, AppIconAppearance.Dark),17)18val SystemAppIcon = AppIconSelection(AppIconDesign.Torii, AppIconAppearance.System)1920enum class AppIconPlatform { Android, Ios, Static }21data class AppIconCapabilities(22    val platform: AppIconPlatform,23    val choices: List<AppIconSelection>,24) { val canChange: Boolean get() = choices.size > 1 }2526interface AppIconService {27    val capabilities: AppIconCapabilities28    /** Read OS-owned selection; null means unknown or inconsistent, never an invented default. */29    suspend fun current(): AppIconSelection?30    /** Returns only after OS completion. Implementations serialize changes and read back the result. */31    suspend fun apply(selection: AppIconSelection)32}3334class StaticAppIconService : AppIconService {35    override val capabilities = AppIconCapabilities(AppIconPlatform.Static, listOf(AppIconSelection.Default))36    override suspend fun current() = AppIconSelection.Default37    override suspend fun apply(selection: AppIconSelection) {38        require(selection == AppIconSelection.Default)39    }40}4142expect fun createPlatformAppIconService(): AppIconService43

Search chapters, reference and source filenames.