forked from IOMechs/RNColorPalette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
115 lines (111 loc) · 2.91 KB
/
App.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
104
105
106
107
108
109
110
111
112
113
114
115
/* eslint-disable react-native/no-inline-styles */
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React from 'react';
import {View} from 'react-native';
import {Container, Content, Text} from 'native-base';
import RNColorPalette from './react-native-color-picker-lib';
import colorList from './colors';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
pickedColor1: 'orange',
pickedColor2: 'green',
colors: colorList,
};
}
colorPicked = color => {
this.setState({
pickedColor1: color,
});
};
colorPicked2 = color => {
this.setState({
pickedColor2: color,
});
};
AddColor = color => {
this.setState({
colors: [...this.state.colors, color],
});
};
render() {
const {pickedColor1, pickedColor2, colors} = this.state;
return (
<Container>
<Content>
<View style={styles.textContainer}>
<Text style={styles.textStyle}>Color Palette</Text>
</View>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
}}>
<RNColorPalette
colorList={colors}
value={pickedColor2}
onItemSelect={this.colorPicked2}
AddPickedColor={colour => this.AddColor(colour)}
style={{
backgroundColor: pickedColor2,
width: 110,
height: 30,
}}>
<View>
<Text>Default Palette</Text>
</View>
</RNColorPalette>
<RNColorPalette
colorList={colors}
value={pickedColor1}
onItemSelect={this.colorPicked}
AddPickedColor={colour => this.AddColor(colour)}
style={{
backgroundColor: pickedColor1,
width: 110,
height: 30,
}}
platteStyle={{
backgroundColor: '#000',
borderRadius: 10,
}}
plattePosition={{
increaseMargin: 5, // to increase margin from element
// decreaseMargin: 20, to decrease default margin
}}
colorContainerStyle={{
borderRadius: 5,
}}>
<View>
<Text>Custom Palette</Text>
</View>
</RNColorPalette>
</View>
<View style={styles.textContainer}>
<Text style={styles.textStyle}>Color Palette</Text>
</View>
</Content>
</Container>
);
}
}
export default App;
const styles = {
textContainer: {
height: 500,
backgroundColor: '#e6c1c1',
justifyContent: 'center',
alignItems: 'center',
},
textStyle: {
fontSize: 20,
fontWeight: 'bold',
},
};