|
@@ -1,6 +1,7 @@
|
|
package eu.kanade.presentation.manga.components
|
|
package eu.kanade.presentation.manga.components
|
|
|
|
|
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.material3.AlertDialog
|
|
import androidx.compose.material3.AlertDialog
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.material3.Text
|
|
@@ -8,6 +9,7 @@ import androidx.compose.material3.TextButton
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.mutableIntStateOf
|
|
import androidx.compose.runtime.mutableIntStateOf
|
|
|
|
+import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Alignment
|
|
@@ -18,7 +20,10 @@ import kotlinx.collections.immutable.toImmutableList
|
|
import tachiyomi.domain.manga.interactor.FetchInterval
|
|
import tachiyomi.domain.manga.interactor.FetchInterval
|
|
import tachiyomi.i18n.MR
|
|
import tachiyomi.i18n.MR
|
|
import tachiyomi.presentation.core.components.WheelTextPicker
|
|
import tachiyomi.presentation.core.components.WheelTextPicker
|
|
|
|
+import tachiyomi.presentation.core.i18n.pluralStringResource
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
+import java.time.Instant
|
|
|
|
+import java.time.temporal.ChronoUnit
|
|
|
|
|
|
@Composable
|
|
@Composable
|
|
fun DeleteChaptersDialog(
|
|
fun DeleteChaptersDialog(
|
|
@@ -54,35 +59,59 @@ fun DeleteChaptersDialog(
|
|
@Composable
|
|
@Composable
|
|
fun SetIntervalDialog(
|
|
fun SetIntervalDialog(
|
|
interval: Int,
|
|
interval: Int,
|
|
|
|
+ nextUpdate: Long,
|
|
onDismissRequest: () -> Unit,
|
|
onDismissRequest: () -> Unit,
|
|
onValueChanged: (Int) -> Unit,
|
|
onValueChanged: (Int) -> Unit,
|
|
) {
|
|
) {
|
|
var selectedInterval by rememberSaveable { mutableIntStateOf(if (interval < 0) -interval else 0) }
|
|
var selectedInterval by rememberSaveable { mutableIntStateOf(if (interval < 0) -interval else 0) }
|
|
|
|
|
|
|
|
+ val nextUpdateDays = remember(nextUpdate) {
|
|
|
|
+ val now = Instant.now()
|
|
|
|
+ val nextUpdateInstant = Instant.ofEpochMilli(nextUpdate)
|
|
|
|
+
|
|
|
|
+ now.until(nextUpdateInstant, ChronoUnit.DAYS)
|
|
|
|
+ }
|
|
|
|
+
|
|
AlertDialog(
|
|
AlertDialog(
|
|
onDismissRequest = onDismissRequest,
|
|
onDismissRequest = onDismissRequest,
|
|
- title = { Text(text = stringResource(MR.strings.manga_modify_calculated_interval_title)) },
|
|
|
|
|
|
+ title = { Text(stringResource(MR.strings.manga_modify_calculated_interval_title)) },
|
|
text = {
|
|
text = {
|
|
- BoxWithConstraints(
|
|
|
|
- modifier = Modifier.fillMaxWidth(),
|
|
|
|
- contentAlignment = Alignment.Center,
|
|
|
|
- ) {
|
|
|
|
- val size = DpSize(width = maxWidth / 2, height = 128.dp)
|
|
|
|
- val items = (0..FetchInterval.MAX_INTERVAL)
|
|
|
|
- .map {
|
|
|
|
- if (it == 0) {
|
|
|
|
- stringResource(MR.strings.label_default)
|
|
|
|
- } else {
|
|
|
|
- it.toString()
|
|
|
|
|
|
+ Column {
|
|
|
|
+ // TODO: figure out why nextUpdate is a weird number sometimes
|
|
|
|
+ if (nextUpdateDays >= 0) {
|
|
|
|
+ Text(
|
|
|
|
+ stringResource(
|
|
|
|
+ MR.strings.manga_interval_expected_update,
|
|
|
|
+ pluralStringResource(
|
|
|
|
+ MR.plurals.day,
|
|
|
|
+ count = nextUpdateDays.toInt(),
|
|
|
|
+ nextUpdateDays,
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BoxWithConstraints(
|
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
|
+ contentAlignment = Alignment.Center,
|
|
|
|
+ ) {
|
|
|
|
+ val size = DpSize(width = maxWidth / 2, height = 128.dp)
|
|
|
|
+ val items = (0..FetchInterval.MAX_INTERVAL)
|
|
|
|
+ .map {
|
|
|
|
+ if (it == 0) {
|
|
|
|
+ stringResource(MR.strings.label_default)
|
|
|
|
+ } else {
|
|
|
|
+ it.toString()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- .toImmutableList()
|
|
|
|
- WheelTextPicker(
|
|
|
|
- items = items,
|
|
|
|
- size = size,
|
|
|
|
- startIndex = selectedInterval,
|
|
|
|
- onSelectionChanged = { selectedInterval = it },
|
|
|
|
- )
|
|
|
|
|
|
+ .toImmutableList()
|
|
|
|
+ WheelTextPicker(
|
|
|
|
+ items = items,
|
|
|
|
+ size = size,
|
|
|
|
+ startIndex = selectedInterval,
|
|
|
|
+ onSelectionChanged = { selectedInterval = it },
|
|
|
|
+ )
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
dismissButton = {
|
|
dismissButton = {
|