|
@@ -1,6 +1,7 @@
|
|
package eu.kanade.presentation.history
|
|
package eu.kanade.presentation.history
|
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
import androidx.compose.foundation.clickable
|
|
|
|
+import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.Spacer
|
|
import androidx.compose.foundation.layout.Spacer
|
|
@@ -42,13 +43,13 @@ import androidx.core.text.buildSpannedString
|
|
import androidx.paging.compose.LazyPagingItems
|
|
import androidx.paging.compose.LazyPagingItems
|
|
import androidx.paging.compose.collectAsLazyPagingItems
|
|
import androidx.paging.compose.collectAsLazyPagingItems
|
|
import androidx.paging.compose.items
|
|
import androidx.paging.compose.items
|
|
|
|
+import eu.kanade.domain.history.model.HistoryWithRelations
|
|
import eu.kanade.presentation.components.EmptyScreen
|
|
import eu.kanade.presentation.components.EmptyScreen
|
|
import eu.kanade.presentation.components.MangaCover
|
|
import eu.kanade.presentation.components.MangaCover
|
|
import eu.kanade.presentation.components.MangaCoverAspect
|
|
import eu.kanade.presentation.components.MangaCoverAspect
|
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
|
import eu.kanade.presentation.util.horizontalPadding
|
|
import eu.kanade.presentation.util.horizontalPadding
|
|
import eu.kanade.tachiyomi.R
|
|
import eu.kanade.tachiyomi.R
|
|
-import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
|
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.ui.recent.history.HistoryPresenter
|
|
import eu.kanade.tachiyomi.ui.recent.history.HistoryPresenter
|
|
import eu.kanade.tachiyomi.ui.recent.history.UiModel
|
|
import eu.kanade.tachiyomi.ui.recent.history.UiModel
|
|
@@ -71,9 +72,9 @@ val chapterFormatter = DecimalFormat(
|
|
fun HistoryScreen(
|
|
fun HistoryScreen(
|
|
composeView: ComposeView,
|
|
composeView: ComposeView,
|
|
presenter: HistoryPresenter,
|
|
presenter: HistoryPresenter,
|
|
- onClickItem: (MangaChapterHistory) -> Unit,
|
|
|
|
- onClickResume: (MangaChapterHistory) -> Unit,
|
|
|
|
- onClickDelete: (MangaChapterHistory, Boolean) -> Unit,
|
|
|
|
|
|
+ onClickItem: (HistoryWithRelations) -> Unit,
|
|
|
|
+ onClickResume: (HistoryWithRelations) -> Unit,
|
|
|
|
+ onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
|
) {
|
|
) {
|
|
val nestedSrollInterop = rememberNestedScrollInteropConnection(composeView)
|
|
val nestedSrollInterop = rememberNestedScrollInteropConnection(composeView)
|
|
TachiyomiTheme {
|
|
TachiyomiTheme {
|
|
@@ -104,16 +105,16 @@ fun HistoryScreen(
|
|
@Composable
|
|
@Composable
|
|
fun HistoryContent(
|
|
fun HistoryContent(
|
|
history: LazyPagingItems<UiModel>,
|
|
history: LazyPagingItems<UiModel>,
|
|
- onClickItem: (MangaChapterHistory) -> Unit,
|
|
|
|
- onClickResume: (MangaChapterHistory) -> Unit,
|
|
|
|
- onClickDelete: (MangaChapterHistory, Boolean) -> Unit,
|
|
|
|
|
|
+ onClickItem: (HistoryWithRelations) -> Unit,
|
|
|
|
+ onClickResume: (HistoryWithRelations) -> Unit,
|
|
|
|
+ onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
|
preferences: PreferencesHelper = Injekt.get(),
|
|
preferences: PreferencesHelper = Injekt.get(),
|
|
nestedScroll: NestedScrollConnection
|
|
nestedScroll: NestedScrollConnection
|
|
) {
|
|
) {
|
|
val relativeTime: Int = remember { preferences.relativeTime().get() }
|
|
val relativeTime: Int = remember { preferences.relativeTime().get() }
|
|
val dateFormat: DateFormat = remember { preferences.dateFormat() }
|
|
val dateFormat: DateFormat = remember { preferences.dateFormat() }
|
|
|
|
|
|
- val (removeState, setRemoveState) = remember { mutableStateOf<MangaChapterHistory?>(null) }
|
|
|
|
|
|
+ val (removeState, setRemoveState) = remember { mutableStateOf<HistoryWithRelations?>(null) }
|
|
|
|
|
|
val scrollState = rememberLazyListState()
|
|
val scrollState = rememberLazyListState()
|
|
LazyColumn(
|
|
LazyColumn(
|
|
@@ -132,7 +133,7 @@ fun HistoryContent(
|
|
dateFormat = dateFormat
|
|
dateFormat = dateFormat
|
|
)
|
|
)
|
|
}
|
|
}
|
|
- is UiModel.History -> {
|
|
|
|
|
|
+ is UiModel.Item -> {
|
|
val value = item.item
|
|
val value = item.item
|
|
HistoryItem(
|
|
HistoryItem(
|
|
modifier = Modifier.animateItemPlacement(),
|
|
modifier = Modifier.animateItemPlacement(),
|
|
@@ -189,7 +190,7 @@ fun HistoryHeader(
|
|
@Composable
|
|
@Composable
|
|
fun HistoryItem(
|
|
fun HistoryItem(
|
|
modifier: Modifier = Modifier,
|
|
modifier: Modifier = Modifier,
|
|
- history: MangaChapterHistory,
|
|
|
|
|
|
+ history: HistoryWithRelations,
|
|
onClickItem: () -> Unit,
|
|
onClickItem: () -> Unit,
|
|
onClickResume: () -> Unit,
|
|
onClickResume: () -> Unit,
|
|
onClickDelete: () -> Unit,
|
|
onClickDelete: () -> Unit,
|
|
@@ -203,7 +204,7 @@ fun HistoryItem(
|
|
) {
|
|
) {
|
|
MangaCover(
|
|
MangaCover(
|
|
modifier = Modifier.fillMaxHeight(),
|
|
modifier = Modifier.fillMaxHeight(),
|
|
- manga = history.manga,
|
|
|
|
|
|
+ data = history.thumbnailUrl,
|
|
aspect = MangaCoverAspect.COVER
|
|
aspect = MangaCoverAspect.COVER
|
|
)
|
|
)
|
|
Column(
|
|
Column(
|
|
@@ -215,7 +216,7 @@ fun HistoryItem(
|
|
color = MaterialTheme.colorScheme.onSurface,
|
|
color = MaterialTheme.colorScheme.onSurface,
|
|
)
|
|
)
|
|
Text(
|
|
Text(
|
|
- text = history.manga.title,
|
|
|
|
|
|
+ text = history.title,
|
|
maxLines = 2,
|
|
maxLines = 2,
|
|
overflow = TextOverflow.Ellipsis,
|
|
overflow = TextOverflow.Ellipsis,
|
|
style = textStyle.copy(fontWeight = FontWeight.SemiBold)
|
|
style = textStyle.copy(fontWeight = FontWeight.SemiBold)
|
|
@@ -223,15 +224,15 @@ fun HistoryItem(
|
|
Row {
|
|
Row {
|
|
Text(
|
|
Text(
|
|
text = buildSpannedString {
|
|
text = buildSpannedString {
|
|
- if (history.chapter.chapter_number > -1) {
|
|
|
|
|
|
+ if (history.chapterNumber > -1) {
|
|
append(
|
|
append(
|
|
stringResource(
|
|
stringResource(
|
|
R.string.history_prefix,
|
|
R.string.history_prefix,
|
|
- chapterFormatter.format(history.chapter.chapter_number)
|
|
|
|
|
|
+ chapterFormatter.format(history.chapterNumber)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
}
|
|
}
|
|
- append(Date(history.history.last_read).toTimestampString())
|
|
|
|
|
|
+ append(history.readAt?.toTimestampString())
|
|
}.toString(),
|
|
}.toString(),
|
|
modifier = Modifier.padding(top = 2.dp),
|
|
modifier = Modifier.padding(top = 2.dp),
|
|
style = textStyle
|
|
style = textStyle
|
|
@@ -270,14 +271,22 @@ fun RemoveHistoryDialog(
|
|
Column {
|
|
Column {
|
|
Text(text = stringResource(id = R.string.dialog_with_checkbox_remove_description))
|
|
Text(text = stringResource(id = R.string.dialog_with_checkbox_remove_description))
|
|
Row(
|
|
Row(
|
|
- modifier = Modifier.toggleable(value = removeEverything, onValueChange = removeEverythingState),
|
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
+ .padding(top = 16.dp)
|
|
|
|
+ .toggleable(
|
|
|
|
+ interactionSource = remember { MutableInteractionSource() },
|
|
|
|
+ indication = null,
|
|
|
|
+ value = removeEverything,
|
|
|
|
+ onValueChange = removeEverythingState
|
|
|
|
+ ),
|
|
verticalAlignment = Alignment.CenterVertically
|
|
verticalAlignment = Alignment.CenterVertically
|
|
) {
|
|
) {
|
|
Checkbox(
|
|
Checkbox(
|
|
checked = removeEverything,
|
|
checked = removeEverything,
|
|
- onCheckedChange = removeEverythingState,
|
|
|
|
|
|
+ onCheckedChange = null,
|
|
)
|
|
)
|
|
Text(
|
|
Text(
|
|
|
|
+ modifier = Modifier.padding(start = 4.dp),
|
|
text = stringResource(id = R.string.dialog_with_checkbox_reset)
|
|
text = stringResource(id = R.string.dialog_with_checkbox_reset)
|
|
)
|
|
)
|
|
}
|
|
}
|