@@ -3,38 +3,32 @@ Card 卡片
33
44最基础的卡片容器,可承载文字、列表、图片、段落。
55
6- ![ ] ( https://user-images.githubusercontent.com/57083007/137632175-fc80bff2-7224-4843-97ec-9f8d9cbc6746.png ) <!-- rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
7-
86### 基础示例
97
10- <!-- DemoStart-->
11- ``` jsx
12- import { SafeAreaView , View , Image } from ' react-native' ;
13- import { Card } from ' @uiw/react-native' ;
14-
8+ ``` jsx mdx:preview
9+ import React ,{ Component } from " react"
10+ import { SafeAreaView , View , Image } from ' react-native' ;
11+ import Card from ' @uiw/react-native/lib/Card' ;
1512class Demo extends Component {
1613 render () {
1714 return (
1815 < SafeAreaView style= {{ flex: 1 }}>
1916 < Card>
2017 < View>
21- < Image source= {{ uri: ' https://img11.51tietu. net/pic/2016-071418/20160714181543xyu10ukncwf221991. jpg' }} style= {{ height: 150 }} / >
18+ < Image source= {{ uri: ' https://nimg.ws.126. net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2019%2F04%2F22%2Fca22d8623fe7454ea9cdb33f3137d14e.jpeg&thumbnail=650x2147483647&quality=80&type= jpg' }} style= {{ height: 150 }} / >
2219 < / View>
2320 < / Card>
2421 < / SafeAreaView>
2522 )
2623 }
2724}
25+ export default Demo
2826```
29- <!-- End-->
30-
3127### 带标题圆角卡片
32-
33- <!-- DemoStart-->
34- ``` jsx
35- import { SafeAreaView , View , Image } from ' react-native' ;
36- import { Card } from ' @uiw/react-native' ;
37-
28+ ``` jsx mdx:preview
29+ import React ,{ Component } from " react"
30+ import { SafeAreaView , View , Image } from ' react-native' ;
31+ import Card from ' @uiw/react-native/lib/Card' ;
3832class Demo extends Component {
3933 render () {
4034 return (
@@ -52,16 +46,14 @@ class Demo extends Component {
5246 )
5347 }
5448}
49+ export default Demo
5550```
56- <!-- End-->
57-
5851### 可点击选中带操作卡片
59-
60- <!-- DemoStart-->
61- ``` jsx
52+ ``` jsx mdx:preview
6253import React , { useState } from ' react' ;
63- import { SafeAreaView , View , Image } from ' react-native' ;
64- import { Card ,Icon } from ' @uiw/react-native' ;
54+ import { SafeAreaView , View , Image } from ' react-native' ;
55+ import Card from ' @uiw/react-native/lib/Card' ;
56+ import Icon from ' @uiw/react-native/lib/Icon' ;
6557
6658const Demo = () => {
6759 const [selected , setSelected ] = useState (false )
@@ -77,73 +69,54 @@ const Demo = () => {
7769 {
7870 text: ' 点赞' ,
7971 icon: < Icon name= " like-o" size= {16 } color= " #5847FF" / > ,
80- onPress : (e : any , index : number ) => { }
72+ onPress : () => {}
8173 },
8274 {
8375 text: ' 分享' ,
8476 icon: < Icon name= " share" size= {16 } color= " #5847FF" / > ,
85- onPress : (e : any , index : number ) => { }
77+ onPress : () => {}
8678 },
8779 ]}
8880 / >
8981 < Image
9082 source= {{
91- uri: ' https://wx1.sinaimg.cn/mw690/4718260ely1gt2cg5r9zij22yo1o0x6p. jpg' ,
83+ uri: ' https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2019%2F04%2F22%2Fca22d8623fe7454ea9cdb33f3137d14e.jpeg&thumbnail=650x2147483647&quality=80&type= jpg'
9284 }}
9385 style= {{ height: 200 }}
9486 / >
9587 < / Card>
9688 < / SafeAreaView>
9789 )
9890}
91+ export default Demo
9992```
100- <!-- End-->
93+ #### 属性
94+ ## CardProps
10195
102- ### CardProps
103- ``` ts
104- export interface CardProps {
105- /** 外容器样式(可选) */
106- containerStyle? : StyleProp <ViewStyle >;
107- /** 内容器样式(可选) */
108- wrapperStyle? : StyleProp <ViewStyle >;
109- /** 设置卡片圆角度数(可选) */
110- borderRadius? : number ;
111- /** 是否选中(可选) */
112- selected? : boolean ;
113- /** 渲染内容 */
114- children? : React .ReactNode ;
115- /** 按下卡片时的动作(可选) */
116- onPress? : TouchableOpacityProps [' onPress' ];
117- /** 长按下卡片时的动作(可选) */
118- onLongPress? : TouchableOpacityProps [' onLongPress' ];
119- /** 自定义选中样式 */
120- selectedStyle? : {
121- icon? : React .ReactNode ;
122- style? : ViewStyle
123- }
124- }
125- ```
96+ | 属性 | 说明 | 类型 | 默认值 |
97+ | --- | --- | --- | --- |
98+ | containerStyle | 外容器样式(可选) | ` StyleProp<ViewStyle> ` | - |
99+ | wrapperStyle | 内容器样式(可选) | ` StyleProp<ViewStyle> ` | - |
100+ | borderRadius | 设置卡片圆角度数(可选) | ` number ` | - |
101+ | selected | 是否选中(可选) | ` boolean ` | - |
102+ | children | 渲染内容 | ` React.ReactNode ` | - |
103+ | onPress | 按下卡片时的动作(可选) | ` TouchableOpacityProps['onPress'] ` | - |
104+ | onLongPress | 长按下卡片时的动作(可选) | ` TouchableOpacityProps['onLongPress'] ` | - |
105+ | selectedStyle | 自定义选中样式 | ` { icon?: React.ReactNode;style?: ViewStyle} ` | - |
126106
127- ### CardTitleProps
128- ``` ts
129- type CardTitleProps = {
130- title? : string ;
131- titleStyle? : StyleProp <TextStyle >
132- children? : React .ReactNode ;
133- };
134- ```
107+ ## CardTitleProps
108+
109+ | 属性 | 说明 | 类型 | 默认值 |
110+ | --- | --- | --- | --- |
111+ | title | 标题 | ` string ` | - |
112+ | titleStyle | 标题样式 | ` StyleProp<TextStyle> ` | - |
113+ | children | 自定义标题 | ` React.ReactNode ` | - |
114+
115+ ## CardActionsProps
116+ | 属性 | 说明 | 类型 | 默认值 |
117+ | --- | --- | --- | --- |
118+ | actions | 操作 | ` Array<{ text?: string; icon?: JSX.Element; onPress?: (e: GestureResponderEvent, index: number) => void; actionsTextStyle?: StyleProp<TextStyle>}> ` | - |
119+ | actionsContainerStyle | 操作容器样式 | ` StyleProp<ViewStyle> ` | - |
120+ | children | 自定义操作 | ` React.ReactNode ` | - |
135121
136- ### CardActionsProps
137- ``` ts
138- type CardActionsProps = {
139- actions? : Array <{
140- text? : string ;
141- icon? : JSX .Element ;
142- onPress? : (e : GestureResponderEvent , index : number ) => void ;
143- actionsTextStyle? : StyleProp <TextStyle >
144- }>;
145- actionsContainerStyle? : StyleProp <ViewStyle >
146- children? : React .ReactNode ;
147- };
148- ```
149122
0 commit comments