Add Compose previews for reading and orientation mode dialogs
This commit is contained in:
parent
092d930175
commit
0a0b686119
@ -15,13 +15,13 @@ import androidx.compose.ui.res.vectorResource
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.domain.manga.model.orientationType
|
import eu.kanade.domain.manga.model.orientationType
|
||||||
import eu.kanade.presentation.components.AdaptiveSheet
|
import eu.kanade.presentation.components.AdaptiveSheet
|
||||||
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import tachiyomi.presentation.core.components.SettingsIconGrid
|
import tachiyomi.presentation.core.components.SettingsIconGrid
|
||||||
import tachiyomi.presentation.core.components.material.IconToggleButton
|
import tachiyomi.presentation.core.components.material.IconToggleButton
|
||||||
|
import tachiyomi.presentation.core.util.ThemePreviews
|
||||||
private val orientationTypeOptions = OrientationType.entries.map { it.stringRes to it }
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OrientationModeSelectDialog(
|
fun OrientationModeSelectDialog(
|
||||||
@ -33,22 +33,46 @@ fun OrientationModeSelectDialog(
|
|||||||
val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) }
|
val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) }
|
||||||
|
|
||||||
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
||||||
|
DialogContent(
|
||||||
|
orientationType = orientationType,
|
||||||
|
onChangeOrientation = {
|
||||||
|
screenModel.onChangeOrientation(it)
|
||||||
|
onChange(it.stringRes)
|
||||||
|
onDismissRequest()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun DialogContent(
|
||||||
|
orientationType: OrientationType,
|
||||||
|
onChangeOrientation: (OrientationType) -> Unit,
|
||||||
|
) {
|
||||||
Box(modifier = Modifier.padding(vertical = 16.dp)) {
|
Box(modifier = Modifier.padding(vertical = 16.dp)) {
|
||||||
SettingsIconGrid(R.string.rotation_type) {
|
SettingsIconGrid(R.string.rotation_type) {
|
||||||
items(orientationTypeOptions) { (stringRes, mode) ->
|
items(OrientationType.entries) { mode ->
|
||||||
IconToggleButton(
|
IconToggleButton(
|
||||||
checked = mode == orientationType,
|
checked = mode == orientationType,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
screenModel.onChangeOrientation(mode)
|
onChangeOrientation(mode)
|
||||||
onChange(stringRes)
|
|
||||||
onDismissRequest()
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
imageVector = ImageVector.vectorResource(mode.iconRes),
|
imageVector = ImageVector.vectorResource(mode.iconRes),
|
||||||
title = stringResource(stringRes),
|
title = stringResource(mode.stringRes),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ThemePreviews
|
||||||
|
@Composable
|
||||||
|
private fun DialogContentPreview() {
|
||||||
|
TachiyomiTheme {
|
||||||
|
DialogContent(
|
||||||
|
orientationType = OrientationType.DEFAULT,
|
||||||
|
onChangeOrientation = {},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@ import androidx.compose.ui.res.stringResource
|
|||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import eu.kanade.domain.manga.model.readingModeType
|
import eu.kanade.domain.manga.model.readingModeType
|
||||||
import eu.kanade.presentation.components.AdaptiveSheet
|
import eu.kanade.presentation.components.AdaptiveSheet
|
||||||
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
import tachiyomi.presentation.core.components.SettingsIconGrid
|
import tachiyomi.presentation.core.components.SettingsIconGrid
|
||||||
import tachiyomi.presentation.core.components.material.IconToggleButton
|
import tachiyomi.presentation.core.components.material.IconToggleButton
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
|
import tachiyomi.presentation.core.util.ThemePreviews
|
||||||
private val readingModeOptions = ReadingModeType.entries.map { it.stringRes to it }
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ReadingModeSelectDialog(
|
fun ReadingModeSelectDialog(
|
||||||
@ -34,22 +34,46 @@ fun ReadingModeSelectDialog(
|
|||||||
val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) }
|
val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) }
|
||||||
|
|
||||||
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
||||||
|
DialogContent(
|
||||||
|
readingMode = readingMode,
|
||||||
|
onChangeReadingMode = {
|
||||||
|
screenModel.onChangeReadingMode(it)
|
||||||
|
onChange(it.stringRes)
|
||||||
|
onDismissRequest()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun DialogContent(
|
||||||
|
readingMode: ReadingModeType,
|
||||||
|
onChangeReadingMode: (ReadingModeType) -> Unit,
|
||||||
|
) {
|
||||||
Box(modifier = Modifier.padding(vertical = MaterialTheme.padding.medium)) {
|
Box(modifier = Modifier.padding(vertical = MaterialTheme.padding.medium)) {
|
||||||
SettingsIconGrid(R.string.pref_category_reading_mode) {
|
SettingsIconGrid(R.string.pref_category_reading_mode) {
|
||||||
items(readingModeOptions) { (stringRes, mode) ->
|
items(ReadingModeType.entries) { mode ->
|
||||||
IconToggleButton(
|
IconToggleButton(
|
||||||
checked = mode == readingMode,
|
checked = mode == readingMode,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
screenModel.onChangeReadingMode(mode)
|
onChangeReadingMode(mode)
|
||||||
onChange(stringRes)
|
|
||||||
onDismissRequest()
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
imageVector = ImageVector.vectorResource(mode.iconRes),
|
imageVector = ImageVector.vectorResource(mode.iconRes),
|
||||||
title = stringResource(stringRes),
|
title = stringResource(mode.stringRes),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ThemePreviews
|
||||||
|
@Composable
|
||||||
|
private fun DialogContentPreview() {
|
||||||
|
TachiyomiTheme {
|
||||||
|
DialogContent(
|
||||||
|
readingMode = ReadingModeType.DEFAULT,
|
||||||
|
onChangeReadingMode = {},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user