re-render on numberOfLines change

This commit is contained in:
Hailey
2024-01-15 05:27:15 -08:00
parent 9f5b7602c1
commit e5472a13da
3 changed files with 9 additions and 4 deletions
@@ -34,10 +34,15 @@ public class ExpoUITextViewModule: Module {
Prop("allowFontScaling") { (view: ExpoUITextView, prop: Bool) in Prop("allowFontScaling") { (view: ExpoUITextView, prop: Bool) in
view.textView.adjustsFontForContentSizeCategory = prop view.textView.adjustsFontForContentSizeCategory = prop
} }
Prop("numberOfLines") { (view: ExpoUITextView, prop: Int) in Prop("numberOfLines") { (view: ExpoUITextView, prop: Int?) in
view.textView.textContainer.maximumNumberOfLines = prop view.textView.textContainer.maximumNumberOfLines = prop ?? 0
if view.textView.attributedText != nil {
view.setText()
}
} }
Prop("ellipsizeMode") { (view: ExpoUITextView, prop: EllipsizeMode) in Prop("ellipsizeMode") { (view: ExpoUITextView, prop: EllipsizeMode) in
print(prop.toLineBreakMode())
view.textView.textContainer.lineBreakMode = prop.toLineBreakMode() view.textView.textContainer.lineBreakMode = prop.toLineBreakMode()
} }
Prop("selectable") { (view: ExpoUITextView, prop: Bool) in Prop("selectable") { (view: ExpoUITextView, prop: Bool) in
@@ -22,7 +22,6 @@ const useTextAncestorContext = () => React.useContext(TextAncestorContext)
const textDefaults: TextProps = { const textDefaults: TextProps = {
allowFontScaling: true, allowFontScaling: true,
selectable: true, selectable: true,
lineBreakMode: 'tail',
} }
export default function ExpoUITextView({ export default function ExpoUITextView({
@@ -45,6 +44,7 @@ export default function ExpoUITextView({
<ExpoUITextViewRoot <ExpoUITextViewRoot
{...textDefaults} {...textDefaults}
{...rest} {...rest}
ellipsizeMode={rest.ellipsizeMode ?? rest.lineBreakMode ?? 'tail'}
style={[{flex: 1}, rootStyle]}> style={[{flex: 1}, rootStyle]}>
{React.Children.toArray(children).map((c, index) => { {React.Children.toArray(children).map((c, index) => {
if (React.isValidElement(c)) { if (React.isValidElement(c)) {
@@ -3,7 +3,7 @@ import {TextProps, TextStyle, ViewStyle} from 'react-native'
export interface ExpoUITextViewProps extends TextProps {} export interface ExpoUITextViewProps extends TextProps {}
export interface ExpoUITextViewNativeProps { export interface ExpoUITextViewNativeProps extends TextProps {
children: React.ReactNode children: React.ReactNode
style: ViewStyle[] style: ViewStyle[]
} }