/
components.js
155 lines (146 loc) · 3.66 KB
/
components.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
// @flow
import React from 'react'
import { View, StyleSheet } from 'react-native'
import { Button, Text } from 'react-native-paper'
import { normalize } from 'react-native-elements'
import { PushButton } from '../appNavigation/stackNavigation'
export const NextButton = (props: {
valid?: boolean,
handleSubmit: () => any,
styles?: any,
children: any,
loading?: boolean
}) => (
<Button
style={[props.styles || {}, styles.continueButton]}
mode="contained"
color="#555555"
dark={true}
disabled={!props.valid || props.loading}
loading={props.loading}
onPress={props.handleSubmit}
>
<Text style={styles.buttonText}>{props.children}</Text>
</Button>
)
export const ActionButton = (props: {
disabled?: boolean,
handleSubmit: () => any,
styles?: any,
children: any,
loading?: boolean
}) => (
<Button
style={[styles.actionButton, props.styles || {}]}
mode="outlined"
color="#555"
loading={props.loading}
disabled={props.disabled}
onPress={props.handleSubmit}
>
<Text style={styles.actionButtonText}>{props.children}</Text>
</Button>
)
const Footer = (props: { valid?: boolean, submitText?: string, handleSubmit: () => any, loading?: boolean }) => {
return (
<React.Fragment>
<NextButton valid={props.valid} handleSubmit={props.handleSubmit} loading={props.loading}>
{props.submitText || 'Next'}
</NextButton>
</React.Fragment>
)
}
export const Wrapper = (props: any) => {
const { footerComponent: FooterComponent } = props
return (
<View style={styles.wrapper} {...props}>
<View style={styles.topContainer}>{props.children}</View>
<View style={styles.bottomContainer}>
{FooterComponent ? <FooterComponent {...props} /> : <Footer {...props} />}
</View>
</View>
)
}
export const LinkButton = (props: any) => (
<Text style={[styles.linkButton, props.style]} onPress={props.onPress}>
{props.children}
</Text>
)
export const Title = (props: any) => <Text style={[styles.title, props.style]}>{props.children}</Text>
export const Description = (props: any) => <Text style={[styles.description, props.style]}>{props.children}</Text>
export const Error = (props: any) => (
<View style={styles.errorWrapper}>
<Text style={[styles.error, props.style]}>{props.children}</Text>
</View>
)
const fontStyle = {
color: '#555',
fontSize: normalize(18),
textAlign: 'center'
}
const styles = StyleSheet.create({
buttonText: {
...fontStyle,
color: 'white',
fontWeight: 'bold',
textTransform: 'uppercase',
padding: normalize(10)
},
wrapper: {
display: 'flex',
maxWidth: '500px',
flex: 1,
justifyContent: 'space-between',
alignItems: 'stretch',
flexDirection: 'column',
padding: normalize(20)
},
linkButton: {
color: '#555',
fontSize: normalize(18),
textAlign: 'center',
marginTop: normalize(10)
},
topContainer: {
flex: 1,
justifyContent: 'space-evenly',
paddingTop: normalize(30)
},
bottomContainer: {
display: 'flex',
flex: 1,
paddingTop: normalize(20),
justifyContent: 'flex-end'
},
continueButton: {
marginBottom: '10px',
paddingTop: 5,
paddingBottom: 5
},
actionButton: {
borderStyle: 'solid',
borderColor: '#555',
borderWidth: 1,
backgroundColor: 'white',
borderRadius: 5
},
actionButtonText: {
color: '#555'
},
title: {
...fontStyle,
fontSize: normalize(28),
marginBottom: normalize(30)
},
description: {
...fontStyle,
marginTop: normalize(30)
},
errorWrapper: {},
error: {
...fontStyle,
color: 'red',
marginVertical: normalize(30),
minHeight: normalize(24)
}
})