diff --git a/src/components/blocks/BottomTabBar.tsx b/src/components/blocks/BottomTabBar.tsx index d565531..852b48f 100644 --- a/src/components/blocks/BottomTabBar.tsx +++ b/src/components/blocks/BottomTabBar.tsx @@ -1,13 +1,16 @@ import styled from "styled-components/native"; -import { useContext, useState } from "react"; -import { InsetsContext } from "../../utils/context"; +import { useContext, useEffect, useState } from "react"; +import { InsetsContext, ScrollContext } from "../../utils/context"; import { Insets } from "../../utils"; import Icon from "../../utils/icon"; import { Shadow } from "react-native-shadow-2"; import { useNavigation } from "@react-navigation/native"; -const TabContainer = styled.View` +export const TabContainer = styled.View` width: 100%; + position: absolute; + bottom: 0; + opacity: ${(props: { opacity: number }) => props.opacity}; height: ${(props: { insets: Insets }) => 60 + props.insets.bottom}px; background-color: #fff; flex-direction: row; @@ -52,16 +55,25 @@ const BottomTabBar = () => { const navigation = useNavigation(); const [curScreen, setCurScreen] = useState("Home"); + const [opacity, setOpacity] = useState(1); const { insets } = useContext(InsetsContext); + const { scrollY } = useContext(ScrollContext); const NavigateBTnOnPress = (screenName: string) => { // @ts-ignore navigation.navigate(screenName); setCurScreen(screenName); }; + + // useEffect(() => { + // // if (opacity >= 0 && opacity <= 1) { + // // setOpacity((prev) => prev - scrollY / 50); + // // } + // console.log(scrollY); + // }, [scrollY]); return ( - + NavigateBTnOnPress("Home")}> diff --git a/src/components/screens/Card.tsx b/src/components/screens/Card.tsx index b87054f..da4d352 100644 --- a/src/components/screens/Card.tsx +++ b/src/components/screens/Card.tsx @@ -3,19 +3,33 @@ import styled from "styled-components/native"; import Babb from "../blocks/Babb"; import { Dimensions } from "react-native"; import BabbInfo from "../blocks/BabbInfo"; +import { useContext, useState } from "react"; +import { ScrollContext } from "../../utils/context"; const { width, height } = Dimensions.get("window"); const Container = styled.View` width: ${width}px; - margin-bottom: 25px; `; const ContentContainer = styled.FlatList``; +const Footer = styled.View` + height: 25px; +`; const Card = ({ babb }: { babb: BabbProps }) => { + const { setScrollY } = useContext(ScrollContext); + const [scrollYState, setScrollYState] = useState(0); + const [prevScrollY, setPrevScrollY] = useState(0); return ( { + //console.log(e.nativeEvent.contentOffset.y); + // 스크롤의 변화량을 계산하여 Context에 저장. + //console.log(e.nativeEvent.contentOffset.y - prevScrollY); + // setScrollYState((prev) => e.nativeEvent.contentOffset.y - prev); + // setScrollY(scrollYState); + }} data={babb.comment} ListHeaderComponent={() => ( <> @@ -29,6 +43,7 @@ const Card = ({ babb }: { babb: BabbProps }) => { )} + ListFooterComponent={() =>