-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix white lines issue in color palette card and make card and other UI
components round
- Loading branch information
1 parent
05c31cb
commit 712e32c
Showing
8 changed files
with
72 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,67 @@ | ||
import * as React from 'react'; | ||
import React, { useRef } from 'react'; | ||
import * as Animatable from 'react-native-animatable'; | ||
import { StyleSheet, View, TouchableOpacity } from 'react-native'; | ||
import { StyleSheet, View, TouchableOpacity, Animated } from 'react-native'; | ||
import Colors from '../constants/Colors'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default class Card extends React.Component { | ||
render() { | ||
return ( | ||
<Animatable.View animation={this.props.animationType} duration={500} useNativeDriver={true}> | ||
<TouchableOpacity | ||
onLongPress={this.props.onLongPress} | ||
onPress={this.props.onPress} | ||
style={[styles.inner]}> | ||
<View {...this.props}>{this.props.children}</View> | ||
</TouchableOpacity> | ||
</Animatable.View> | ||
); | ||
} | ||
} | ||
const Card = ({ animationType, onLongPress, onPress, children }) => { | ||
const scaleValue = useRef(new Animated.Value(1)).current; | ||
|
||
const handlePressIn = () => { | ||
Animated.timing(scaleValue, { | ||
toValue: 0.95, | ||
duration: 200, | ||
useNativeDriver: true | ||
}).start(); | ||
}; | ||
|
||
const handlePressOut = () => { | ||
Animated.timing(scaleValue, { | ||
toValue: 1, | ||
duration: 200, | ||
useNativeDriver: true | ||
}).start(); | ||
}; | ||
|
||
const scaleStyle = { | ||
transform: [{ scale: scaleValue }] | ||
}; | ||
|
||
return ( | ||
<Animatable.View animation={animationType} duration={500} useNativeDriver={true}> | ||
<TouchableOpacity | ||
activeOpacity={1} | ||
onLongPress={onLongPress} | ||
onPress={onPress} | ||
onPressIn={handlePressIn} | ||
onPressOut={handlePressOut} | ||
style={styles.touchable}> | ||
<Animated.View style={[styles.inner, scaleStyle]}> | ||
<View>{children}</View> | ||
</Animated.View> | ||
</TouchableOpacity> | ||
</Animatable.View> | ||
); | ||
}; | ||
|
||
Card.propTypes = { | ||
animationType: PropTypes.string, | ||
onLongPress: PropTypes.func, | ||
onPress: PropTypes.func, | ||
children: PropTypes.children | ||
children: PropTypes.node | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
touchable: { | ||
borderRadius: 8 | ||
}, | ||
inner: { | ||
backgroundColor: Colors.white, | ||
marginVertical: 8, | ||
elevation: 1 | ||
elevation: 1, | ||
overflow: 'hidden', | ||
borderRadius: 8 | ||
} | ||
}); | ||
|
||
export default Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters