-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThemeWithProps.js
79 lines (71 loc) · 1.69 KB
/
ThemeWithProps.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
import React, { Component } from 'react'
import { styles } from './styles'
import {
Theme,
View,
TouchableHighlight,
Text,
withProps,
} from 'react-native-themeable'
const redTheme = withProps([
{
$type: Text,
style: {
color: 'black',
fontSize: 16,
},
}, {
$type: View,
style: {
backgroundColor: 'red',
},
}, {
$type: TouchableHighlight,
activeOpacity: 0.5,
underlayColor: 'green',
},
])
const blueTheme = withProps([
{
$type: Text,
style: {
color: 'white',
fontSize: 26,
},
}, {
$type: View,
style: {
backgroundColor: 'blue',
},
}, {
$type: TouchableHighlight,
activeOpacity: 0.8,
underlayColor: 'pink',
},
])
export default class ThemeWithProps extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.description}>
Following elements use themes which besides styles define component props.
You can see that `underlayColor` property of TouchableHighlight is different in each theme.
</Text>
<Theme apply={redTheme}>
<View>
<TouchableHighlight onPress={() => console.log('Hello from red theme!')}>
<Text>Red theme - press me to see theme specific highlight color</Text>
</TouchableHighlight>
</View>
</Theme>
<Theme apply={blueTheme}>
<View>
<TouchableHighlight onPress={() => console.log('Hello from blue theme!')}>
<Text>Blue theme - press me to see theme specific highlight color</Text>
</TouchableHighlight>
</View>
</Theme>
</View>
)
}
}