Fix font weight

This commit is contained in:
Zhiyuan Zheng 2022-05-10 23:19:26 +02:00
parent 282ba1267d
commit c105b36b3d
10 changed files with 31 additions and 54 deletions

View File

@ -1,5 +1,4 @@
import CustomText from '@components/Text' import CustomText from '@components/Text'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import React from 'react' import React from 'react'
@ -17,9 +16,9 @@ const HeaderCenter = React.memo(
<CustomText <CustomText
style={{ style={{
fontSize: 18, fontSize: 18,
fontWeight: StyleConstants.Font.Weight.Bold,
color: inverted ? colors.primaryOverlay : colors.primaryDefault color: inverted ? colors.primaryOverlay : colors.primaryDefault
}} }}
fontWeight='Bold'
children={content} children={content}
/> />
) )

View File

@ -32,10 +32,10 @@ const InstanceInfo = React.memo(
<CustomText <CustomText
fontStyle='S' fontStyle='S'
style={{ style={{
fontWeight: StyleConstants.Font.Weight.Bold,
marginBottom: StyleConstants.Spacing.XS, marginBottom: StyleConstants.Spacing.XS,
color: colors.primaryDefault color: colors.primaryDefault
}} }}
fontWeight='Bold'
children={header} children={header}
/> />
{content ? ( {content ? (

View File

@ -46,8 +46,7 @@ const ParseEmojis = React.memo(
text: { text: {
color: colors.primaryDefault, color: colors.primaryDefault,
fontSize: adaptedFontsize, fontSize: adaptedFontsize,
lineHeight: adaptedLineheight, lineHeight: adaptedLineheight
...(fontBold && { fontWeight: StyleConstants.Font.Weight.Bold })
}, },
image: { image: {
width: adaptedFontsize, width: adaptedFontsize,
@ -58,7 +57,10 @@ const ParseEmojis = React.memo(
}, [theme, adaptiveFontsize]) }, [theme, adaptiveFontsize])
return ( return (
<CustomText style={styles.text}> <CustomText
style={styles.text}
fontWeight={fontBold ? 'Bold' : undefined}
>
{emojis ? ( {emojis ? (
content content
.split(regexEmoji) .split(regexEmoji)

View File

@ -23,7 +23,7 @@ const CustomText: React.FC<Props & TextProps> = ({
style, style,
fontStyle, fontStyle,
fontSize, fontSize,
fontWeight = 'Normal', fontWeight,
lineHeight, lineHeight,
...rest ...rest
}) => { }) => {
@ -46,9 +46,11 @@ const CustomText: React.FC<Props & TextProps> = ({
}) })
}, },
{ {
fontWeight: boldTextEnabled fontWeight: fontWeight
? BoldMapping[fontWeight] ? boldTextEnabled
: StyleConstants.Font.Weight[fontWeight] ? BoldMapping[fontWeight]
: StyleConstants.Font.Weight[fontWeight]
: undefined
} }
]} ]}
{...rest} {...rest}

View File

@ -53,9 +53,9 @@ const TimelineCard = React.memo(({ card }: Props) => {
numberOfLines={2} numberOfLines={2}
style={{ style={{
marginBottom: StyleConstants.Spacing.XS, marginBottom: StyleConstants.Spacing.XS,
fontWeight: StyleConstants.Font.Weight.Bold,
color: colors.primaryDefault color: colors.primaryDefault
}} }}
fontWeight='Bold'
testID='title' testID='title'
> >
{card.title} {card.title}

View File

@ -64,10 +64,8 @@ const ComposeEditAttachmentRoot: React.FC<Props> = ({ index }) => {
<View style={{ padding: StyleConstants.Spacing.Global.PagePadding }}> <View style={{ padding: StyleConstants.Spacing.Global.PagePadding }}>
<CustomText <CustomText
fontStyle='M' fontStyle='M'
style={{ style={{ color: colors.primaryDefault }}
fontWeight: StyleConstants.Font.Weight.Bold, fontWeight='Bold'
color: colors.primaryDefault
}}
> >
{t('content.editAttachment.content.altText.heading')} {t('content.editAttachment.content.altText.heading')}
</CustomText> </CustomText>

View File

@ -2,7 +2,6 @@ import analytics from '@components/analytics'
import Icon from '@components/Icon' import Icon from '@components/Icon'
import { useActionSheet } from '@expo/react-native-action-sheet' import { useActionSheet } from '@expo/react-native-action-sheet'
import { getInstanceConfigurationStatusMaxAttachments } from '@utils/slices/instancesSlice' import { getInstanceConfigurationStatusMaxAttachments } from '@utils/slices/instancesSlice'
import { StyleConstants } from '@utils/styles/constants'
import layoutAnimation from '@utils/styles/layoutAnimation' import layoutAnimation from '@utils/styles/layoutAnimation'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import React, { useCallback, useContext, useMemo } from 'react' import React, { useCallback, useContext, useMemo } from 'react'
@ -175,13 +174,15 @@ const ComposeActions: React.FC = () => {
return ( return (
<View <View
accessibilityRole='toolbar' accessibilityRole='toolbar'
style={[ style={{
styles.additions, height: 45,
{ borderTopWidth: StyleSheet.hairlineWidth,
backgroundColor: colors.backgroundDefault, flexDirection: 'row',
borderTopColor: colors.border justifyContent: 'space-around',
} alignItems: 'center',
]} backgroundColor: colors.backgroundDefault,
borderTopColor: colors.border
}}
> >
<Pressable <Pressable
accessibilityRole='button' accessibilityRole='button'
@ -271,18 +272,6 @@ const styles = StyleSheet.create({
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
height: '100%' height: '100%'
},
additions: {
height: 45,
borderTopWidth: StyleSheet.hairlineWidth,
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center'
},
count: {
textAlign: 'center',
...StyleConstants.FontStyle.M,
fontWeight: StyleConstants.Font.Weight.Bold
} }
}) })

View File

@ -85,15 +85,12 @@ const TabMeSettingsFontsize: React.FC<
marginBottom: StyleConstants.Spacing.M, marginBottom: StyleConstants.Spacing.M,
fontSize: adaptiveScale(StyleConstants.Font.Size.M, size), fontSize: adaptiveScale(StyleConstants.Font.Size.M, size),
lineHeight: adaptiveScale(StyleConstants.Font.LineHeight.M, size), lineHeight: adaptiveScale(StyleConstants.Font.LineHeight.M, size),
fontWeight:
initialSize === size
? StyleConstants.Font.Weight.Bold
: undefined,
color: color:
initialSize === size ? colors.primaryDefault : colors.secondary, initialSize === size ? colors.primaryDefault : colors.secondary,
borderWidth: StyleSheet.hairlineWidth, borderWidth: StyleSheet.hairlineWidth,
borderColor: colors.border borderColor: colors.border
}} }}
fontWeight={initialSize === size ? 'Bold' : undefined}
> >
{t(`me.fontSize.sizes.${mapFontsizeToName(size)}`)} {t(`me.fontSize.sizes.${mapFontsizeToName(size)}`)}
</CustomText> </CustomText>

View File

@ -73,10 +73,8 @@ const TabSharedRoot = ({
/>, />,
<CustomText <CustomText
fontStyle='M' fontStyle='M'
style={{ style={{ color: colors.primaryDefault }}
color: colors.primaryDefault, fontWeight='Bold'
fontWeight: StyleConstants.Font.Weight.Bold
}}
/> />
]} ]}
/> />

