forked from uday8373/React-Native-View-Slider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdots.js
More file actions
48 lines (43 loc) · 1.05 KB
/
dots.js
File metadata and controls
48 lines (43 loc) · 1.05 KB
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
import React from 'react';
import { View, StyleSheet } from 'react-native';
export default Indicators = (props) => {
const activeColor = props.activeColor;
const inactiveColor = props.inactiveColor;
const dotsCount = props.count;
const activeDot = props.activeDot;
const containerStyle = props.containerStyle;
const createDots = () => {
let dot = [];
for (let i = 1; i <= dotsCount; i++) {
dot.push(
<View
key={i}
style={[
styles.dot,
{ backgroundColor: activeDot === i ? activeColor : inactiveColor },
]}
></View>
);
}
return dot;
};
return (
<View style={[styles.dotContainer, containerStyle]}>
{createDots().map((dot, i) => (
<React.Fragment key={i}>{dot}</React.Fragment>
))}
</View>
);
};
const styles = StyleSheet.create({
dotContainer: {
marginVertical: 20,
flexDirection: 'row',
justifyContent: 'space-between',
},
dot: {
marginHorizontal: 10,
padding: 5,
borderRadius: 100,
},
});