mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Try to Preview the navigation (not working)
This commit is contained in:
@@ -11,9 +11,10 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import com.ramcosta.composedestinations.DestinationsNavHost
|
import com.ramcosta.composedestinations.DestinationsNavHost
|
||||||
import com.ramcosta.composedestinations.rememberNavHostEngine
|
import com.ramcosta.composedestinations.rememberNavHostEngine
|
||||||
|
import com.ramcosta.composedestinations.spec.Route
|
||||||
import io.element.android.x.core.compose.OnLifecycleEvent
|
import io.element.android.x.core.compose.OnLifecycleEvent
|
||||||
import io.element.android.x.designsystem.ElementXTheme
|
import io.element.android.x.designsystem.ElementXTheme
|
||||||
import io.element.android.x.destinations.OnBoardingScreenNavigationDestination
|
import io.element.android.x.destinations.OnBoardingScreenNavigationDestination
|
||||||
@@ -36,8 +37,6 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MainScreen(viewModel: MainViewModel) {
|
private fun MainScreen(viewModel: MainViewModel) {
|
||||||
val engine = rememberNavHostEngine()
|
|
||||||
val navController = engine.rememberNavController()
|
|
||||||
val startRoute = runBlocking {
|
val startRoute = runBlocking {
|
||||||
if (!viewModel.isLoggedIn()) {
|
if (!viewModel.isLoggedIn()) {
|
||||||
OnBoardingScreenNavigationDestination
|
OnBoardingScreenNavigationDestination
|
||||||
@@ -47,11 +46,7 @@ private fun MainScreen(viewModel: MainViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DestinationsNavHost(
|
MainContent(
|
||||||
modifier = Modifier.background(MaterialTheme.colorScheme.background),
|
|
||||||
engine = engine,
|
|
||||||
navController = navController,
|
|
||||||
navGraph = NavGraphs.root,
|
|
||||||
startRoute = startRoute
|
startRoute = startRoute
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,3 +54,23 @@ private fun MainScreen(viewModel: MainViewModel) {
|
|||||||
Timber.v("OnLifecycleEvent: $event")
|
Timber.v("OnLifecycleEvent: $event")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun MainContent(startRoute: Route) {
|
||||||
|
val engine = rememberNavHostEngine()
|
||||||
|
val navController = engine.rememberNavController()
|
||||||
|
|
||||||
|
DestinationsNavHost(
|
||||||
|
modifier = Modifier.background(MaterialTheme.colorScheme.background),
|
||||||
|
engine = engine,
|
||||||
|
navController = navController,
|
||||||
|
navGraph = NavGraphs.root,
|
||||||
|
startRoute = startRoute
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@Preview
|
||||||
|
private fun MainContentPreview() {
|
||||||
|
MainContent(startRoute = OnBoardingScreenNavigationDestination)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user