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
|
else -> FontScale.Normal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// log(2 + 0.1 * n) / log(2)
|
||||||
private object ReferenceValues {
|
private object ReferenceValues {
|
||||||
const val largest = 1.953125f
|
const val largest = 1.2f
|
||||||
const val larger = 1.5625f
|
const val larger = 1.14f
|
||||||
const val large = 1.25f
|
const val large = 1.07f
|
||||||
const val normal = 1f
|
const val normal = 1f
|
||||||
const val small = 0.8f
|
const val small = 0.93f
|
||||||
const val smaller = 0.64f
|
const val smaller = 0.85f
|
||||||
const val smallest = 0.512f
|
const val smallest = 0.77f
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,13 @@ fun CustomizedContent(
|
|||||||
) {
|
) {
|
||||||
val themeRepository = remember { getThemeRepository() }
|
val themeRepository = remember { getThemeRepository() }
|
||||||
val fontScale by themeRepository.contentFontScale.collectAsState()
|
val fontScale by themeRepository.contentFontScale.collectAsState()
|
||||||
|
val uiFontScale by themeRepository.uiFontScale.collectAsState()
|
||||||
val scaleFactor = when (contentClass) {
|
val scaleFactor = when (contentClass) {
|
||||||
ContentFontClass.Title -> fontScale.title
|
ContentFontClass.Title -> fontScale.title
|
||||||
ContentFontClass.Body -> fontScale.body
|
ContentFontClass.Body -> fontScale.body
|
||||||
ContentFontClass.Comment -> fontScale.comment
|
ContentFontClass.Comment -> fontScale.comment
|
||||||
ContentFontClass.AncillaryText -> fontScale.ancillary
|
ContentFontClass.AncillaryText -> fontScale.ancillary
|
||||||
}
|
} * uiFontScale
|
||||||
|
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalDensity provides Density(
|
LocalDensity provides Density(
|
||||||
|
@ -31,9 +31,7 @@ import androidx.compose.ui.graphics.ColorFilter
|
|||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import cafe.adriel.voyager.core.screen.Screen
|
import cafe.adriel.voyager.core.screen.Screen
|
||||||
import cafe.adriel.voyager.koin.getScreenModel
|
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.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.toFontScale
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toReadableName
|
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toReadableName
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getColorSchemeProvider
|
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getColorSchemeProvider
|
||||||
@ -228,13 +226,7 @@ class SettingsColorAndFontScreen : Screen {
|
|||||||
title = LocalXmlStrings.current.settingsUiFontScale,
|
title = LocalXmlStrings.current.settingsUiFontScale,
|
||||||
value = uiState.uiFontScale.toFontScale().toReadableName(),
|
value = uiState.uiFontScale.toFontScale().toReadableName(),
|
||||||
onTap = rememberCallback {
|
onTap = rememberCallback {
|
||||||
val sheet = FontScaleBottomSheet(
|
val sheet = FontScaleBottomSheet()
|
||||||
values = listOf(
|
|
||||||
FontScale.Large,
|
|
||||||
FontScale.Normal,
|
|
||||||
FontScale.Small,
|
|
||||||
).map { it.scaleFactor },
|
|
||||||
)
|
|
||||||
navigationCoordinator.showBottomSheet(sheet)
|
navigationCoordinator.showBottomSheet(sheet)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user