-
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.
* #11 feat: add product & service item * #11 feat: add carousel module * #11 feat: add market product page
- Loading branch information
Showing
20 changed files
with
600 additions
and
277 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 |
---|---|---|
|
@@ -12,5 +12,6 @@ module.exports = { | |
allowUndefined: true, | ||
}, | ||
], | ||
'react-native-reanimated/plugin' | ||
], | ||
}; |
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
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { useState } from 'react'; | ||
import { View, Dimensions } from 'react-native'; | ||
import CarouselModule from 'react-native-snap-carousel'; | ||
import Slider from './Slider'; | ||
import styled from 'styled-components/native'; | ||
import { LIGHTGRAY, PURPLE } from '../styles/GlobalColor'; | ||
|
||
interface CarouselProps { | ||
data: any[]; | ||
renderItem: any; | ||
dot?: boolean; | ||
slider?: boolean; | ||
} | ||
|
||
const Carousel = ({ data, renderItem, dot, slider }: CarouselProps) => { | ||
const { width } = Dimensions.get('window'); | ||
const [page, setPage] = useState<number>(0); | ||
return ( | ||
<> | ||
<CarouselModule | ||
data={data} | ||
renderItem={renderItem} | ||
sliderWidth={width} | ||
itemWidth={width} | ||
onSnapToItem={(index: number) => setPage(index)} | ||
keyExtractor={(item, index) => index.toString()} | ||
/> | ||
{dot ? ( | ||
<DotContainer> | ||
{Array.from({length: data.length}, (_, i) => i).map((i) => ( | ||
<Dot key={i} focused={i === page ? true : false} /> | ||
))} | ||
</DotContainer> | ||
):(<></>)} | ||
{slider ? ( | ||
<SliderContainer> | ||
<Slider total={data.length-1} page={page} /> | ||
</SliderContainer> | ||
):(<></>)} | ||
</> | ||
) | ||
} | ||
|
||
const Dot = styled.View<{ focused: boolean }>` | ||
width: ${(props: { focused: boolean; }) => props.focused ? 10 : 7}px; | ||
height: ${(props: { focused: boolean; }) => props.focused ? 10 : 7}px; | ||
margin: 0px 6px; | ||
border-radius: 16px; | ||
background: ${(props: { focused: boolean; }) => props.focused ? PURPLE : LIGHTGRAY}; | ||
opacity: ${(props: { focused: boolean; }) => props.focused ? 1 : 0.5}; | ||
` | ||
|
||
const DotContainer = styled.View` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: center; | ||
` | ||
|
||
const SliderContainer = styled.View` | ||
display: flex; | ||
padding: 5px 20px; | ||
` | ||
|
||
export default Carousel; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useState, useEffect, useRef } from 'react'; | ||
import { View, Animated } from 'react-native'; | ||
import styled from 'styled-components/native'; | ||
import { BLACK, BLACK2 } from '../styles/GlobalColor'; | ||
|
||
interface SliderProps { | ||
total: number; | ||
page: number; | ||
} | ||
|
||
const Slider = ({ total, page }: SliderProps) => { | ||
const loaderValue = useRef(new Animated.Value(0)).current; | ||
|
||
const load = (count: number) => { | ||
Animated.timing(loaderValue, { | ||
toValue: (count / total) * 100, | ||
duration: 500, | ||
useNativeDriver: false, | ||
}).start(); | ||
}; | ||
|
||
const width = loaderValue.interpolate({ | ||
inputRange: [0, 100], | ||
outputRange: ['10%', '100%'], | ||
extrapolate: 'clamp' | ||
}); | ||
|
||
useEffect(() => { | ||
load(page) | ||
}, [page]); | ||
|
||
return ( | ||
<> | ||
<SliderBar> | ||
<Animated.View | ||
style={{ | ||
backgroundColor: BLACK, | ||
width, | ||
height: 3 | ||
}} | ||
/> | ||
</SliderBar> | ||
</> | ||
) | ||
} | ||
|
||
const SliderBar = styled.View` | ||
width: 100%; | ||
height: 3px; | ||
background: ${BLACK2}; | ||
` | ||
|
||
export default Slider; |
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,26 @@ | ||
import styled from 'styled-components/native'; | ||
import { PURPLE3 } from '../styles/GlobalColor'; | ||
import { Caption11M } from '../styles/GlobalText'; | ||
|
||
interface ThumbnailHashtagProps { | ||
value: string; | ||
} | ||
|
||
const ThumbnailHashtag = ({ value }: ThumbnailHashtagProps) => { | ||
return ( | ||
<Container> | ||
<Caption11M>{value}</Caption11M> | ||
</Container> | ||
) | ||
} | ||
|
||
const Container = styled.View` | ||
display: flex; | ||
padding: 4px 8px; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 4px; | ||
background: ${PURPLE3}; | ||
` | ||
|
||
export default ThumbnailHashtag; |
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
Oops, something went wrong.