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

(cherry picked from commit ec08ba05fcc6cb2c77ae64016b9eafc2125733ba)
This commit is contained in:
AntsyLich 2023-07-16 01:47:01 +06:00 committed by Jobobby04
parent c93edec2fa
commit 26dfe4d07d
2 changed files with 71 additions and 85 deletions

View File

@ -32,7 +32,6 @@ import tachiyomi.domain.library.service.LibraryPreferences
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.IconItem import tachiyomi.presentation.core.components.IconItem
import tachiyomi.presentation.core.components.RadioItem
import tachiyomi.presentation.core.components.SettingsFlowRow import tachiyomi.presentation.core.components.SettingsFlowRow
import tachiyomi.presentation.core.components.SliderItem import tachiyomi.presentation.core.components.SliderItem
import tachiyomi.presentation.core.components.SortItem import tachiyomi.presentation.core.components.SortItem

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()
@ -66,57 +65,49 @@ 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) },
) )
}
// SY --> // SY -->
val pageLayout by screenModel.preferences.pageLayout().collectAsState() val pageLayout by screenModel.preferences.pageLayout().collectAsState()
HeadingItem(R.string.page_layout) SelectItem(
ReaderPreferences.PageLayouts.mapIndexed { index, it -> label = stringResource(R.string.page_layout),
RadioItem( options = ReaderPreferences.PageLayouts.map { stringResource(it) }.toTypedArray(),
label = stringResource(it), selectedIndex = pageLayout,
selected = pageLayout == index + 1, onSelect = { screenModel.preferences.pageLayout().set(it) },
onClick = { screenModel.preferences.pageLayout().set(index + 1) },
) )
}
// SY <-- // SY <--
val cropBorders by screenModel.preferences.cropBorders().collectAsState() val cropBorders by screenModel.preferences.cropBorders().collectAsState()
@ -206,14 +197,12 @@ private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenMod
) )
val centerMarginType by screenModel.preferences.centerMarginType().collectAsState() val centerMarginType by screenModel.preferences.centerMarginType().collectAsState()
HeadingItem(R.string.pref_center_margin) SelectItem(
ReaderPreferences.CenterMarginTypes.mapIndexed { index, it -> label = stringResource(R.string.pref_center_margin),
RadioItem( options = ReaderPreferences.CenterMarginTypes.map { stringResource(it) }.toTypedArray(),
label = stringResource(it), selectedIndex = centerMarginType,
selected = centerMarginType == index + 1, onSelect = { screenModel.preferences.centerMarginType().set(it) },
onClick = { screenModel.preferences.centerMarginType().set(index + 1) },
) )
}
// SY <-- // SY <--
} }
@ -224,26 +213,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(