summaryrefslogtreecommitdiff
path: root/app/src/main/java/org/terst/feedreader/data/Settings.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/data/Settings.kt')
-rw-r--r--app/src/main/java/org/terst/feedreader/data/Settings.kt7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/src/main/java/org/terst/feedreader/data/Settings.kt b/app/src/main/java/org/terst/feedreader/data/Settings.kt
index be3e809..ebeba6c 100644
--- a/app/src/main/java/org/terst/feedreader/data/Settings.kt
+++ b/app/src/main/java/org/terst/feedreader/data/Settings.kt
@@ -13,6 +13,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withContext
+import kotlin.math.roundToInt
val Context.settingsDataStore by preferencesDataStore(name = "settings")
@@ -38,6 +39,12 @@ private const val READER_FONT_SIZE_MIN_PX = 14
private const val READER_FONT_SIZE_MAX_PX = 28
val READER_FONT_SIZE_RANGE_PX = READER_FONT_SIZE_MIN_PX..READER_FONT_SIZE_MAX_PX
+// Pure so the pinch-to-zoom math is testable without a WebView/gesture detector in the loop --
+// ReaderWebView.kt calls this once per gesture (at pinch-end, with the cumulative scale factor
+// accumulated across the whole gesture), not per touch-move frame.
+fun pinchZoomFontSizePx(basePx: Int, scaleFactor: Float): Int =
+ (basePx * scaleFactor).roundToInt().coerceIn(READER_FONT_SIZE_RANGE_PX.first, READER_FONT_SIZE_RANGE_PX.last)
+
/** Stash connection settings, configured on the Settings screen. Both blank until set. */
class Settings(private val context: Context) {
val stashBaseUrl: Flow<String> =