@@ -35,13 +35,10 @@ import { Card } from '@uiw/react-native';
3535
3636class Demo extends Component {
3737 render () {
38- return (
38+ return (
3939 < SafeAreaView style= {{ flex: 1 }}>
40- < Card
41- title= " 我是标题"
42- showDriver= {true }
43- borderRadius= {12 }
44- >
40+ < Card borderRadius= {12 }>
41+ < Card .Title title= " @uiw/react-native" / >
4542 < Image
4643 source= {{
4744 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' ,
@@ -56,25 +53,37 @@ class Demo extends Component {
5653```
5754<!-- End-->
5855
59- ### 可点击选中卡片
56+ ### 可点击选中带操作卡片
6057
6158<!-- DemoStart-->
6259``` jsx
6360import React , { useState } from ' react' ;
6461import { SafeAreaView , View , Image } from ' react-native' ;
65- import { Card } from ' @uiw/react-native' ;
62+ import { Card , Icon } from ' @uiw/react-native' ;
6663
6764const Demo = () => {
6865 const [selected , setSelected ] = useState (false )
6966 return (
7067 < SafeAreaView style= {{ flex: 1 }}>
7168 < Card
7269 selected= {selected}
73- title= " 我是标题"
74- showDriver= {true }
7570 borderRadius= {12 }
7671 onPress= {() => { setSelected (! selected) }}
7772 >
73+ < Card .Actions
74+ actions= {[
75+ {
76+ text: ' 点赞' ,
77+ icon: < Icon name= " like-o" size= {16 } color= " #5847FF" / > ,
78+ onPress : (e : any , index : number ) => { }
79+ },
80+ {
81+ text: ' 分享' ,
82+ icon: < Icon name= " share" size= {16 } color= " #5847FF" / > ,
83+ onPress : (e : any , index : number ) => { }
84+ },
85+ ]}
86+ / >
7887 < Image
7988 source= {{
8089 uri: ' https://wx1.sinaimg.cn/mw690/4718260ely1gt2cg5r9zij22yo1o0x6p.jpg' ,
@@ -88,38 +97,46 @@ const Demo = () => {
8897```
8998<!-- End-->
9099
91- ### Props
92-
100+ ### CardProps
93101``` ts
94102export interface CardProps {
95103 /** 外容器样式(可选) */
96104 containerStyle? : StyleProp <ViewStyle >;
97105 /** 内容器样式(可选) */
98106 wrapperStyle? : StyleProp <ViewStyle >;
99- /** 标题(可选) */
100- title? : string
101- /** 标题样式(可选) */
102- titleStyle? : StyleProp <TextStyle >;
103107 /** 设置卡片圆角度数(可选) */
104108 borderRadius? : number ;
105109 /** 是否选中(可选) */
106110 selected? : boolean ;
107111 /** 渲染内容 */
108112 children? : React .ReactNode ;
109- /** 操作 */
110- actions? : Array <{
111- text? : string ;
112- icon? : JSX .Element ;
113- onPress? : (e : GestureResponderEvent , index : number ) => void ;
114- }>;
115- /** 操作容器样式(可选) */
116- actionsContainerStyle? : StyleProp <ViewStyle >;
117- /** 操作文字样式(可选) */
118- actionsTextStyle? : StyleProp <ViewStyle >;
119113 /** 按下卡片时的动作(可选) */
120114 onPress? : TouchableOpacityProps [' onPress' ];
121115 /** 长按下卡片时的动作(可选) */
122116 onLongPress? : TouchableOpacityProps [' onLongPress' ];
123117}
124118```
125119
120+ ### CardTitleProps
121+ ``` ts
122+ type CardTitleProps = {
123+ title? : string ;
124+ titleStyle? : StyleProp <TextStyle >
125+ children? : React .ReactNode ;
126+ };
127+ ```
128+
129+ ### CardActionsProps
130+ ``` ts
131+ type CardActionsProps = {
132+ actions? : Array <{
133+ text? : string ;
134+ icon? : JSX .Element ;
135+ onPress? : (e : GestureResponderEvent , index : number ) => void ;
136+ actionsTextStyle? : StyleProp <TextStyle >
137+ }>;
138+ actionsContainerStyle? : StyleProp <ViewStyle >
139+ children? : React .ReactNode ;
140+ };
141+ ```
142+
0 commit comments