-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into Feat/#3-HomeScreen
- Loading branch information
Showing
25 changed files
with
1,222 additions
and
64 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 |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import { View, Text } from "react-native"; | ||
import React from "react"; | ||
import { createNativeStackNavigator } from "@react-navigation/native-stack"; | ||
import FavoritesPage from "../favorites/FavoritesPage"; | ||
import FavoritesNoticePage from "../favorites/FavoritesNoticePage"; | ||
import FavoritesSchedulePage from "../favorites/FavoritesSchedulePage"; | ||
|
||
const FavoriteStack = createNativeStackNavigator(); | ||
|
||
export default function Favorites() { | ||
return ( | ||
<View> | ||
<Text>Favorites</Text> | ||
</View> | ||
<FavoriteStack.Navigator> | ||
<FavoriteStack.Screen | ||
name="Favorites" | ||
component={FavoritesPage} | ||
options={{ headerShown: false }} | ||
/> | ||
<FavoriteStack.Screen | ||
name="FavoritesSchedule" | ||
component={FavoritesSchedulePage} | ||
options={{ headerShown: false }} | ||
/> | ||
<FavoriteStack.Screen | ||
name="FavoritesNotice" | ||
component={FavoritesNoticePage} | ||
options={{ headerShown: false }} | ||
/> | ||
</FavoriteStack.Navigator> | ||
); | ||
} |
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,77 @@ | ||
import { Color } from "@/constants/Theme"; | ||
import React, { useEffect, useState } from "react"; | ||
import { View, ScrollView } from "react-native"; | ||
import { TCategoryKey, TCategorySearch } from "@/types/category"; | ||
import CategoryItem from "@/components/category/CategoryItem"; | ||
import { dummyFavoritesNotice } from "@/assets/data/dummyFavorites"; | ||
import FavoritesNoticeHeader from "@/components/header/FavoritesNoticeHeader"; | ||
|
||
const FavoritesNoticePage = () => { | ||
const [noticelist, setNoticeList] = useState<TCategorySearch>({}); //즐겨찾기한 공지사항 목록 | ||
const [categoryKeyList, setCategoryKeyList] = useState<TCategoryKey[]>([]); //카테고리 목록 | ||
const [selectedCategoryKey, setSelectedCategoryKey] = | ||
useState<TCategoryKey | null>(null); //선택한 카테고리 | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
setNoticeList(dummyFavoritesNotice); | ||
const keys = Object.keys(dummyFavoritesNotice) as TCategoryKey[]; | ||
setCategoryKeyList(keys); | ||
|
||
if (keys.length > 0) { | ||
setSelectedCategoryKey(keys[0]); | ||
} | ||
setIsLoading(false); | ||
}, []); | ||
|
||
const updateList = (id: number) => { | ||
setNoticeList((prevList) => { | ||
if (!prevList || !selectedCategoryKey || !prevList[selectedCategoryKey]) | ||
return prevList; | ||
|
||
const updatedCategoryItems = prevList[selectedCategoryKey].map((item) => | ||
item.id === id ? { ...item, marked: !item.marked } : item | ||
); | ||
|
||
return { | ||
...prevList, | ||
[selectedCategoryKey]: updatedCategoryItems, | ||
}; | ||
}); | ||
}; | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flex: 1, | ||
backgroundColor: Color.WHITE, | ||
}} | ||
> | ||
{!isLoading && ( | ||
<> | ||
<FavoritesNoticeHeader | ||
categoryKeyList={categoryKeyList} | ||
selectedCategoryKey={selectedCategoryKey} | ||
setSelectedCategoryKey={setSelectedCategoryKey} | ||
/> | ||
<ScrollView showsVerticalScrollIndicator={false}> | ||
<View style={{ paddingBottom: 100 }}> | ||
{selectedCategoryKey && | ||
noticelist[selectedCategoryKey] && | ||
noticelist[selectedCategoryKey].map((item, index) => ( | ||
<CategoryItem | ||
key={index} | ||
item={item} | ||
categoryKey={selectedCategoryKey} | ||
updateList={updateList} | ||
/> | ||
))} | ||
</View> | ||
</ScrollView> | ||
</> | ||
)} | ||
</View> | ||
); | ||
}; | ||
|
||
export default FavoritesNoticePage; |
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,83 @@ | ||
import { Color } from "@/constants/Theme"; | ||
import React, { useEffect, useState } from "react"; | ||
import { View, ScrollView } from "react-native"; | ||
import { | ||
dummyFavoritesRecentNotice, | ||
dummyRecentFavorites, | ||
} from "@/assets/data/dummyFavorites"; | ||
import { TFavoritesList, TFavoritesRecentNoticeList } from "@/types/favorites"; | ||
import FavoritesNoticeItem from "@/components/favorites/FavoritesNoticeItem"; | ||
import FavoritesHeader from "@/components/header/FavoritesHeader"; | ||
import FavoritesEmpty from "@/components/favorites/FavoritesEmpty"; | ||
import FavoritesHead from "@/components/favorites/FavoritesHead"; | ||
import FavoritesScheduleItem from "@/components/favorites/FavoritesScheduleItem"; | ||
|
||
const FavoritesPage = ({ navigation }: { navigation: any }) => { | ||
const [scheduleList, setScheduleList] = useState<TFavoritesList[]>([]); //최근 즐겨찾기한 학사일정 목록 | ||
const [noticelist, setNoticeList] = useState<TFavoritesRecentNoticeList[]>( | ||
[] | ||
); //최근 즐겨찾기한 공지사항 목록 | ||
|
||
useEffect(() => { | ||
const updatedFavorites = dummyRecentFavorites.map((item) => ({ | ||
...item, | ||
marked: true, | ||
})); | ||
|
||
setScheduleList(updatedFavorites); | ||
setNoticeList(dummyFavoritesRecentNotice); | ||
}, []); | ||
|
||
const updateList = (id: number) => { | ||
setScheduleList((prevList) => | ||
prevList.map((item) => | ||
item.id === id ? { ...item, marked: !item.marked } : item | ||
) | ||
); | ||
}; | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flex: 1, | ||
backgroundColor: Color.WHITE, | ||
}} | ||
> | ||
<FavoritesHeader navigation={navigation} /> | ||
<ScrollView showsVerticalScrollIndicator={false}> | ||
<FavoritesHead | ||
text="학사일정" | ||
isDisabled={scheduleList.length === 0} | ||
onPress={() => navigation.navigate("FavoritesSchedule")} | ||
/> | ||
{scheduleList.length > 0 ? ( | ||
scheduleList.map((item, index) => { | ||
return ( | ||
<FavoritesScheduleItem | ||
key={index} | ||
item={item} | ||
updateList={updateList} | ||
/> | ||
); | ||
}) | ||
) : ( | ||
<FavoritesEmpty text="학사일정" /> | ||
)} | ||
<FavoritesHead | ||
text="공지사항" | ||
isDisabled={noticelist.length === 0} | ||
onPress={() => navigation.navigate("FavoritesNotice")} | ||
/> | ||
{noticelist.length > 0 ? ( | ||
noticelist.map((item, index) => { | ||
return <FavoritesNoticeItem key={index} item={item} />; | ||
}) | ||
) : ( | ||
<FavoritesEmpty text="공지사항" /> | ||
)} | ||
</ScrollView> | ||
</View> | ||
); | ||
}; | ||
|
||
export default FavoritesPage; |
Oops, something went wrong.