-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
FixedFooter.tsx
33 lines (25 loc) · 1006 Bytes
/
FixedFooter.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type {ReactNode} from 'react';
import React from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
import useKeyboardState from '@hooks/useKeyboardState';
import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
import useThemeStyles from '@hooks/useThemeStyles';
type FixedFooterProps = {
/** Children to wrap in FixedFooter. */
children: ReactNode;
/** Styles to be assigned to Container */
style?: StyleProp<ViewStyle>;
};
function FixedFooter({style, children}: FixedFooterProps) {
const {isKeyboardShown} = useKeyboardState();
const insets = useSafeAreaInsets();
const styles = useThemeStyles();
if (!children) {
return null;
}
const shouldAddBottomPadding = isKeyboardShown || !insets.bottom;
return <View style={[styles.ph5, shouldAddBottomPadding && styles.pb5, styles.flexShrink0, style]}>{children}</View>;
}
FixedFooter.displayName = 'FixedFooter';
export default FixedFooter;