View File

@ -92,11 +92,7 @@ const TabSharedSearch: React.FC<
<Trans <Trans
i18nKey='screenTabs:shared.search.empty.general' i18nKey='screenTabs:shared.search.empty.general'
components={{ components={{
bold: ( bold: <CustomText fontWeight='Bold' />
<CustomText
style={{ fontWeight: StyleConstants.Font.Weight.Bold }}
/>
)
}} }}
/> />
</CustomText> </CustomText>
@ -154,10 +150,10 @@ const TabSharedSearch: React.FC<
<CustomText <CustomText
fontStyle='M' fontStyle='M'
style={{ style={{
fontWeight: StyleConstants.Font.Weight.Bold,
textAlign: 'center', textAlign: 'center',
color: colors.primaryDefault color: colors.primaryDefault
}} }}
fontWeight='Bold'
> >
{translation} {translation}
</CustomText> </CustomText>
@ -182,11 +178,7 @@ const TabSharedSearch: React.FC<
i18nKey='screenTabs:shared.search.notFound' i18nKey='screenTabs:shared.search.notFound'
values={{ searchTerm: text, type: translation }} values={{ searchTerm: text, type: translation }}
components={{ components={{
bold: ( bold: <CustomText fontWeight='Bold' />
<CustomText
style={{ fontWeight: StyleConstants.Font.Weight.Bold }}
/>
)
}} }}
/> />
</CustomText> </CustomText>