callstack / callstack/react-native-paper

Multiline text in SegmentedButtonItem

Open
#4,452 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.5k
Forks
2.2k
Avg merge
5d 23h
Merged PRs (30d)
12

Description

Hi! 👋

Firstly, thanks for your work on this project! 🙂
Today I used [patch-package](https://github.com/ds300/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
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](https://github.com/ds300/patch-package/issues/296).

Contributor guide

Open the contributing guide

Research direction

Start in src/components/SegmentedButtons/SegmentedButtonItem.tsx and compare the reported patch with the current component props and layout. The work is complete when SegmentedButtonItem supports multiline labels and exposes options for the relevant text and TouchableRipple props.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.