-
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.
- Loading branch information
Showing
7 changed files
with
163 additions
and
46 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
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
39 changes: 39 additions & 0 deletions
39
src/components/molecules/screens/library/LibraryRoomStatus.tsx
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,39 @@ | ||
import {useQuery} from '@tanstack/react-query'; | ||
import styled from '@emotion/native'; | ||
import {colors} from '@uoslife/design-system'; | ||
import {useState} from 'react'; | ||
import {UtilAPI} from '../../../../api/services'; | ||
import LibraryRoomItem from './LibraryRoomItem'; | ||
import usePullToRefresh from '../../../../hooks/usePullToRefresh'; | ||
import {LibraryRoomStatusTabsType} from '../../../../configs/utility/libraryTabs'; | ||
|
||
type Props = {roomType: LibraryRoomStatusTabsType}; | ||
|
||
const LibraryRoomStatus = ({roomType}: Props) => { | ||
const {data, refetch} = useQuery({ | ||
queryKey: ['getLibraryRoomStatus', roomType], | ||
queryFn: () => UtilAPI.getLibraryRoomStatus({type: roomType}), | ||
}); | ||
|
||
const {onRefresh, refreshing} = usePullToRefresh(() => refetch()); | ||
const [width, setWidth] = useState(0); | ||
return ( | ||
<S.Container | ||
data={data?.item} | ||
refreshing={refreshing} | ||
onRefresh={onRefresh} | ||
renderItem={({item}) => <LibraryRoomItem item={item} boxWidth={width} />} | ||
numColumns={2} | ||
onLayout={event => setWidth(event.nativeEvent.layout.width)} | ||
/> | ||
); | ||
}; | ||
|
||
export default LibraryRoomStatus; | ||
|
||
const S = { | ||
Container: styled.FlatList` | ||
padding: 8px 10px; | ||
background-color: ${colors.primaryLighterAlt}; | ||
`, | ||
}; |
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,8 +1,20 @@ | ||
export type LibraryTabsType = 'MY_SEAT' | 'SEAT_LIST' | 'RECORD'; | ||
export type LibraryTabsEnumType = Record<LibraryTabsType, string>; | ||
|
||
export type LibraryRoomStatusTabsType = 'ECONOMY' | 'LAW' | 'CENTRAL'; | ||
export type LibraryRoomStatusTabsEnumType = Record< | ||
LibraryRoomStatusTabsType, | ||
string | ||
>; | ||
|
||
export const LibraryTabsEnum: LibraryTabsEnumType = { | ||
MY_SEAT: '내자리', | ||
SEAT_LIST: '좌석', | ||
RECORD: '기록', | ||
}; | ||
|
||
export const LibraryRoomStatusTabsEnum: LibraryRoomStatusTabsEnumType = { | ||
CENTRAL: '중앙도서관', | ||
LAW: '법학전문도서관', | ||
ECONOMY: '경영경제도서관', | ||
}; |
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
58 changes: 53 additions & 5 deletions
58
src/screens/library/room_status/LibraryRoomStatusScreen.tsx
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,14 +1,62 @@ | ||
import {useMemo, useState} from 'react'; | ||
import {useNavigation} from '@react-navigation/native'; | ||
import {useSafeAreaInsets} from 'react-native-safe-area-context'; | ||
import { | ||
LibraryRoomStatusTabsEnum, | ||
LibraryRoomStatusTabsType, | ||
} from '../../../configs/utility/libraryTabs'; | ||
import {LibraryRoomStatusScreenProps} from '../../../navigators/types/library'; | ||
|
||
import Header from '../../../components/molecules/common/header/Header'; | ||
import TabView from '../../../components/molecules/common/tab_view/TabView'; | ||
import LibraryRoomStatus from '../../../components/molecules/screens/library/LibraryRoomStatus'; | ||
|
||
const LibraryRoomStatusScreen = ({ | ||
route: {params}, | ||
}: LibraryRoomStatusScreenProps) => { | ||
const initialRoomType = (params?.roomType ?? 'CENTRAL') satisfies | ||
| 'ECONOMY' | ||
| 'LAW' | ||
| 'CENTRAL'; | ||
const insets = useSafeAreaInsets(); | ||
const navigation = useNavigation(); | ||
const handleGoBack = () => { | ||
navigation.goBack(); | ||
}; | ||
const initialRoomType = (params?.roomType ?? | ||
'CENTRAL') satisfies LibraryRoomStatusTabsType; | ||
|
||
const initialIndex = useMemo( | ||
() => | ||
Object.keys(LibraryRoomStatusTabsEnum).findIndex(i => | ||
i.match(initialRoomType), | ||
), | ||
[initialRoomType], | ||
); | ||
const [index, setIndex] = useState(initialIndex); | ||
|
||
return <></>; | ||
return ( | ||
<> | ||
<Header | ||
label="도서관" | ||
onPressBackButton={handleGoBack} | ||
style={{paddingTop: insets.top}} | ||
/> | ||
<TabView index={index} setIndex={setIndex}> | ||
<TabView.Screen | ||
tabKey="CENTRAL" | ||
tabTitle={LibraryRoomStatusTabsEnum.CENTRAL} | ||
component={<LibraryRoomStatus roomType="CENTRAL" />} | ||
/> | ||
<TabView.Screen | ||
tabKey="LAW" | ||
tabTitle={LibraryRoomStatusTabsEnum.LAW} | ||
component={<LibraryRoomStatus roomType="LAW" />} | ||
/> | ||
<TabView.Screen | ||
tabKey="ECONOMY" | ||
tabTitle={LibraryRoomStatusTabsEnum.ECONOMY} | ||
component={<LibraryRoomStatus roomType="ECONOMY" />} | ||
/> | ||
</TabView> | ||
</> | ||
); | ||
}; | ||
|
||
export default LibraryRoomStatusScreen; |