-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathShadowsControl.js
168 lines (164 loc) · 4.79 KB
/
ShadowsControl.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* eslint-disable react-native/no-inline-styles */
import React, { useState } from 'react';
import { StyleSheet, View, Text, Dimensions } from 'react-native';
import Slider from '@react-native-community/slider';
import { Shadow } from '../';
const ShadowsControl = () => {
const [color, setColor] = useState(160);
const [colorRed, setColorRed] = useState(160);
const [colorGreen, setColorGreen] = useState(160);
const [colorBlue, setColorBlue] = useState(160);
const [borderRadius, setBorderRadius] = useState(20);
const [shadowRadius, setShadowRadius] = useState(10);
const colorStr = `rgb(${colorRed}, ${colorGreen}, ${colorBlue})`;
return (
<View style={styles.main}>
<Shadow
inner
style={{
borderRadius: borderRadius,
shadowColor: colorStr,
shadowRadius: shadowRadius,
...styles.shadowStyle,
}}>
<Text style={styles.textShadow}>INNER ONLY{'\n'}ART SHADOW</Text>
</Shadow>
<View style={{ height: 20 }} />
<View style={{ flexDirection: 'row' }}>
<Shadow
draw
style={{
borderRadius: borderRadius,
shadowColor: colorStr,
shadowRadius: shadowRadius,
...styles.shadowStyle,
}}>
<Text style={styles.textShadow}>ART{'\n'}SHADOW</Text>
</Shadow>
<View style={{ width: 40 }} />
<Shadow
style={{
borderRadius: borderRadius,
shadowColor: colorStr,
shadowRadius: shadowRadius,
...styles.shadowStyle,
}}>
<Text style={styles.textShadow}>NATIVE IOS{'\n'}SHADOW</Text>
</Shadow>
</View>
<View style={{ height: 50 }} />
<View style={{ width: 300 }}>
<View style={styles.blockValue}>
<Text style={styles.blockValueText}>Color:</Text>
<Text style={styles.blockValueText2}>{colorStr}</Text>
</View>
<Slider
minimumTrackTintColor="red"
maximumValue={255}
minimumValue={0}
style={{ width: '100%' }}
onValueChange={val => setColorRed(val)}
step={1}
value={color}
/>
<Slider
minimumTrackTintColor="green"
maximumValue={255}
minimumValue={0}
style={{ width: '100%' }}
onValueChange={val => setColorGreen(val)}
step={1}
value={color}
/>
<Slider
minimumTrackTintColor="blue"
maximumValue={255}
minimumValue={0}
style={{ width: '100%' }}
onValueChange={val => setColorBlue(val)}
step={1}
value={color}
/>
<Slider
minimumTrackTintColor="transparent"
maximumTrackTintColor="transparent"
maximumValue={255}
minimumValue={0}
style={{ width: '100%' }}
onValueChange={val => {
setColorRed(val);
setColorGreen(val);
setColorBlue(val);
setColor(val);
}}
step={1}
value={230}
/>
<View style={{ height: 25 }} />
<View style={styles.blockValue}>
<Text style={styles.blockValueText}>Border radius:</Text>
<Text style={styles.blockValueText2}>{Math.round(borderRadius)}</Text>
</View>
<Slider
minimumTrackTintColor="black"
maximumValue={200}
minimumValue={0}
style={{ width: '100%' }}
onValueChange={val => setBorderRadius(val)}
value={20}
step={1}
/>
<View style={{ height: 25 }} />
<View style={styles.blockValue}>
<Text style={styles.blockValueText}>Shadow radius:</Text>
<Text style={styles.blockValueText2}>{Math.round(shadowRadius)}</Text>
</View>
<Slider
minimumTrackTintColor="black"
maximumValue={50}
minimumValue={0}
style={{ width: '100%' }}
onValueChange={val => setShadowRadius(val)}
value={10}
/>
</View>
</View>
);
};
const styles = StyleSheet.create({
main: {
width: Dimensions.get('window').width,
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ECF0F3',
textAlign: 'center',
},
textShadow: {
fontWeight: 'bold',
fontSize: 13,
textAlign: 'center',
},
blockValue: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
blockValueText: {
fontSize: 14,
},
blockValueText2: {
fontWeight: 'bold',
fontSize: 14,
textAlign: 'left',
},
shadowStyle: {
shadowOpacity: 1,
backgroundColor: '#ECF0F3',
width: 150,
height: 150,
justifyContent: 'center',
alignItems: 'center',
},
});
export default ShadowsControl;