Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline text in SegmentedButtonItem #4452

Open
marko-mihajlovic opened this issue Jul 11, 2024 · 0 comments
Open

Multiline text in SegmentedButtonItem #4452

marko-mihajlovic opened this issue Jul 11, 2024 · 0 comments

Comments

@marko-mihajlovic
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch react-native-paper@5.12.3 for the project I'm working on.

I needed multiline text in SegmentedButtonItem. So i removed numberOfLines and vertically centered TouchableRipple's content. Would be nice to have option to change those props in next versions.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-paper/src/components/SegmentedButtons/SegmentedButtonItem.tsx b/node_modules/react-native-paper/src/components/SegmentedButtons/SegmentedButtonItem.tsx
index d88f2a4..600859e 100644
--- a/node_modules/react-native-paper/src/components/SegmentedButtons/SegmentedButtonItem.tsx
+++ b/node_modules/react-native-paper/src/components/SegmentedButtons/SegmentedButtonItem.tsx
@@ -214,7 +214,10 @@ const SegmentedButtonItem = ({
         disabled={disabled}
         rippleColor={rippleColor}
         testID={testID}
-        style={rippleStyle}
+        style={[rippleStyle, {    
+          flex: 1,
+          justifyContent: 'center'
+        }]}
         background={background}
         theme={theme}
       >
@@ -236,7 +239,6 @@ const SegmentedButtonItem = ({
             variant="labelLarge"
             style={[styles.label, labelTextStyle, labelStyle]}
             selectable={false}
-            numberOfLines={1}
             maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
             testID={`${testID}-label`}
           >

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant