-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #77 feat: add lookbook button component * #77 feat: add lookbook addButton component * #77 feat: add toggle component * fix: set patch package to solve deprecated prop types error
- Loading branch information
1 parent
48a8547
commit ac85b71
Showing
7 changed files
with
1,068 additions
and
137 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Dispatch, SetStateAction, useEffect, useRef } from 'react'; | ||
import { | ||
Animated, | ||
StyleSheet, | ||
Touchable, | ||
TouchableOpacity, | ||
TouchableWithoutFeedback, | ||
View, | ||
} from 'react-native'; | ||
import { PURPLE, PURPLE2 } from '../styles/GlobalColor'; | ||
|
||
const Toggle = ({ | ||
isOn, | ||
setIsOn, | ||
}: { | ||
isOn: boolean; | ||
setIsOn: Dispatch<SetStateAction<boolean>>; | ||
}) => { | ||
const X_COORD_OFF = 0; | ||
const X_COORD_ON = 24; | ||
const ANIMATION_DURATION = 500; | ||
|
||
const animationXTrans = useRef(new Animated.Value(0)).current; | ||
|
||
const handlePress = () => { | ||
setIsOn(prev => !prev); | ||
}; | ||
|
||
useEffect(() => { | ||
console.log('animation on'); | ||
Animated.timing(animationXTrans, { | ||
toValue: isOn ? X_COORD_ON : X_COORD_OFF, | ||
duration: ANIMATION_DURATION, | ||
useNativeDriver: true, | ||
}).start(); | ||
}, [animationXTrans, isOn]); | ||
|
||
return ( | ||
<View> | ||
<TouchableWithoutFeedback onPress={handlePress}> | ||
<View | ||
style={{ | ||
backgroundColor: isOn ? PURPLE : PURPLE2, | ||
...Styles.container, | ||
}}> | ||
<Animated.View | ||
style={{ | ||
transform: [{ translateX: animationXTrans }], | ||
...Styles.button, | ||
}} | ||
/> | ||
</View> | ||
</TouchableWithoutFeedback> | ||
</View> | ||
); | ||
}; | ||
|
||
const Styles = StyleSheet.create({ | ||
container: { | ||
width: 50, | ||
height: 26, | ||
borderRadius: 100, | ||
margin: 5, | ||
justifyContent: 'center', | ||
paddingHorizontal: 3, | ||
}, | ||
button: { | ||
width: 20, | ||
height: 20, | ||
borderRadius: 100, | ||
backgroundColor: 'white', | ||
}, | ||
}); | ||
|
||
export default Toggle; |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { StyleSheet, TouchableOpacity, View } from 'react-native'; | ||
import PlusSquare from '../../assets/lookbook/plusSquare.svg'; | ||
|
||
const LookbookAddButton = ({ onPress }: { onPress: () => void }) => { | ||
return ( | ||
<View> | ||
<TouchableOpacity onPress={onPress}> | ||
<View style={Styles.container}> | ||
<PlusSquare /> | ||
</View> | ||
</TouchableOpacity> | ||
</View> | ||
); | ||
}; | ||
|
||
const Styles = StyleSheet.create({ | ||
container: { | ||
width: 54, | ||
height: 54, | ||
backgroundColor: 'black', | ||
borderRadius: 100, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
margin: 5, | ||
}, | ||
}); | ||
|
||
export default LookbookAddButton; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { StyleSheet, View, ViewStyle } from 'react-native'; | ||
import { GREEN, PURPLE } from '../../styles/GlobalColor'; | ||
import { Upcymall12M } from '../../styles/GlobalText'; | ||
|
||
const LookbookButton = ({ positioning }: { positioning?: ViewStyle }) => { | ||
return ( | ||
<View style={{ ...positioning }}> | ||
<View style={Styles.container}> | ||
<Upcymall12M style={{ color: GREEN }}>UPCYMALL</Upcymall12M> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const Styles = StyleSheet.create({ | ||
container: { | ||
backgroundColor: PURPLE, | ||
paddingHorizontal: 8, | ||
paddingVertical: 6, | ||
borderRadius: 5, | ||
width: 'auto', | ||
alignSelf: 'flex-start', | ||
margin: 5, | ||
}, | ||
}); | ||
|
||
export default LookbookButton; |
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
Oops, something went wrong.