Skip to content

Commit ada861f

Browse files
authored
Merge pull request #471 from hy916/dev
fix(CardCollapse): add Cardcollapse Document Instance
2 parents cd04511 + 4837e26 commit ada861f

File tree

6 files changed

+64
-67
lines changed

6 files changed

+64
-67
lines changed

example/examples/src/routes/CardCollapse/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import {ScrollView, View, Image} from 'react-native';
3-
import {CardCollapse} from '@uiw/react-native';
2+
import { ScrollView, View, Image } from 'react-native';
3+
import { CardCollapse } from '@uiw/react-native';
44
import Layout from '../../Layout';
55
import map from 'lodash/map';
66

@@ -12,20 +12,20 @@ const contents = [
1212
];
1313

1414
const CardCollapseDemo = (props: any) => {
15-
const {Header} = Layout;
16-
const {route} = props;
15+
const { Header } = Layout;
16+
const { route } = props;
1717
const description = route.params.description;
1818
const title = route.params.title;
1919

2020
const renderItem = (_: string, index: number) => {
2121
return (
22-
<View key={index} style={{padding: 12}}>
23-
<Image source={{uri: contents[index]}} style={{height: 180}} />
22+
<View key={index} style={{ padding: 12 }}>
23+
<Image source={{ uri: contents[index] }} style={{ height: 180 }} />
2424
</View>
2525
);
2626
};
2727
return (
28-
<ScrollView style={{flex: 1}}>
28+
<ScrollView style={{ flex: 1 }}>
2929
<Header title={title} description={description} />
3030
<Header description={'基本使用'} />
3131
<CardCollapse isCollapsed={false} disablePresses={false}>

packages/core/src/Calendar/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ const styles = StyleSheet.create({
298298
},
299299
calendarWeekdays: {
300300
flexDirection: 'row',
301-
justifyContent: 'space-between',
301+
justifyContent: 'space-around',
302302
alignItems: 'center',
303303
paddingHorizontal: MainWidth < 1000 ? MainWidth / 7 - 33 : MainWidth / 30,
304-
paddingTop: 10,
304+
paddingTop: 12,
305305
},
306306
calendarWedText: {
307307
color: '#616161',
@@ -312,10 +312,10 @@ const styles = StyleSheet.create({
312312
},
313313
weekDay: {
314314
flexDirection: 'row',
315-
paddingHorizontal: 2,
315+
paddingHorizontal: 22,
316316
},
317317
dateBase: {
318-
marginHorizontal: 2,
318+
marginHorizontal: 8,
319319
width: MainWidth < 1000 ? MainWidth / 7 - 4.5 : MainWidth / 14,
320320
height: MainHeight < 300 ? MainWidth / 7 - 4.5 : MainWidth / 14,
321321
...Platform.select({
@@ -327,15 +327,15 @@ const styles = StyleSheet.create({
327327
},
328328
currentMonth: {
329329
backgroundColor: '#329BCB',
330-
borderRadius: 50,
330+
borderRadius: 60,
331331
},
332332
selectMonth: {
333333
borderWidth: 1,
334334
borderColor: '#329BCB',
335-
borderRadius: 50,
335+
borderRadius: 60,
336336
},
337337
otherMonth: {
338-
borderRadius: 50,
338+
borderRadius: 60,
339339
},
340340
dayText: {
341341
textAlign: 'center',

packages/core/src/CardCollapse/README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,55 @@ CardCollapse 可折叠卡片列表
33

44
可折叠卡片列表
55

6-
![](https://user-images.githubusercontent.com/66067296/137702190-e48c11e3-77d9-40c3-8d59-09ac6ddc9efb.gif)
7-
86
### 基础示例
97

108
<!--DemoStart-->
11-
```jsx
12-
import React from 'react';
9+
```jsx mdx:preview
10+
import React,{ Component } from 'react';
1311
import { ScrollView, View,Image } from 'react-native';
1412
import { CardCollapse } from '@uiw/react-native';
15-
import Layout from '../../Layout';
13+
import Layout from '../Layout';
1614
import map from 'lodash/map'
1715

16+
const { Header} = Layout;
1817
const contents = [
19-
'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2019%2F04%2F22%2Fca22d8623fe7454ea9cdb33f3137d14e.jpeg&thumbnail=650x2147483647&quality=80&type=jpg',
20-
'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2019%2F04%2F22%2Fca22d8623fe7454ea9cdb33f3137d14e.jpeg&thumbnail=650x2147483647&quality=80&type=jpg',
21-
'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2019%2F04%2F22%2Fca22d8623fe7454ea9cdb33f3137d14e.jpeg&thumbnail=650x2147483647&quality=80&type=jpg',
22-
'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2019%2F04%2F22%2Fca22d8623fe7454ea9cdb33f3137d14e.jpeg&thumbnail=650x2147483647&quality=80&type=jpg'
18+
'https://wx3.sinaimg.cn/mw690/4718260ely1gt2cg7t5udj23dw1wkhdu.jpg',
19+
'https://wx1.sinaimg.cn/mw690/4718260ely1gt2cg5r9zij22yo1o0x6p.jpg',
20+
'https://wx1.sinaimg.cn/mw690/4718260ely1gt2cg5r9zij22yo1o0x6p.jpg',
21+
'https://wx3.sinaimg.cn/mw690/4718260ely1gt2cg7t5udj23dw1wkhdu.jpg',
2322
];
2423

25-
const CardCollapseDemo = (props: any) => {
26-
const { Header } = Layout;
27-
const { route } = props;
28-
const description = route.params.description;
29-
const title = route.params.title;
30-
31-
const renderItem = (_: string, index: number) => {
24+
class Demo extends Component {
25+
render() {
26+
const renderItem = (_, index) => {
3227
return (
33-
<View key={index} style={{ padding: 18 }}>
34-
<Image source={{uri: contents[index]}} style={{ height: 150 }} />
28+
<View key={index} style={{ padding: 20,backgroundColor: '#fff'}}>
29+
<Image source={{uri: contents[index]}} style={{ height: 120 }} />
3530
</View>
3631
);
3732
}
38-
return (
33+
return (
3934
<ScrollView style={{ flex: 1 }}>
40-
<Header title={title} description={description} />
4135
<Header description={'基本使用'} />
4236
<CardCollapse
43-
isCollapsed
44-
disablePresses={true}
37+
isCollapsed={false}//是否折叠
38+
disablePresses={true}//卡片是否可以点击
39+
onCollapseWillChange={()=>{}}
40+
onCollapseChanged={()=>{}}
4541
>
4642
{map(contents, (item, index) => {
4743
return renderItem(item, index);
4844
})}
4945
</CardCollapse>
5046
</ScrollView>
51-
);
52-
};
53-
export default CardCollapseDemo;
47+
)
48+
}
49+
}
50+
51+
export default Demo
5452

5553
```
54+
5655
<!--End-->
5756

5857
### Props

packages/core/src/CardCollapse/index.tsx

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ export default function CardCollapse(props: CardCollapseProps) {
9292
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
9393
}, [collapsed]);
9494

95-
function getItemScale(index: number) {
96-
if (collapsed) {
97-
if (index === itemsCount - 2) {
98-
return 0.95;
99-
}
100-
if (index === itemsCount - 1) {
101-
return 0.9;
102-
}
103-
}
104-
return 1;
105-
}
10695
// 动画
10796
const animate = async () => {
10897
return Promise.all([animateValues(), animateCards()]);
@@ -133,6 +122,13 @@ export default function CardCollapse(props: CardCollapseProps) {
133122
});
134123
};
135124

125+
function getItemScale(index: number) {
126+
if (collapsed) {
127+
return 0.9;
128+
}
129+
return 1;
130+
}
131+
136132
const animateCards = () => {
137133
const promises = [];
138134
for (let index = 0; index < itemsCount; index++) {
@@ -210,21 +206,23 @@ export default function CardCollapse(props: CardCollapseProps) {
210206

211207
const renderItem = (item: JSX.Element | JSX.Element[], index: number) => {
212208
return (
213-
<Animated.View
209+
< Animated.View
214210
key={index}
215-
onLayout={index === 0 ? onLayout : undefined}
216-
style={[
217-
Platform.OS === 'ios' && styles.containerShadow,
218-
getStyle(index),
219-
{
220-
borderRadius: Platform.OS === 'ios' ? itemBorderRadius : undefined,
221-
alignSelf: 'center',
222-
zIndex: itemsCount - index,
223-
transform: [{ scaleX: animatedScaleArray[index] }],
224-
width: Dimensions.get('screen').width - 40,
225-
height: collapsed ? firstItemHeight : undefined,
226-
},
227-
]}
211+
onLayout={index === 0 ? onLayout : undefined
212+
}
213+
style={
214+
[
215+
Platform.OS === 'ios' && styles.containerShadow,
216+
getStyle(index),
217+
{
218+
borderRadius: Platform.OS === 'ios' ? itemBorderRadius : undefined,
219+
alignSelf: 'center',
220+
zIndex: itemsCount - index,
221+
transform: [{ scaleX: animatedScaleArray[index] }],
222+
width: Dimensions.get('screen').width - 40,
223+
height: collapsed ? firstItemHeight : undefined,
224+
},
225+
]}
228226
collapsable={false}
229227
>
230228
<Container
@@ -237,7 +235,7 @@ export default function CardCollapse(props: CardCollapseProps) {
237235
</Animated.View>
238236
</TouchableOpacity>
239237
</Container>
240-
</Animated.View>
238+
</Animated.View >
241239
);
242240
};
243241
return (

packages/core/src/SearchBar/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SearchBar 模糊搜素组件
1+
SearchBar 模糊搜索组件
22
---
33

44
### 基础示例

website/src/routes/menus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const componentMenus: MenuData[] = [
2828
{ path: '/components/segmentedcontrol', name: 'SegmentedControl 分段器' },
2929
{ path: '/components/slider', name: 'Slider 滑块输入条' },
3030
{ path: '/components/switch', name: 'Switch 开关' },
31-
{ path: '/components/searchbar', name: 'SearchBar 模糊搜素组件' },
31+
{ path: '/components/searchbar', name: 'SearchBar 模糊搜索组件' },
3232
{ divider: true, name: 'Data Display' },
3333
{ path: '/components/avatar', name: 'Avatar 头像' },
3434
{ path: '/components/badge', name: 'Badge 标记' },

0 commit comments

Comments
 (0)