Fix `lineHeight` problems on native with new `Text` (#3175)
parent
a289e6bce5
commit
3a6e58ba6e
|
@ -3,7 +3,7 @@ import {Text as RNText, TextStyle, TextProps as RNTextProps} from 'react-native'
|
||||||
import {UITextView} from 'react-native-ui-text-view'
|
import {UITextView} from 'react-native-ui-text-view'
|
||||||
|
|
||||||
import {useTheme, atoms, web, flatten} from '#/alf'
|
import {useTheme, atoms, web, flatten} from '#/alf'
|
||||||
import {isIOS} from '#/platform/detection'
|
import {isIOS, isNative} from '#/platform/detection'
|
||||||
|
|
||||||
export type TextProps = RNTextProps & {
|
export type TextProps = RNTextProps & {
|
||||||
/**
|
/**
|
||||||
|
@ -40,11 +40,11 @@ function normalizeTextStyles(styles: TextStyle[]) {
|
||||||
const fontSize = s.fontSize || atoms.text_md.fontSize
|
const fontSize = s.fontSize || atoms.text_md.fontSize
|
||||||
|
|
||||||
if (s?.lineHeight) {
|
if (s?.lineHeight) {
|
||||||
if (s.lineHeight <= 2) {
|
if (s.lineHeight !== 0 && s.lineHeight <= 2) {
|
||||||
s.lineHeight = Math.round(fontSize * s.lineHeight)
|
s.lineHeight = Math.round(fontSize * s.lineHeight)
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!isNative) {
|
||||||
s.lineHeight = fontSize
|
s.lineHeight = s.fontSize
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
Loading…
Reference in New Issue