/
App.js
109 lines (96 loc) · 3.16 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
import * as React from 'react';
import { useState } from 'react'
import {StyleSheet, Text, View, TextInput, TouchableOpacity, Clipboard } from 'react-native';
export default function App() {
const [borderTopLeft, setBorderTopLeft] = useState(0)
const [borderTopRight, setBorderTopRight] = useState(0)
const [borderBottomRight, setBorderBottomRight] = useState(0)
const [borderBottomLeft, setBorderBottomLeft] = useState(0)
return (
<View style={styles.container}>
{/* Title*/}
<Text style={styles.title}>Border Radius Previewer</Text>
{/*Form and inputs*/}
<View style={{margin: 20, flexDirection: "row"}}>
{/* Input View Left*/}
<View style={styles.inputView}>
<TextInput
style={styles.input} keyboardType={'numeric'}
onChangeText={text => text ? setBorderTopLeft(parseInt(text)) : console.log("value invalid")}>
</TextInput>
<TextInput
style={styles.input} keyboardType={'numeric'}
onChangeText={text => text ? setBorderBottomLeft(parseInt(text)) : console.log("value invalid")}>
</TextInput>
</View>
{/* Form square*/}
<View style={[styles.form, {borderTopRightRadius: borderTopRight, borderTopLeftRadius: borderTopLeft, borderBottomRightRadius: borderBottomRight, borderBottomLeftRadius: borderBottomLeft }]}/>
{/* Input View Right*/}
<View style={styles.inputView}>
<TextInput
style={styles.input} keyboardType={'numeric'}
onChangeText={text => text ? setBorderTopRight(parseInt(text)) : console.log("value invalid")}>
</TextInput>
<TextInput
style={styles.input} keyboardType={'numeric'}
onChangeText={text => text ? setBorderBottomRight(parseInt(text)) : console.log("value invalid")}>
</TextInput>
</View>
</View>
{/* Button to copy to clipboard*/}
<TouchableOpacity style={styles.button}
onPress={() => {
Clipboard.setString(
'borderTopLeftRadius: ' + borderTopLeft
+ ', borderBottomLeftRadius: ' + borderBottomLeft
+ ', borderTopRightRadius: ' + borderTopRight
+ ', borderBottomRightRadius: ' + borderBottomRight)
alert("Copied to clipboard")
}}>
<Text>Copy to clipborad</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#212121',
},
title: {
fontSize: 20,
textAlign: 'center',
margin: 10,
color: '#59dbff',
},
form:{
width: 180,
height: 180,
borderWidth: 1,
borderColor: "#606060",
},
input:{
margin: 10,
textAlign: 'center',
color: 'white',
width: 40,
height: 30,
borderWidth: 1,
borderColor: "#606060",
},
inputView: {
marginHorizontal: 10,
justifyContent: 'space-between',
},
button:{
margin: 20,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#59dbff',
width: 140,
height:30,
borderRadius: 10,
}
});