Skip to content

Commit c3ab92b

Browse files
committed
extract more custom cells to components/
1 parent 3aa26f3 commit c3ab92b

File tree

3 files changed

+58
-32
lines changed

3 files changed

+58
-32
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// @flow
2+
3+
import React from 'react'
4+
import {StyleSheet, Text} from 'react-native'
5+
import {Cell} from 'react-native-tableview-simple'
6+
import * as c from '../../components/colors'
7+
8+
const styles = StyleSheet.create({
9+
title: {
10+
textAlign: 'left',
11+
},
12+
active: {
13+
color: c.infoBlue,
14+
},
15+
disabled: {
16+
color: c.iosDisabledText,
17+
},
18+
})
19+
20+
export function ButtonCell({
21+
indeterminate,
22+
disabled,
23+
onPress,
24+
title,
25+
}: {
26+
indeterminate?: boolean,
27+
disabled?: boolean,
28+
onPress: () => any,
29+
title: string,
30+
}) {
31+
return (
32+
<Cell
33+
titleTextStyle={styles.title}
34+
isDisabled={indeterminate || disabled}
35+
onPress={onPress}
36+
title={
37+
<Text
38+
style={[
39+
styles.text,
40+
indeterminate || disabled ? styles.disabled : styles.active,
41+
]}
42+
>
43+
{title}
44+
</Text>
45+
}
46+
/>
47+
)
48+
}
Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
// @flow
2-
import React from 'react'
3-
import {StyleSheet, Text} from 'react-native'
4-
import {Cell} from 'react-native-tableview-simple'
5-
import * as c from '../../components/colors'
62

7-
const styles = StyleSheet.create({
8-
button: {
9-
justifyContent: 'flex-start',
10-
},
11-
text: {
12-
fontSize: 16,
13-
},
14-
active: {
15-
color: c.infoBlue,
16-
},
17-
disabled: {
18-
color: c.iosDisabledText,
19-
},
20-
})
3+
import React from 'react'
4+
import {ButtonCell} from '../../components/cells/button'
215

226
export function LoginButton({
237
loading,
@@ -32,22 +16,16 @@ export function LoginButton({
3216
onPress: () => any,
3317
label: string,
3418
}) {
35-
let loginTextStyle = loading || disabled ? styles.disabled : styles.active
36-
37-
const contents = (
38-
<Text style={[styles.text, loginTextStyle]}>
39-
{loading
40-
? `Logging in to ${label}…`
41-
: loggedIn ? `Sign Out of ${label}` : `Sign In to ${label}`}
42-
</Text>
43-
)
44-
4519
return (
46-
<Cell
47-
contentContainerStyle={styles.button}
48-
isDisabled={loading || disabled}
20+
<ButtonCell
21+
disabled={loading || disabled}
22+
indeterminate={loading}
4923
onPress={onPress}
50-
title={contents}
24+
title={
25+
loading
26+
? `Logging in to ${label}…`
27+
: loggedIn ? `Sign Out of ${label}` : `Sign In to ${label}`
28+
}
5129
/>
5230
)
5331
}

0 commit comments

Comments
 (0)