feat(connector): add ScreenModel for SimulatorTest

This commit is contained in:
Anthony 2024-05-01 12:54:30 +01:00
parent 878b4f6a0c
commit c5e20d6363
3 changed files with 32 additions and 2 deletions

View File

@ -151,6 +151,7 @@ class ListProcedures (
DropdownMenuItem( DropdownMenuItem(
text = { Text("Run Test") }, text = { Text("Run Test") },
onClick = { onClick = {
viewModel.procedureId = procedure.id
tabNavigator.current = SimulatorTest tabNavigator.current = SimulatorTest
}, },
leadingIcon = { leadingIcon = {

View File

@ -1,7 +1,8 @@
package tab.test package tab.test
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import cafe.adriel.voyager.navigator.CurrentScreen
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.tab.Tab import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabOptions import cafe.adriel.voyager.navigator.tab.TabOptions
import connector.composeapp.generated.resources.Res import connector.composeapp.generated.resources.Res
@ -30,6 +31,8 @@ object SimulatorTest : Tab {
@Composable @Composable
override fun Content() { override fun Content() {
Text("Simulator Test") Navigator(TestContent()) {
CurrentScreen()
}
} }
} }

View File

@ -0,0 +1,26 @@
package tab.test
import androidx.compose.runtime.*
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.koin.getScreenModel
import tab.LoadingScreen
import tab.procedure.ActionsScreenModel
import tab.procedure.ActionsState
class TestContent : Screen {
@Composable
override fun Content() {
val screenModel = getScreenModel<ActionsScreenModel>()
val state by screenModel.state.collectAsState()
when (val s = state) {
is ActionsState.Loading -> LoadingScreen("Simulator Test")
is ActionsState.Idle -> { /* TODO implement error? */ }
is ActionsState.Result -> TODO("Not yet implemented")
}
LaunchedEffect(currentCompositeKeyHash) {
screenModel.getActions()
}
}
}