Refactor webtoon zoom option
This commit is contained in:
@@ -106,6 +106,12 @@ class ReaderViewModel @AssistedInject constructor(
|
|||||||
valueProducer = { isReaderBarEnabled },
|
valueProducer = { isReaderBarEnabled },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val isWebtoonZoomEnabled = settings.observeAsLiveData(
|
||||||
|
context = viewModelScope.coroutineContext + Dispatchers.Default,
|
||||||
|
key = AppSettings.KEY_WEBTOON_ZOOM,
|
||||||
|
valueProducer = { isWebtoonZoomEnable },
|
||||||
|
)
|
||||||
|
|
||||||
val readerSettings = ReaderSettings(
|
val readerSettings = ReaderSettings(
|
||||||
parentScope = viewModelScope,
|
parentScope = viewModelScope,
|
||||||
settings = settings,
|
settings = settings,
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ package org.koitharu.kotatsu.reader.ui.config
|
|||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.lifecycle.MediatorLiveData
|
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.FlowCollector
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
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.model.ZoomMode
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
|
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
|
||||||
@@ -27,9 +31,6 @@ class ReaderSettings(
|
|||||||
val isPagesNumbersEnabled: Boolean
|
val isPagesNumbersEnabled: Boolean
|
||||||
get() = settings.isPagesNumbersEnabled
|
get() = settings.isPagesNumbersEnabled
|
||||||
|
|
||||||
val isWebtoonZoomEnable: Boolean
|
|
||||||
get() = settings.isWebtoonZoomEnable
|
|
||||||
|
|
||||||
override fun onInactive() {
|
override fun onInactive() {
|
||||||
super.onInactive()
|
super.onInactive()
|
||||||
settings.unsubscribe(internalObserver)
|
settings.unsubscribe(internalObserver)
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ class WebtoonReaderFragment : BaseReader<FragmentReaderWebtoonBinding>() {
|
|||||||
addOnPageScrollListener(PageScrollListener())
|
addOnPageScrollListener(PageScrollListener())
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.readerSettings.observe(viewLifecycleOwner) { binding.frame.isZoomEnable = it.isWebtoonZoomEnable }
|
viewModel.isWebtoonZoomEnabled.observe(viewLifecycleOwner) {
|
||||||
|
binding.frame.isZoomEnable = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|||||||
@@ -391,4 +391,5 @@
|
|||||||
<string name="error_no_space_left">No space left on device</string>
|
<string name="error_no_space_left">No space left on device</string>
|
||||||
<string name="reader_slider">Show page switching slider</string>
|
<string name="reader_slider">Show page switching slider</string>
|
||||||
<string name="webtoon_zoom">Webtoon zoom</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>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user