mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Ask to add an entry to the library before editing its cover (#2265)
Closes #2265 Co-authored-by: Quickdev <fyfrive@gmail.com>
This commit is contained in:
@@ -12,6 +12,7 @@ enum class DownloadAction {
|
||||
enum class EditCoverAction {
|
||||
EDIT,
|
||||
DELETE,
|
||||
ADD_TO_LIBRARY,
|
||||
}
|
||||
|
||||
enum class MangaScreenItem {
|
||||
|
||||
@@ -65,6 +65,7 @@ import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
import tachiyomi.presentation.core.util.clickableNoIndication
|
||||
import tachiyomi.source.local.isLocal
|
||||
|
||||
@Composable
|
||||
fun MangaCoverDialog(
|
||||
@@ -125,10 +126,12 @@ fun MangaCoverDialog(
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (isCustomCover) {
|
||||
expanded = true
|
||||
} else {
|
||||
onEditClick(EditCoverAction.EDIT)
|
||||
when {
|
||||
!manga.favorite && !manga.isLocal() -> {
|
||||
onEditClick(EditCoverAction.ADD_TO_LIBRARY)
|
||||
}
|
||||
isCustomCover -> expanded = true
|
||||
else -> onEditClick(EditCoverAction.EDIT)
|
||||
}
|
||||
},
|
||||
) {
|
||||
|
||||
@@ -160,6 +160,15 @@ class MangaCoverViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun addToLibraryWarning(context: Context) {
|
||||
viewModelScope.launch {
|
||||
snackbarHostState.showSnackbar(
|
||||
context.stringResource(MR.strings.notification_first_add_to_library),
|
||||
withDismissAction = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifyCoverUpdated(context: Context) {
|
||||
viewModelScope.launch {
|
||||
snackbarHostState.showSnackbar(
|
||||
|
||||
@@ -253,6 +253,7 @@ class MangaScreen(
|
||||
when (it) {
|
||||
EditCoverAction.EDIT -> getContent.launch("image/*")
|
||||
EditCoverAction.DELETE -> vm.deleteCustomCover(context)
|
||||
EditCoverAction.ADD_TO_LIBRARY -> vm.addToLibraryWarning(context)
|
||||
}
|
||||
},
|
||||
onDismissRequest = onDismissRequest,
|
||||
|
||||
Reference in New Issue
Block a user