Skip to content

Commit

Permalink
(fix):Update CardCollapse
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenlingasMx committed Aug 27, 2021
1 parent 785cc3b commit a531d15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions example/examples/src/routes/CardCollapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const CardCollapseDemo = (props: any) => {
<Header title={title} description={description} />
<Header description={'基本使用'} />
<CardCollapse
isCollapsed
disablePresses={true}
isCollapsed={false}
disablePresses={false}
>
{map(contents, (item, index) => {
return renderItem(item, index);
Expand Down
25 changes: 15 additions & 10 deletions packages/core/src/CardCollapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function CardCollapse(props: CardCollapseProps) {
const animatedScaleArray: Animated.Value[] = getAnimatedScales();
const itemsCount = React.Children.count(children);
const easeOut = Easing.bezier(0, 0, 0.58, 1);
const Container: any = !disablePresses ? TouchableOpacity : View;
const Container: any = !disablePresses ? TouchableOpacity : View;
useEffect(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
}, [collapsed])
Expand All @@ -100,7 +100,7 @@ export default function CardCollapse(props: CardCollapseProps) {
}
return 1;
}

// 动画
const animate = async () => {
return Promise.all([animateValues(), animateCards()]);
};
Expand Down Expand Up @@ -134,7 +134,6 @@ export default function CardCollapse(props: CardCollapseProps) {
const promises = [];
for (let index = 0; index < itemsCount; index++) {
const newScale = getItemScale(index);

promises.push(
new Promise(resolve => {
Animated.timing(animatedScaleArray[index], {
Expand Down Expand Up @@ -225,7 +224,7 @@ export default function CardCollapse(props: CardCollapseProps) {
collapsable={false}
>
<Container
style={[contentContainerStyle, styles.card,{borderRadius:itemBorderRadius}]}
style={[contentContainerStyle, styles.card, { borderRadius: itemBorderRadius }]}
onPress={() => disablePresses && onItemPress(index)}
>
<Animated.View style={index !== 0 ? { opacity: animatedContentOpacity } : undefined} collapsable={false}>
Expand All @@ -247,17 +246,23 @@ export default function CardCollapse(props: CardCollapseProps) {
}}
>
{
collapsed ? <Icon xml={up} size={24} /> : <TouchableOpacity onPress={close}><Icon xml={down} size={24} /></TouchableOpacity>
collapsed ? (
<TouchableOpacity onPress={open}>
<Icon xml={up} size={26} />
</TouchableOpacity>
) : (
<TouchableOpacity onPress={close}>
<Icon xml={down} size={26} />
</TouchableOpacity>
)
}
</Animated.View>

{React.Children.map(children, (item, index) => {
return renderItem(item, index);
})}

{collapsed && (
{collapsed &&
<TouchableOpacity
onPress={open}
onPress={collapsed ? open : close}
activeOpacity={1}
style={[
styles.touchable,
Expand All @@ -267,7 +272,7 @@ export default function CardCollapse(props: CardCollapseProps) {
}
]}
/>
)}
}
</View>
</View>
)
Expand Down

0 comments on commit a531d15

Please sign in to comment.