Skip to content

Commit

Permalink
Feat/dnd-side-project#41 TabBar를 가리는 기능을 추가합니다. (dnd-side-project#45)
Browse files Browse the repository at this point in the history
* fix: buttonStyle을 변경합니다.

* Normalize all line endings to LF

* feat: TabBar를 가리는 기능을 추가합니다.

* refactor: 커스텀 훅으로 분리합니다.
  • Loading branch information
Zero-1016 committed Sep 26, 2024
1 parent c5fedbd commit 49e2b0e
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
7 changes: 7 additions & 0 deletions app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MAIN_NAVIGATIONS } from '@/constants';
import { SITE_URLS } from '@/constants';
import { useSession } from '@/store';
import { useOnboarding } from '@/store/useOnboarding';
import useTabBar from '@/store/useTabBar';

const tabBarOptions = {
[MAIN_NAVIGATIONS.HOME]: {
Expand Down Expand Up @@ -56,6 +57,12 @@ const tabBarOptions = {
};

const TabBar = ({ state, descriptors, navigation }: BottomTabBarProps) => {
const isVisible = useTabBar((state) => state.isVisible);

if (!isVisible) {
return null;
}

return (
<S.TabBar>
{state.routes.map((route, index) => {
Expand Down
55 changes: 45 additions & 10 deletions app/(app)/project/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,63 @@
import { Stack } from 'expo-router';
import { AntDesign, Feather } from '@expo/vector-icons';
import { Stack, useRouter } from 'expo-router';
import { Pressable } from 'react-native';

import { PROJECT_NAVIGATIONS } from '@/constants';
import { color } from '@/styles/theme';

import * as S from './layout.style';

function Layout() {
const router = useRouter();
return (
<Stack>
<Stack
screenOptions={() => ({
headerStyle: { height: 40, backgroundColor: color.Background.Alternative },
headerTitleStyle: {
paddingTop: 12,
fontFamily: 'Pretendard-Bold',
},
headerTitleAlign: 'center',
headerShadowVisible: false,
})}>
<Stack.Screen
name={PROJECT_NAVIGATIONS.HOME}
options={{
title: '프로젝트',
headerTitleStyle: {
fontFamily: 'Pretendard',
fontWeight: 'bold',
},
headerLeft: () => null,
headerRight: () => (
<S.ButtonGroup>
<Pressable>
<AntDesign
name='search1'
size={24}
/>
</Pressable>
<Pressable onPress={() => router.push('/project/create')}>
<AntDesign
name='plus'
size={24}
/>
</Pressable>
</S.ButtonGroup>
),
}}
/>
<Stack.Screen
name={PROJECT_NAVIGATIONS.CREATE}
options={{
animation: 'flip',
title: '프로젝트 등록',
headerTitleStyle: {
fontFamily: 'Pretendard',
fontWeight: 'bold',
},
headerLeft: ({ canGoBack }) => (
<S.ButtonGroup>
<Pressable onPress={() => (canGoBack ? router.back() : router.push('/project'))}>
<Feather
name='chevron-left'
size={24}
/>
</Pressable>
</S.ButtonGroup>
),
}}
/>
</Stack>
Expand Down
17 changes: 13 additions & 4 deletions app/(app)/project/create.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { View } from 'react-native';
import { SafeAreaView } from 'react-native';

import Typography from '@/components/common/typography';
import { useTabBarEffect } from '@/hooks';
import { color } from '@/styles/theme';
import { getSize } from '@/utils';

function Create() {
useTabBarEffect();
return (
<View>
<Typography>Create</Typography>
</View>
<SafeAreaView
style={{
flex: 1,
backgroundColor: color.Background.Alternative,
height: getSize.screenHeight,
}}>
<Typography>프로젝트 생성</Typography>
</SafeAreaView>
);
}

Expand Down
3 changes: 2 additions & 1 deletion app/(app)/project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SafeAreaView } from 'react-native';

import ProjectInviteModal from '@/components/project/ProjectInviteModal';
import ProjectList from '@/components/project/ProjectList';
import { color } from '@/styles/theme';

function Project() {
const [visible, setVisible] = useState(false);
Expand Down Expand Up @@ -97,7 +98,7 @@ function Project() {
];

return (
<SafeAreaView style={{ flex: 1 }}>
<SafeAreaView style={{ flex: 1, backgroundColor: color.Background.Alternative }}>
<ProjectInviteModal
project_name={data.project_name}
project_profile={data.project_profile}
Expand Down
9 changes: 9 additions & 0 deletions app/(app)/project/layout.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from '@emotion/native';

import { flexDirectionRow } from '@/styles/common';

export const ButtonGroup = styled.View`
${flexDirectionRow};
gap: 10px;
padding: 20px 20px 8px;
`;
Binary file modified assets/images/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/onboarding-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/partial-react-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/react-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/react-logo@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/react-logo@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './useAppOpen';
export * from './useStorageState';
export * from './useTabBarEffect';
1 change: 0 additions & 1 deletion src/hooks/useButtonStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export function useButtonStyle(size: ButtonProps['size']) {
iconSize: number;
}>(() => {
switch (size) {
case 'full':
case 'large':
return { textSize: 'Body1/Normal', iconSize: 16 };
case 'medium':
Expand Down
13 changes: 13 additions & 0 deletions src/hooks/useTabBarEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useLayoutEffect } from 'react';

import useTabBar from '@/store/useTabBar';

export function useTabBarEffect() {
const { hideTabBar, showTabBar } = useTabBar();

useLayoutEffect(() => {
hideTabBar();

return () => showTabBar();
}, [hideTabBar, showTabBar]);
}
15 changes: 15 additions & 0 deletions src/store/useTabBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { create } from 'zustand';

type TabBarStore = {
isVisible: boolean;
showTabBar: () => void;
hideTabBar: () => void;
};

const useTabBar = create<TabBarStore>((set) => ({
isVisible: true,
showTabBar: () => set({ isVisible: true }),
hideTabBar: () => set({ isVisible: false }),
}));

export default useTabBar;

0 comments on commit 49e2b0e

Please sign in to comment.