Clean up create backup UI
(cherry picked from commit a1e84911be14d353056cc63dc79c341c06c27079) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/backup/create/BackupOptions.kt
This commit is contained in:
parent
d13f08ca7a
commit
54b9b4f548
@ -7,6 +7,7 @@ import android.net.Uri
|
|||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@ -34,10 +35,12 @@ import eu.kanade.tachiyomi.data.backup.create.BackupCreator
|
|||||||
import eu.kanade.tachiyomi.data.backup.create.BackupOptions
|
import eu.kanade.tachiyomi.data.backup.create.BackupOptions
|
||||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.components.LabeledCheckbox
|
import tachiyomi.presentation.core.components.LabeledCheckbox
|
||||||
|
import tachiyomi.presentation.core.components.SectionCard
|
||||||
import tachiyomi.presentation.core.components.material.Scaffold
|
import tachiyomi.presentation.core.components.material.Scaffold
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
@ -88,27 +91,25 @@ class CreateBackupScreen : Screen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: separate sections for library and settings
|
item {
|
||||||
|
SectionCard(MR.strings.label_library) {
|
||||||
|
Column {
|
||||||
|
LabeledCheckbox(
|
||||||
|
label = stringResource(MR.strings.manga),
|
||||||
|
checked = true,
|
||||||
|
onCheckedChange = {},
|
||||||
|
enabled = false,
|
||||||
|
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
||||||
|
)
|
||||||
|
|
||||||
|
Options(BackupOptions.libraryOptions, state, model)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
LabeledCheckbox(
|
SectionCard(MR.strings.label_settings) {
|
||||||
label = stringResource(MR.strings.manga),
|
Options(BackupOptions.settingsOptions, state, model)
|
||||||
checked = true,
|
|
||||||
onCheckedChange = {},
|
|
||||||
enabled = false,
|
|
||||||
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
BackupOptions.entries.forEach { option ->
|
|
||||||
item {
|
|
||||||
LabeledCheckbox(
|
|
||||||
label = stringResource(option.label),
|
|
||||||
checked = option.getter(state.options),
|
|
||||||
onCheckedChange = {
|
|
||||||
model.toggle(option.setter, it)
|
|
||||||
},
|
|
||||||
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,6 +140,24 @@ class CreateBackupScreen : Screen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ColumnScope.Options(
|
||||||
|
options: ImmutableList<BackupOptions.Entry>,
|
||||||
|
state: CreateBackupScreenModel.State,
|
||||||
|
model: CreateBackupScreenModel,
|
||||||
|
) {
|
||||||
|
options.forEach { option ->
|
||||||
|
LabeledCheckbox(
|
||||||
|
label = stringResource(option.label),
|
||||||
|
checked = option.getter(state.options),
|
||||||
|
onCheckedChange = {
|
||||||
|
model.toggle(option.setter, it)
|
||||||
|
},
|
||||||
|
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CreateBackupScreenModel : StateScreenModel<CreateBackupScreenModel.State>(State()) {
|
private class CreateBackupScreenModel : StateScreenModel<CreateBackupScreenModel.State>(State()) {
|
||||||
|
@ -21,8 +21,7 @@ data class BackupOptions(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
val libraryOptions = persistentListOf(
|
||||||
val entries = persistentListOf<Entry>(
|
|
||||||
Entry(
|
Entry(
|
||||||
label = MR.strings.categories,
|
label = MR.strings.categories,
|
||||||
getter = BackupOptions::categories,
|
getter = BackupOptions::categories,
|
||||||
@ -43,6 +42,21 @@ data class BackupOptions(
|
|||||||
getter = BackupOptions::history,
|
getter = BackupOptions::history,
|
||||||
setter = { options, enabled -> options.copy(history = enabled) },
|
setter = { options, enabled -> options.copy(history = enabled) },
|
||||||
),
|
),
|
||||||
|
// SY -->
|
||||||
|
Entry(
|
||||||
|
label = SYMR.strings.custom_entry_info,
|
||||||
|
getter = BackupOptions::customInfo,
|
||||||
|
setter = { options, enabled -> options.copy(customInfo = enabled) },
|
||||||
|
),
|
||||||
|
Entry(
|
||||||
|
label = SYMR.strings.all_read_entries,
|
||||||
|
getter = BackupOptions::readEntries,
|
||||||
|
setter = { options, enabled -> options.copy(readEntries = enabled) },
|
||||||
|
),
|
||||||
|
// SY <--
|
||||||
|
)
|
||||||
|
|
||||||
|
val settingsOptions = persistentListOf(
|
||||||
Entry(
|
Entry(
|
||||||
label = MR.strings.app_settings,
|
label = MR.strings.app_settings,
|
||||||
getter = BackupOptions::appSettings,
|
getter = BackupOptions::appSettings,
|
||||||
@ -58,18 +72,6 @@ data class BackupOptions(
|
|||||||
getter = BackupOptions::privateSettings,
|
getter = BackupOptions::privateSettings,
|
||||||
setter = { options, enabled -> options.copy(privateSettings = enabled) },
|
setter = { options, enabled -> options.copy(privateSettings = enabled) },
|
||||||
),
|
),
|
||||||
// SY -->
|
|
||||||
Entry(
|
|
||||||
label = SYMR.strings.custom_entry_info,
|
|
||||||
getter = BackupOptions::customInfo,
|
|
||||||
setter = { options, enabled -> options.copy(customInfo = enabled) },
|
|
||||||
),
|
|
||||||
Entry(
|
|
||||||
label = SYMR.strings.all_read_entries,
|
|
||||||
getter = BackupOptions::readEntries,
|
|
||||||
setter = { options, enabled -> options.copy(readEntries = enabled) },
|
|
||||||
),
|
|
||||||
// SY <--
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user