mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 23:35:04 +01:00
Use primitive state holders
This commit is contained in:
parent
0189fc1f66
commit
dfd38db7e3
@ -11,7 +11,7 @@ import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@ -69,7 +69,7 @@ fun LibraryPager(
|
||||
|
||||
remember(isLandscape) { getColumnsForOrientation(isLandscape) }
|
||||
} else {
|
||||
remember { mutableStateOf(0) }
|
||||
remember { mutableIntStateOf(0) }
|
||||
}
|
||||
|
||||
when (displayMode) {
|
||||
|
@ -32,7 +32,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -488,7 +488,7 @@ fun MangaScreenLargeImpl(
|
||||
val chapters = remember(state) { state.processedChapters.toList() }
|
||||
|
||||
val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
|
||||
var topBarHeight by remember { mutableStateOf(0) }
|
||||
var topBarHeight by remember { mutableIntStateOf(0) }
|
||||
PullRefresh(
|
||||
refreshing = state.isRefreshingData,
|
||||
onRefresh = onRefresh,
|
||||
|
@ -34,6 +34,7 @@ import androidx.compose.material3.contentColorFor
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -191,7 +192,7 @@ fun MangaChapterListItem(
|
||||
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
var textHeight by remember { mutableStateOf(0) }
|
||||
var textHeight by remember { mutableIntStateOf(0) }
|
||||
if (!read) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Circle,
|
||||
|
@ -48,6 +48,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
@ -573,8 +574,8 @@ private fun MangaSummary(
|
||||
expanded: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var expandedHeight by remember { mutableStateOf(0) }
|
||||
var shrunkHeight by remember { mutableStateOf(0) }
|
||||
var expandedHeight by remember { mutableIntStateOf(0) }
|
||||
var shrunkHeight by remember { mutableIntStateOf(0) }
|
||||
val heightDelta = remember(expandedHeight, shrunkHeight) { expandedHeight - shrunkHeight }
|
||||
val animProgress by animateFloatAsState(if (expanded) 1f else 0f)
|
||||
val scrimHeight = with(LocalDensity.current) { remember { 24.sp.roundToPx() } }
|
||||
|
@ -13,6 +13,7 @@ import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@ -165,7 +166,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
|
||||
|
||||
val chapterCache = remember { Injekt.get<ChapterCache>() }
|
||||
var readableSizeSema by remember { mutableStateOf(0) }
|
||||
var readableSizeSema by remember { mutableIntStateOf(0) }
|
||||
val readableSize = remember(readableSizeSema) { chapterCache.readableSize }
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
|
@ -26,6 +26,7 @@ import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@ -86,7 +87,7 @@ object SettingsBackupScreen : SearchableSettings {
|
||||
val scope = rememberCoroutineScope()
|
||||
val context = LocalContext.current
|
||||
|
||||
var flag by rememberSaveable { mutableStateOf(0) }
|
||||
var flag by rememberSaveable { mutableIntStateOf(0) }
|
||||
val chooseBackupDir = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.CreateDocument("application/*"),
|
||||
) {
|
||||
|
@ -22,7 +22,7 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -198,7 +198,7 @@ private fun UpdatesUiItem(
|
||||
)
|
||||
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
var textHeight by remember { mutableStateOf(0) }
|
||||
var textHeight by remember { mutableIntStateOf(0) }
|
||||
if (!update.read) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Circle,
|
||||
|
@ -15,6 +15,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -93,7 +94,7 @@ class SourcePreferencesScreen(val sourceId: Long) : Screen() {
|
||||
commit: FragmentTransaction.(containerId: Int) -> Unit,
|
||||
) {
|
||||
val containerId by rememberSaveable {
|
||||
mutableStateOf(View.generateViewId())
|
||||
mutableIntStateOf(View.generateViewId())
|
||||
}
|
||||
var initialized by rememberSaveable { mutableStateOf(false) }
|
||||
AndroidView(
|
||||
|
@ -26,7 +26,7 @@ import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -61,7 +61,7 @@ fun AdaptiveSheet(
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
if (isTabletUi) {
|
||||
var targetAlpha by remember { mutableStateOf(0f) }
|
||||
var targetAlpha by remember { mutableFloatStateOf(0f) }
|
||||
val alpha by animateFloatAsState(
|
||||
targetValue = targetAlpha,
|
||||
animationSpec = SheetAnimationSpec,
|
||||
|
@ -28,7 +28,7 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
@ -83,7 +83,7 @@ fun VerticalFastScroller(
|
||||
if (!showScroller) return@subcompose
|
||||
|
||||
val thumbTopPadding = with(LocalDensity.current) { topContentPadding.toPx() }
|
||||
var thumbOffsetY by remember(thumbTopPadding) { mutableStateOf(thumbTopPadding) }
|
||||
var thumbOffsetY by remember(thumbTopPadding) { mutableFloatStateOf(thumbTopPadding) }
|
||||
|
||||
val dragInteractionSource = remember { MutableInteractionSource() }
|
||||
val isThumbDragged by dragInteractionSource.collectIsDraggedAsState()
|
||||
@ -248,7 +248,7 @@ fun VerticalGridFastScroller(
|
||||
val showScroller = layoutInfo.visibleItemsInfo.size < layoutInfo.totalItemsCount
|
||||
if (!showScroller) return@subcompose
|
||||
val thumbTopPadding = with(LocalDensity.current) { topContentPadding.toPx() }
|
||||
var thumbOffsetY by remember(thumbTopPadding) { mutableStateOf(thumbTopPadding) }
|
||||
var thumbOffsetY by remember(thumbTopPadding) { mutableFloatStateOf(thumbTopPadding) }
|
||||
|
||||
val dragInteractionSource = remember { MutableInteractionSource() }
|
||||
val isThumbDragged by dragInteractionSource.collectIsDraggedAsState()
|
||||
|
@ -20,6 +20,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@ -113,7 +114,7 @@ private fun <T> WheelPicker(
|
||||
val haptic = LocalHapticFeedback.current
|
||||
val lazyListState = rememberLazyListState(startIndex)
|
||||
|
||||
var internalIndex by remember { mutableStateOf(startIndex) }
|
||||
var internalIndex by remember { mutableIntStateOf(startIndex) }
|
||||
val internalOnSelectionChanged: (Int) -> Unit = {
|
||||
internalIndex = it
|
||||
onSelectionChanged(it)
|
||||
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -30,8 +31,8 @@ fun LazyListState.isScrolledToEnd(): Boolean {
|
||||
|
||||
@Composable
|
||||
fun LazyListState.isScrollingUp(): Boolean {
|
||||
var previousIndex by remember { mutableStateOf(firstVisibleItemIndex) }
|
||||
var previousScrollOffset by remember { mutableStateOf(firstVisibleItemScrollOffset) }
|
||||
var previousIndex by remember { mutableIntStateOf(firstVisibleItemIndex) }
|
||||
var previousScrollOffset by remember { mutableIntStateOf(firstVisibleItemScrollOffset) }
|
||||
return remember {
|
||||
derivedStateOf {
|
||||
if (previousIndex != firstVisibleItemIndex) {
|
||||
@ -48,8 +49,8 @@ fun LazyListState.isScrollingUp(): Boolean {
|
||||
|
||||
@Composable
|
||||
fun LazyListState.isScrollingDown(): Boolean {
|
||||
var previousIndex by remember { mutableStateOf(firstVisibleItemIndex) }
|
||||
var previousScrollOffset by remember { mutableStateOf(firstVisibleItemScrollOffset) }
|
||||
var previousIndex by remember { mutableIntStateOf(firstVisibleItemIndex) }
|
||||
var previousScrollOffset by remember { mutableIntStateOf(firstVisibleItemScrollOffset) }
|
||||
return remember {
|
||||
derivedStateOf {
|
||||
if (previousIndex != firstVisibleItemIndex) {
|
||||
|
Loading…
Reference in New Issue
Block a user