|
1 | | ---- |
2 | | -title: ImageHeader - 图片头部组件 |
3 | | -nav: |
4 | | - title: RN组件 |
5 | | - path: /react-native |
6 | | -group: |
7 | | - title: Display |
8 | | - path: /display |
9 | | ---- |
10 | | - |
11 | 1 | # ImageHeader 图片头部组件 |
12 | 2 |
|
13 | 3 | ## 效果演示 |
14 | 4 |
|
15 | | -### 1. 普通 ImageHeader |
16 | | - |
17 | | -```tsx | pure |
18 | | -<ImageHeader headerBackgroundImg={require('../../assets/images/bg_rank.png')} headerHeight={px(161)} {...props}> |
19 | | - <Flex justifyContent="center" backgroundColor="white" height={100}> |
20 | | - <Text>111</Text> |
21 | | - </Flex> |
22 | | -</ImageHeader> |
23 | | -``` |
24 | | - |
25 | | -<center> |
26 | | - <figure> |
27 | | - <img |
28 | | - alt="header-ios1.png" |
29 | | - src="https://td-dev-public.oss-cn-hangzhou.aliyuncs.com/maoyes-app/1609999430064140139.png" |
30 | | - style="width: 375px; margin-right: 10px; border: 1px solid #ddd;" |
31 | | - /> |
32 | | - </figure> |
33 | | -</center> |
34 | | - |
35 | | -### 2. ImageHeader 配置 left、right 和 headerLeftColor |
36 | | - |
37 | | -```tsx | pure |
38 | | -<ImageHeader |
39 | | - headerBackgroundImg={require('../../assets/images/bg_rank.png')} |
40 | | - headerHeight={px(161)} |
41 | | - headerLeftColor={theme.colors.white} |
42 | | - headerLeft="返回" |
43 | | - headerRight={<Icon name="delete" size={px(20)} color={theme.colors.white} />} |
44 | | - {...props} |
45 | | -> |
46 | | - <Flex justifyContent="center" backgroundColor="white" height={100}> |
47 | | - <Text>111</Text> |
48 | | - </Flex> |
49 | | -</ImageHeader> |
50 | | -``` |
51 | | - |
52 | | -<center> |
53 | | - <figure> |
54 | | - <img |
55 | | - alt="header-ios2.png" |
56 | | - src="https://td-dev-public.oss-cn-hangzhou.aliyuncs.com/maoyes-app/1609999550703021067.png" |
57 | | - style="width: 375px; margin-right: 10px; border: 1px solid #ddd;" |
58 | | - /> |
59 | | - </figure> |
60 | | -</center> |
| 5 | +### 1. 基础示例 ImageHeader |
61 | 6 |
|
62 | | -### 3. ImageHeader 配置 headerBackgroundColor |
63 | | - |
64 | | -```tsx | pure |
65 | | -<ImageHeader |
66 | | - headerBackgroundImg={require('../../assets/images/bg_rank.png')} |
67 | | - headerHeight={px(161)} |
68 | | - headerBackgroundColor={theme.colors.white} |
69 | | - headerLeft="返回" |
70 | | - headerRight={<Icon name="delete" size={px(20)} color={theme.colors.white} />} |
71 | | - {...props} |
72 | | -> |
73 | | - <Flex justifyContent="center" height={100}> |
74 | | - <Text>111</Text> |
75 | | - </Flex> |
76 | | -</ImageHeader> |
77 | | -``` |
78 | | - |
79 | | -<center> |
80 | | - <figure> |
81 | | - <img |
82 | | - alt="header-ios3.png" |
83 | | - src="https://td-dev-public.oss-cn-hangzhou.aliyuncs.com/maoyes-app/1610000705310241428.png" |
84 | | - style="width: 375px; margin-right: 10px; border: 1px solid #ddd;" |
85 | | - /> |
86 | | - </figure> |
87 | | -</center> |
88 | | - |
89 | | -### 4. AnimatedHeader |
90 | | - |
91 | | -```tsx | pure |
92 | | -import { useScrollHandler } from 'react-native-redash'; |
93 | | -import Animated from 'react-native-reanimated'; |
94 | | - |
95 | | -export default () => { |
96 | | - const { scrollHandler, y } = useScrollHandler(); |
| 7 | +```jsx |
| 8 | +import React, { Component } from 'react'; |
| 9 | +import { ImageHeader,Avatar } from '@uiw/react-native'; |
| 10 | +import { View, Text } from 'react-native'; |
97 | 11 |
|
| 12 | +function Demo () { |
98 | 13 | return ( |
99 | | - <AnimateHeader |
100 | | - scrollY={y} |
101 | | - scrollHeight={200} |
102 | | - headerTitle="测试啊啊啊啊啊" |
103 | | - headerLeft="返回" |
104 | | - headerBackgroundColor={theme.colors.white} |
105 | | - {...props} |
106 | | - headerRight={ |
107 | | - <TouchableOpacity activeOpacity={0.5} onPress={() => props.navigation.goBack()}> |
108 | | - <Icon name="delete" size={px(20)} color={theme.colors.primaryColor} /> |
109 | | - </TouchableOpacity> |
110 | | - } |
111 | | - /> |
112 | | - <Animated.ScrollView {...scrollHandler}> |
113 | | - <ImageHeader |
114 | | - headerBackgroundImg={require('../../assets/images/bg_rank.png')} |
115 | | - headerHeight={px(161)} |
116 | | - headerLeftColor={theme.colors.white} |
117 | | - headerRight={ |
118 | | - <TouchableOpacity activeOpacity={0.5} onPress={() => props.navigation.goBack()}> |
119 | | - <Icon name="delete" size={px(20)} color={theme.colors.primaryColor} /> |
120 | | - </TouchableOpacity> |
121 | | - } |
122 | | - {...props} |
123 | | - > |
124 | | - <Flex justifyContent="center" height={100}> |
125 | | - <Text>111</Text> |
126 | | - </Flex> |
127 | | - </ImageHeader> |
128 | | - <Box width={200} height={900} /> |
129 | | - </Animated.ScrollView> |
130 | | - ) |
| 14 | + <ImageHeader |
| 15 | + safeBgColor='#010101' |
| 16 | + headerHeight={150} |
| 17 | + headerLeft={<></>} |
| 18 | + > |
| 19 | + <View style={{ |
| 20 | + backgroundColor: '#010101', |
| 21 | + overflow: 'hidden', |
| 22 | + zIndex: 1, |
| 23 | + }}> |
| 24 | + <View |
| 25 | + style={{ |
| 26 | + flexDirection: 'row', |
| 27 | + padding: 20, |
| 28 | + justifyContent: 'space-around', |
| 29 | + alignItems: 'center', |
| 30 | + }} |
| 31 | + > |
| 32 | + <View style={{ flexDirection: 'row' }}> |
| 33 | + <Avatar style={{ marginRight: 10 }} size={70} shape="circle" src="https://avatars.githubusercontent.com/u/32630937?v=4" /> |
| 34 | + <View style={{ flexDirection: 'column' }}> |
| 35 | + <Text style={{ fontSize: 17, color: '#fff', fontWeight: '500', lineHeight: 30 }}> |
| 36 | + 胡意(huyi) |
| 37 | + </Text> |
| 38 | + <Text |
| 39 | + style={{ |
| 40 | + color: '#fff', |
| 41 | + fontSize: 14, |
| 42 | + fontWeight: '500', |
| 43 | + }} |
| 44 | + > |
| 45 | + 96313241@qq.com |
| 46 | + </Text> |
| 47 | + <Text |
| 48 | + numberOfLines={1} |
| 49 | + ellipsizeMode="tail" |
| 50 | + style={{ |
| 51 | + width: 240, |
| 52 | + color: '#fff', |
| 53 | + fontSize: 12, |
| 54 | + lineHeight: 25, |
| 55 | + }} |
| 56 | + > |
| 57 | + 大屏素材库概要,集成一些常见的大屏组件及图表组件,统一样式。 |
| 58 | + </Text> |
| 59 | + </View> |
| 60 | + </View> |
| 61 | + </View> |
| 62 | + </View> |
| 63 | + </ImageHeader> |
| 64 | + ); |
131 | 65 | } |
| 66 | +export default Demo |
132 | 67 | ``` |
133 | | - |
134 | | -<center> |
135 | | - <figure> |
136 | | - <img |
137 | | - alt="header-ios4.gif" |
138 | | - src="https://td-dev-public.oss-cn-hangzhou.aliyuncs.com/maoyes-app/1608877076955547998.gif" |
139 | | - style="width: 375px; margin-right: 10px; border: 1px solid #ddd;" |
140 | | - /> |
141 | | - </figure> |
142 | | -</center> |
143 | | - |
144 | 68 | ## ImageHeader 组件 API |
145 | 69 |
|
146 | 70 | | 属性 | 必填 | 说明 | 类型 | 默认值 | |
|
0 commit comments