From 070abd79ce4e6004b5484a3f91a9c4527bd42bcd Mon Sep 17 00:00:00 2001 From: CrepeTF <70870719+CrepeTF@users.noreply.github.com> Date: Sat, 23 Apr 2022 15:58:33 +0100 Subject: [PATCH] Resume when history item is tapped (#6982) * Remove resume button * Rename onClickItem to onClickCover * Optimize imports * Rename reference to onClickItem in HistoryController.kt Co-authored-by: CrepeTF --- .../presentation/history/HistoryScreen.kt | 50 ++++++------------- .../ui/recent/history/HistoryController.kt | 2 +- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 228c604789..b96e321066 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -2,32 +2,14 @@ package eu.kanade.presentation.history import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.navigationBarsPadding -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.selection.toggleable import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.PlayArrow import androidx.compose.material.icons.outlined.Delete -import androidx.compose.material3.AlertDialog -import androidx.compose.material3.Checkbox -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember +import androidx.compose.material3.* +import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.NestedScrollConnection @@ -56,13 +38,13 @@ import uy.kohesive.injekt.api.get import java.text.DateFormat import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import java.util.Date +import java.util.* @Composable fun HistoryScreen( nestedScrollInterop: NestedScrollConnection, presenter: HistoryPresenter, - onClickItem: (HistoryWithRelations) -> Unit, + onClickCover: (HistoryWithRelations) -> Unit, onClickResume: (HistoryWithRelations) -> Unit, onClickDelete: (HistoryWithRelations, Boolean) -> Unit, ) { @@ -81,7 +63,7 @@ fun HistoryScreen( HistoryContent( nestedScroll = nestedScrollInterop, history = history, - onClickItem = onClickItem, + onClickCover = onClickCover, onClickResume = onClickResume, onClickDelete = onClickDelete, ) @@ -92,7 +74,7 @@ fun HistoryScreen( @Composable fun HistoryContent( history: LazyPagingItems, - onClickItem: (HistoryWithRelations) -> Unit, + onClickCover: (HistoryWithRelations) -> Unit, onClickResume: (HistoryWithRelations) -> Unit, onClickDelete: (HistoryWithRelations, Boolean) -> Unit, preferences: PreferencesHelper = Injekt.get(), @@ -125,7 +107,7 @@ fun HistoryContent( HistoryItem( modifier = Modifier.animateItemPlacement(), history = value, - onClickItem = { onClickItem(value) }, + onClickCover = { onClickCover(value) }, onClickResume = { onClickResume(value) }, onClickDelete = { setRemoveState(value) }, ) @@ -175,19 +157,21 @@ fun HistoryHeader( fun HistoryItem( modifier: Modifier = Modifier, history: HistoryWithRelations, - onClickItem: () -> Unit, + onClickCover: () -> Unit, onClickResume: () -> Unit, onClickDelete: () -> Unit, ) { Row( modifier = modifier - .clickable(onClick = onClickItem) + .clickable(onClick = onClickResume) .height(96.dp) .padding(horizontal = horizontalPadding, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically, ) { MangaCover( - modifier = Modifier.fillMaxHeight(), + modifier = Modifier + .fillMaxHeight() + .clickable(onClick = onClickCover), data = history.thumbnailUrl, aspect = MangaCoverAspect.COVER ) @@ -221,6 +205,7 @@ fun HistoryItem( ) } } + IconButton(onClick = onClickDelete) { Icon( imageVector = Icons.Outlined.Delete, @@ -228,13 +213,6 @@ fun HistoryItem( tint = MaterialTheme.colorScheme.onSurface, ) } - IconButton(onClick = onClickResume) { - Icon( - imageVector = Icons.Filled.PlayArrow, - contentDescription = stringResource(id = R.string.action_resume), - tint = MaterialTheme.colorScheme.onSurface, - ) - } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt index d2a04a131b..bf6cdd61ef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt @@ -33,7 +33,7 @@ class HistoryController : ComposeController(), RootController HistoryScreen( nestedScrollInterop = nestedScrollInterop, presenter = presenter, - onClickItem = { history -> + onClickCover = { history -> router.pushController(MangaController(history).withFadeTransaction()) }, onClickResume = { history ->