Wrap list in SafeAreaView

This commit is contained in:
Brent Vatne 2018-10-31 15:21:07 -07:00
parent 62dd8e530a
commit 7261d62233
2 changed files with 18 additions and 2 deletions

View File

@ -1,7 +1,11 @@
import React from 'react'; import React from 'react';
import Expo from 'expo'; import Expo from 'expo';
import { FlatList, I18nManager } from 'react-native'; import { FlatList, I18nManager } from 'react-native';
import { createAppContainer } from '@react-navigation/native'; import {
createAppContainer,
SafeAreaView,
ScrollView,
} from '@react-navigation/native';
import { import {
Assets as StackAssets, Assets as StackAssets,
createStackNavigator, createStackNavigator,
@ -99,6 +103,7 @@ class Home extends React.Component {
ItemSeparatorComponent={Divider} ItemSeparatorComponent={Divider}
renderItem={this._renderItem} renderItem={this._renderItem}
keyExtractor={this._keyExtractor} keyExtractor={this._keyExtractor}
renderScrollComponent={props => <SafeAreaScrollView {...props} />}
data={data} data={data}
style={{ backgroundColor: '#fff' }} style={{ backgroundColor: '#fff' }}
/> />
@ -106,6 +111,17 @@ class Home extends React.Component {
} }
} }
class SafeAreaScrollView extends React.Component {
render() {
let { children, ...scrollViewProps } = this.props;
return (
<ScrollView {...scrollViewProps}>
<SafeAreaView forceInset={{ top: 'never' }}>{children}</SafeAreaView>
</ScrollView>
);
}
}
const Root = createStackNavigator( const Root = createStackNavigator(
{ {
Home: createStackNavigator({ Home }), Home: createStackNavigator({ Home }),

View File

@ -1,6 +1,6 @@
{ {
"name": "react-navigation-stack", "name": "react-navigation-stack",
"version": "1.0.0-alpha.27", "version": "1.0.0-alpha.28",
"description": "Stack navigator component for React Navigation", "description": "Stack navigator component for React Navigation",
"main": "dist/index.js", "main": "dist/index.js",
"files": [ "files": [