chat android tv adaptation

This commit is contained in:
2026-08-09 11:59:33 +03:00
parent db47d8c2ce
commit 523b164964
8 changed files with 302 additions and 164 deletions
@@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.ComposeViewport
@@ -62,24 +61,19 @@ fun mainInternal() {
startKoin<VBox>()
val lifecycle = LifecycleRegistry()
val composeRoot = document.getElementById("compose-root") as HTMLElement
var rootRef: VBoxRootComponent? = null
val root: VBoxRootComponent = withWebHistory { stateKeeper: StateKeeper, deepLinkUrl: String? ->
if (rootRef == null) {
rootRef = createRoot(lifecycle, stateKeeper, deepLinkUrl)
}
rootRef
createRoot(lifecycle, stateKeeper, deepLinkUrl)
}
hookPageVisibility(lifecycle)
lifecycle.doOnResume { hideElementById("loader") }
ComposeViewport(viewportContainer = composeRoot, content = {
val r = remember { root }
ComposeViewport(composeRoot) {
LaunchedEffect(null) {
r.onFinish.collect { r.navReplace(Route.Loading()) }
root.onFinish.collect { root.navReplace(Route.Loading()) }
}
Box(Modifier.fillMaxSize().padding(WindowInsets.safeDrawing.asPaddingValues())) {
Nav(r)
Nav(root)
}
})
}
}
private fun createRoot(
@@ -87,9 +81,7 @@ private fun createRoot(
stateKeeper: StateKeeper,
deepLinkUrl: String?
): VBoxRootComponent {
val ctx = DefaultComponentContext(
lifecycle = lifecycle, stateKeeper = stateKeeper
)
val ctx = DefaultComponentContext(lifecycle, stateKeeper)
val deep = deepLinkUrl?.let { UrlRoutes.parseUrl(it) }
val initRoute: Route = deep ?: Route.default
return koin.get<RootFactory>().create(context = ctx, initStack = initRoute)