Skip to content

Commit 2394394

Browse files
authored
Feat/modal top bar allow sending use safe area (#1653)
* Add useSafeArea * Prettify * Fix TS
1 parent d77c202 commit 2394394

File tree

2 files changed

+60
-52
lines changed

2 files changed

+60
-52
lines changed

generatedTypes/src/components/modal/TopBar.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { ViewProps } from '../../components/view';
44
import { ButtonProps } from '../../components/button';
55
export interface ModalTopBarProps {
66
/**
7-
* title to display in the center of the top bar
8-
*/
7+
* title to display in the center of the top bar
8+
*/
99
title?: string;
1010
/**
1111
* title custom style
@@ -51,6 +51,10 @@ export interface ModalTopBarProps {
5151
* style for the TopBar container
5252
*/
5353
containerStyle?: ViewProps['style'];
54+
/**
55+
* Whether or not to handle SafeArea
56+
*/
57+
useSafeArea?: boolean;
5458
}
5559
declare const _default: React.ComponentClass<ModalTopBarProps & {
5660
useCustomTheme?: boolean | undefined;

src/components/modal/TopBar.tsx

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,57 @@ import Text from '../../components/text';
1010

1111
export interface ModalTopBarProps {
1212
/**
13-
* title to display in the center of the top bar
14-
*/
15-
title?: string;
16-
/**
17-
* title custom style
18-
*/
19-
titleStyle?: StyleProp<TextStyle>;
20-
/**
21-
* done action props (Button props)
22-
*/
23-
doneButtonProps?: Omit<ButtonProps, 'onPress'>;
24-
/**
25-
* done action label
26-
*/
27-
doneLabel?: string;
28-
/**
29-
* done action icon
30-
*/
31-
doneIcon?: ImageSourcePropType;
32-
/**
33-
* done action callback
34-
*/
35-
onDone?: (props?: any) => void;
36-
/**
37-
* cancel action props (Button props)
38-
*/
39-
cancelButtonProps?: Omit<ButtonProps, 'onPress'>;
40-
/**
41-
* cancel action label
42-
*/
43-
cancelLabel?: string;
44-
/**
45-
* cancel action icon
46-
*/
47-
cancelIcon?: ImageSourcePropType;
48-
/**
49-
* cancel action callback
50-
*/
51-
onCancel?: (props?: any) => void;
52-
/**
53-
* whether to include status bar or not (height claculations)
54-
*/
55-
includeStatusBar?: boolean;
56-
/**
57-
* style for the TopBar container
58-
*/
59-
containerStyle?: ViewProps['style'];
13+
* title to display in the center of the top bar
14+
*/
15+
title?: string;
16+
/**
17+
* title custom style
18+
*/
19+
titleStyle?: StyleProp<TextStyle>;
20+
/**
21+
* done action props (Button props)
22+
*/
23+
doneButtonProps?: Omit<ButtonProps, 'onPress'>;
24+
/**
25+
* done action label
26+
*/
27+
doneLabel?: string;
28+
/**
29+
* done action icon
30+
*/
31+
doneIcon?: ImageSourcePropType;
32+
/**
33+
* done action callback
34+
*/
35+
onDone?: (props?: any) => void;
36+
/**
37+
* cancel action props (Button props)
38+
*/
39+
cancelButtonProps?: Omit<ButtonProps, 'onPress'>;
40+
/**
41+
* cancel action label
42+
*/
43+
cancelLabel?: string;
44+
/**
45+
* cancel action icon
46+
*/
47+
cancelIcon?: ImageSourcePropType;
48+
/**
49+
* cancel action callback
50+
*/
51+
onCancel?: (props?: any) => void;
52+
/**
53+
* whether to include status bar or not (height claculations)
54+
*/
55+
includeStatusBar?: boolean;
56+
/**
57+
* style for the TopBar container
58+
*/
59+
containerStyle?: ViewProps['style'];
60+
/**
61+
* Whether or not to handle SafeArea
62+
*/
63+
useSafeArea?: boolean;
6064
}
6165

6266
type topBarButtonProp = {
@@ -65,7 +69,7 @@ type topBarButtonProp = {
6569
icon?: ImageSourcePropType;
6670
accessibilityLabel?: string;
6771
buttonProps?: Omit<ButtonProps, 'onPress'>;
68-
}
72+
};
6973

7074
const TOP_BAR_HEIGHT = Constants.isIOS ? 44 : 56;
7175
const DEFAULT_BUTTON_PROPS = {
@@ -132,10 +136,10 @@ class TopBar extends Component<ModalTopBarProps> {
132136
}
133137

134138
render() {
135-
const {title, titleStyle, includeStatusBar, containerStyle} = this.props;
139+
const {title, titleStyle, includeStatusBar, containerStyle, useSafeArea} = this.props;
136140

137141
return (
138-
<View style={containerStyle}>
142+
<View style={containerStyle} useSafeArea={useSafeArea}>
139143
{includeStatusBar && <View style={styles.statusBar}/>}
140144
<View style={styles.container}>
141145
<View row flex bottom paddingL-15 centerV>

0 commit comments

Comments
 (0)