updater ui, data implementation

This commit is contained in:
2026-07-25 17:57:46 +03:00
parent 7bd09459fa
commit aa6c62d283
14 changed files with 178 additions and 13 deletions
@@ -67,4 +67,5 @@
<string name="user_tags_tag_delete">Удалить</string>
<string name="movie_tags_empty">Настроить теги</string>
<string name="user_tags_filter_disable">Не фильтровать</string>
<string name="check_for_updates">Поиск обновлений</string>
</resources>
@@ -1,7 +1,7 @@
package ru.shadowsparky.vbox.shared.presentation.settings
import com.arkivanov.decompose.ComponentContext
import kotlinx.coroutines.flow.filterNotNull
import com.arkivanov.decompose.childContext
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import org.koin.core.annotation.Factory
@@ -11,6 +11,7 @@ import ru.shadowsparky.http.domain.LogoutAction
import ru.shadowsparky.http.domain.TokenStorage
import ru.shadowsparky.ui.nav.BaseRootComponent
import ru.shadowsparky.ui.nav.ComponentFactory
import ru.shadowsparky.updater.presentation.UpdateComponentFactory
import ru.shadowsparky.vbox.shared.di.factory.DispatcherProvider
import ru.shadowsparky.vbox.shared.domain.OfflineStorage
import ru.shadowsparky.vbox.shared.domain.PlayerSettingsStorge
@@ -29,6 +30,7 @@ class SettingsComponent(
private val playerSettingsStorge: PlayerSettingsStorge,
val offlineSupport: Boolean,
val isDebug: Boolean,
updateComponentFactory: UpdateComponentFactory,
val doBack: () -> Unit,
val editServAddr: () -> Unit,
val doAuth: () -> Unit,
@@ -37,9 +39,11 @@ class SettingsComponent(
val showOffline: () -> Unit,
val showTags: () -> Unit
) : ComponentContext by context {
val serverInfo = serverConfigurationRepository.serverConfiguration
.filterNotNull()
.map { it.asHttpStr() }
private val updateComponent = updateComponentFactory.create(childContext("UpdateComponent"))
val hasUpdateSupport = updateComponent.hasSupport
val serverInfo = serverConfigurationRepository.serverConfiguration.map { it.asHttpStr() }
private val componentScope = createComponentScope()
val externalPlayerState = playerSettingsStorge.useExternalPlayer
@@ -52,6 +56,10 @@ class SettingsComponent(
}
}
fun checkUpdates() {
updateComponent.checkUpdates()
}
fun logout() {
componentScope.launch(dispatcherProvider.main) {
logoutUseCase.logout()
@@ -68,7 +76,8 @@ class SettingsComponentFactory(
private val appConfig: AppConfig,
private val playerSettingsStorge: PlayerSettingsStorge,
private val tokenStorage: TokenStorage,
private val offlineStorage: OfflineStorage?
private val offlineStorage: OfflineStorage?,
private val updateComponentFactory: UpdateComponentFactory
) : ComponentFactory<Child.SettingsChild, Route.Settings, Route> {
override fun create(
@@ -80,7 +89,8 @@ class SettingsComponentFactory(
child,
dispatcherProvider,
serverConfigurationRepository,
isDebug = appConfig.isDebug(),
isDebug = appConfig.debug,
updateComponentFactory = updateComponentFactory,
doBack = { root.onBack() },
editServAddr = { root.nav(Route.Settings.EditServ()) },
doAuth = { root.nav(Route.Settings.Auth(required = true)) },
@@ -4,6 +4,7 @@ import androiddev.apps.vbox.client.shared.generated.resources.Res
import androiddev.apps.vbox.client.shared.generated.resources.account_auth
import androiddev.apps.vbox.client.shared.generated.resources.account_logout_auth
import androiddev.apps.vbox.client.shared.generated.resources.account_reg
import androiddev.apps.vbox.client.shared.generated.resources.check_for_updates
import androiddev.apps.vbox.client.shared.generated.resources.custom_serv_addr
import androiddev.apps.vbox.client.shared.generated.resources.edit_password
import androiddev.apps.vbox.client.shared.generated.resources.external_player_title
@@ -72,6 +73,14 @@ fun SettingsContent(comp: SettingsComponent, paddingValues: PaddingValues) {
modifier = Modifier.clickable { comp.showTags() }
)
}
if (comp.hasUpdateSupport) {
item {
TextPreference(
text = stringResource(Res.string.check_for_updates),
modifier = Modifier.clickable { comp.checkUpdates() }
)
}
}
}
section {
val needAuth = tokenInfo == null