enhancement: font scaling options (#606)

This commit is contained in:
Diego Beraldin 2024-03-16 12:13:44 +01:00 committed by GitHub
parent a652db280d
commit 265c7d2a8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 16 deletions

View File

@ -45,12 +45,14 @@ fun Float.toFontScale(): FontScale = when (this) {
else -> FontScale.Normal
}
// log(2 + 0.1 * n) / log(2)
private object ReferenceValues {
const val largest = 1.953125f
const val larger = 1.5625f
const val large = 1.25f
const val largest = 1.2f
const val larger = 1.14f
const val large = 1.07f
const val normal = 1f
const val small = 0.8f
const val smaller = 0.64f
const val smallest = 0.512f
const val small = 0.93f
const val smaller = 0.85f
const val smallest = 0.77f
}

View File

@ -17,12 +17,13 @@ fun CustomizedContent(
) {
val themeRepository = remember { getThemeRepository() }
val fontScale by themeRepository.contentFontScale.collectAsState()
val uiFontScale by themeRepository.uiFontScale.collectAsState()
val scaleFactor = when (contentClass) {
ContentFontClass.Title -> fontScale.title
ContentFontClass.Body -> fontScale.body
ContentFontClass.Comment -> fontScale.comment
ContentFontClass.AncillaryText -> fontScale.ancillary
}
} * uiFontScale
CompositionLocalProvider(
LocalDensity provides Density(

View File

@ -31,9 +31,7 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.input.nestedscroll.nestedScroll
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.koin.getScreenModel
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.FontScale
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.UiTheme
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.scaleFactor
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toFontScale
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toReadableName
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getColorSchemeProvider
@ -228,13 +226,7 @@ class SettingsColorAndFontScreen : Screen {
title = LocalXmlStrings.current.settingsUiFontScale,
value = uiState.uiFontScale.toFontScale().toReadableName(),
onTap = rememberCallback {
val sheet = FontScaleBottomSheet(
values = listOf(
FontScale.Large,
FontScale.Normal,
FontScale.Small,
).map { it.scaleFactor },
)
val sheet = FontScaleBottomSheet()
navigationCoordinator.showBottomSheet(sheet)
},
)