diff --git a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt index 425d7bbff..6fbd4f5d4 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt @@ -6,6 +6,8 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.res.stringResource +import eu.kanade.domain.manga.model.orientationType +import eu.kanade.domain.manga.model.readingModeType import eu.kanade.presentation.util.collectAsState import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.setting.OrientationType @@ -26,12 +28,15 @@ internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) HeadingItem(R.string.pref_category_for_this_series) + 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) ReadingModeType.values().map { RadioItem( label = stringResource(it.stringRes), - // TODO: Reading mode - selected = false, + selected = readingMode == it, onClick = { screenModel.onChangeReadingMode(it) }, ) } @@ -40,8 +45,7 @@ internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) OrientationType.values().map { RadioItem( label = stringResource(it.stringRes), - // TODO: Rotation type - selected = false, + selected = orientation == it, onClick = { screenModel.onChangeOrientation(it) }, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt index fb7df6282..0125a78a4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt @@ -18,8 +18,6 @@ enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val str companion object { const val MASK = 0x00000038 - fun fromPreference(preference: Int?): OrientationType = values().find { it.flagValue == preference } ?: FREE - - fun fromSpinner(position: Int?) = values().find { value -> value.prefValue == position } ?: DEFAULT + fun fromPreference(preference: Int?): OrientationType = values().find { it.flagValue == preference } ?: DEFAULT } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsScreenModel.kt index 87068fa61..11125ac77 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsScreenModel.kt @@ -25,6 +25,11 @@ class ReaderSettingsScreenModel( .distinctUntilChanged() .stateIn(ioCoroutineScope, SharingStarted.Lazily, null) + val mangaFlow = readerState + .map { it.manga } + .distinctUntilChanged() + .stateIn(ioCoroutineScope, SharingStarted.Lazily, null) + fun togglePreference(preference: (ReaderPreferences) -> Preference) { preference(preferences).toggle() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt index 88e1a3f02..73975e28f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt @@ -29,8 +29,6 @@ enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @D return mode == LEFT_TO_RIGHT || mode == RIGHT_TO_LEFT || mode == VERTICAL } - fun fromSpinner(position: Int?) = values().find { value -> value.prefValue == position } ?: DEFAULT - fun toViewer(preference: Int?, activity: ReaderActivity): Viewer { return when (fromPreference(preference)) { LEFT_TO_RIGHT -> L2RPagerViewer(activity)