-
Notifications
You must be signed in to change notification settings - Fork 0
/
number-button.tsx
55 lines (52 loc) · 1.12 KB
/
number-button.tsx
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
import { COLOR, COLOR_BACKGROUND } from '../core/constants'
import React from 'react'
import { StyleSheet, Text, TouchableOpacity } from 'react-native'
interface NumberButtonProps {
index: number
number: number
onPress: (number: number) => void
selected?: boolean
}
const NumberButton = (props: NumberButtonProps) => {
const { index, number, onPress, selected } = props
return (
<TouchableOpacity
key={number}
style={[
styles.container,
{
backgroundColor: selected ? COLOR_BACKGROUND : undefined,
borderColor: COLOR_BACKGROUND,
borderWidth: selected ? 0 : 2,
marginLeft: index === 0 ? 0 : 8
}
]}
onPress={() => {
console.log(`Pressing ${number}`)
onPress(number)
}}
>
<Text style={styles.text}>{number}</Text>
</TouchableOpacity>
)
}
export default NumberButton
const styles = StyleSheet.create({
container: {
flex: 1,
height: 48,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
borderRadius: 24,
paddingLeft: 16,
paddingRight: 16,
marginTop: 16
},
text: {
color: COLOR,
fontSize: 20,
fontWeight: '600'
}
})