Skip to content

Commit

Permalink
add rn-tester ScrollViewIndicatorInsets example to demonstrate the af…
Browse files Browse the repository at this point in the history
…fect of iOS 13 automaticallyAdjustsScrollIndicatorInsets=NO
  • Loading branch information
justinwh committed May 6, 2021
1 parent da80e37 commit d48b23b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
'use strict';

const React = require('react');

const {
Button,
DeviceInfo,
Modal,
ScrollView,
StyleSheet,
Switch,
Text,
View,
} = require('react-native');

class ScrollViewIndicatorInsetsExample extends React.Component<
{...},
{|
modalVisible: boolean
|},
> {
state = {
modalVisible: false
};

_setModalVisible = visible => {
this.setState({modalVisible: visible});
};

render() {
return (
<View>
<Modal
visible={this.state.modalVisible}
onRequestClose={() => this._setModalVisible(false)}
animationType="slide"
supportedOrientations={['portrait', 'landscape']}>
<View style={styles.modal}>
<ScrollView
style={styles.scrollView}>
<View style={styles.scrollViewContent}>
<Button
onPress={() => this._setModalVisible(false)}
title="Close"
/>
</View>
</ScrollView>
</View>
</Modal>
<Button
onPress={() => this._setModalVisible(true)}
title="Present Modal Screen with ScrollView"
/>
</View>
);
}
}

const styles = StyleSheet.create({
modal: {
flex: 1,
},
scrollView: {
flex: 1,
height: 1000,
},
scrollViewContent: {
alignItems: 'center',
backgroundColor: '#ffaaaa',
height: 2000,
justifyContent: 'flex-start',
paddingTop: 200,
},
});

exports.title = 'ScrollViewIndicatorInsets';
exports.category = 'iOS';
exports.description =
'ScrollView indicator insets should ignore the device\'s safe area on all iOS versions.';
exports.examples = [
{
title: '<ScrollView> Indicator Insets Example',
render: (): React.Node => <ScrollViewIndicatorInsetsExample/>,
}
];
4 changes: 4 additions & 0 deletions packages/rn-tester/js/utils/RNTesterList.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ const ComponentExamples: Array<RNTesterExample> = [
module: require('../examples/ScrollView/ScrollViewAnimatedExample'),
supportsTVOS: true,
},
{
key: 'ScrollViewIndicatorInsetsExample',
module: require('../examples/ScrollView/ScrollViewIndicatorInsetsExample'),
},
{
key: 'SectionList-inverted',
module: require('../examples/SectionList/SectionList-inverted'),
Expand Down

0 comments on commit d48b23b

Please sign in to comment.