mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 04:38:42 +01:00
enhancement: font scaling options (#606)
This commit is contained in:
parent
a652db280d
commit
265c7d2a8a
@ -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
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user