react-native-safe-area-context#EdgeInsets TypeScript Examples
The following examples show how to use
react-native-safe-area-context#EdgeInsets.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CardStack.tsx From nlw2-proffy with MIT License | 6 votes |
getHeaderHeights = (
routes: Route<string>[],
insets: EdgeInsets,
descriptors: StackDescriptorMap,
layout: Layout,
previous: Record<string, number>
) => {
return routes.reduce<Record<string, number>>((acc, curr) => {
const { options = {} } = descriptors[curr.key] || {};
const style: any = StyleSheet.flatten(options.headerStyle || {});
const height =
typeof style.height === 'number' ? style.height : previous[curr.key];
const safeAreaInsets = {
...insets,
...options.safeAreaInsets,
};
const { headerStatusBarHeight = safeAreaInsets.top } = options;
acc[curr.key] =
typeof height === 'number'
? height
: getDefaultHeaderHeight(layout, headerStatusBarHeight);
return acc;
}, {});
}
Example #2
Source File: Footer.tsx From hive-keychain-mobile with MIT License | 6 votes |
getStyles = (height: number, insets: EdgeInsets) =>
StyleSheet.create({
icon: {color: 'white', fontSize: 28},
disabled: {color: 'darkgrey'},
footer: {
height: height || 40,
paddingBottom: insets.bottom,
backgroundColor: 'black',
width: '100%',
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center',
},
manage: {
borderColor: '#838383',
borderWidth: 3,
borderRadius: 5,
width: 27,
height: 27,
},
text: {
flex: 2,
textAlign: 'center',
color: '#838383',
},
})
Example #3
Source File: Header.tsx From hive-keychain-mobile with MIT License | 6 votes |
getStyles = (height: number, insets: EdgeInsets, landscape: boolean) =>
StyleSheet.create({
container: {
height: height + insets.top,
backgroundColor: 'black',
width: '100%',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingTop: insets.top,
paddingLeft: 20,
paddingBottom: 7,
},
topBar: {
height: 32,
backgroundColor: '#535353',
borderRadius: 6,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
textContainer: {
lineHeight: 32,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
url: {color: 'white', fontSize: 18, flex: 1},
search: {fontSize: 18, flex: 1, color: '#E5E5E5', fontStyle: 'italic'},
browser: {color: 'white', fontSize: 18, fontWeight: 'bold'},
icon: {paddingHorizontal: 10},
drawerButton: {alignSelf: 'center'},
})
Example #4
Source File: BottomBar.tsx From hive-keychain-mobile with MIT License | 6 votes |
getsStyles = (insets: EdgeInsets) =>
StyleSheet.create({
container: {
height: BrowserConfig.HEADER_HEIGHT + insets.bottom,
paddingHorizontal: 20,
paddingBottom: insets.bottom,
backgroundColor: 'black',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
noSideButtons: {justifyContent: 'space-around'},
icon: {color: 'white', fontSize: 30},
})
Example #5
Source File: index.tsx From hive-keychain-mobile with MIT License | 6 votes |
getStyles = (insets: EdgeInsets) =>
StyleSheet.create({
urlModal: {
height: '100%',
width: '100%',
margin: 0,
paddingTop: insets.top,
justifyContent: 'flex-start',
backgroundColor: 'white',
},
option: {alignSelf: 'center', marginLeft: 20},
eraseText: {fontWeight: 'bold', fontSize: 16},
urlModalContent: {
flexDirection: 'row',
borderColor: 'lightgrey',
borderBottomWidth: 2,
padding: 20,
margin: 0,
},
urlInput: {flex: 1},
clearHistory: {
marginLeft: 20,
marginTop: 20,
fontWeight: 'bold',
},
})
Example #6
Source File: StackView.tsx From nlw2-proffy with MIT License | 5 votes |
render() {
const {
state,
navigation,
keyboardHandlingEnabled,
mode = 'card',
headerMode = mode === 'card' && Platform.OS === 'ios'
? 'float'
: 'screen',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
descriptors: _,
...rest
} = this.props;
const {
routes,
descriptors,
openingRouteKeys,
closingRouteKeys,
} = this.state;
return (
<NavigationHelpersContext.Provider value={navigation}>
<GestureHandlerWrapper style={styles.container}>
<SafeAreaProviderCompat>
<SafeAreaConsumer>
{(insets) => (
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
{(props) => (
<CardStack
mode={mode}
insets={insets as EdgeInsets}
getPreviousRoute={this.getPreviousRoute}
getGesturesEnabled={this.getGesturesEnabled}
routes={routes}
openingRouteKeys={openingRouteKeys}
closingRouteKeys={closingRouteKeys}
onOpenRoute={this.handleOpenRoute}
onCloseRoute={this.handleCloseRoute}
onTransitionStart={this.handleTransitionStart}
onTransitionEnd={this.handleTransitionEnd}
renderHeader={this.renderHeader}
renderScene={this.renderScene}
headerMode={headerMode}
state={state}
descriptors={descriptors}
onGestureStart={this.handleGestureStart}
onGestureEnd={this.handleGestureEnd}
onGestureCancel={this.handleGestureCancel}
{...rest}
{...props}
/>
)}
</KeyboardManager>
)}
</SafeAreaConsumer>
</SafeAreaProviderCompat>
</GestureHandlerWrapper>
</NavigationHelpersContext.Provider>
);
}