Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nav Transition Animation #234

Merged
merged 5 commits into from
Jan 18, 2024
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
8 changes: 8 additions & 0 deletions Demo/src/main/java/com/paypal/android/ui/DemoApp.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.paypal.android.ui

import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -31,6 +34,7 @@ import com.paypal.android.ui.vaultcard.VaultCardView
import com.paypal.android.ui.vaultcard.VaultCardViewModel
import com.paypal.android.uishared.components.DemoAppTopBar
import com.paypal.android.uishared.effects.NavDestinationChangeDisposableEffect
import com.paypal.android.utils.UIConstants

// The architecture of the Demo app is heavily influenced by Google sample apps written
// entirely in compose, most specifically the Jetsnack app
Expand Down Expand Up @@ -68,6 +72,10 @@ fun DemoApp() {
NavHost(
navController = navController,
startDestination = "features",
enterTransition = {
fadeIn() + slideInVertically { UIConstants.getSlideInStartOffsetY(it) }
},
exitTransition = { fadeOut() },
modifier = Modifier.padding(innerPadding)
) {
// Ref: https://youtu.be/goFpG25uoc8?si=hqYGEaA95We6qUiE&t=76
Expand Down
2 changes: 1 addition & 1 deletion Demo/src/main/java/com/paypal/android/ui/OptionList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun OptionList(
.selectable(
selected = (option == selectedOption),
onClick = { onSelectedOptionChange(option) },
role = Role.RadioButton
role = Role.RadioButton,
)
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import com.paypal.android.R
Expand Down Expand Up @@ -117,7 +118,10 @@ fun FeatureView(
modifier = Modifier
.background(MaterialTheme.colorScheme.surfaceVariant)
.fillMaxWidth()
.clickable(onClick = onClick)
.clickable(
onClick = onClick,
role = Role.Button
)
) {
Row {
Text(
Expand Down
4 changes: 4 additions & 0 deletions Demo/src/main/java/com/paypal/android/utils/UIConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.ui.unit.dp

object UIConstants {
private const val slideInOffsetPercentY = 0.05
fun getSlideInStartOffsetY(fullHeightOfComposable: Int) =
(fullHeightOfComposable * slideInOffsetPercentY).toInt()

// Ref: https://support.google.com/accessibility/android/answer/7101858
val minimumTouchSize = 48.dp
val stepNumberBackgroundSize = 40.dp
Expand Down
Loading