Fix FAB animation on lexicon / quest / map list.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-05-29 13:53:58 +02:00
parent 7652a6a902
commit 1c3d1a1036
7 changed files with 20 additions and 13 deletions

View file

@ -1,5 +1,6 @@
package com.pixelized.rplexicon.ui.navigation package com.pixelized.rplexicon.ui.navigation
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.runtime.staticCompositionLocalOf
@ -32,6 +33,10 @@ fun ScreenNavHost(
navHostController: NavHostController = rememberNavController(), navHostController: NavHostController = rememberNavController(),
startDestination: String = AUTHENTICATION_ROUTE, startDestination: String = AUTHENTICATION_ROUTE,
) { ) {
val lexiconLazyListState = rememberLazyListState()
val questsLazyListState = rememberLazyListState()
val locationsLazyListState = rememberLazyListState()
CompositionLocalProvider( CompositionLocalProvider(
LocalScreenNavHost provides navHostController, LocalScreenNavHost provides navHostController,
) { ) {
@ -46,11 +51,11 @@ fun ScreenNavHost(
) )
composableLanding() composableLanding()
composableSearch() composableSearch()
composableLexicon() composableLexicon(lazyListState = lexiconLazyListState)
composableLexiconDetail() composableLexiconDetail()
composableQuests() composableQuests(lazyListState = questsLazyListState)
composableQuestDetail() composableQuestDetail()
composableLocations() composableLocations(lazyListState = locationsLazyListState)
composableLocationDetail() composableLocationDetail()
composableCharacterSheet() composableCharacterSheet()
composableSpellDetail() composableSpellDetail()

View file

@ -1,5 +1,6 @@
package com.pixelized.rplexicon.ui.navigation.screens package com.pixelized.rplexicon.ui.navigation.screens
import androidx.compose.foundation.lazy.LazyListState
import androidx.navigation.NavGraphBuilder import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import androidx.navigation.NavOptionsBuilder import androidx.navigation.NavOptionsBuilder
@ -11,12 +12,12 @@ private const val ROUTE = "lexicon"
const val LEXICON_LIST_ROUTE = ROUTE const val LEXICON_LIST_ROUTE = ROUTE
fun NavGraphBuilder.composableLexicon() { fun NavGraphBuilder.composableLexicon(lazyListState: LazyListState) {
animatedComposable( animatedComposable(
route = LEXICON_LIST_ROUTE, route = LEXICON_LIST_ROUTE,
animation = NavigationAnimation.Push, animation = NavigationAnimation.Push,
) { ) {
LexiconScreen() LexiconScreen(lazyListState = lazyListState)
} }
} }

View file

@ -1,5 +1,6 @@
package com.pixelized.rplexicon.ui.navigation.screens package com.pixelized.rplexicon.ui.navigation.screens
import androidx.compose.foundation.lazy.LazyListState
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptionsBuilder import androidx.navigation.NavOptionsBuilder
@ -11,12 +12,12 @@ private const val ROUTE = "locations"
const val LOCATION_LIST_ROUTE = ROUTE const val LOCATION_LIST_ROUTE = ROUTE
fun NavGraphBuilder.composableLocations() { fun NavGraphBuilder.composableLocations(lazyListState: LazyListState) {
animatedComposable( animatedComposable(
route = LOCATION_LIST_ROUTE, route = LOCATION_LIST_ROUTE,
animation = NavigationAnimation.Push, animation = NavigationAnimation.Push,
) { ) {
LocationScreen() LocationScreen(lazyListState = lazyListState)
} }
} }

View file

@ -1,5 +1,6 @@
package com.pixelized.rplexicon.ui.navigation.screens package com.pixelized.rplexicon.ui.navigation.screens
import androidx.compose.foundation.lazy.LazyListState
import androidx.navigation.NavGraphBuilder import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import androidx.navigation.NavOptionsBuilder import androidx.navigation.NavOptionsBuilder
@ -11,12 +12,12 @@ private const val ROUTE = "quests"
const val QUEST_LIST_ROUTE = ROUTE const val QUEST_LIST_ROUTE = ROUTE
fun NavGraphBuilder.composableQuests() { fun NavGraphBuilder.composableQuests(lazyListState: LazyListState) {
animatedComposable( animatedComposable(
route = QUEST_LIST_ROUTE, route = QUEST_LIST_ROUTE,
animation = NavigationAnimation.Push, animation = NavigationAnimation.Push,
) { ) {
QuestListScreen() QuestListScreen(lazyListState = lazyListState)
} }
} }

View file

@ -61,10 +61,10 @@ import kotlinx.coroutines.launch
@Composable @Composable
fun LexiconScreen( fun LexiconScreen(
viewModel: LexiconViewModel = hiltViewModel(), viewModel: LexiconViewModel = hiltViewModel(),
lazyListState: LazyListState = rememberLazyListState(),
) { ) {
val screen = LocalScreenNavHost.current val screen = LocalScreenNavHost.current
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val lazyListState = rememberLazyListState()
val refresh = rememberPullRefreshState( val refresh = rememberPullRefreshState(
refreshing = false, refreshing = false,
onRefresh = { onRefresh = {

View file

@ -58,10 +58,10 @@ import kotlinx.coroutines.launch
@Composable @Composable
fun LocationScreen( fun LocationScreen(
viewModel: LocationViewModel = hiltViewModel(), viewModel: LocationViewModel = hiltViewModel(),
lazyListState: LazyListState = rememberLazyListState(),
) { ) {
val screen = LocalScreenNavHost.current val screen = LocalScreenNavHost.current
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val lazyListState = rememberLazyListState()
val refresh = rememberPullRefreshState( val refresh = rememberPullRefreshState(
refreshing = false, refreshing = false,

View file

@ -58,11 +58,10 @@ import kotlinx.coroutines.launch
@Composable @Composable
fun QuestListScreen( fun QuestListScreen(
viewModel: QuestListViewModel = hiltViewModel(), viewModel: QuestListViewModel = hiltViewModel(),
lazyListState: LazyListState = rememberLazyListState(),
) { ) {
val screen = LocalScreenNavHost.current val screen = LocalScreenNavHost.current
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val lazyListState = rememberLazyListState()
val refresh = rememberPullRefreshState( val refresh = rememberPullRefreshState(
refreshing = false, refreshing = false,
onRefresh = { onRefresh = {