feat: possibility to customize content font family; closes #306 (#307)

This commit is contained in:
Diego Beraldin 2023-12-16 11:44:23 +01:00 committed by GitHub
parent 0ce7519166
commit d3b945dbb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 160 additions and 46 deletions

View File

@ -14,6 +14,7 @@ internal class DefaultThemeRepository : ThemeRepository {
override val uiFontFamily = MutableStateFlow(UiFontFamily.Poppins)
override val uiFontScale = MutableStateFlow(1f)
override val contentFontScale = MutableStateFlow(1f)
override val contentFontFamily = MutableStateFlow(UiFontFamily.Poppins)
override val navItemTitles = MutableStateFlow(false)
override val dynamicColors = MutableStateFlow(false)
override val customSeedColor = MutableStateFlow<Color?>(null)
@ -38,6 +39,10 @@ internal class DefaultThemeRepository : ThemeRepository {
contentFontScale.value = value
}
override fun changeContentFontFamily(value: UiFontFamily) {
contentFontFamily.value = value
}
override fun changeNavItemTitles(value: Boolean) {
navItemTitles.value = value
}

View File

@ -15,6 +15,7 @@ interface ThemeRepository {
val uiFontFamily: StateFlow<UiFontFamily>
val uiFontScale: StateFlow<Float>
val contentFontScale: StateFlow<Float>
val contentFontFamily: StateFlow<UiFontFamily>
val navItemTitles: StateFlow<Boolean>
val dynamicColors: StateFlow<Boolean>
val customSeedColor: StateFlow<Color?>
@ -31,6 +32,8 @@ interface ThemeRepository {
fun changeContentFontScale(value: Float)
fun changeContentFontFamily(value: UiFontFamily)
fun changeNavItemTitles(value: Boolean)
fun changeDynamicColors(value: Boolean)

View File

@ -41,7 +41,7 @@ fun AppTheme(
)
val fontFamily by repository.uiFontFamily.collectAsState()
val typography = getTypography(fontFamily)
val typography = fontFamily.toTypography()
val barColorProvider = remember { getBarColorProvider() }
barColorProvider.setBarColorAccordingToTheme(theme ?: defaultTheme)

View File

@ -11,10 +11,8 @@ import com.github.diegoberaldin.raccoonforlemmy.resources.MR
import dev.icerock.moko.resources.compose.fontFamilyResource
@Composable
internal fun getTypography(
fontFamily: UiFontFamily = UiFontFamily.TitilliumWeb,
): Typography {
val fontFamily = when (fontFamily) {
fun UiFontFamily.toTypography(): Typography {
val fontFamily = when (this) {
UiFontFamily.CharisSIL -> fontFamilyResource(MR.fonts.CharisSIL.regular)
UiFontFamily.NotoSans -> fontFamilyResource(MR.fonts.NotoSans.regular)
UiFontFamily.EBGaramond -> fontFamilyResource(MR.fonts.EBGaramond.regular)

View File

@ -10,9 +10,10 @@ import androidx.compose.ui.unit.Density
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getThemeRepository
@Composable
fun ScaledContent(content: @Composable () -> Unit) {
fun CustomizedContent(content: @Composable () -> Unit) {
val themeRepository = remember { getThemeRepository() }
val fontScale by themeRepository.contentFontScale.collectAsState()
CompositionLocalProvider(
LocalDensity provides Density(
density = LocalDensity.current.density,
@ -21,4 +22,4 @@ fun ScaledContent(content: @Composable () -> Unit) {
) {
content()
}
}
}

View File

@ -24,8 +24,8 @@ import androidx.compose.ui.unit.dp
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.CornerSize
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.IconSize
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomizedContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCardBody
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ScaledContent
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.prettifyDate
@Composable
@ -90,7 +90,7 @@ internal fun MessageCard(
)
).fillMaxWidth().padding(Spacing.s)
) {
ScaledContent {
CustomizedContent {
Column {
PostCardBody(
text = content,

View File

@ -40,8 +40,8 @@ import cafe.adriel.voyager.core.screen.Screen
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.BottomSheetHandle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomizedContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCardBody
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ScaledContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getCommunityInfoViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.prettifyDate
import com.github.diegoberaldin.raccoonforlemmy.core.utils.getPrettyNumber
@ -171,7 +171,7 @@ class CommunityInfoScreen(
}
}
item {
ScaledContent {
CustomizedContent {
PostCardBody(
modifier = Modifier.fillMaxWidth(),
text = uiState.community.description,

View File

@ -94,7 +94,7 @@ fun CommentCard(
onToggleExpanded = onToggleExpanded,
distinguished = comment.distinguished,
)
ScaledContent {
CustomizedContent {
PostCardBody(
text = comment.text,
autoLoadImages = autoLoadImages,

View File

@ -79,7 +79,7 @@ fun CommunityItem(
)
}
ScaledContent {
CustomizedContent {
Column(
modifier = Modifier.weight(1f)
) {

View File

@ -67,7 +67,7 @@ fun InboxCard(
mention = mention,
type = type,
)
ScaledContent {
CustomizedContent {
PostCardBody(
modifier = Modifier.padding(
horizontal = Spacing.xs,

View File

@ -69,7 +69,7 @@ fun MultiCommunityItem(
)
}
ScaledContent {
CustomizedContent {
Column(
modifier = Modifier.weight(1f)
) {

View File

@ -198,7 +198,7 @@ private fun CompactPost(
verticalAlignment = Alignment.Top,
horizontalArrangement = Arrangement.spacedBy(Spacing.xs)
) {
ScaledContent {
CustomizedContent {
PostCardTitle(
modifier = Modifier.weight(0.75f),
text = post.title,
@ -307,7 +307,7 @@ private fun ExtendedPost(
optionsMenuOpen.value = true
},
)
ScaledContent {
CustomizedContent {
PostCardTitle(
modifier = Modifier.padding(
vertical = Spacing.xs,
@ -349,7 +349,7 @@ private fun ExtendedPost(
},
)
if (showBody) {
ScaledContent {
CustomizedContent {
Box(
modifier = Modifier.padding(top = Spacing.xxs)
) {

View File

@ -1,11 +1,16 @@
package com.github.diegoberaldin.raccoonforlemmy.core.commonui.components
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getThemeRepository
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.toTypography
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose.CustomMarkdown
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.model.markdownTypography
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.di.getSettingsRepository
@ -21,6 +26,9 @@ fun PostCardBody(
val uriHandler = LocalUriHandler.current
val navigationCoordinator = remember { getNavigationCoordinator() }
val settingsRepository = remember { getSettingsRepository() }
val themeRepository = remember { getThemeRepository() }
val fontFamily by themeRepository.contentFontFamily.collectAsState()
val typography = fontFamily.toTypography()
if (text.isNotEmpty()) {
CustomMarkdown(
@ -28,6 +36,16 @@ fun PostCardBody(
content = text,
inlineImages = false,
autoLoadImages = autoLoadImages,
typography = markdownTypography(
h1 = typography.titleLarge,
h2 = typography.titleLarge,
h3 = typography.titleMedium,
h4 = typography.titleMedium,
h5 = typography.titleSmall,
h6 = typography.titleSmall,
text = typography.bodyMedium,
paragraph = typography.bodyMedium,
),
onOpenUrl = { url ->
navigationCoordinator.handleUrl(
url = url,

View File

@ -1,11 +1,14 @@
package com.github.diegoberaldin.raccoonforlemmy.core.commonui.components
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.font.FontWeight
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getThemeRepository
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.toTypography
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose.CustomMarkdown
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.model.markdownTypography
@ -24,20 +27,23 @@ fun PostCardTitle(
val uriHandler = LocalUriHandler.current
val navigationCoordinator = remember { getNavigationCoordinator() }
val settingsRepository = remember { getSettingsRepository() }
val themeRepository = remember { getThemeRepository() }
val fontFamily by themeRepository.contentFontFamily.collectAsState()
val typography = fontFamily.toTypography()
CustomMarkdown(
modifier = modifier,
content = text,
autoLoadImages = autoLoadImages,
typography = markdownTypography(
h1 = MaterialTheme.typography.titleLarge,
h2 = MaterialTheme.typography.titleLarge,
h3 = MaterialTheme.typography.titleMedium,
h4 = MaterialTheme.typography.titleMedium,
h5 = MaterialTheme.typography.titleSmall,
h6 = MaterialTheme.typography.titleSmall,
text = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Medium),
paragraph = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Medium),
h1 = typography.titleLarge,
h2 = typography.titleLarge,
h3 = typography.titleMedium,
h4 = typography.titleMedium,
h5 = typography.titleSmall,
h6 = typography.titleSmall,
text = typography.bodyMedium.copy(fontWeight = FontWeight.Medium),
paragraph = typography.bodyMedium.copy(fontWeight = FontWeight.Medium),
),
onOpenUrl = { url ->
navigationCoordinator.handleUrl(

View File

@ -51,7 +51,7 @@ fun UserItem(
)
}
ScaledContent {
CustomizedContent {
Text(
text = buildString {
append(name)

View File

@ -41,7 +41,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.communitydetail.CommunityDetailScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CommunityItem
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ScaledContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomizedContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getInstanceInfoViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.selectcommunity.CommunityItemPlaceholder
@ -172,7 +172,7 @@ class InstanceInfoScreen(
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
item {
ScaledContent {
CustomizedContent {
Column(
modifier = Modifier.padding(horizontal = Spacing.s),
verticalArrangement = Arrangement.spacedBy(Spacing.s),

View File

@ -39,6 +39,7 @@ class FontFamilyBottomSheet(
UiFontFamily.Comfortaa,
UiFontFamily.Default,
),
private val content: Boolean = false,
) : Screen {
@Composable
@ -78,9 +79,12 @@ class FontFamilyBottomSheet(
.fillMaxWidth()
.onClick(
onClick = rememberCallback {
notificationCenter.send(
val event = if (content) {
NotificationCenterEvent.ChangeContentFontFamily(value)
} else {
NotificationCenterEvent.ChangeFontFamily(value)
)
}
notificationCenter.send(event)
navigationCoordinator.hideBottomSheet()
},
),

View File

@ -44,10 +44,10 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.IconSize
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomDropDown
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomImage
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomizedContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Option
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.OptionId
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCardBody
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ScaledContent
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallback
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.prettifyDate
@ -89,7 +89,7 @@ internal fun InnerReportCard(
autoLoadImages = autoLoadImages,
onOpenCreator = onOpenCreator,
)
ScaledContent {
CustomizedContent {
PostCardBody(
modifier = Modifier.padding(
horizontal = Spacing.xs,

View File

@ -30,6 +30,7 @@ sealed interface NotificationCenterEvent {
data class ChangeContentFontSize(val value: Float) : NotificationCenterEvent
data class ChangeUiFontSize(val value: Float) : NotificationCenterEvent
data class ChangeFontFamily(val value: UiFontFamily) : NotificationCenterEvent
data class ChangeContentFontFamily(val value: UiFontFamily) : NotificationCenterEvent
data class ChangeZombieInterval(val value: Duration) : NotificationCenterEvent
data class ChangeLanguage(val value: String) : NotificationCenterEvent
data class ChangePostLayout(val value: PostLayout) : NotificationCenterEvent

View File

@ -11,6 +11,7 @@ data class SettingsModel(
val uiFontFamily: Int = 0,
val uiFontScale: Float = 1f,
val contentFontScale: Float = 1f,
val contentFontFamily: Int = 0,
val locale: String? = null,
val defaultListingType: Int = 2,
val defaultPostSortType: Int = 1,

View File

@ -44,6 +44,7 @@ private object KeyStoreKeys {
const val CommentBarTheme = "commentBarTheme"
const val SharePostOriginal = "sharePostOriginal"
const val SearchPostTitleOnly = "searchPostTitleOnly"
const val ContentFontFamily = "contentFontFamily"
}
internal class DefaultSettingsRepository(
@ -90,6 +91,7 @@ internal class DefaultSettingsRepository(
commentBarTheme = settings.commentBarTheme.toLong(),
sharePostOriginal = if (settings.sharePostOriginal) 1 else 0,
searchPostTitleOnly = if (settings.searchPostTitleOnly) 1 else 0,
contentFontFamily = settings.contentFontFamily.toLong(),
)
}
@ -131,6 +133,7 @@ internal class DefaultSettingsRepository(
commentBarTheme = keyStore[KeyStoreKeys.CommentBarTheme, 0],
sharePostOriginal = keyStore[KeyStoreKeys.SharePostOriginal, true],
searchPostTitleOnly = keyStore[KeyStoreKeys.SearchPostTitleOnly, false],
contentFontFamily = keyStore[KeyStoreKeys.ContentFontFamily, 0],
)
} else {
val entity = db.settingsQueries.getBy(accountId).executeAsOneOrNull()
@ -215,6 +218,7 @@ internal class DefaultSettingsRepository(
KeyStoreKeys.SearchPostTitleOnly,
settings.searchPostTitleOnly,
)
keyStore.save(KeyStoreKeys.ContentFontFamily, settings.contentFontFamily)
} else {
db.settingsQueries.update(
theme = settings.theme?.toLong(),
@ -249,6 +253,7 @@ internal class DefaultSettingsRepository(
commentBarTheme = settings.commentBarTheme.toLong(),
sharePostOriginal = if (settings.sharePostOriginal) 1L else 0L,
searchPostTitleOnly = if (settings.searchPostTitleOnly) 1L else 0L,
contentFontFamily = settings.contentFontFamily.toLong(),
)
}
}
@ -291,4 +296,5 @@ private fun GetBy.toModel() = SettingsModel(
commentBarTheme = commentBarTheme.toInt(),
sharePostOriginal = sharePostOriginal != 0L,
searchPostTitleOnly = searchPostTitleOnly != 0L,
contentFontFamily = contentFontFamily.toInt(),
)

View File

@ -2,7 +2,7 @@ CREATE TABLE SettingsEntity (
id INTEGER PRIMARY KEY AUTOINCREMENT,
theme INTEGER DEFAULT NULL,
uiFontScale REAL NOT NULL DEFAULT 1,
uiFontFamily INTEGER NOT NULL DEFAULT 1,
uiFontFamily INTEGER NOT NULL DEFAULT 0,
contentFontScale REAL NOT NULL DEFAULT 1,
locale TEXT DEFAULT NULL,
defaultListingType INTEGER NOT NULL DEFAULT 0,
@ -31,6 +31,7 @@ CREATE TABLE SettingsEntity (
commentBarTheme INTEGER NOT NULL DEFAULT 0,
sharePostOriginal INTEGER NOT NULL DEFAULT 1,
searchPostTitleOnly INTEGER NOT NULL DEFAULT 0,
contentFontFamily INTEGER NOT NULL DEFAULT 0,
account_id INTEGER,
FOREIGN KEY (account_id) REFERENCES AccountEntity(id) ON DELETE CASCADE,
UNIQUE(account_id)
@ -69,6 +70,7 @@ INSERT OR IGNORE INTO SettingsEntity (
commentBarTheme,
sharePostOriginal,
searchPostTitleOnly,
contentFontFamily,
account_id
) VALUES (
?,
@ -102,6 +104,7 @@ INSERT OR IGNORE INTO SettingsEntity (
?,
?,
?,
?,
?
);
@ -137,7 +140,8 @@ SET theme = ?,
markAsReadWhileScrolling = ?,
commentBarTheme = ?,
sharePostOriginal = ?,
searchPostTitleOnly = ?
searchPostTitleOnly = ?,
contentFontFamily = ?
WHERE account_id = ?;
getBy:
@ -173,6 +177,7 @@ SELECT
markAsReadWhileScrolling,
commentBarTheme,
sharePostOriginal,
searchPostTitleOnly
searchPostTitleOnly,
contentFontFamily
FROM SettingsEntity
WHERE account_id = ?;

View File

@ -0,0 +1,2 @@
ALTER TABLE SettingsEntity
ADD COLUMN contentFontFamily INTEGER NOT NULL DEFAULT 0;

View File

@ -35,11 +35,11 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.IconSize
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomDropDown
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomImage
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomizedContent
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Option
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.OptionId
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PlaceholderImage
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCardBody
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ScaledContent
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallback
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.prettifyDate
@ -139,7 +139,7 @@ internal fun ChatCard(
)
}
}
ScaledContent {
CustomizedContent {
// last message text
PostCardBody(
modifier = Modifier.heightIn(max = 76.dp),

View File

@ -23,6 +23,7 @@ interface SettingsMviModel :
data class ChangeUiFontSize(val value: Float) : Intent
data class ChangeUiFontFamily(val value: UiFontFamily) : Intent
data class ChangeContentFontSize(val value: Float) : Intent
data class ChangeContentFontFamily(val value: UiFontFamily) : Intent
data class ChangeLanguage(val value: String) : Intent
data class ChangeDefaultListingType(val value: ListingType) : Intent
data class ChangePostLayout(val value: PostLayout) : Intent
@ -55,12 +56,13 @@ interface SettingsMviModel :
data class UiState(
val isLogged: Boolean = false,
val uiTheme: UiTheme? = null,
val uiFontFamily: UiFontFamily = UiFontFamily.TitilliumWeb,
val uiFontFamily: UiFontFamily = UiFontFamily.Poppins,
val customSeedColor: Color? = null,
val upvoteColor: Color? = null,
val downvoteColor: Color? = null,
val uiFontScale: FontScale = FontScale.Normal,
val contentFontScale: FontScale = FontScale.Normal,
val contentFontFamily: UiFontFamily = UiFontFamily.Poppins,
val lang: String = "",
val postLayout: PostLayout = PostLayout.Card,
val defaultListingType: ListingType = ListingType.Local,

View File

@ -283,6 +283,14 @@ class SettingsScreen : Screen {
navigationCoordinator.showBottomSheet(sheet)
},
)
SettingsRow(
title = stringResource(MR.strings.settings_content_font_family),
value = uiState.contentFontFamily.toReadableName(),
onTap = rememberCallback {
val sheet = FontFamilyBottomSheet(content = true)
navigationCoordinator.showBottomSheet(sheet)
},
)
// font scale
SettingsRow(
title = stringResource(MR.strings.settings_ui_font_scale),

View File

@ -56,15 +56,18 @@ class SettingsViewModel(
override fun onStarted() {
mvi.onStarted()
mvi.scope?.launch(Dispatchers.Main) {
themeRepository.uiTheme.onEach { currentTheme ->
mvi.updateState { it.copy(uiTheme = currentTheme) }
themeRepository.uiTheme.onEach { value ->
mvi.updateState { it.copy(uiTheme = value) }
}.launchIn(this)
themeRepository.uiFontFamily.onEach { fontFamily ->
mvi.updateState { it.copy(uiFontFamily = fontFamily) }
themeRepository.uiFontFamily.onEach { value ->
mvi.updateState { it.copy(uiFontFamily = value) }
}.launchIn(this)
themeRepository.contentFontScale.onEach { value ->
mvi.updateState { it.copy(contentFontScale = value.toFontScale()) }
}.launchIn(this)
themeRepository.contentFontFamily.onEach { value ->
mvi.updateState { it.copy(contentFontFamily = value) }
}.launchIn(this)
themeRepository.uiFontScale.onEach { value ->
mvi.updateState { it.copy(uiFontScale = value.toFontScale()) }
}.launchIn(this)
@ -119,6 +122,10 @@ class SettingsViewModel(
.onEach { evt ->
changeContentFontScale(evt.value)
}.launchIn(this)
notificationCenter.subscribe(NotificationCenterEvent.ChangeContentFontFamily::class)
.onEach { evt ->
changeContentFontFamily(evt.value)
}.launchIn(this)
notificationCenter.subscribe(NotificationCenterEvent.ChangeUiFontSize::class)
.onEach { evt ->
changeUiFontScale(evt.value)
@ -219,6 +226,10 @@ class SettingsViewModel(
changeContentFontScale(intent.value)
}
is SettingsMviModel.Intent.ChangeContentFontFamily -> {
changeContentFontFamily(intent.value)
}
is SettingsMviModel.Intent.ChangeUiFontSize -> {
changeUiFontScale(intent.value)
}
@ -373,6 +384,16 @@ class SettingsViewModel(
}
}
private fun changeContentFontFamily(value: UiFontFamily) {
themeRepository.changeContentFontFamily(value)
mvi.scope?.launch {
val settings = settingsRepository.currentSettings.value.copy(
contentFontFamily = value.toInt()
)
saveSettings(settings)
}
}
private fun changeLanguage(value: String) {
languageRepository.changeLanguage(value)
mvi.scope?.launch {

View File

@ -259,4 +259,5 @@
<string name="settings_share_post_original">مشاركة المشاركات من المثيل الأصلي</string>
<string name="community_action_unsubscribe">إلغاء الاشتراك</string>
<string name="settings_search_posts_title_only">البحث عن المشاركات فقط في العنوان</string>
<string name="settings_content_font_family">عائلة خطوط المحتوى</string>
</resources>

View File

@ -290,4 +290,5 @@
<string name="settings_share_post_original">Share posts from original instance</string>
<string name="community_action_unsubscribe">Unsubscribe</string>
<string name="settings_search_posts_title_only">Search posts only in title</string>
<string name="settings_content_font_family">Content font family</string>
</resources>

View File

@ -270,4 +270,5 @@
</string>
<string name="community_action_unsubscribe">Отписване</string>
<string name="settings_search_posts_title_only">Търсете публикации само в заглавието</string>
<string name="settings_content_font_family">Семейство шрифтове за съдържание</string>
</resources>

View File

@ -261,4 +261,5 @@
<string name="settings_share_post_original">Sdílejte příspěvky z původní instance</string>
<string name="community_action_unsubscribe">Odhlásit odběr</string>
<string name="settings_search_posts_title_only">Hledejte příspěvky pouze v názvu</string>
<string name="settings_content_font_family">Rodina písem obsahu</string>
</resources>

View File

@ -261,4 +261,5 @@
<string name="settings_share_post_original">Del indlæg fra den oprindelige instans</string>
<string name="community_action_unsubscribe">Opsige abonnement</string>
<string name="settings_search_posts_title_only">Søg kun efter indlæg i titlen</string>
<string name="settings_content_font_family">Indhold skrifttypefamilie</string>
</resources>

View File

@ -267,4 +267,5 @@
<string name="settings_share_post_original">Teilen Sie Beiträge von der Originalinstanz</string>
<string name="community_action_unsubscribe">Abbestellen</string>
<string name="settings_search_posts_title_only">Durchsuchen Sie Beiträge nur nach Titel</string>
<string name="settings_content_font_family">Content-Schriftfamilie</string>
</resources>

View File

@ -271,4 +271,5 @@
</string>
<string name="community_action_unsubscribe">Απεγγραφή</string>
<string name="settings_search_posts_title_only">Αναζήτηση αναρτήσεων μόνο στον τίτλο</string>
<string name="settings_content_font_family">Γραμματοσειρά περιεχομένων</string>
</resources>

View File

@ -260,4 +260,5 @@
<string name="settings_share_post_original">Kunhavigi afiŝojn de origina nodo</string>
<string name="community_action_unsubscribe">Malaboni</string>
<string name="settings_search_posts_title_only">Serĉi afiŝojn nur en titolo</string>
<string name="settings_content_font_family">Enhavo tiparo</string>
</resources>

View File

@ -267,4 +267,5 @@
</string>
<string name="community_action_unsubscribe">Cancelar suscripción</string>
<string name="settings_search_posts_title_only">Buscar publicaciones sólo en el título</string>
<string name="settings_content_font_family">Fuente del contenido</string>
</resources>

View File

@ -261,4 +261,5 @@
<string name="settings_share_post_original">Jaga postitusi algsest eksemplarist</string>
<string name="community_action_unsubscribe">Loobu tellimusest</string>
<string name="settings_search_posts_title_only">Otsi postitusi ainult pealkirjast</string>
<string name="settings_content_font_family">Sisu fondiperekond</string>
</resources>

View File

@ -261,4 +261,5 @@
<string name="settings_share_post_original">Jaa viestejä alkuperäisestä esiintymisestä</string>
<string name="community_action_unsubscribe">Lopeta tilaus</string>
<string name="settings_search_posts_title_only">Hae viestejä vain otsikosta</string>
<string name="settings_content_font_family">Sisällön kirjasinperhe</string>
</resources>

View File

@ -267,4 +267,5 @@
<string name="settings_search_posts_title_only">Rechercher les publications uniquement dans le
titre
</string>
<string name="settings_content_font_family">Police des contenus</string>
</resources>

View File

@ -270,4 +270,5 @@
<string name="settings_share_post_original">Roinn postálacha ón mbunús</string>
<string name="community_action_unsubscribe">Díliostáil</string>
<string name="settings_search_posts_title_only">Cuardaigh postálacha i dteideal amháin</string>
<string name="settings_content_font_family">Teaghlach cló ábhar</string>
</resources>

View File

@ -266,4 +266,5 @@
<string name="settings_share_post_original">Dijelite postove iz izvorne instance</string>
<string name="community_action_unsubscribe">Odjavi pretplatu</string>
<string name="settings_search_posts_title_only">Pretraži postove samo u naslovu</string>
<string name="settings_content_font_family">Obitelj fontova sadržaja</string>
</resources>

View File

@ -265,4 +265,5 @@
<string name="settings_share_post_original">Oszd meg az eredeti példány bejegyzéseit</string>
<string name="community_action_unsubscribe">Leiratkozás</string>
<string name="settings_search_posts_title_only">Keresés a bejegyzésekben csak a címben</string>
<string name="settings_content_font_family">Tartalmi betűtípuscsalád</string>
</resources>

View File

@ -265,4 +265,5 @@
<string name="settings_share_post_original">Condividi post dall\'istanza originale</string>
<string name="community_action_unsubscribe">Disiscriviti</string>
<string name="settings_search_posts_title_only">Cerca solo nel titolo dei post</string>
<string name="settings_content_font_family">Font contenuti</string>
</resources>

View File

@ -264,4 +264,5 @@
</string>
<string name="community_action_unsubscribe">Atsisakyti prenumeratos</string>
<string name="settings_search_posts_title_only">Ieškoti įrašų tik pavadinime</string>
<string name="settings_content_font_family">Turinio šriftų šeima</string>
</resources>

View File

@ -265,4 +265,5 @@
<string name="settings_share_post_original">Kopīgojiet ziņas no sākotnējās instances</string>
<string name="community_action_unsubscribe">Anulēt abonementu</string>
<string name="settings_search_posts_title_only">Meklēt ziņas tikai virsrakstā</string>
<string name="settings_content_font_family">Satura fontu saime</string>
</resources>

View File

@ -266,4 +266,5 @@
<string name="settings_share_post_original">Aqsam il-postijiet mill-istanza oriġinali</string>
<string name="community_action_unsubscribe">Annulla l-abbonament</string>
<string name="settings_search_posts_title_only">Fittex postijiet biss fit-titlu</string>
<string name="settings_content_font_family">Familja tat-tipa tal-kontenut</string>
</resources>

View File

@ -265,4 +265,5 @@
</string>
<string name="community_action_unsubscribe">Uitschrijven</string>
<string name="settings_search_posts_title_only">Zoek berichten alleen op titel</string>
<string name="settings_content_font_family">Inhoud lettertypefamilie</string>
</resources>

View File

@ -264,4 +264,5 @@
</string>
<string name="community_action_unsubscribe">Avslutte abonnementet</string>
<string name="settings_search_posts_title_only">Søk kun innlegg i tittel</string>
<string name="settings_content_font_family">Innhold fontfamilie</string>
</resources>

View File

@ -264,4 +264,5 @@
<string name="settings_share_post_original">Udostępniaj posty z oryginalnej instancji</string>
<string name="community_action_unsubscribe">Zrezygnuj z subskrypcji</string>
<string name="settings_search_posts_title_only">Szukaj postów tylko po tytule</string>
<string name="settings_content_font_family">Rodzina czcionek treści</string>
</resources>

View File

@ -181,7 +181,7 @@
<string name="settings_content_font_larger">Extra grande</string>
<string name="settings_content_font_largest">Duplo extra large</string>
<string name="settings_content_font_normal">Normal</string>
<string name="settings_content_font_scale">Tamanho do texto do conteúdo</string>
<string name="settings_content_font_scale">Tamanho do texto dos conteúdos</string>
<string name="settings_content_font_small">Pequeno</string>
<string name="settings_content_font_smaller">Extra pequeno</string>
<string name="settings_content_font_smallest">Doblo extra pequeno</string>
@ -264,4 +264,5 @@
</string>
<string name="community_action_unsubscribe">Cancelar subscrição</string>
<string name="settings_search_posts_title_only">Pesquise postagens apenas no título</string>
<string name="settings_content_font_family">Fonte dos conteúdos</string>
</resources>

View File

@ -182,7 +182,7 @@
<string name="settings_content_font_larger">Foarte mare</string>
<string name="settings_content_font_largest">Dublu extra mare</string>
<string name="settings_content_font_normal">Normal</string>
<string name="settings_content_font_scale">Dimensiunea textului conținutului</string>
<string name="settings_content_font_scale">Dimensiunea textului conținuturilor</string>
<string name="settings_content_font_small">Mic</string>
<string name="settings_content_font_smaller">Extra mic</string>
<string name="settings_content_font_smallest">Dublu extra mic</string>
@ -262,4 +262,5 @@
<string name="settings_share_post_original">Distribui postări din instanța originală</string>
<string name="community_action_unsubscribe">Dezabonează-te</string>
<string name="settings_search_posts_title_only">Căută postări numai în titlu</string>
<string name="settings_content_font_family">Font conținuturilor</string>
</resources>

View File

@ -265,4 +265,5 @@
</string>
<string name="community_action_unsubscribe">Отписаться</string>
<string name="settings_search_posts_title_only">Искать сообщения только по заголовку</string>
<string name="settings_content_font_family">Размер шрифта контента</string>
</resources>

View File

@ -262,4 +262,5 @@
<string name="settings_share_post_original">Dela inlägg från den ursprungliga instansen</string>
<string name="community_action_unsubscribe">Säga upp</string>
<string name="settings_search_posts_title_only">Sök endast inlägg i rubriken</string>
<string name="settings_content_font_family">Teckenstorlek för innehåll</string>
</resources>

View File

@ -263,4 +263,5 @@
<string name="settings_share_post_original">Zdieľajte príspevky z pôvodnej inštancie</string>
<string name="community_action_unsubscribe">Zrušte odber</string>
<string name="settings_search_posts_title_only">Hľadajte príspevky iba v názve</string>
<string name="settings_content_font_family">Veľkosť písma obsahu</string>
</resources>

View File

@ -261,4 +261,5 @@
<string name="settings_share_post_original">Delite objave iz prvotnega primerka</string>
<string name="community_action_unsubscribe">Odjavi se</string>
<string name="settings_search_posts_title_only">Išči objave samo v naslovu</string>
<string name="settings_content_font_family">Velikost pisave vsebine</string>
</resources>

View File

@ -267,4 +267,5 @@
<string name="settings_share_post_original">Ndani postimet nga shembulli origjinal</string>
<string name="community_action_unsubscribe">Çregjistrohu</string>
<string name="settings_search_posts_title_only">Kërkoni postimet vetëm në titull</string>
<string name="settings_content_font_family">Madhësia e shkronjave të përmbajtjes</string>
</resources>

View File

@ -264,4 +264,5 @@
<string name="settings_share_post_original">Orijinal örnekteki gönderileri paylaşın</string>
<string name="community_action_unsubscribe">Abonelikten çık</string>
<string name="settings_search_posts_title_only">Gönderileri yalnızca başlıkta ara</string>
<string name="settings_content_font_family">İçerik yazı tipi boyutu</string>
</resources>

View File

@ -264,4 +264,5 @@
</string>
<string name="community_action_unsubscribe">Відписатися</string>
<string name="settings_search_posts_title_only">Шукати публікації лише за назвою</string>
<string name="settings_content_font_family">Розмір шрифту вмісту</string>
</resources>

View File

@ -115,6 +115,7 @@ fun App(onLoadingFinished: () -> Unit = {}) {
changeContentFontScale(currentSettings.contentFontScale)
changeUiFontScale(currentSettings.uiFontScale)
changeUiFontFamily(currentSettings.uiFontFamily.toUiFontFamily())
changeContentFontFamily(currentSettings.contentFontFamily.toUiFontFamily())
changeCommentBarTheme(currentSettings.commentBarTheme.toCommentBarTheme())
with(themeRepository) {
@ -148,6 +149,7 @@ fun App(onLoadingFinished: () -> Unit = {}) {
changeContentFontScale(settings.contentFontScale)
changeUiFontScale(settings.uiFontScale)
changeUiFontFamily(settings.uiFontFamily.toUiFontFamily())
changeContentFontFamily(settings.contentFontFamily.toUiFontFamily())
with(themeRepository) {
changeUpvoteColor(settings.upvoteColor?.let { Color(it) })