mirror of
https://github.com/mihonapp/mihon.git
synced 2025-01-30 20:04:56 +01:00
sticky header
This commit is contained in:
parent
8aa2eccfaa
commit
58d59a555d
@ -130,17 +130,18 @@ fun LibraryUpdateErrorScreen(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
) { paddingValues ->
|
) { contentPadding ->
|
||||||
when {
|
when {
|
||||||
state.isLoading -> LoadingScreen(modifier = Modifier.padding(paddingValues))
|
state.isLoading -> LoadingScreen(modifier = Modifier.padding(contentPadding))
|
||||||
state.items.isEmpty() -> EmptyScreen(
|
state.items.isEmpty() -> EmptyScreen(
|
||||||
message = stringResource(MR.strings.info_empty_library_update_errors),
|
message = stringResource(MR.strings.info_empty_library_update_errors),
|
||||||
modifier = Modifier.padding(paddingValues),
|
modifier = Modifier.padding(contentPadding),
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
FastScrollLazyColumn(
|
FastScrollLazyColumn(
|
||||||
contentPadding = paddingValues,
|
// Using modifier instead of contentPadding so we can use stickyHeader
|
||||||
|
modifier = Modifier.padding(contentPadding),
|
||||||
state = listState,
|
state = listState,
|
||||||
) {
|
) {
|
||||||
libraryUpdateErrorUiItems(
|
libraryUpdateErrorUiItems(
|
||||||
|
@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyListScope
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
import androidx.compose.foundation.lazy.items
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
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
|
||||||
@ -17,10 +16,12 @@ import androidx.compose.ui.platform.LocalHapticFeedback
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.presentation.manga.components.MangaCover
|
import eu.kanade.presentation.manga.components.MangaCover
|
||||||
|
import eu.kanade.presentation.util.animateItemFastScroll
|
||||||
import eu.kanade.tachiyomi.ui.libraryUpdateError.LibraryUpdateErrorItem
|
import eu.kanade.tachiyomi.ui.libraryUpdateError.LibraryUpdateErrorItem
|
||||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateErrorWithRelations
|
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateErrorWithRelations
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
import tachiyomi.domain.source.service.SourceManager
|
||||||
import tachiyomi.presentation.core.components.ListGroupHeader
|
import tachiyomi.presentation.core.components.ListGroupHeader
|
||||||
|
import tachiyomi.presentation.core.components.Scroller.STICKY_HEADER_KEY_PREFIX
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
||||||
import tachiyomi.presentation.core.util.selectedBackground
|
import tachiyomi.presentation.core.util.selectedBackground
|
||||||
@ -34,57 +35,52 @@ internal fun LazyListScope.libraryUpdateErrorUiItems(
|
|||||||
onClick: (LibraryUpdateErrorItem) -> Unit,
|
onClick: (LibraryUpdateErrorItem) -> Unit,
|
||||||
onClickCover: (LibraryUpdateErrorItem) -> Unit,
|
onClickCover: (LibraryUpdateErrorItem) -> Unit,
|
||||||
) {
|
) {
|
||||||
items(
|
uiModels.forEach {
|
||||||
items = uiModels,
|
when (it) {
|
||||||
contentType = {
|
|
||||||
when (it) {
|
|
||||||
is LibraryUpdateErrorUiModel.Header -> "header"
|
|
||||||
is LibraryUpdateErrorUiModel.Item -> "item"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
key = {
|
|
||||||
when (it) {
|
|
||||||
is LibraryUpdateErrorUiModel.Header -> "sticky:errorHeader-${it.hashCode()}"
|
|
||||||
is LibraryUpdateErrorUiModel.Item -> "error-${it.item.error.errorId}-${it.item.error.mangaId}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
) { item ->
|
|
||||||
when (item) {
|
|
||||||
is LibraryUpdateErrorUiModel.Header -> {
|
is LibraryUpdateErrorUiModel.Header -> {
|
||||||
ListGroupHeader(
|
stickyHeader(
|
||||||
modifier = Modifier.animateItemPlacement(),
|
key = "$STICKY_HEADER_KEY_PREFIX-errorHeader-${it.hashCode()}",
|
||||||
text = item.errorMessage,
|
contentType = "header",
|
||||||
)
|
) {
|
||||||
|
ListGroupHeader(
|
||||||
|
modifier = Modifier.animateItemFastScroll(),
|
||||||
|
text = it.errorMessage,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is LibraryUpdateErrorUiModel.Item -> {
|
is LibraryUpdateErrorUiModel.Item -> {
|
||||||
val libraryUpdateErrorItem = item.item
|
item(
|
||||||
LibraryUpdateErrorUiItem(
|
key = "error-${it.item.error.errorId}-${it.item.error.mangaId}",
|
||||||
modifier = Modifier.animateItemPlacement(),
|
contentType = "item",
|
||||||
error = libraryUpdateErrorItem.error,
|
) {
|
||||||
selected = libraryUpdateErrorItem.selected,
|
val libraryUpdateErrorItem = it.item
|
||||||
onClick = {
|
LibraryUpdateErrorUiItem(
|
||||||
when {
|
modifier = Modifier.animateItemFastScroll(),
|
||||||
selectionMode -> onErrorSelected(
|
error = libraryUpdateErrorItem.error,
|
||||||
|
selected = libraryUpdateErrorItem.selected,
|
||||||
|
onClick = {
|
||||||
|
when {
|
||||||
|
selectionMode -> onErrorSelected(
|
||||||
|
libraryUpdateErrorItem,
|
||||||
|
!libraryUpdateErrorItem.selected,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> onClick(libraryUpdateErrorItem)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongClick = {
|
||||||
|
onErrorSelected(
|
||||||
libraryUpdateErrorItem,
|
libraryUpdateErrorItem,
|
||||||
!libraryUpdateErrorItem.selected,
|
!libraryUpdateErrorItem.selected,
|
||||||
true,
|
true,
|
||||||
false,
|
true,
|
||||||
)
|
)
|
||||||
|
},
|
||||||
else -> onClick(libraryUpdateErrorItem)
|
onClickCover = { onClickCover(libraryUpdateErrorItem) }.takeIf { !selectionMode },
|
||||||
}
|
)
|
||||||
},
|
}
|
||||||
onLongClick = {
|
|
||||||
onErrorSelected(
|
|
||||||
libraryUpdateErrorItem,
|
|
||||||
!libraryUpdateErrorItem.selected,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClickCover = { onClickCover(libraryUpdateErrorItem) }.takeIf { !selectionMode },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package tachiyomi.presentation.core.components
|
package tachiyomi.presentation.core.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -13,15 +15,21 @@ fun ListGroupHeader(
|
|||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Text(
|
Surface(
|
||||||
text = text,
|
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.padding(
|
.fillMaxWidth(),
|
||||||
horizontal = MaterialTheme.padding.medium,
|
color = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||||
vertical = MaterialTheme.padding.small,
|
) {
|
||||||
),
|
Text(
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
text = text,
|
||||||
fontWeight = FontWeight.SemiBold,
|
modifier = Modifier
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
.padding(
|
||||||
)
|
horizontal = MaterialTheme.padding.medium,
|
||||||
|
vertical = MaterialTheme.padding.small,
|
||||||
|
),
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user