This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
forked from stief510/react-native-step-indicator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
VerticalStepIndicatorExample.js
103 lines (95 loc) · 2.62 KB
/
VerticalStepIndicatorExample.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import React, { Component } from 'react';
import { View, Text, StyleSheet, ListView } from 'react-native';
import StepIndicator from 'react-native-step-indicator';
import dummyData from './data';
const stepIndicatorStyles = {
stepIndicatorSize: 30,
currentStepIndicatorSize:40,
separatorStrokeWidth: 3,
currentStepStrokeWidth: 5,
stepStrokeCurrentColor: '#fe7013',
separatorFinishedColor: '#fe7013',
separatorUnFinishedColor: '#aaaaaa',
stepIndicatorFinishedColor: '#fe7013',
stepIndicatorUnFinishedColor: '#aaaaaa',
stepIndicatorCurrentColor: '#ffffff',
stepIndicatorLabelFontSize: 15,
currentStepIndicatorLabelFontSize: 15,
stepIndicatorLabelCurrentColor: '#000000',
stepIndicatorLabelFinishedColor: '#ffffff',
stepIndicatorLabelUnFinishedColor: 'rgba(255,255,255,0.5)',
labelColor: '#666666',
labelSize: 15,
currentStepLabelColor: '#fe7013'
}
export default class VerticalStepIndicator extends Component {
constructor() {
super();
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(dummyData.data),
currentPage:0
};
}
render() {
return (
<View style={styles.container}>
<View style={styles.stepIndicator}>
<StepIndicator
customStyles={stepIndicatorStyles}
stepCount={6}
direction='vertical'
currentPosition={this.state.currentPage}
labels={dummyData.data.map(item => item.title)}
/>
</View>
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderPage}
onChangeVisibleRows={this.getVisibleRows}
/>
</View>
);
}
renderPage = (rowData) => {
return (
<View style={styles.rowItem}>
<Text allowFontScaling={false} style={styles.title}>{rowData.title}</Text>
<Text allowFontScaling={false} style={styles.body}>{rowData.body}</Text>
</View>
)
}
getVisibleRows = (visibleRows) => {
const visibleRowNumbers = Object.keys(visibleRows.s1).map((row) => parseInt(row));
this.setState({currentPage:visibleRowNumbers[0]})
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection:'row',
backgroundColor:'#ffffff'
},
stepIndicator: {
marginVertical:50,
paddingHorizontal:20
},
rowItem: {
flex:3,
paddingVertical:20
},
title: {
flex: 1,
fontSize:20,
color:'#333333',
paddingVertical:16,
fontWeight:'600'
},
body: {
flex: 1,
fontSize:15,
color:'#606060',
lineHeight:24,
marginRight:8
}
});