-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomStyleDefinition.js
More file actions
55 lines (46 loc) · 1.26 KB
/
CustomStyleDefinition.js
File metadata and controls
55 lines (46 loc) · 1.26 KB
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 React, { Component } from 'react'
import { styles } from './styles'
import { Theme, Text, View, withStyles } from 'react-native-themeable'
const customApply = options => withStyles([
{
$type: Text,
color: options.fontColor,
fontSize: options.fontSize,
padding: 10,
}, {
$type: View,
backgroundColor: options.backgroundColor,
},
])
const redTheme = customApply({
backgroundColor: 'red',
fontColor: 'black',
fontSize: 16,
})
const blueTheme = customApply({
backgroundColor: 'blue',
fontColor: 'white',
fontSize: 26,
})
export default class CustomStyleDefinition extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.description}>
This example demonstrates custom `apply` function implementation.
Apply function is flexible and powerful, you can implement your own whenever you need:
</Text>
<Theme apply={redTheme}>
<View>
<Text>This component uses red theme with small black fonts</Text>
</View>
</Theme>
<Theme apply={blueTheme}>
<View>
<Text>This component uses blue theme and large white fonts</Text>
</View>
</Theme>
</View>
)
}
}