Move the home scrollstate to the main composable to avoid fab annimation.
This commit is contained in:
parent
6924418d21
commit
be602d5325
10 changed files with 46 additions and 18 deletions
|
|
@ -49,6 +49,9 @@ fun HomeNavHost(
|
|||
navHostController: NavHostController = rememberNavController(),
|
||||
bottomBarItems: List<BottomBarItem> = rememberBottomBarItems(navHostController),
|
||||
startDestination: String = LEXICON_LIST_ROUTE,
|
||||
lexiconListState: LazyListState,
|
||||
questListState: LazyListState,
|
||||
locationListState: LazyListState,
|
||||
) {
|
||||
CompositionLocalProvider(
|
||||
LocalSnack provides remember { SnackbarHostState() },
|
||||
|
|
@ -105,9 +108,9 @@ fun HomeNavHost(
|
|||
navController = navHostController,
|
||||
startDestination = startDestination,
|
||||
) {
|
||||
composableLexicon()
|
||||
composableQuests()
|
||||
composableLocations()
|
||||
composableLexicon(lazyListState = lexiconListState)
|
||||
composableQuests(lazyListState = questListState)
|
||||
composableLocations(lazyListState = locationListState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import androidx.navigation.NavHostController
|
|||
import androidx.navigation.NavOptionsBuilder
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.pixelized.rplexicon.ui.navigation.screens.AUTHENTICATION_ROUTE
|
||||
import com.pixelized.rplexicon.ui.navigation.screens.HOME_ROUTE
|
||||
import com.pixelized.rplexicon.ui.navigation.screens.composableAuthentication
|
||||
import com.pixelized.rplexicon.ui.navigation.screens.composableCharacterSheet
|
||||
|
|
@ -41,7 +40,11 @@ fun ScreenNavHost(
|
|||
startDestination = startDestination,
|
||||
) {
|
||||
composableAuthentication()
|
||||
composableHome()
|
||||
composableHome(
|
||||
lexiconListState = lexiconListState,
|
||||
questListState = questListState,
|
||||
locationListState = locationListState,
|
||||
)
|
||||
composableLexiconDetail()
|
||||
composableLexiconSearch()
|
||||
composableQuestDetail()
|
||||
|
|
|
|||
|
|
@ -12,12 +12,16 @@ private const val ROUTE = "lexicon"
|
|||
|
||||
const val LEXICON_LIST_ROUTE = ROUTE
|
||||
|
||||
fun NavGraphBuilder.composableLexicon() {
|
||||
fun NavGraphBuilder.composableLexicon(
|
||||
lazyListState: LazyListState,
|
||||
) {
|
||||
animatedComposable(
|
||||
route = LEXICON_LIST_ROUTE,
|
||||
animation = NavigationAnimation.Fade,
|
||||
) {
|
||||
LexiconScreen()
|
||||
LexiconScreen(
|
||||
lazyListState = lazyListState
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,16 @@ private const val ROUTE = "locations"
|
|||
|
||||
const val LOCATION_LIST_ROUTE = ROUTE
|
||||
|
||||
fun NavGraphBuilder.composableLocations() {
|
||||
fun NavGraphBuilder.composableLocations(
|
||||
lazyListState: LazyListState,
|
||||
) {
|
||||
animatedComposable(
|
||||
route = LOCATION_LIST_ROUTE,
|
||||
animation = NavigationAnimation.Fade,
|
||||
) {
|
||||
LocationScreen()
|
||||
LocationScreen(
|
||||
lazyListState = lazyListState,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,16 @@ private const val ROUTE = "quests"
|
|||
|
||||
const val QUEST_LIST_ROUTE = ROUTE
|
||||
|
||||
fun NavGraphBuilder.composableQuests() {
|
||||
fun NavGraphBuilder.composableQuests(
|
||||
lazyListState: LazyListState,
|
||||
) {
|
||||
animatedComposable(
|
||||
route = QUEST_LIST_ROUTE,
|
||||
animation = NavigationAnimation.Fade,
|
||||
) {
|
||||
QuestListScreen()
|
||||
QuestListScreen(
|
||||
lazyListState = lazyListState,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.pixelized.rplexicon.ui.navigation.screens
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.NavOptionsBuilder
|
||||
|
|
@ -11,12 +12,20 @@ private const val ROUTE = "home"
|
|||
|
||||
const val HOME_ROUTE = ROUTE
|
||||
|
||||
fun NavGraphBuilder.composableHome() {
|
||||
fun NavGraphBuilder.composableHome(
|
||||
lexiconListState: LazyListState,
|
||||
questListState: LazyListState,
|
||||
locationListState: LazyListState,
|
||||
) {
|
||||
animatedComposable(
|
||||
route = HOME_ROUTE,
|
||||
animation = NavigationAnimation.Push,
|
||||
) {
|
||||
HomeNavHost()
|
||||
HomeNavHost(
|
||||
lexiconListState = lexiconListState,
|
||||
questListState = questListState,
|
||||
locationListState = locationListState,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.sizeIn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ import kotlinx.coroutines.launch
|
|||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun LexiconScreen(
|
||||
viewModel: LexiconViewModel = hiltViewModel()
|
||||
viewModel: LexiconViewModel = hiltViewModel(),
|
||||
lazyListState: LazyListState,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val screen = LocalScreenNavHost.current
|
||||
val lazyListState = rememberLazyListState()
|
||||
|
||||
val refresh = rememberPullRefreshState(
|
||||
refreshing = false,
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ import kotlinx.coroutines.launch
|
|||
@Composable
|
||||
fun LocationScreen(
|
||||
viewModel: LocationViewModel = hiltViewModel(),
|
||||
lazyListState: LazyListState,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val lazyListState = rememberLazyListState()
|
||||
val screen = LocalScreenNavHost.current
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
val refresh = rememberPullRefreshState(
|
||||
refreshing = false,
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ import kotlinx.coroutines.launch
|
|||
@Composable
|
||||
fun QuestListScreen(
|
||||
viewModel: QuestListViewModel = hiltViewModel(),
|
||||
lazyListState: LazyListState,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val screen = LocalScreenNavHost.current
|
||||
val lazyListState = rememberLazyListState()
|
||||
|
||||
val refresh = rememberPullRefreshState(
|
||||
refreshing = false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue