Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.github.triplet.gradle.androidpublisher.ReleaseStatus
import java.util.Properties

plugins {
Expand Down Expand Up @@ -67,7 +66,10 @@ android {
targetCompatibility = javaVersion
}

buildFeatures { compose = true }
buildFeatures {
compose = true
buildConfig = true
}

packaging {
resources {
Expand All @@ -91,7 +93,6 @@ dependencies {
debugImplementation(libs.compose.ui.tooling)
}


play {
// The play_config.json file will be provided on CI
serviceAccountCredentials.set(file("../play_config.json"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.prof18.moneyflow.navigation

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
Expand Down Expand Up @@ -61,6 +69,25 @@ import org.jetbrains.compose.resources.stringResource
import org.koin.compose.koinInject
import org.koin.compose.viewmodel.koinViewModel

private const val DEFAULT_ANIMATION_DURATION_MILLIS = 300

private fun bottomSheetForwardTransition() =
slideInVertically(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
initialOffsetY = { it },
) togetherWith ExitTransition.None

private fun bottomSheetPopTransition() =
EnterTransition.None togetherWith slideOutVertically(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
targetOffsetY = { it },
)

private val bottomSheetTransitionMetadata =
NavDisplay.transitionSpec { bottomSheetForwardTransition() } +
NavDisplay.popTransitionSpec { bottomSheetPopTransition() } +
NavDisplay.predictivePopTransitionSpec { _: Int -> bottomSheetPopTransition() }

@Composable
fun MoneyFlowNavHost(modifier: Modifier = Modifier) {
val backStack = rememberSerializable(serializer = SnapshotStateListSerializer(AppRoute.serializer())) {
Expand Down Expand Up @@ -98,6 +125,33 @@ fun MoneyFlowNavHost(modifier: Modifier = Modifier) {
rememberSaveableStateHolderNavEntryDecorator(),
rememberViewModelStoreNavEntryDecorator(),
),
transitionSpec = {
slideInHorizontally(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
initialOffsetX = { it },
) togetherWith slideOutHorizontally(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
targetOffsetX = { -it },
)
},
popTransitionSpec = {
slideInHorizontally(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
initialOffsetX = { -it },
) togetherWith slideOutHorizontally(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
targetOffsetX = { it },
)
},
predictivePopTransitionSpec = { edge ->
slideInHorizontally(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
initialOffsetX = { -it },
) togetherWith slideOutHorizontally(
animationSpec = tween(DEFAULT_ANIMATION_DURATION_MILLIS),
targetOffsetX = { it },
)
},
)
}
}
Expand Down Expand Up @@ -205,7 +259,7 @@ private fun EntryProviderScope<AppRoute>.screens(
)
}

entry<CategoriesRoute> { route ->
entry<CategoriesRoute>(metadata = bottomSheetTransitionMetadata) { route ->
val viewModel = koinViewModel<CategoriesViewModel>()
val categoryModel by viewModel.categories.collectAsState()

Expand All @@ -222,7 +276,7 @@ private fun EntryProviderScope<AppRoute>.screens(
)
}

entry<AllTransactionsRoute> {
entry<AllTransactionsRoute>(metadata = bottomSheetTransitionMetadata) {
val viewModel = koinViewModel<AllTransactionsViewModel>()
AllTransactionsScreen(
stateFlow = viewModel.state,
Expand Down
Loading