Эх сурвалжийг харах

탭 이동후에도 상태 저장되도록 수정

jh-mac 7 сар өмнө
parent
commit
74c7614dca
4 өөрчлөгдсөн 109 нэмэгдсэн , 22 устгасан
  1. 38 0
      app/favorites.tsx
  2. 12 6
      app/index.tsx
  3. 21 16
      app/main.tsx
  4. 38 0
      app/myInfo.tsx

+ 38 - 0
app/favorites.tsx

@@ -0,0 +1,38 @@
+import React, { useState } from 'react';
+import {
+  View,
+  Text,
+  TextInput,
+  TouchableOpacity,
+  FlatList,
+  StyleSheet,
+  Dimensions,
+  KeyboardAvoidingView,
+  Platform,
+  Modal,
+  Keyboard,
+  StatusBar
+} from 'react-native';
+import { fetchSongs } from '@/service/api';
+import { addToFavoritesStorage } from '@/service/storage';
+import { Song, Criteria } from '@/types/song';
+import { API_FIELDS } from '@/constants/apiFields';
+import Loading from '@/components/Loading';
+
+interface Option {
+  label: string;
+  value: Criteria;
+}
+
+export default function FavoriteScreen() {
+  
+  return (
+    <View>
+      <Text>⭐즐겨찾기</Text>
+    </View>
+  );
+}
+
+const styles = StyleSheet.create({
+  
+});

+ 12 - 6
app/index.tsx

@@ -18,10 +18,14 @@ export default function IntroScreen() {
   useEffect(() => {
     const checkGuest = async () => {
       const isGuest = await AsyncStorage.getItem('isGuest');
-      if (isGuest === 'true') {
-        router.replace('/main');
-      }
+      router.replace('/main');
+
+      // TODO: Google Login 기능 구현시
+      // if (isGuest === 'true') {
+      //   router.replace('/main');
+      // }
     };
+    
     checkGuest();
   }, []);
 
@@ -46,9 +50,11 @@ export default function IntroScreen() {
         <TouchableOpacity style={styles.button} onPress={handleGuestStart}>
           <Text style={styles.buttonText}>게스트로 시작하기</Text>
         </TouchableOpacity>
-        <TouchableOpacity style={styles.buttonOutline} onPress={handleLoginPress}>
-          <Text style={styles.buttonOutlineText}>Gmail로 로그인</Text>
-        </TouchableOpacity>
+        
+        {/* TODO: Google 로그인 추후 구현 */}
+        {/*<TouchableOpacity style={styles.buttonOutline} onPress={handleLoginPress}>*/}
+        {/*  <Text style={styles.buttonOutlineText}>Gmail로 로그인</Text>*/}
+        {/*</TouchableOpacity>*/}
       </View>
     </View>
   );

+ 21 - 16
app/main.tsx

@@ -1,25 +1,26 @@
 import React, { useState } from 'react';
-import { View, Text, SafeAreaView, StyleSheet } from 'react-native';
-import SearchScreen from '@/app/seach.tsx';
+import { View, StyleSheet, SafeAreaView } from 'react-native';
+import SearchScreen from '@/app/seach';
 import BottomTabBar from '@/components/BottomTabBar';
+import FavoritesScreen from "@/app/favorites";
+import MyInfoScreen from "@/app/myInfo";
 
 export default function MainScreen() {
   const [tab, setTab] = useState<'search' | 'favorites' | 'settings'>('search');
 
-  const renderContent = () => {
-    switch (tab) {
-      case 'search':
-        return <SearchScreen />;
-      case 'favorites':
-        return <Text>⭐ 즐겨찾기 화면</Text>;
-      case 'settings':
-        return <Text>👤 내 설정 화면</Text>;
-    }
-  };
-
   return (
     <SafeAreaView style={styles.container}>
-      <View style={styles.content}>{renderContent()}</View>
+      <View style={styles.content}>
+        <View style={[styles.screen, tab !== 'search' && styles.hidden]}>
+          <SearchScreen />
+        </View>
+        <View style={[styles.screen, tab !== 'favorites' && styles.hidden]}>
+          <FavoritesScreen />
+        </View>
+        <View style={[styles.screen, tab !== 'settings' && styles.hidden]}>
+          <MyInfoScreen />
+        </View>
+      </View>
       <BottomTabBar activeTab={tab} onTabChange={setTab} />
     </SafeAreaView>
   );
@@ -32,7 +33,11 @@ const styles = StyleSheet.create({
   },
   content: {
     flex: 1,
-    justifyContent: 'center',
-    alignItems: 'center',
+  },
+  screen: {
+    ...StyleSheet.absoluteFillObject,
+  },
+  hidden: {
+    display: 'none',
   },
 });

+ 38 - 0
app/myInfo.tsx

@@ -0,0 +1,38 @@
+import React, { useState } from 'react';
+import {
+  View,
+  Text,
+  TextInput,
+  TouchableOpacity,
+  FlatList,
+  StyleSheet,
+  Dimensions,
+  KeyboardAvoidingView,
+  Platform,
+  Modal,
+  Keyboard,
+  StatusBar
+} from 'react-native';
+import { fetchSongs } from '@/service/api';
+import { addToFavoritesStorage } from '@/service/storage';
+import { Song, Criteria } from '@/types/song';
+import { API_FIELDS } from '@/constants/apiFields';
+import Loading from '@/components/Loading';
+
+interface Option {
+  label: string;
+  value: Criteria;
+}
+
+export default function MyInfoScreen() {
+  
+  return (
+    <View>
+      <Text>👤 내 설정 화면</Text>
+    </View>
+  );
+}
+
+const styles = StyleSheet.create({
+  
+});