Finish up reader reading mode settings compose migration (#9721)

This commit is contained in:
AntsyLich 2023-07-16 01:47:01 +06:00 committed by GitHub
parent 30bea8b753
commit ec08ba05fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,36 +18,35 @@ import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
import eu.kanade.tachiyomi.util.system.isReleaseBuildType import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import tachiyomi.presentation.core.components.CheckboxItem import tachiyomi.presentation.core.components.CheckboxItem
import tachiyomi.presentation.core.components.HeadingItem import tachiyomi.presentation.core.components.HeadingItem
import tachiyomi.presentation.core.components.RadioItem import tachiyomi.presentation.core.components.SelectItem
import tachiyomi.presentation.core.components.SliderItem import tachiyomi.presentation.core.components.SliderItem
import java.text.NumberFormat import java.text.NumberFormat
private val readingModeOptions = ReadingModeType.values().map { it.stringRes to it }
private val orientationTypeOptions = OrientationType.values().map { it.stringRes to it }
private val tappingInvertModeOptions = ReaderPreferences.TappingInvertMode.values().map { it.titleResId to it }
@Composable @Composable
internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) { internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) {
HeadingItem("This is still a WIP, the UI will be improved soon")
HeadingItem(R.string.pref_category_for_this_series) HeadingItem(R.string.pref_category_for_this_series)
val manga by screenModel.mangaFlow.collectAsState() val manga by screenModel.mangaFlow.collectAsState()
val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) }
val orientation = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) }
HeadingItem(R.string.pref_category_reading_mode) val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) }
ReadingModeType.values().map { SelectItem(
RadioItem( label = stringResource(R.string.pref_category_reading_mode),
label = stringResource(it.stringRes), options = readingModeOptions.map { stringResource(it.first) }.toTypedArray(),
selected = readingMode == it, selectedIndex = readingModeOptions.indexOfFirst { it.second == readingMode },
onClick = { screenModel.onChangeReadingMode(it) }, ) {
) screenModel.onChangeReadingMode(readingModeOptions[it].second)
} }
HeadingItem(R.string.rotation_type) val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) }
OrientationType.values().map { SelectItem(
RadioItem( label = stringResource(R.string.rotation_type),
label = stringResource(it.stringRes), options = orientationTypeOptions.map { stringResource(it.first) }.toTypedArray(),
selected = orientation == it, selectedIndex = orientationTypeOptions.indexOfFirst { it.second == orientationType },
onClick = { screenModel.onChangeOrientation(it) }, ) {
) screenModel.onChangeOrientation(orientationTypeOptions[it].second)
} }
val viewer by screenModel.viewerFlow.collectAsState() val viewer by screenModel.viewerFlow.collectAsState()
@ -63,46 +62,40 @@ private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenMod
HeadingItem(R.string.pager_viewer) HeadingItem(R.string.pager_viewer)
val navigationModePager by screenModel.preferences.navigationModePager().collectAsState() val navigationModePager by screenModel.preferences.navigationModePager().collectAsState()
HeadingItem(R.string.pref_viewer_nav) SelectItem(
ReaderPreferences.TapZones.mapIndexed { index, titleResId -> label = stringResource(R.string.pref_viewer_nav),
RadioItem( options = ReaderPreferences.TapZones.map { stringResource(it) }.toTypedArray(),
label = stringResource(titleResId), selectedIndex = navigationModePager,
selected = navigationModePager == index, onSelect = { screenModel.preferences.navigationModePager().set(it) },
onClick = { screenModel.preferences.navigationModePager().set(index) },
) )
}
if (navigationModePager != 5) { if (navigationModePager != 5) {
val pagerNavInverted by screenModel.preferences.pagerNavInverted().collectAsState() val pagerNavInverted by screenModel.preferences.pagerNavInverted().collectAsState()
HeadingItem(R.string.pref_read_with_tapping_inverted) SelectItem(
ReaderPreferences.TappingInvertMode.values().map { label = stringResource(R.string.pref_read_with_tapping_inverted),
RadioItem( options = tappingInvertModeOptions.map { stringResource(it.first) }.toTypedArray(),
label = stringResource(it.titleResId), selectedIndex = tappingInvertModeOptions.indexOfFirst { it.second == pagerNavInverted },
selected = pagerNavInverted == it, onSelect = {
onClick = { screenModel.preferences.pagerNavInverted().set(it) }, screenModel.preferences.pagerNavInverted().set(tappingInvertModeOptions[it].second)
},
) )
} }
}
val imageScaleType by screenModel.preferences.imageScaleType().collectAsState() val imageScaleType by screenModel.preferences.imageScaleType().collectAsState()
HeadingItem(R.string.pref_image_scale_type) SelectItem(
ReaderPreferences.ImageScaleType.mapIndexed { index, it -> label = stringResource(R.string.pref_image_scale_type),
RadioItem( options = ReaderPreferences.ImageScaleType.map { stringResource(it) }.toTypedArray(),
label = stringResource(it), selectedIndex = imageScaleType - 1,
selected = imageScaleType == index + 1, onSelect = { screenModel.preferences.imageScaleType().set(it + 1) },
onClick = { screenModel.preferences.imageScaleType().set(index + 1) },
) )
}
val zoomStart by screenModel.preferences.zoomStart().collectAsState() val zoomStart by screenModel.preferences.zoomStart().collectAsState()
HeadingItem(R.string.pref_zoom_start) SelectItem(
ReaderPreferences.ZoomStart.mapIndexed { index, it -> label = stringResource(R.string.pref_zoom_start),
RadioItem( options = ReaderPreferences.ZoomStart.map { stringResource(it) }.toTypedArray(),
label = stringResource(it), selectedIndex = zoomStart - 1,
selected = zoomStart == index + 1, onSelect = { screenModel.preferences.zoomStart().set(it + 1) },
onClick = { screenModel.preferences.zoomStart().set(index + 1) },
) )
}
val cropBorders by screenModel.preferences.cropBorders().collectAsState() val cropBorders by screenModel.preferences.cropBorders().collectAsState()
CheckboxItem( CheckboxItem(
@ -179,26 +172,24 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
HeadingItem(R.string.webtoon_viewer) HeadingItem(R.string.webtoon_viewer)
val navigationModeWebtoon by screenModel.preferences.navigationModeWebtoon().collectAsState() val navigationModeWebtoon by screenModel.preferences.navigationModeWebtoon().collectAsState()
HeadingItem(R.string.pref_viewer_nav) SelectItem(
ReaderPreferences.TapZones.mapIndexed { index, titleResId -> label = stringResource(R.string.pref_viewer_nav),
RadioItem( options = ReaderPreferences.TapZones.map { stringResource(it) }.toTypedArray(),
label = stringResource(titleResId), selectedIndex = navigationModeWebtoon,
selected = navigationModeWebtoon == index, onSelect = { screenModel.preferences.navigationModeWebtoon().set(it) },
onClick = { screenModel.preferences.navigationModeWebtoon().set(index) },
) )
}
if (navigationModeWebtoon != 5) { if (navigationModeWebtoon != 5) {
val webtoonNavInverted by screenModel.preferences.webtoonNavInverted().collectAsState() val webtoonNavInverted by screenModel.preferences.webtoonNavInverted().collectAsState()
HeadingItem(R.string.pref_read_with_tapping_inverted) SelectItem(
ReaderPreferences.TappingInvertMode.values().map { label = stringResource(R.string.pref_read_with_tapping_inverted),
RadioItem( options = tappingInvertModeOptions.map { stringResource(it.first) }.toTypedArray(),
label = stringResource(it.titleResId), selectedIndex = tappingInvertModeOptions.indexOfFirst { it.second == webtoonNavInverted },
selected = webtoonNavInverted == it, onSelect = {
onClick = { screenModel.preferences.webtoonNavInverted().set(it) }, screenModel.preferences.webtoonNavInverted().set(tappingInvertModeOptions[it].second)
},
) )
} }
}
val webtoonSidePadding by screenModel.preferences.webtoonSidePadding().collectAsState() val webtoonSidePadding by screenModel.preferences.webtoonSidePadding().collectAsState()
SliderItem( SliderItem(