feat(settings): add option for independent content font size and presets
- Introduced `useDifferentFontSizeForContent` and `mobileContentFontSize` settings in UISettings. - Updated Appearance screen to allow users to toggle and select content-specific font sizes. - Added localization for new settings in English, Japanese, Simplified Chinese, and Traditional Chinese. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
## Shiny new things
|
||||
|
||||
- Add option for independent content font size and presets
|
||||
|
||||
## Improvements
|
||||
|
||||
## No longer broken
|
||||
|
||||
@@ -8,6 +8,8 @@ import { createSettingAtom } from "./internal/helper"
|
||||
export interface UISettings extends BaseUISettings {
|
||||
fontScale: number
|
||||
useSystemFontScaling: boolean
|
||||
useDifferentFontSizeForContent: boolean
|
||||
mobileContentFontSize: number
|
||||
}
|
||||
export const createDefaultSettings = (): UISettings => ({
|
||||
...defaultUISettings,
|
||||
@@ -15,6 +17,8 @@ export const createDefaultSettings = (): UISettings => ({
|
||||
|
||||
fontScale: 1,
|
||||
useSystemFontScaling: true,
|
||||
useDifferentFontSizeForContent: false,
|
||||
mobileContentFontSize: 16,
|
||||
})
|
||||
|
||||
export const {
|
||||
|
||||
@@ -61,12 +61,25 @@ export function useWebViewEntry({
|
||||
const readerRenderInlineStyle = useUISettingKey("readerRenderInlineStyle")
|
||||
const useSystemFontScaling = useUISettingKey("useSystemFontScaling")
|
||||
const customFontScale = useUISettingKey("fontScale")
|
||||
const useDifferentFontSizeForContent = useUISettingKey("useDifferentFontSizeForContent")
|
||||
const mobileContentFontSize = useUISettingKey("mobileContentFontSize")
|
||||
|
||||
useEffect(() => {
|
||||
const fontScale = useSystemFontScaling ? PixelRatio.getFontScale() : customFontScale
|
||||
WebViewManager.setRootFontSize(fontScale * 16)
|
||||
}, [useSystemFontScaling, customFontScale])
|
||||
|
||||
// Handle content-specific font size
|
||||
useEffect(() => {
|
||||
if (useDifferentFontSizeForContent) {
|
||||
WebViewManager.setRootFontSize(mobileContentFontSize)
|
||||
} else {
|
||||
// Reset to use the global font scaling
|
||||
const fontScale = useSystemFontScaling ? PixelRatio.getFontScale() : customFontScale
|
||||
WebViewManager.setRootFontSize(fontScale * 16)
|
||||
}
|
||||
}, [useDifferentFontSizeForContent, mobileContentFontSize, useSystemFontScaling, customFontScale])
|
||||
|
||||
// Prepare entry data for WebView
|
||||
const entryInWebview = useMemo(() => {
|
||||
if (!entry) return null
|
||||
|
||||
@@ -40,6 +40,31 @@ const fontSizePresets = [
|
||||
key: "xl",
|
||||
},
|
||||
] as const
|
||||
|
||||
// Content font size presets (in px)
|
||||
const contentFontSizePresets = [
|
||||
{
|
||||
value: 12,
|
||||
key: "xs",
|
||||
},
|
||||
{
|
||||
value: 14,
|
||||
key: "s",
|
||||
},
|
||||
{
|
||||
value: 16,
|
||||
key: "m",
|
||||
},
|
||||
{
|
||||
value: 18,
|
||||
key: "l",
|
||||
},
|
||||
{
|
||||
value: 20,
|
||||
key: "xl",
|
||||
},
|
||||
] as const
|
||||
|
||||
export const AppearanceScreen = () => {
|
||||
const { t } = useTranslation("settings")
|
||||
const showUnreadCountViewAndSubscriptionMobile = useUISettingKey(
|
||||
@@ -57,6 +82,8 @@ export const AppearanceScreen = () => {
|
||||
// Font scaling settings
|
||||
const fontScale = useUISettingKey("fontScale")
|
||||
const useSystemFontScaling = useUISettingKey("useSystemFontScaling")
|
||||
const useDifferentFontSizeForContent = useUISettingKey("useDifferentFontSizeForContent")
|
||||
const mobileContentFontSize = useUISettingKey("mobileContentFontSize")
|
||||
return (
|
||||
<SafeNavigationScrollView
|
||||
className="bg-system-grouped-background"
|
||||
@@ -165,6 +192,37 @@ export const AppearanceScreen = () => {
|
||||
/>
|
||||
</View>
|
||||
</GroupedInsetListCell>
|
||||
<GroupedInsetListCell
|
||||
label={t("appearance.font_scaling.content_different.label")}
|
||||
description={t("appearance.font_scaling.content_different.description")}
|
||||
>
|
||||
<Switch
|
||||
size="sm"
|
||||
value={useDifferentFontSizeForContent}
|
||||
onValueChange={(val) => {
|
||||
setUISetting("useDifferentFontSizeForContent", val)
|
||||
}}
|
||||
/>
|
||||
</GroupedInsetListCell>
|
||||
{useDifferentFontSizeForContent && (
|
||||
<GroupedInsetListCell
|
||||
label={t("appearance.font_scaling.content_size.label")}
|
||||
description={t("appearance.font_scaling.content_size.description")}
|
||||
>
|
||||
<View className="w-[100px]">
|
||||
<Select
|
||||
options={contentFontSizePresets.map((preset) => ({
|
||||
label: t(`appearance.font_scaling.content_size.${preset.key}`),
|
||||
value: preset.value.toString(),
|
||||
}))}
|
||||
value={mobileContentFontSize.toString()}
|
||||
onValueChange={(val) => {
|
||||
setUISetting("mobileContentFontSize", Number.parseInt(val))
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</GroupedInsetListCell>
|
||||
)}
|
||||
</GroupedInsetListCard>
|
||||
|
||||
<GroupedInsetListSectionHeader label="Content" />
|
||||
|
||||
@@ -116,6 +116,15 @@
|
||||
"appearance.date_format.label": "Date Format",
|
||||
"appearance.font.custom": "Custom",
|
||||
"appearance.font.system": "System UI",
|
||||
"appearance.font_scaling.content_different.description": "Set independent font size for article content",
|
||||
"appearance.font_scaling.content_different.label": "Use Different Font Size for Content",
|
||||
"appearance.font_scaling.content_size.description": "Set the font size for article content",
|
||||
"appearance.font_scaling.content_size.l": "Large",
|
||||
"appearance.font_scaling.content_size.label": "Content Font Size",
|
||||
"appearance.font_scaling.content_size.m": "Default",
|
||||
"appearance.font_scaling.content_size.s": "Small",
|
||||
"appearance.font_scaling.content_size.xl": "Larger",
|
||||
"appearance.font_scaling.content_size.xs": "Smaller",
|
||||
"appearance.font_scaling.scale.description": "Adjust the font size scaling factor",
|
||||
"appearance.font_scaling.scale.label": "Font Scale",
|
||||
"appearance.font_scaling.size.l": "Large",
|
||||
|
||||
@@ -116,6 +116,15 @@
|
||||
"appearance.date_format.label": "日付形式",
|
||||
"appearance.font.custom": "カスタム",
|
||||
"appearance.font.system": "システムUI",
|
||||
"appearance.font_scaling.content_different.description": "記事コンテンツに独立したフォントサイズを設定",
|
||||
"appearance.font_scaling.content_different.label": "コンテンツに独立したフォントサイズを使用",
|
||||
"appearance.font_scaling.content_size.description": "記事コンテンツのフォントサイズを設定",
|
||||
"appearance.font_scaling.content_size.l": "大きく",
|
||||
"appearance.font_scaling.content_size.label": "コンテンツフォントサイズ",
|
||||
"appearance.font_scaling.content_size.m": "デフォルト",
|
||||
"appearance.font_scaling.content_size.s": "小さく",
|
||||
"appearance.font_scaling.content_size.xl": "より大きく",
|
||||
"appearance.font_scaling.content_size.xs": "より小さく",
|
||||
"appearance.font_scaling.scale.description": "フォントサイズのスケール係数を調整",
|
||||
"appearance.font_scaling.scale.label": "フォントスケール",
|
||||
"appearance.font_scaling.size.l": "大きく",
|
||||
|
||||
@@ -112,6 +112,10 @@
|
||||
"appearance.date_format.label": "日期格式",
|
||||
"appearance.font.custom": "自定义",
|
||||
"appearance.font.system": "系统字体",
|
||||
"appearance.font_scaling.content_different.description": "为文章内容设置独立的字体大小",
|
||||
"appearance.font_scaling.content_different.label": "内容使用独立字体大小",
|
||||
"appearance.font_scaling.content_size.description": "设置文章内容的字体大小",
|
||||
"appearance.font_scaling.content_size.label": "内容字体大小",
|
||||
"appearance.font_scaling.scale.description": "调整字体大小缩放比例",
|
||||
"appearance.font_scaling.scale.label": "字体缩放",
|
||||
"appearance.font_scaling.size.l": "大",
|
||||
|
||||
@@ -105,6 +105,15 @@
|
||||
"appearance.date_format.label": "日期格式",
|
||||
"appearance.font.custom": "自訂",
|
||||
"appearance.font.system": "系統字體",
|
||||
"appearance.font_scaling.content_different.description": "為文章內容設定獨立的字體大小",
|
||||
"appearance.font_scaling.content_different.label": "內容使用獨立字體大小",
|
||||
"appearance.font_scaling.content_size.description": "設定文章內容的字體大小",
|
||||
"appearance.font_scaling.content_size.l": "大",
|
||||
"appearance.font_scaling.content_size.label": "內容字體大小",
|
||||
"appearance.font_scaling.content_size.m": "預設",
|
||||
"appearance.font_scaling.content_size.s": "小",
|
||||
"appearance.font_scaling.content_size.xl": "較大",
|
||||
"appearance.font_scaling.content_size.xs": "較小",
|
||||
"appearance.font_scaling.scale.description": "調整字體大小縮放比例",
|
||||
"appearance.font_scaling.scale.label": "字體縮放",
|
||||
"appearance.font_scaling.size.l": "大",
|
||||
|
||||
Reference in New Issue
Block a user