Skip to content
Open
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
122 changes: 107 additions & 15 deletions packages/rn-tester/js/examples/RefreshControl/RefreshControlExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/

'use strict';
Expand All @@ -15,10 +16,17 @@ const {
StyleSheet,
RefreshControl,
Text,
TextInput,
TouchableWithoutFeedback,
View,
Platform,
} = require('react-native');

const {
PlainInput,
renderSmallSwitchOption,
} = require('../../components/ListExampleShared');

const styles = StyleSheet.create({
row: {
borderColor: 'grey',
Expand All @@ -34,6 +42,22 @@ const styles = StyleSheet.create({
scrollview: {
flex: 1,
},
container: {
backgroundColor: 'rgb(239, 239, 244)',
flex: 1,
},
list: {
backgroundColor: 'white',
flexGrow: 1,
},
options: {
flexDirection: 'row',
flexWrap: 'wrap',
alignItems: 'center',
},
searchRow: {
paddingHorizontal: 10,
},
});

class Row extends React.Component {
Expand Down Expand Up @@ -62,6 +86,12 @@ class RefreshControlExample extends React.Component {
text: 'Initial row ' + i,
clicks: 0,
})),
tintColor: '',
titleColor: '',
title: '',
progressBgColor: '',
progressViewOffset: null,
enabled: true,
};

_onClick = row => {
Expand All @@ -71,26 +101,88 @@ class RefreshControlExample extends React.Component {
});
};

_onChangeTintColor = tintColor => {
this.setState({tintColor});
};

_onChangeTitleColor = titleColor => {
this.setState({titleColor});
};

_onChangeProgressBgColor = progressBgColor => {
this.setState({progressBgColor});
};

_onChangeProgressViewOffset = progessViewOffset => {
this.setState({progessViewOffset});
};

_onChangeTitle = title => {
this.setState({title});
};

render() {
const rows = this.state.rowData.map((row, ii) => {
return <Row key={ii} data={row} onClick={this._onClick} />;
});
return (
<ScrollView
style={styles.scrollview}
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={this._onRefresh}
tintColor="#ff0000"
title="Loading..."
titleColor="#00ff00"
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#ffff00"
/>
}>
{rows}
</ScrollView>
<View style={styles.container}>
<View style={styles.searchRow}>
{renderSmallSwitchOption(this, 'isRefreshing')}
{Platform.OS === 'android' && (
<View style={styles.options}>
{renderSmallSwitchOption(this, 'enabled')}
<PlainInput
onChangeText={this._onChangeProgressViewOffset}
placeholder="Progress View Offset"
value={this.state.progressViewOffset}
/>
<PlainInput
onChangeText={this._onChangeProgressBgColor}
placeholder="Progress Background Color"
value={this.state.progressBgColor}
/>
</View>
)}

{Platform.OS !== 'android' && (
<View style={styles.options}>
<PlainInput
onChangeText={this._onChangeTintColor}
placeholder="Tint Color"
value={this.state.tintColor}
/>
<PlainInput
onChangeText={this._onChangeTitleColor}
placeholder="Title Color"
value={this.state.titleColor}
/>
<PlainInput
onChangeText={this._onChangeTitle}
placeholder="Title"
value={this.state.title}
/>
</View>
)}
</View>
<ScrollView
style={styles.scrollview}
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={this._onRefresh}
enabled={this.state.enabled || true}
tintColor={this.state.tintColor || '#ff0000'}
title={this.state.title || 'Loading...'}
titleColor={this.state.titleColor || '#00ff00'}
colors={['#ff0000', '#00ff00', '#0000ff']}
progressViewOffset={this.state.progressViewOffset || null}
progressBackgroundColor={this.state.progressBgColor || '#ffff00'}
/>
}>
{rows}
</ScrollView>
</View>
);
}

Expand Down