Refactor webtoon zoom option

This commit is contained in:
Koitharu
2022-10-12 12:35:33 +03:00
parent 2925900214
commit d0650c7cf4
4 changed files with 15 additions and 5 deletions

View File

@@ -106,6 +106,12 @@ class ReaderViewModel @AssistedInject constructor(
valueProducer = { isReaderBarEnabled },
)
val isWebtoonZoomEnabled = settings.observeAsLiveData(
context = viewModelScope.coroutineContext + Dispatchers.Default,
key = AppSettings.KEY_WEBTOON_ZOOM,
valueProducer = { isWebtoonZoomEnable },
)
val readerSettings = ReaderSettings(
parentScope = viewModelScope,
settings = settings,

View File

@@ -2,9 +2,13 @@ package org.koitharu.kotatsu.reader.ui.config
import android.content.SharedPreferences
import androidx.lifecycle.MediatorLiveData
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.koitharu.kotatsu.core.model.ZoomMode
import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
@@ -27,9 +31,6 @@ class ReaderSettings(
val isPagesNumbersEnabled: Boolean
get() = settings.isPagesNumbersEnabled
val isWebtoonZoomEnable: Boolean
get() = settings.isWebtoonZoomEnable
override fun onInactive() {
super.onInactive()
settings.unsubscribe(internalObserver)

View File

@@ -36,7 +36,9 @@ class WebtoonReaderFragment : BaseReader<FragmentReaderWebtoonBinding>() {
addOnPageScrollListener(PageScrollListener())
}
viewModel.readerSettings.observe(viewLifecycleOwner) { binding.frame.isZoomEnable = it.isWebtoonZoomEnable }
viewModel.isWebtoonZoomEnabled.observe(viewLifecycleOwner) {
binding.frame.isZoomEnable = it
}
}
override fun onDestroyView() {

View File

@@ -391,4 +391,5 @@
<string name="error_no_space_left">No space left on device</string>
<string name="reader_slider">Show page switching slider</string>
<string name="webtoon_zoom">Webtoon zoom</string>
<string name="webtoon_zoom_summary">Allow zoom in/zoom out gesture in webtoon mode (beta)</string>
</resources>