I have the following component
const InputLabel => (props: InputLabelProps) {
return (
<Animated.View
style={[
StyleSheet.absoluteFill,
{
justifyContent: 'flex-start',
flexDirection: 'row',
backgroundColor: 'red',
alignItems: 'center',
},
]}
>
<Animated.Text
onLayout={onLayoutAnimatedText}
numberOfLines={1}
ellipsizeMode="tail"
textBreakStrategy={'highQuality'}
style={[
animatedLabelContainerStyle,
{
textAlign: 'right',
fontSize: fontSize,
color: labelColor,
backgroundColor: 'yellow',
},
]}
>
{label}
</Animated.Text>
</Animated.View>
);
}
When I reference it from another component and I set the width of wrapper component below a certain value the text is truncated too much leaving a big gap.
<View style={{ width: '40%', height: 50, borderWidth: 1, backgroundColor: 'yellow' }}>
<InputLabel
fontSize={16}
hasOutline={false}
label={'label 12345678901234567890123456789012345678901234567890'}
// labelAnimatedValue={labelAnimation}
labelColor={'black'}
labelLayout={labelLayout}
OffsetY={2} //container borderWidth
placeholderColor={'red'}
showPlaceholder={false}
onLayoutAnimatedText={handleLayoutAnimatedText}
/>
</View>
The code above with width at 40% produces the below Width at 40%
When I set width at 50% or greater the text is truncated how I want it Width at 50%
What I want is:
yellow background to stretch to the end of the red container at all width
Please note if the label length is not long enough to be truncated the yellow color should only wrap text and not stretch to end of red container
Snack: https://snack.expo.dev/@danro/inputlabel