fix:动画问题
This commit is contained in:
1 parent
b5bb7ed77e
commit
87f01900c3
1 file changed
+22
-15
@@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.sheet
|
|||||||
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||||
|
import androidx.compose.animation.core.LinearEasing
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.animation.expandVertically
|
import androidx.compose.animation.expandVertically
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
@@ -22,13 +23,12 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.filled.ChevronRight
|
import androidx.compose.material.icons.filled.ChevronRight
|
||||||
import androidx.compose.material.icons.filled.ExpandMore
|
import androidx.compose.material.icons.filled.ExpandMore
|
||||||
import androidx.compose.material.icons.filled.TextFields
|
import androidx.compose.material.icons.filled.TextFields
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.derivedStateOf
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
@@ -43,21 +43,19 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clipToBounds
|
import androidx.compose.ui.draw.clipToBounds
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
|
||||||
import androidx.compose.ui.res.stringArrayResource
|
import androidx.compose.ui.res.stringArrayResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.Dp
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.ui.theme.LegadoTheme
|
|
||||||
import io.legado.app.data.repository.ReadPreferences
|
import io.legado.app.data.repository.ReadPreferences
|
||||||
import io.legado.app.data.repository.ReadSettingsRepository
|
import io.legado.app.data.repository.ReadSettingsRepository
|
||||||
import io.legado.app.help.config.ReadBookConfig
|
import io.legado.app.help.config.ReadBookConfig
|
||||||
import io.legado.app.ui.book.read.ConfigUpdate
|
import io.legado.app.ui.book.read.ConfigUpdate
|
||||||
import io.legado.app.ui.book.read.ReadBookIntent
|
import io.legado.app.ui.book.read.ReadBookIntent
|
||||||
|
import io.legado.app.ui.theme.LegadoTheme
|
||||||
import io.legado.app.ui.widget.components.FontSelectSheet
|
import io.legado.app.ui.widget.components.FontSelectSheet
|
||||||
import io.legado.app.ui.widget.components.dialog.ColorPickerSheet
|
import io.legado.app.ui.widget.components.dialog.ColorPickerSheet
|
||||||
import io.legado.app.ui.widget.components.settingItem.TinyClickableSettingItem
|
import io.legado.app.ui.widget.components.settingItem.TinyClickableSettingItem
|
||||||
@@ -70,6 +68,7 @@ import io.legado.app.utils.getCompatColor
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.koin.compose.koinInject
|
import org.koin.compose.koinInject
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
// Color picker IDs
|
// Color picker IDs
|
||||||
private const val COLOR_HEADER = 7
|
private const val COLOR_HEADER = 7
|
||||||
@@ -127,19 +126,23 @@ internal fun HeaderFooterPage(
|
|||||||
|
|
||||||
LaunchedEffect(expandHeaderPadding) {
|
LaunchedEffect(expandHeaderPadding) {
|
||||||
if (expandHeaderPadding) {
|
if (expandHeaderPadding) {
|
||||||
snapshotFlow { headerScrollState.maxValue }
|
//等动画结束后再滚动到底部,否则maxValue值不是最新
|
||||||
.collect { maxVal ->
|
delay(300.milliseconds)
|
||||||
headerScrollState.scrollTo(maxVal)
|
headerScrollState.animateScrollTo(
|
||||||
}
|
headerScrollState.maxValue,
|
||||||
|
animationSpec = tween(durationMillis = 200, easing = LinearEasing)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(expandFooterPadding) {
|
LaunchedEffect(expandFooterPadding) {
|
||||||
if (expandFooterPadding) {
|
if (expandFooterPadding) {
|
||||||
snapshotFlow { footerScrollState.maxValue }
|
//等动画结束后再滚动到底部,否则maxValue值不是最新
|
||||||
.collect { maxVal ->
|
delay(300.milliseconds)
|
||||||
footerScrollState.scrollTo(maxVal)
|
footerScrollState.animateScrollTo(
|
||||||
}
|
footerScrollState.maxValue,
|
||||||
|
animationSpec = tween(durationMillis = 200, easing = LinearEasing)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +322,9 @@ internal fun HeaderFooterPage(
|
|||||||
modifier = Modifier.size(20.dp),
|
modifier = Modifier.size(20.dp),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick = { expandHeaderPadding = !expandHeaderPadding },
|
onClick = {
|
||||||
|
expandHeaderPadding = !expandHeaderPadding
|
||||||
|
},
|
||||||
)
|
)
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = expandHeaderPadding,
|
visible = expandHeaderPadding,
|
||||||
@@ -441,7 +446,9 @@ internal fun HeaderFooterPage(
|
|||||||
modifier = Modifier.size(20.dp),
|
modifier = Modifier.size(20.dp),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick = { expandFooterPadding = !expandFooterPadding },
|
onClick = {
|
||||||
|
expandFooterPadding = !expandFooterPadding
|
||||||
|
},
|
||||||
)
|
)
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = expandFooterPadding,
|
visible = expandFooterPadding,
|
||||||
|
|||||||
Reference in new issue
Block a user