diff --git a/features/home/src/main/kotlin/app/dapk/st/home/HomeScreen.kt b/features/home/src/main/kotlin/app/dapk/st/home/HomeScreen.kt index 5f8ce7d..2cca6ae 100644 --- a/features/home/src/main/kotlin/app/dapk/st/home/HomeScreen.kt +++ b/features/home/src/main/kotlin/app/dapk/st/home/HomeScreen.kt @@ -10,15 +10,18 @@ import app.dapk.st.core.LifecycleEffect import app.dapk.st.core.components.CenteredLoading import app.dapk.st.design.components.CircleishAvatar import app.dapk.st.directory.DirectoryScreen +import app.dapk.st.directory.state.DirectoryState import app.dapk.st.home.HomeScreenState.* import app.dapk.st.home.HomeScreenState.Page.Directory import app.dapk.st.home.HomeScreenState.Page.Profile import app.dapk.st.login.LoginScreen +import app.dapk.st.login.state.LoginState import app.dapk.st.profile.ProfileScreen +import app.dapk.st.profile.state.ProfileState @OptIn(ExperimentalMaterial3Api::class) @Composable -internal fun HomeScreen(homeViewModel: HomeViewModel) { +internal fun HomeScreen(homeViewModel: HomeViewModel, directoryState: DirectoryState, loginState: LoginState, profileState: ProfileState) { LifecycleEffect( onStart = { homeViewModel.start() }, onStop = { homeViewModel.stop() } @@ -34,9 +37,9 @@ internal fun HomeScreen(homeViewModel: HomeViewModel) { content = { innerPadding -> Box(modifier = Modifier.padding(innerPadding)) { when (state.page) { - Directory -> DirectoryScreen(homeViewModel.directory()) + Directory -> DirectoryScreen(directoryState) Profile -> { - ProfileScreen(homeViewModel.profile()) { + ProfileScreen(profileState) { homeViewModel.changePage(Directory) } } @@ -47,7 +50,7 @@ internal fun HomeScreen(homeViewModel: HomeViewModel) { } SignedOut -> { - LoginScreen(homeViewModel.login()) { + LoginScreen(loginState) { homeViewModel.loggedIn() } } diff --git a/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt b/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt index 30174fe..b9cc982 100644 --- a/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt +++ b/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt @@ -30,10 +30,6 @@ internal class HomeViewModel( private var listenForInvitesJob: Job? = null - fun directory() = directoryState - fun login() = loginState - fun profile() = profileState - fun start() { viewModelScope.launch { state = if (chatEngine.isSignedIn()) { diff --git a/features/home/src/main/kotlin/app/dapk/st/home/MainActivity.kt b/features/home/src/main/kotlin/app/dapk/st/home/MainActivity.kt index fb41b05..a3315b3 100644 --- a/features/home/src/main/kotlin/app/dapk/st/home/MainActivity.kt +++ b/features/home/src/main/kotlin/app/dapk/st/home/MainActivity.kt @@ -43,7 +43,7 @@ class MainActivity : DapkActivity() { BetaUpgradeDialog() } else { Surface(Modifier.fillMaxSize()) { - HomeScreen(homeViewModel) + HomeScreen(homeViewModel, directoryState, loginState, profileState) } } }