Skip to content

Commit 0ac6eba

Browse files
committed
feat: enhance NitroText layout and truncation handling
1 parent f863b84 commit 0ac6eba

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

example/App.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ export default function App() {
5959
{/* Layout Measurement */}
6060
<View style={styles.section}>
6161
<NitroText style={styles.sectionTitle}>Layout Measurement</NitroText>
62-
<NitroText style={styles.measuredText} onLayout={handleLayout} onTextLayout={handleTextLayout}>
62+
<NitroText
63+
style={styles.measuredText}
64+
onLayout={handleLayout}
65+
onTextLayout={handleTextLayout}
66+
>
6367
This text demonstrates layout measurement capabilities. The component
6468
can measure its dimensions and report back to JavaScript.
6569
{'\n\n'}
@@ -73,13 +77,30 @@ export default function App() {
7377
<View style={styles.section}>
7478
<NitroText style={styles.sectionTitle}>Line Limiting</NitroText>
7579
<NitroText style={styles.description}>Two lines maximum:</NitroText>
80+
81+
{/* BUG: This does not work correctly in NitroText. needs to be fixed. */}
7682
<NitroText style={styles.limitedText} numberOfLines={2}>
77-
This is a very long text that would normally span multiple lines, but
78-
we're limiting it to just two lines. The text will be truncated with
79-
an ellipsis when it exceeds the specified number of lines. This is
80-
useful for creating consistent layouts in lists or cards where you
81-
need predictable text heights.
83+
This is a very long text that would normally{' '}
84+
<NitroText style={[styles.limitedText, { fontWeight: 'bold' }]}>
85+
span multiple lines, but we're limiting it to just two lines. The
86+
text will be truncated with an ellipsis when it exceeds the
87+
specified number of lines. This is useful for creating consistent
88+
layouts in lists or cards where you need predictable text heights.
89+
</NitroText>
8290
</NitroText>
91+
92+
<Text style={[styles.description, { marginTop: 8 }]}>
93+
RN Text (with tail ellipsize mode):
94+
</Text>
95+
<Text style={styles.limitedText} numberOfLines={2}>
96+
This is a very long text that would normally{' '}
97+
<Text style={styles.limitedText}>
98+
span multiple lines, but we're limiting it to just two lines. The
99+
text will be truncated with an ellipsis when it exceeds the
100+
specified number of lines. This is useful for creating consistent
101+
layouts in lists or cards where you need predictable text heights.
102+
</Text>
103+
</Text>
83104
</View>
84105

85106
{/* Mixed Content */}

ios/HybridNitroText.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ class HybridNitroText : HybridNitroTextSpec, NitroTextViewDelegate {
9898
var numberOfLines: Double? {
9999
didSet {
100100
nitroTextImpl.setNumberOfLines(numberOfLines)
101+
applyFragmentsAndProps()
101102
}
102103
}
103104

104105
var ellipsizeMode: EllipsizeMode? {
105106
didSet {
106107
nitroTextImpl.setEllipsizeMode(ellipsizeMode)
108+
applyFragmentsAndProps()
107109
}
108110
}
109111

0 commit comments

Comments
 (0)