Skip to content

Feat/modal top bar allow sending use safe area #1653

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

Merged
merged 5 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions generatedTypes/src/components/modal/TopBar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ViewProps } from '../../components/view';
import { ButtonProps } from '../../components/button';
export interface ModalTopBarProps {
/**
* title to display in the center of the top bar
*/
* title to display in the center of the top bar
*/
title?: string;
/**
* title custom style
Expand Down Expand Up @@ -51,6 +51,10 @@ export interface ModalTopBarProps {
* style for the TopBar container
*/
containerStyle?: ViewProps['style'];
/**
* Whether or not to handle SafeArea
*/
useSafeArea?: boolean;
}
declare const _default: React.ComponentClass<ModalTopBarProps & {
useCustomTheme?: boolean | undefined;
Expand Down
104 changes: 54 additions & 50 deletions src/components/modal/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,57 @@ import Text from '../../components/text';

export interface ModalTopBarProps {
/**
* title to display in the center of the top bar
*/
title?: string;
/**
* title custom style
*/
titleStyle?: StyleProp<TextStyle>;
/**
* done action props (Button props)
*/
doneButtonProps?: Omit<ButtonProps, 'onPress'>;
/**
* done action label
*/
doneLabel?: string;
/**
* done action icon
*/
doneIcon?: ImageSourcePropType;
/**
* done action callback
*/
onDone?: (props?: any) => void;
/**
* cancel action props (Button props)
*/
cancelButtonProps?: Omit<ButtonProps, 'onPress'>;
/**
* cancel action label
*/
cancelLabel?: string;
/**
* cancel action icon
*/
cancelIcon?: ImageSourcePropType;
/**
* cancel action callback
*/
onCancel?: (props?: any) => void;
/**
* whether to include status bar or not (height claculations)
*/
includeStatusBar?: boolean;
/**
* style for the TopBar container
*/
containerStyle?: ViewProps['style'];
* title to display in the center of the top bar
*/
title?: string;
/**
* title custom style
*/
titleStyle?: StyleProp<TextStyle>;
/**
* done action props (Button props)
*/
doneButtonProps?: Omit<ButtonProps, 'onPress'>;
/**
* done action label
*/
doneLabel?: string;
/**
* done action icon
*/
doneIcon?: ImageSourcePropType;
/**
* done action callback
*/
onDone?: (props?: any) => void;
/**
* cancel action props (Button props)
*/
cancelButtonProps?: Omit<ButtonProps, 'onPress'>;
/**
* cancel action label
*/
cancelLabel?: string;
/**
* cancel action icon
*/
cancelIcon?: ImageSourcePropType;
/**
* cancel action callback
*/
onCancel?: (props?: any) => void;
/**
* whether to include status bar or not (height claculations)
*/
includeStatusBar?: boolean;
/**
* style for the TopBar container
*/
containerStyle?: ViewProps['style'];
/**
* Whether or not to handle SafeArea
*/
useSafeArea?: boolean;
}

type topBarButtonProp = {
Expand All @@ -65,7 +69,7 @@ type topBarButtonProp = {
icon?: ImageSourcePropType;
accessibilityLabel?: string;
buttonProps?: Omit<ButtonProps, 'onPress'>;
}
};

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

render() {
const {title, titleStyle, includeStatusBar, containerStyle} = this.props;
const {title, titleStyle, includeStatusBar, containerStyle, useSafeArea} = this.props;

return (
<View style={containerStyle}>
<View style={containerStyle} useSafeArea={useSafeArea}>
{includeStatusBar && <View style={styles.statusBar}/>}
<View style={styles.container}>
<View row flex bottom paddingL-15 centerV>
Expand Down