1 | ## Header
|
2 |
|
3 |
|
4 | ### 基础版
|
5 | ```jsx
|
6 | <Header onPressLeft={() => console.log('default, onPressLeft')} onPressRight={() => console.log('default, onPressRight')}>
|
7 | <Text>默认样式</Text>
|
8 | </Header>
|
9 | ```
|
10 |
|
11 |
|
12 | ### 自定义文字
|
13 | ```jsx
|
14 | <Header left={<CustomText onPress={() => console.log('custom, onPressLeft')}>返回</CustomText>}>
|
15 | <Text>自定义左侧文字</Text>
|
16 | </Header>
|
17 |
|
18 | function CustomText({
|
19 | onPress,
|
20 | children, style,
|
21 | }) {
|
22 | return (
|
23 | <TouchableWithoutFeedback onPress={onPress}>
|
24 | <Text style={style}>{children}</Text>
|
25 | </TouchableWithoutFeedback>
|
26 | );
|
27 | }
|
28 | ```
|
29 |
|
30 |
|
31 | ### 自定义视图
|
32 | ```jsx
|
33 | <Header right={<CustomTools />}>
|
34 | <Text>自定义右侧视图</Text>
|
35 | </Header>
|
36 |
|
37 | function CustomTools() {
|
38 | return (
|
39 | <View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
40 | <TouchableWithoutFeedback onPress={() => console.log('custom, onPressTool1')}>
|
41 | <Text>工具1</Text>
|
42 | </TouchableWithoutFeedback>
|
43 | <TouchableWithoutFeedback onPress={() => console.log('custom, onPressTool2')}>
|
44 | <Text>工具2</Text>
|
45 | </TouchableWithoutFeedback>
|
46 | </View>
|
47 | );
|
48 | }
|
49 | ```
|
50 |
|
51 |
|
52 | ## 待实现
|
53 |
|
54 | - [] 跟左右布局无关的居中标题
|