mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 02:08:40 +00:00
Slide in country picker vertically in regV5.
This commit is contained in:
committed by
Alex Hart
parent
49abece92b
commit
d1400928ce
@@ -72,7 +72,7 @@ fun TransferAccountNavHost(
|
||||
modifier = modifier,
|
||||
transitionSpec = TransitionSpecs.HorizontalSlide.transitionSpec,
|
||||
popTransitionSpec = TransitionSpecs.HorizontalSlide.popTransitionSpec,
|
||||
predictivePopTransitionSpec = TransitionSpecs.HorizontalSlide.predictivePopTransitonSpec
|
||||
predictivePopTransitionSpec = TransitionSpecs.HorizontalSlide.predictivePopTransitionSpec
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
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.navigation3.runtime.NavKey
|
||||
import androidx.navigation3.scene.Scene
|
||||
@@ -26,18 +28,20 @@ object TransitionSpecs {
|
||||
* Screens slide in from the right and slide out from the left.
|
||||
*/
|
||||
object HorizontalSlide {
|
||||
private const val DURATION = 200
|
||||
|
||||
val transitionSpec: AnimatedContentTransitionScope<Scene<NavKey>>.() -> ContentTransform = {
|
||||
(
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeIn(animationSpec = tween(200))
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeIn(animationSpec = tween(DURATION))
|
||||
) togetherWith
|
||||
(
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { -it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeOut(animationSpec = tween(200))
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeOut(animationSpec = tween(DURATION))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,30 +49,61 @@ object TransitionSpecs {
|
||||
(
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { -it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeIn(animationSpec = tween(200))
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeIn(animationSpec = tween(DURATION))
|
||||
) togetherWith
|
||||
(
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeOut(animationSpec = tween(200))
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeOut(animationSpec = tween(DURATION))
|
||||
)
|
||||
}
|
||||
|
||||
val predictivePopTransitonSpec: AnimatedContentTransitionScope<Scene<NavKey>>.(@NavigationEvent.SwipeEdge Int) -> ContentTransform = {
|
||||
val predictivePopTransitionSpec: AnimatedContentTransitionScope<Scene<NavKey>>.(@NavigationEvent.SwipeEdge Int) -> ContentTransform = {
|
||||
(
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { -it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeIn(animationSpec = tween(200))
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeIn(animationSpec = tween(DURATION))
|
||||
) togetherWith
|
||||
(
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeOut(animationSpec = tween(200))
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeOut(animationSpec = tween(DURATION))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Screens slide in from the bottom and slide out to the bottom, like a sheet.
|
||||
*/
|
||||
object VerticalSlide {
|
||||
private const val DURATION = 300
|
||||
|
||||
val transitionSpec: AnimatedContentTransitionScope<Scene<NavKey>>.() -> ContentTransform = {
|
||||
slideInVertically(
|
||||
initialOffsetY = { it },
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeIn(animationSpec = tween(DURATION)) togetherWith
|
||||
fadeOut(animationSpec = tween(DURATION))
|
||||
}
|
||||
|
||||
val popTransitionSpec: AnimatedContentTransitionScope<Scene<NavKey>>.() -> ContentTransform = {
|
||||
fadeIn(animationSpec = tween(DURATION)) togetherWith
|
||||
slideOutVertically(
|
||||
targetOffsetY = { it },
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeOut(animationSpec = tween(DURATION))
|
||||
}
|
||||
|
||||
val predictivePopTransitionSpec: AnimatedContentTransitionScope<Scene<NavKey>>.(@NavigationEvent.SwipeEdge Int) -> ContentTransform = {
|
||||
fadeIn(animationSpec = tween(DURATION)) togetherWith
|
||||
slideOutVertically(
|
||||
targetOffsetY = { it },
|
||||
animationSpec = tween(DURATION)
|
||||
) + fadeOut(animationSpec = tween(DURATION))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ private fun TranscodeApp() {
|
||||
backStack = backStack,
|
||||
transitionSpec = TransitionSpecs.HorizontalSlide.transitionSpec,
|
||||
popTransitionSpec = TransitionSpecs.HorizontalSlide.popTransitionSpec,
|
||||
predictivePopTransitionSpec = TransitionSpecs.HorizontalSlide.predictivePopTransitonSpec,
|
||||
predictivePopTransitionSpec = TransitionSpecs.HorizontalSlide.predictivePopTransitionSpec,
|
||||
entryProvider = entryProvider {
|
||||
addEntryProvider(
|
||||
key = Screen.VideoSelection,
|
||||
|
||||
@@ -8,12 +8,6 @@
|
||||
package org.signal.registration
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -32,6 +26,7 @@ import com.google.accompanist.permissions.rememberMultiplePermissionsState
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.signal.core.ui.navigation.ResultEffect
|
||||
import org.signal.core.ui.navigation.TransitionSpecs
|
||||
import org.signal.registration.screens.accountlocked.AccountLockedScreen
|
||||
import org.signal.registration.screens.accountlocked.AccountLockedScreenEvents
|
||||
import org.signal.registration.screens.accountlocked.AccountLockedState
|
||||
@@ -172,51 +167,25 @@ fun RegistrationNavHost(
|
||||
onBack = { viewModel.onEvent(RegistrationFlowEvent.NavigateBack) },
|
||||
modifier = modifier,
|
||||
transitionSpec = {
|
||||
// Slide in from right and fade in when navigating forward
|
||||
(
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeIn(animationSpec = tween(200))
|
||||
) togetherWith
|
||||
// Slide out to left and fade out
|
||||
(
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { -it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeOut(animationSpec = tween(200))
|
||||
)
|
||||
if (targetState.key == RegistrationRoute.CountryCodePicker.toString()) {
|
||||
TransitionSpecs.VerticalSlide.transitionSpec.invoke(this)
|
||||
} else {
|
||||
TransitionSpecs.HorizontalSlide.transitionSpec.invoke(this)
|
||||
}
|
||||
},
|
||||
popTransitionSpec = {
|
||||
// Slide in from left and fade in when navigating back
|
||||
(
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { -it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeIn(animationSpec = tween(200))
|
||||
) togetherWith
|
||||
// Slide out to right and fade out
|
||||
(
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeOut(animationSpec = tween(200))
|
||||
)
|
||||
if (initialState.key == RegistrationRoute.CountryCodePicker.toString()) {
|
||||
TransitionSpecs.VerticalSlide.popTransitionSpec.invoke(this)
|
||||
} else {
|
||||
TransitionSpecs.HorizontalSlide.popTransitionSpec.invoke(this)
|
||||
}
|
||||
},
|
||||
predictivePopTransitionSpec = {
|
||||
// Same as popTransitionSpec for predictive back gestures
|
||||
(
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { -it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeIn(animationSpec = tween(200))
|
||||
) togetherWith
|
||||
(
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { it },
|
||||
animationSpec = tween(200)
|
||||
) + fadeOut(animationSpec = tween(200))
|
||||
)
|
||||
if (initialState.key == RegistrationRoute.CountryCodePicker.toString()) {
|
||||
TransitionSpecs.VerticalSlide.predictivePopTransitionSpec.invoke(this, it)
|
||||
} else {
|
||||
TransitionSpecs.HorizontalSlide.predictivePopTransitionSpec.invoke(this, it)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user