Skip to content

Commit 8f20bae

Browse files
authored
Feat/ Support subtitle in Modal.TopBar (#2594)
* Support subtitle in Modal.TopBar * bodySmall
1 parent 93e09db commit 8f20bae

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

demo/src/screens/componentScreens/ModalScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
6363
<View bg-violet80 flex style={styles.page}>
6464
<Modal.TopBar
6565
title="another example"
66+
subtitle="with a subtitle"
6667
onCancel={() => Alert.alert('cancel')}
6768
onDone={() => Alert.alert('done')}
6869
cancelIcon={null}

src/components/modal/TopBar.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ export interface ModalTopBarProps {
1717
* title custom style
1818
*/
1919
titleStyle?: StyleProp<TextStyle>;
20+
/**
21+
* subtitle to display below the top bar title
22+
*/
23+
subtitle?: string;
24+
/**
25+
* subtitle custom style
26+
*/
27+
subtitleStyle?: StyleProp<TextStyle>;
2028
/**
2129
* done action props (Button props)
2230
*/
@@ -162,22 +170,27 @@ class TopBar extends Component<ModalTopBarProps> {
162170
};
163171

164172
render() {
165-
const {title, titleStyle, includeStatusBar, containerStyle, useSafeArea} = this.props;
173+
const {title, titleStyle, subtitle, subtitleStyle, includeStatusBar, containerStyle, useSafeArea} = this.props;
166174

167175
return (
168176
<View style={containerStyle} useSafeArea={useSafeArea}>
169177
{includeStatusBar && <View style={styles.statusBar}/>}
170178
<View style={styles.container}>
171-
<View row flex bottom paddingL-15 centerV>
179+
<View row flex paddingL-15 centerV>
172180
{this.renderCancel()}
173181
{this.renderLeftButtons()}
174182
</View>
175-
<View row flex-3 bottom centerH centerV>
183+
<View flex-3 centerH centerV>
176184
<Text $textDefault accessible={!!title} numberOfLines={1} text70 style={[styles.title, titleStyle]}>
177185
{title}
178186
</Text>
187+
{subtitle && (
188+
<Text $textDefault accessible={!!subtitle} bodySmall numberOfLines={1} style={subtitleStyle}>
189+
{subtitle}
190+
</Text>
191+
)}
179192
</View>
180-
<View row flex bottom right paddingR-15 centerV>
193+
<View row flex right paddingR-15 centerV>
181194
{this.renderRightButtons()}
182195
{this.renderDone()}
183196
</View>

src/components/modal/api/modalTopBar.api.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"props": [
88
{"name": "title", "type": "string", "description": "Title to display in the center of the top bar"},
99
{"name": "titleStyle", "type": "TextStyle", "description": "Title custom style"},
10+
{"name": "subtitle", "type": "string", "description": "Subtitle to display below the top bar title"},
11+
{"name": "subtitleStyle", "type": "TextStyle", "description": "Subtitle custom style"},
1012
{
1113
"name": "doneButtonProps",
1214
"type": "ButtonProps",

0 commit comments

Comments
 (0)