Skip to content

Commit

Permalink
refactor: 학사일정 리팩토링
Browse files Browse the repository at this point in the history
* 학사일정에서 오늘이 해당되는 내용은 파란색으로 표시
* 학사일정 페이지에서 우측 상단에 현재 날짜 표시
  • Loading branch information
jcw1031 committed Sep 24, 2024
1 parent cf42550 commit 5a22617
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/calendar/components/CalendarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const CalendarItem = ({ item }: { item: ScheduleProps }) => {
<FontText fontWeight="500" style={[styles.date, { color: colors[theme].gray100 }]}>
{item.scheduleDate}
</FontText>
<FontText fontWeight="500" style={[styles.contents]}>{item.scheduleContents}</FontText>
<FontText fontWeight="500"
style={[styles.contents, { color: item.isToday ? colors.blue : colors[theme].contrast }]}>{item.scheduleContents}</FontText>
</View>
);
};
Expand Down
12 changes: 9 additions & 3 deletions app/calendar/components/ScheduleItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ const ScheduleItem = ({ schedule }: ScheduleItemProps) => {

return (
<View style={[styles.container, { borderLeftColor: colors[theme].contrast }]}>
<FontText fontWeight="500"
style={[styles.date, { color: colors[theme].gray100 }]}>{schedule.scheduleDate}</FontText>
<FontText fontWeight="500">{schedule.scheduleContents}</FontText>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<FontText fontWeight="500"
style={[styles.date, { color: colors[theme].gray100 }]}>
{schedule.scheduleDate}
</FontText>
</View>
<FontText fontWeight="500" style={{ color: schedule.isToday ? colors.blue : colors[theme].contrast }}>
{schedule.scheduleContents}
</FontText>
</View>
);
};
Expand Down
26 changes: 25 additions & 1 deletion app/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PageLayout from '@/common/components/PageLayout';
import { useTheme } from '@/common/contexts/ThemeContext';
import FontText from '@/common/text/FontText';
import colors from '@/constants/colors';
import { useEffect } from 'react';
import { SectionList, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

Expand All @@ -17,9 +18,32 @@ const CalendarPage = () => {
data: calendar.scheduleWrapper
})) : [];

const getCurrentDate = () => {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
const date = now.getDate();
const day = now.getDay();
return { year, month, date, day };
};

const getDayOfWeek = (day: number) => {
const days = ['일', '월', '화', '수', '목', '금', '토'];
return days[day];
};

const { year, month, date, day } = getCurrentDate();

return (
<PageLayout edges={['top']}>
<BackHeader title="학사일정" />
<BackHeader title="학사일정" button={
<View style={{ alignItems: 'flex-end' }}>
<FontText style={{ color: colors[theme].gray100 }}>{`${year}`}</FontText>
<FontText fontWeight="500" style={{ color: colors[theme].gray100 }}>
{`${month}${date}일(${getDayOfWeek(day)})`}
</FontText>
</View>
} />
<SectionList
contentContainerStyle={{ paddingHorizontal: 20, paddingBottom: bottom }}
sections={sectionedData}
Expand Down
1 change: 1 addition & 0 deletions types/calendarTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface ScheduleProps {
scheduleId: string;
scheduleContents: string;
scheduleDate: string;
isToday: boolean;
}

export interface CalendarProps {
Expand Down

0 comments on commit 5a22617

Please sign in to comment.