Yokan / rebuild
Course 1 8624561

DbReaderPreferences.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbReaderPreferences.kt

implementation49 lines
1package eu.friedcutlet.yokan.database23import kotlinx.serialization.Serializable45/** Page processing and navigation that differ between paged and continuous (webtoon) readers. */6@Serializable7data class DbReaderModePreferences(8    val cropBorders: Boolean = false,9    val animatePageTransitions: Boolean = true,10    val usePageTapZones: Boolean = true,11    val navigationLayout: Int = 0,12    /** Shows a landscape page as two consecutive half pages in reading direction. */13    val splitWidePages: Boolean = false,14    val invertSplit: Boolean = false,15    /** Rotates landscape pages a quarter turn (clockwise unless inverted); splitting takes precedence. */16    val rotateWidePages: Boolean = false,17    val invertRotation: Boolean = false,18)1920/** Reader preferences; defaults keep the pre-existing reader behavior. */21@Serializable22data class DbReaderPreferences(23    /** Null until first changed: the group follows the legacy global reader settings. */24    val paged: DbReaderModePreferences? = null,25    val webtoon: DbReaderModePreferences? = null,26    val skipReadChapters: Boolean = false,27    val skipFilteredChapters: Boolean = true,28    val alwaysShowChapterTransition: Boolean = true,29    val saveImagesInTitleFolder: Boolean = false,30    val volumeKeyNavigation: Boolean = false,31    val invertVolumeKeys: Boolean = false,32)3334/** [paged] covers LTR/RTL/vertical pagers; every continuous mode uses the webtoon group. */35fun DbSettings.readerModePreferences(paged: Boolean): DbReaderModePreferences =36    (if (paged) features.reader.paged else features.reader.webtoon) ?: DbReaderModePreferences(37        cropBorders = cropBorders,38        animatePageTransitions = animatePageTransitions,39        usePageTapZones = usePageTapZones,40        navigationLayout = readerNavigationLayout,41    )4243fun DbSettings.withReader(transform: (DbReaderPreferences) -> DbReaderPreferences): DbSettings =44    copy(features = features.copy(reader = transform(features.reader)))4546fun DbSettings.withReaderModePreferences(paged: Boolean, transform: (DbReaderModePreferences) -> DbReaderModePreferences): DbSettings {47    val updated = transform(readerModePreferences(paged))48    return withReader { if (paged) it.copy(paged = updated) else it.copy(webtoon = updated) }49}50

Search chapters, reference and source filenames.