Keep the last update time on an empty Updates screen (#3790)
Closes #3790 Closes #4052 Fixes #3647 Co-authored-by: AMendoza <allanmaleman@gmail.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package eu.kanade.presentation.updates
|
package eu.kanade.presentation.updates
|
||||||
|
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
@@ -93,10 +95,6 @@ fun UpdateScreen(
|
|||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
when {
|
when {
|
||||||
state.isLoading -> LoadingScreen(Modifier.padding(contentPadding))
|
state.isLoading -> LoadingScreen(Modifier.padding(contentPadding))
|
||||||
state.items.isEmpty() -> EmptyScreen(
|
|
||||||
stringRes = MR.strings.information_no_recent,
|
|
||||||
modifier = Modifier.padding(contentPadding),
|
|
||||||
)
|
|
||||||
else -> {
|
else -> {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
var isRefreshing by remember { mutableStateOf(false) }
|
var isRefreshing by remember { mutableStateOf(false) }
|
||||||
@@ -116,19 +114,37 @@ fun UpdateScreen(
|
|||||||
enabled = !state.selectionMode,
|
enabled = !state.selectionMode,
|
||||||
indicatorPadding = contentPadding,
|
indicatorPadding = contentPadding,
|
||||||
) {
|
) {
|
||||||
FastScrollLazyColumn(
|
if (state.items.isEmpty()) {
|
||||||
contentPadding = contentPadding,
|
Column(
|
||||||
) {
|
modifier = Modifier
|
||||||
updatesLastUpdatedItem(lastUpdated)
|
.padding(contentPadding)
|
||||||
|
.fillMaxSize(),
|
||||||
|
) {
|
||||||
|
UpdatesLastUpdatedHeader(lastUpdated = lastUpdated)
|
||||||
|
EmptyScreen(
|
||||||
|
stringRes = if (hasActiveFilters) {
|
||||||
|
MR.strings.error_no_match
|
||||||
|
} else {
|
||||||
|
MR.strings.information_no_recent
|
||||||
|
},
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FastScrollLazyColumn(
|
||||||
|
contentPadding = contentPadding,
|
||||||
|
) {
|
||||||
|
updatesLastUpdatedItem(lastUpdated)
|
||||||
|
|
||||||
updatesUiItems(
|
updatesUiItems(
|
||||||
uiModels = state.getUiModel(),
|
uiModels = state.getUiModel(),
|
||||||
selectionMode = state.selectionMode,
|
selectionMode = state.selectionMode,
|
||||||
onUpdateSelected = onUpdateSelected,
|
onUpdateSelected = onUpdateSelected,
|
||||||
onClickCover = onClickCover,
|
onClickCover = onClickCover,
|
||||||
onClickUpdate = onOpenChapter,
|
onClickUpdate = onOpenChapter,
|
||||||
onDownloadChapter = onDownloadChapter,
|
onDownloadChapter = onDownloadChapter,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,16 +52,26 @@ internal fun LazyListScope.updatesLastUpdatedItem(
|
|||||||
lastUpdated: Long,
|
lastUpdated: Long,
|
||||||
) {
|
) {
|
||||||
item(key = "updates-lastUpdated") {
|
item(key = "updates-lastUpdated") {
|
||||||
Box(
|
UpdatesLastUpdatedHeader(
|
||||||
modifier = Modifier
|
lastUpdated = lastUpdated,
|
||||||
.animateItem(fadeInSpec = null, fadeOutSpec = null)
|
modifier = Modifier.animateItem(fadeInSpec = null, fadeOutSpec = null),
|
||||||
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
|
)
|
||||||
) {
|
}
|
||||||
Text(
|
}
|
||||||
text = stringResource(MR.strings.updates_last_update_info, relativeTimeSpanString(lastUpdated)),
|
|
||||||
fontStyle = FontStyle.Italic,
|
@Composable
|
||||||
)
|
internal fun UpdatesLastUpdatedHeader(
|
||||||
}
|
lastUpdated: Long,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = modifier
|
||||||
|
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(MR.strings.updates_last_update_info, relativeTimeSpanString(lastUpdated)),
|
||||||
|
fontStyle = FontStyle.Italic,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user