show duplicating manga cover on Duplicate dialog
This commit is contained in:
parent
3a48f424f8
commit
e874092d3e
5 changed files with 106 additions and 20 deletions
|
|
@ -2,6 +2,7 @@ package eu.kanade.presentation.manga
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.FlowColumn
|
import androidx.compose.foundation.layout.FlowColumn
|
||||||
import androidx.compose.foundation.layout.FlowRow
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
|
|
@ -10,8 +11,10 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.sizeIn
|
import androidx.compose.foundation.layout.sizeIn
|
||||||
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Add
|
import androidx.compose.material.icons.outlined.Add
|
||||||
import androidx.compose.material.icons.outlined.Book
|
import androidx.compose.material.icons.outlined.Book
|
||||||
|
|
@ -23,18 +26,27 @@ import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import eu.kanade.domain.ui.UiPreferences
|
||||||
import eu.kanade.presentation.components.AdaptiveSheet
|
import eu.kanade.presentation.components.AdaptiveSheet
|
||||||
import eu.kanade.presentation.components.TabbedDialogPaddings
|
import eu.kanade.presentation.components.TabbedDialogPaddings
|
||||||
|
import eu.kanade.presentation.manga.components.MangaCover
|
||||||
|
import eu.kanade.presentation.manga.components.RatioSwitchToPanorama
|
||||||
import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight
|
import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight
|
||||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||||
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.kmk.KMR
|
import tachiyomi.i18n.kmk.KMR
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
|
import tachiyomi.presentation.core.util.collectAsState
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DuplicateMangaDialog(
|
fun DuplicateMangaDialog(
|
||||||
|
|
@ -42,10 +54,19 @@ fun DuplicateMangaDialog(
|
||||||
onConfirm: () -> Unit,
|
onConfirm: () -> Unit,
|
||||||
onOpenManga: () -> Unit,
|
onOpenManga: () -> Unit,
|
||||||
onMigrate: () -> Unit,
|
onMigrate: () -> Unit,
|
||||||
|
// KMK -->
|
||||||
|
duplicate: Manga,
|
||||||
|
// KMK <--
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val minHeight = LocalPreferenceMinHeight.current
|
val minHeight = LocalPreferenceMinHeight.current
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
|
val usePanoramaCover by Injekt.get<UiPreferences>().usePanoramaCover().collectAsState()
|
||||||
|
val coverRatio = remember { mutableFloatStateOf(1f) }
|
||||||
|
val coverIsWide = coverRatio.floatValue <= RatioSwitchToPanorama
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
AdaptiveSheet(
|
AdaptiveSheet(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
|
|
@ -71,6 +92,37 @@ fun DuplicateMangaDialog(
|
||||||
|
|
||||||
Spacer(Modifier.height(PaddingSize))
|
Spacer(Modifier.height(PaddingSize))
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth(),
|
||||||
|
) {
|
||||||
|
if (usePanoramaCover && coverIsWide) {
|
||||||
|
MangaCover.Panorama(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.Center)
|
||||||
|
.heightIn(max = 150.dp),
|
||||||
|
data = duplicate,
|
||||||
|
onCoverLoaded = { _, result ->
|
||||||
|
val image = result.result.image
|
||||||
|
coverRatio.floatValue = image.height.toFloat() / image.width
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
MangaCover.Book(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.Center)
|
||||||
|
.widthIn(max = 150.dp),
|
||||||
|
data = duplicate,
|
||||||
|
onCoverLoaded = { _, result ->
|
||||||
|
val image = result.result.image
|
||||||
|
coverRatio.floatValue = image.height.toFloat() / image.width
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
TextPreferenceWidget(
|
TextPreferenceWidget(
|
||||||
title = stringResource(MR.strings.action_show_manga),
|
title = stringResource(MR.strings.action_show_manga),
|
||||||
icon = Icons.Outlined.Book,
|
icon = Icons.Outlined.Book,
|
||||||
|
|
@ -141,18 +193,56 @@ fun DuplicateMangasDialog(
|
||||||
onAllowDuplicate: () -> Unit,
|
onAllowDuplicate: () -> Unit,
|
||||||
onSkipDuplicate: () -> Unit,
|
onSkipDuplicate: () -> Unit,
|
||||||
stopRunning: () -> Unit,
|
stopRunning: () -> Unit,
|
||||||
duplicatedName: String,
|
mangaName: String,
|
||||||
|
duplicate: Manga,
|
||||||
) {
|
) {
|
||||||
|
val usePanoramaCover by Injekt.get<UiPreferences>().usePanoramaCover().collectAsState()
|
||||||
|
val coverRatio = remember { mutableFloatStateOf(1f) }
|
||||||
|
val coverIsWide = coverRatio.floatValue <= RatioSwitchToPanorama
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
stopRunning()
|
stopRunning()
|
||||||
onDismissRequest()
|
onDismissRequest()
|
||||||
},
|
},
|
||||||
title = {
|
title = {
|
||||||
Text(text = duplicatedName)
|
Text(text = mangaName)
|
||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Text(text = stringResource(MR.strings.confirm_add_duplicate_manga))
|
Column {
|
||||||
|
Text(text = stringResource(MR.strings.confirm_add_duplicate_manga))
|
||||||
|
|
||||||
|
Spacer(Modifier.height(PaddingSize))
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth(),
|
||||||
|
) {
|
||||||
|
if (usePanoramaCover && coverIsWide) {
|
||||||
|
MangaCover.Panorama(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.Center)
|
||||||
|
.heightIn(max = 150.dp),
|
||||||
|
data = duplicate,
|
||||||
|
onCoverLoaded = { _, result ->
|
||||||
|
val image = result.result.image
|
||||||
|
coverRatio.floatValue = image.height.toFloat() / image.width
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
MangaCover.Book(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.Center)
|
||||||
|
.widthIn(max = 150.dp),
|
||||||
|
data = duplicate,
|
||||||
|
onCoverLoaded = { _, result ->
|
||||||
|
val image = result.result.image
|
||||||
|
coverRatio.floatValue = image.height.toFloat() / image.width
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
FlowRow(
|
FlowRow(
|
||||||
|
|
@ -229,19 +319,4 @@ fun DuplicateMangasDialog(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
|
||||||
@Composable
|
|
||||||
fun DuplicateMangasDialogPreview() {
|
|
||||||
DuplicateMangasDialog(
|
|
||||||
onDismissRequest = { },
|
|
||||||
onAllowAllDuplicate = { },
|
|
||||||
onSkipAllDuplicate = { },
|
|
||||||
onOpenManga = { },
|
|
||||||
onAllowDuplicate = { },
|
|
||||||
onSkipDuplicate = { },
|
|
||||||
duplicatedName = "Berserk",
|
|
||||||
stopRunning = { },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
|
||||||
|
|
@ -453,6 +453,7 @@ fun AddDuplicateMangaDialog(bulkFavoriteScreenModel: BulkFavoriteScreenModel) {
|
||||||
dialog.manga.id,
|
dialog.manga.id,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
duplicate = dialog.duplicate,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -525,8 +526,9 @@ fun AllowDuplicateDialog(bulkFavoriteScreenModel: BulkFavoriteScreenModel) {
|
||||||
bulkFavoriteScreenModel.removeDuplicateSelectedManga(index = dialog.duplicatedManga.first)
|
bulkFavoriteScreenModel.removeDuplicateSelectedManga(index = dialog.duplicatedManga.first)
|
||||||
bulkFavoriteScreenModel.addFavorite(startIdx = dialog.duplicatedManga.first)
|
bulkFavoriteScreenModel.addFavorite(startIdx = dialog.duplicatedManga.first)
|
||||||
},
|
},
|
||||||
duplicatedName = dialog.duplicatedManga.second.title,
|
mangaName = dialog.duplicatedManga.second.title,
|
||||||
stopRunning = bulkFavoriteScreenModel::stopRunning,
|
stopRunning = bulkFavoriteScreenModel::stopRunning,
|
||||||
|
duplicate = dialog.duplicatedManga.second,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -438,6 +438,9 @@ data class BrowseSourceScreen(
|
||||||
)
|
)
|
||||||
// SY <--
|
// SY <--
|
||||||
},
|
},
|
||||||
|
// KMK -->
|
||||||
|
duplicate = dialog.duplicate,
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
||||||
|
|
|
||||||
|
|
@ -440,6 +440,9 @@ class MangaScreen(
|
||||||
migrateManga(navigator, dialog.duplicate, screenModel.manga!!.id)
|
migrateManga(navigator, dialog.duplicate, screenModel.manga!!.id)
|
||||||
// SY <--
|
// SY <--
|
||||||
},
|
},
|
||||||
|
// KMK -->
|
||||||
|
duplicate = dialog.duplicate,
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,9 @@ class MangaDexFollowsScreen(private val sourceId: Long) : Screen() {
|
||||||
dialog.manga.id,
|
dialog.manga.id,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
// KMK -->
|
||||||
|
duplicate = dialog.duplicate,
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
is BrowseSourceScreenModel.Dialog.RemoveManga -> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue