feat(updates-screen): Animated Updates group expand visibility (#912)
This commit is contained in:
parent
d33efced68
commit
2f55a0bc16
2 changed files with 64 additions and 52 deletions
|
|
@ -29,7 +29,6 @@ import eu.kanade.presentation.manga.components.MangaBottomActionMenu
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.ui.updates.UpdatesItem
|
import eu.kanade.tachiyomi.ui.updates.UpdatesItem
|
||||||
import eu.kanade.tachiyomi.ui.updates.UpdatesScreenModel
|
import eu.kanade.tachiyomi.ui.updates.UpdatesScreenModel
|
||||||
import eu.kanade.tachiyomi.ui.updates.groupByDateAndManga
|
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -130,15 +129,8 @@ fun UpdateScreen(
|
||||||
updatesLastUpdatedItem(lastUpdated)
|
updatesLastUpdatedItem(lastUpdated)
|
||||||
|
|
||||||
updatesUiItems(
|
updatesUiItems(
|
||||||
uiModels = state.getUiModel()
|
uiModels = state.getUiModel(),
|
||||||
// KMK -->
|
// KMK -->
|
||||||
.filter {
|
|
||||||
when (it) {
|
|
||||||
is UpdatesUiModel.Header, is UpdatesUiModel.Leader -> true
|
|
||||||
is UpdatesUiModel.Item ->
|
|
||||||
state.expandedState.contains(it.item.update.groupByDateAndManga())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
expandedState = state.expandedState,
|
expandedState = state.expandedState,
|
||||||
collapseToggle = collapseToggle,
|
collapseToggle = collapseToggle,
|
||||||
usePanoramaCover = usePanoramaCover.value,
|
usePanoramaCover = usePanoramaCover.value,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
package eu.kanade.presentation.updates
|
package eu.kanade.presentation.updates
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.expandVertically
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.graphics.res.animatedVectorResource
|
import androidx.compose.animation.graphics.res.animatedVectorResource
|
||||||
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
|
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
|
||||||
import androidx.compose.animation.graphics.vector.AnimatedImageVector
|
import androidx.compose.animation.graphics.vector.AnimatedImageVector
|
||||||
|
import androidx.compose.animation.shrinkVertically
|
||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
|
@ -119,47 +124,58 @@ internal fun LazyListScope.updatesUiItems(
|
||||||
}
|
}
|
||||||
is UpdatesUiModel.Item -> {
|
is UpdatesUiModel.Item -> {
|
||||||
val updatesItem = item.item
|
val updatesItem = item.item
|
||||||
UpdatesUiItem(
|
val isLeader = item is UpdatesUiModel.Leader
|
||||||
modifier = Modifier.animateItemFastScroll(),
|
val isExpanded = expandedState.contains(updatesItem.update.groupByDateAndManga())
|
||||||
update = updatesItem.update,
|
|
||||||
selected = updatesItem.selected,
|
// KMK -->
|
||||||
readProgress = updatesItem.update.lastPageRead
|
AnimatedVisibility(
|
||||||
.takeIf {
|
visible = isLeader || isExpanded,
|
||||||
/* SY --> */(
|
enter = fadeIn() + expandVertically(),
|
||||||
!updatesItem.update.read ||
|
exit = fadeOut() + shrinkVertically(),
|
||||||
(preserveReadingPosition && updatesItem.isEhBasedUpdate())
|
) {
|
||||||
)/* SY <-- */ &&
|
|
||||||
it > 0L
|
|
||||||
}
|
|
||||||
?.let {
|
|
||||||
stringResource(
|
|
||||||
MR.strings.chapter_progress,
|
|
||||||
it + 1,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onLongClick = {
|
|
||||||
onUpdateSelected(updatesItem, !updatesItem.selected, true, true)
|
|
||||||
},
|
|
||||||
onClick = {
|
|
||||||
when {
|
|
||||||
selectionMode -> onUpdateSelected(updatesItem, !updatesItem.selected, true, false)
|
|
||||||
else -> onClickUpdate(updatesItem)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClickCover = { onClickCover(updatesItem) }.takeIf { !selectionMode },
|
|
||||||
onDownloadChapter = { action: ChapterDownloadAction ->
|
|
||||||
onDownloadChapter(listOf(updatesItem), action)
|
|
||||||
}.takeIf { !selectionMode },
|
|
||||||
downloadStateProvider = updatesItem.downloadStateProvider,
|
|
||||||
downloadProgressProvider = updatesItem.downloadProgressProvider,
|
|
||||||
// KMK -->
|
|
||||||
isLeader = item is UpdatesUiModel.Leader,
|
|
||||||
isExpandable = item.isExpandable,
|
|
||||||
expanded = expandedState.contains(updatesItem.update.groupByDateAndManga()),
|
|
||||||
collapseToggle = collapseToggle,
|
|
||||||
usePanoramaCover = usePanoramaCover,
|
|
||||||
// KMK <--
|
// KMK <--
|
||||||
)
|
UpdatesUiItem(
|
||||||
|
modifier = Modifier.animateItemFastScroll(),
|
||||||
|
update = updatesItem.update,
|
||||||
|
selected = updatesItem.selected,
|
||||||
|
readProgress = updatesItem.update.lastPageRead
|
||||||
|
.takeIf {
|
||||||
|
/* SY --> */(
|
||||||
|
!updatesItem.update.read ||
|
||||||
|
(preserveReadingPosition && updatesItem.isEhBasedUpdate())
|
||||||
|
)/* SY <-- */ &&
|
||||||
|
it > 0L
|
||||||
|
}
|
||||||
|
?.let {
|
||||||
|
stringResource(
|
||||||
|
MR.strings.chapter_progress,
|
||||||
|
it + 1,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onLongClick = {
|
||||||
|
onUpdateSelected(updatesItem, !updatesItem.selected, true, true)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
when {
|
||||||
|
selectionMode -> onUpdateSelected(updatesItem, !updatesItem.selected, true, false)
|
||||||
|
else -> onClickUpdate(updatesItem)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClickCover = { onClickCover(updatesItem) }.takeIf { !selectionMode },
|
||||||
|
onDownloadChapter = { action: ChapterDownloadAction ->
|
||||||
|
onDownloadChapter(listOf(updatesItem), action)
|
||||||
|
}.takeIf { !selectionMode },
|
||||||
|
downloadStateProvider = updatesItem.downloadStateProvider,
|
||||||
|
downloadProgressProvider = updatesItem.downloadProgressProvider,
|
||||||
|
// KMK -->
|
||||||
|
isLeader = isLeader,
|
||||||
|
isExpandable = item.isExpandable,
|
||||||
|
expanded = isExpanded,
|
||||||
|
collapseToggle = collapseToggle,
|
||||||
|
usePanoramaCover = usePanoramaCover,
|
||||||
|
// KMK <--
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -348,6 +364,11 @@ fun CollapseButton(
|
||||||
collapseToggle: () -> Unit,
|
collapseToggle: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
|
val painter = rememberAnimatedVectorPainter(
|
||||||
|
AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down),
|
||||||
|
!expanded,
|
||||||
|
)
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(IndicatorSize + MaterialTheme.padding.extraSmall),
|
.size(IndicatorSize + MaterialTheme.padding.extraSmall),
|
||||||
|
|
@ -357,9 +378,8 @@ fun CollapseButton(
|
||||||
onClick = { collapseToggle() },
|
onClick = { collapseToggle() },
|
||||||
modifier = Modifier.size(IndicatorSize),
|
modifier = Modifier.size(IndicatorSize),
|
||||||
) {
|
) {
|
||||||
val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down)
|
|
||||||
Icon(
|
Icon(
|
||||||
painter = rememberAnimatedVectorPainter(image, !expanded),
|
painter = painter,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = MaterialTheme.colorScheme.primary,
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue