Transitions: SlidingTransition is now based on constant value(animation is the same for all items now) + Replaced AnimatedVisibility with SlidingTransition in LicenseInfoScreen. (v1.0.1)
This commit is contained in:
parent
2a20ab29fa
commit
21bb739499
2 changed files with 13 additions and 27 deletions
|
|
@ -1,11 +1,6 @@
|
||||||
package ua.acclorite.book_story.presentation.screens.about.nested.license_info
|
package ua.acclorite.book_story.presentation.screens.about.nested.license_info
|
||||||
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.animation.core.tween
|
|
||||||
import androidx.compose.animation.fadeIn
|
|
||||||
import androidx.compose.animation.fadeOut
|
|
||||||
import androidx.compose.animation.slideInVertically
|
|
||||||
import androidx.compose.animation.slideOutVertically
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
|
@ -47,7 +42,6 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import ua.acclorite.book_story.R
|
import ua.acclorite.book_story.R
|
||||||
import ua.acclorite.book_story.presentation.components.CustomAnimatedVisibility
|
|
||||||
import ua.acclorite.book_story.presentation.components.CustomIconButton
|
import ua.acclorite.book_story.presentation.components.CustomIconButton
|
||||||
import ua.acclorite.book_story.presentation.components.GoBackButton
|
import ua.acclorite.book_story.presentation.components.GoBackButton
|
||||||
import ua.acclorite.book_story.presentation.components.collapsibleUntilExitScrollBehaviorWithLazyListState
|
import ua.acclorite.book_story.presentation.components.collapsibleUntilExitScrollBehaviorWithLazyListState
|
||||||
|
|
@ -57,6 +51,7 @@ import ua.acclorite.book_story.presentation.data.Navigator
|
||||||
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoEvent
|
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoEvent
|
||||||
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoState
|
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoState
|
||||||
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoViewModel
|
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoViewModel
|
||||||
|
import ua.acclorite.book_story.presentation.ui.SlidingTransition
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LicenseInfoScreenRoot() {
|
fun LicenseInfoScreenRoot() {
|
||||||
|
|
@ -190,12 +185,8 @@ private fun LicenseInfoScreen(
|
||||||
.padding(vertical = 6.dp, horizontal = 12.dp)
|
.padding(vertical = 6.dp, horizontal = 12.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
CustomAnimatedVisibility(
|
SlidingTransition(
|
||||||
visible = showed.value && license.licenseContent?.isNotBlank() == true,
|
visible = showed.value && license.licenseContent?.isNotBlank() == true,
|
||||||
enter = slideInVertically(tween(300)) { -50 } +
|
|
||||||
fadeIn(tween(300)),
|
|
||||||
exit = slideOutVertically(tween(200)) { -30 } +
|
|
||||||
fadeOut(tween(150)),
|
|
||||||
modifier = Modifier.padding(horizontal = 8.dp)
|
modifier = Modifier.padding(horizontal = 8.dp)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,10 @@ import androidx.compose.animation.slideOutHorizontally
|
||||||
import androidx.compose.animation.slideOutVertically
|
import androidx.compose.animation.slideOutVertically
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import ua.acclorite.book_story.presentation.components.CustomAnimatedVisibility
|
import ua.acclorite.book_story.presentation.components.CustomAnimatedVisibility
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
object Transitions {
|
object Transitions {
|
||||||
val DefaultTransitionIn = fadeIn(tween(300))
|
val DefaultTransitionIn = fadeIn(tween(300))
|
||||||
|
|
@ -70,24 +73,16 @@ fun SlidingTransition(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
|
val density = LocalDensity.current
|
||||||
CustomAnimatedVisibility(
|
CustomAnimatedVisibility(
|
||||||
visible = visible,
|
visible = visible,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
enter = slideInVertically(tween(300)) { -it / 10 } +
|
enter = slideInVertically(tween(300)) {
|
||||||
fadeIn(tween(300)),
|
with(density) { -12.dp.toPx() }.roundToInt()
|
||||||
exit = slideOutVertically(tween(150)) { -it / 10 } +
|
} + fadeIn(tween(300)),
|
||||||
fadeOut(tween(100)),
|
exit = slideOutVertically(tween(150)) {
|
||||||
|
with(density) { -10.dp.toPx() }.roundToInt()
|
||||||
|
} + fadeOut(tween(100)),
|
||||||
content = content
|
content = content
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue