a0786d9b09
* Add Copy to Clipboard * Removing Unused Import * Reusing onShare function * Commit Suggestion * Early Return on null Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 0af90999c8eed4b6c56a94418e5558833f273aa9) # Conflicts: # app/src/main/java/eu/kanade/presentation/reader/ReaderPageActionsDialog.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt
236 lines
8.7 KiB
Kotlin
236 lines
8.7 KiB
Kotlin
package eu.kanade.presentation.reader
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.material.icons.Icons
|
|
import androidx.compose.material.icons.outlined.ContentCopy
|
|
import androidx.compose.material.icons.outlined.Photo
|
|
import androidx.compose.material.icons.outlined.Save
|
|
import androidx.compose.material.icons.outlined.Share
|
|
import androidx.compose.material3.AlertDialog
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.material3.TextButton
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.unit.dp
|
|
import eu.kanade.presentation.components.AdaptiveSheet
|
|
import tachiyomi.i18n.MR
|
|
import tachiyomi.i18n.sy.SYMR
|
|
import tachiyomi.presentation.core.components.ActionButton
|
|
import tachiyomi.presentation.core.components.material.padding
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
@Composable
|
|
fun ReaderPageActionsDialog(
|
|
onDismissRequest: () -> Unit,
|
|
// SY -->
|
|
onSetAsCover: (useExtraPage: Boolean) -> Unit,
|
|
onShare: (copy: Boolean, useExtraPage: Boolean) -> Unit,
|
|
onSave: (useExtraPage: Boolean) -> Unit,
|
|
onShareCombined: (copy: Boolean) -> Unit,
|
|
onSaveCombined: () -> Unit,
|
|
hasExtraPage: Boolean,
|
|
// SY <--
|
|
) {
|
|
var showSetCoverDialog by remember { mutableStateOf(false) }
|
|
// SY -->
|
|
var useExtraPage by remember { mutableStateOf(false) }
|
|
// SY <--
|
|
|
|
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
|
Column(modifier = Modifier.padding(vertical = 16.dp)) {
|
|
Row(
|
|
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
) {
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(
|
|
// SY -->
|
|
if (hasExtraPage) {
|
|
SYMR.strings.action_set_first_page_cover
|
|
} else {
|
|
MR.strings.set_as_cover
|
|
},
|
|
// SY <--
|
|
),
|
|
icon = Icons.Outlined.Photo,
|
|
onClick = { showSetCoverDialog = true },
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(
|
|
// SY -->
|
|
if (hasExtraPage) {
|
|
SYMR.strings.action_copy_first_page
|
|
} else {
|
|
MR.strings.action_copy_to_clipboard
|
|
},
|
|
// SY <--
|
|
),
|
|
icon = Icons.Outlined.ContentCopy,
|
|
onClick = {
|
|
// SY -->
|
|
onShare(true, false)
|
|
// SY <--
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(
|
|
// SY -->
|
|
if (hasExtraPage) {
|
|
SYMR.strings.action_share_first_page
|
|
} else {
|
|
MR.strings.action_share
|
|
},
|
|
// SY <--
|
|
),
|
|
icon = Icons.Outlined.Share,
|
|
onClick = {
|
|
// SY -->
|
|
onShare(false, false)
|
|
// SY <--
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(
|
|
// SY -->
|
|
if (hasExtraPage) {
|
|
SYMR.strings.action_save_first_page
|
|
} else {
|
|
MR.strings.action_save
|
|
},
|
|
// SY <--
|
|
),
|
|
icon = Icons.Outlined.Save,
|
|
onClick = {
|
|
// SY -->
|
|
onSave(false)
|
|
// SY <--
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
}
|
|
if (hasExtraPage) {
|
|
Row(
|
|
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
) {
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_set_second_page_cover),
|
|
icon = Icons.Outlined.Photo,
|
|
onClick = {
|
|
showSetCoverDialog = true
|
|
},
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_copy_second_page),
|
|
icon = Icons.Outlined.ContentCopy,
|
|
onClick = {
|
|
onShare(true, true)
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_share_second_page),
|
|
icon = Icons.Outlined.Share,
|
|
onClick = {
|
|
onShare(false, true)
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_save_second_page),
|
|
icon = Icons.Outlined.Save,
|
|
onClick = {
|
|
onSave(true)
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
}
|
|
Row(
|
|
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
) {
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_copy_combined_page),
|
|
icon = Icons.Outlined.ContentCopy,
|
|
onClick = {
|
|
onShareCombined(true)
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_share_combined_page),
|
|
icon = Icons.Outlined.Share,
|
|
onClick = {
|
|
onShareCombined(false)
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
ActionButton(
|
|
modifier = Modifier.weight(1f),
|
|
title = stringResource(SYMR.strings.action_save_combined_page),
|
|
icon = Icons.Outlined.Save,
|
|
onClick = {
|
|
onSaveCombined()
|
|
onDismissRequest()
|
|
},
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (showSetCoverDialog) {
|
|
SetCoverDialog(
|
|
onConfirm = {
|
|
// SY -->
|
|
onSetAsCover(useExtraPage)
|
|
showSetCoverDialog = false
|
|
useExtraPage = false
|
|
// SY <--
|
|
},
|
|
onDismiss = { showSetCoverDialog = false },
|
|
)
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
private fun SetCoverDialog(
|
|
onConfirm: () -> Unit,
|
|
onDismiss: () -> Unit,
|
|
) {
|
|
AlertDialog(
|
|
text = {
|
|
Text(stringResource(MR.strings.confirm_set_image_as_cover))
|
|
},
|
|
confirmButton = {
|
|
TextButton(onClick = onConfirm) {
|
|
Text(stringResource(MR.strings.action_ok))
|
|
}
|
|
},
|
|
dismissButton = {
|
|
TextButton(onClick = onDismiss) {
|
|
Text(stringResource(MR.strings.action_cancel))
|
|
}
|
|
},
|
|
onDismissRequest = onDismiss,
|
|
)
|
|
}
|