From 93fab2a6caf2afb600aa6cf2be6b69364a9d01a6 Mon Sep 17 00:00:00 2001 From: SJ-Kwak Date: Sat, 27 Jan 2024 15:39:54 +0900 Subject: [PATCH] sdp-tech#11 feat: add heart, footer, bottom button component --- src/assets/common/Heart.svg | 3 ++ src/common/BottomButton.tsx | 30 +++++++++++++++++++ src/common/Footer.tsx | 31 ++++++++++++++++++++ src/common/Hashtag.tsx | 7 +++-- src/common/HeartButton.tsx | 19 ++++++++++++ src/components/Home/Market/MarketTabView.tsx | 6 ++-- 6 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 src/assets/common/Heart.svg create mode 100644 src/common/BottomButton.tsx create mode 100644 src/common/Footer.tsx create mode 100644 src/common/HeartButton.tsx diff --git a/src/assets/common/Heart.svg b/src/assets/common/Heart.svg new file mode 100644 index 0000000..7bbebef --- /dev/null +++ b/src/assets/common/Heart.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/common/BottomButton.tsx b/src/common/BottomButton.tsx new file mode 100644 index 0000000..ca86198 --- /dev/null +++ b/src/common/BottomButton.tsx @@ -0,0 +1,30 @@ +import { useState } from 'react'; +import { View, TouchableOpacity } from 'react-native'; +import styled from 'styled-components/native'; +import { Body16M } from '../styles/GlobalText'; +import { PURPLE, GREEN } from '../styles/GlobalColor'; + +interface BottomButtonParams { + value: string; + pressed: boolean; + onPress: () => void; +} + +const BottomButton = ({ value, pressed, onPress }: BottomButtonParams) => { + return ( + + {value} + + ) +} + +const ButtonContainer = styled.TouchableOpacity<{ pressed: boolean }>` + display: flex; + align-items: center; + justify-content: center; + border-radius: 8px; + padding: 10px 90px; + background-color: ${(props: { pressed: boolean; }) => props.pressed ? GREEN : PURPLE}; +` + +export default BottomButton; \ No newline at end of file diff --git a/src/common/Footer.tsx b/src/common/Footer.tsx new file mode 100644 index 0000000..b3cbc9f --- /dev/null +++ b/src/common/Footer.tsx @@ -0,0 +1,31 @@ +import { useState } from 'react'; +import styled from 'styled-components/native'; +import HeartButton from './HeartButton'; +import BottomButton from './BottomButton'; + +const Footer = () => { + // API 연결 전, 인터랙션만 + const [like, setLike] = useState(false); + const [pressed, setPressed] = useState(false); + return ( + + setLike(!like)} /> + setPressed(!pressed)} /> + + ) +} + +const FooterContainer = styled.View` + position: absolute; + bottom: 0px; + width: 100%; + display: flex; + flex-direction: row; + flex: 1; + align-items: center; + justify-content: space-between; + background-color: white; + padding: 5px 15px; +` + +export default Footer; \ No newline at end of file diff --git a/src/common/Hashtag.tsx b/src/common/Hashtag.tsx index f7b2643..1c53dd3 100644 --- a/src/common/Hashtag.tsx +++ b/src/common/Hashtag.tsx @@ -7,12 +7,13 @@ import { PURPLE } from '../styles/GlobalColor'; interface HashtagParams { value: string; pressable?: boolean; + pressed?: boolean; + onPress?: () => void; } -const Hashtag = ({value, pressable} : HashtagParams) => { - const [pressed, setPressed] = useState(false); +const Hashtag = ({value, pressable, pressed, onPress} : HashtagParams) => { return ( - setPressed(!pressed)} disabled={!pressable}> + {value} ) diff --git a/src/common/HeartButton.tsx b/src/common/HeartButton.tsx new file mode 100644 index 0000000..682c082 --- /dev/null +++ b/src/common/HeartButton.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { TouchableOpacity } from 'react-native'; +import Heart from '../assets/common/Heart.svg'; +import { PURPLE } from '../styles/GlobalColor'; + +interface HeartProps { + like: boolean; + onPress: () => void; +} + +const HeartButton = ({ like, onPress }: HeartProps) => { + return ( + + + + ) +} + +export default HeartButton; \ No newline at end of file diff --git a/src/components/Home/Market/MarketTabView.tsx b/src/components/Home/Market/MarketTabView.tsx index 380ef0c..5623119 100644 --- a/src/components/Home/Market/MarketTabView.tsx +++ b/src/components/Home/Market/MarketTabView.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { SafeAreaView, ScrollView, View, Text, TouchableOpacity, useWindowDimensions } from 'react-native'; +import { SafeAreaView, ScrollView, View, FlatList, Text, TouchableOpacity, useWindowDimensions } from 'react-native'; import styled from 'styled-components/native'; import { TabView, TabBar, SceneMap } from "react-native-tab-view"; import { Title20B, Body14R, Caption11M } from '../../../styles/GlobalText.tsx'; @@ -7,8 +7,9 @@ import { Title20B, Body14R, Caption11M } from '../../../styles/GlobalText.tsx'; import { StackScreenProps } from '@react-navigation/stack'; import { HomeStackParams } from '../../../pages/Home'; +import Footer from '../../../common/Footer.tsx'; + import LeftArrow from '../../../assets/common/LeftArrow.svg'; -import { FlatList } from 'react-native-gesture-handler'; import Hashtag from '../../../common/Hashtag.tsx'; const ProfileSection = () => { @@ -113,6 +114,7 @@ const MarketTabView = ({ navigation, route } : StackScreenProps )} /> +