Skip to content

Commit

Permalink
Merge branch 'main' into feature/quick-task-screen-frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
patela22 authored Mar 19, 2024
2 parents 0725f88 + dde6f4d commit 32a8be4
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 6 deletions.
4 changes: 3 additions & 1 deletion backend/db/migrations/1.user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ VALUES
('onrQs8HVGBVMPNz4Fk1uE94bSxg1', 'Danny', 'Rollo', '[email protected]', '', ''),
('8Sy7xBkGiGQv4ZKphcQfY8PxAqw1', 'Narayan', 'Sharma', '[email protected]', '', ''),
('iL7PnjS4axQffmlPceobjUUZ9DF2', 'Caitlin', 'Flynn', '[email protected]', '', ''),
('5JgN2PQxCRM9VoCiiFPlQPNqkL32', 'Linwood', 'Blaisdell', '[email protected]', '', '')
('5JgN2PQxCRM9VoCiiFPlQPNqkL32', 'Linwood', 'Blaisdell', '[email protected]', '', ''),
('9rIMSUo6qNf8ToTABkCfNqnByRv1', 'Haley', 'Martin', '[email protected]', '', '')

-- End Care-Wallet Team
;
4 changes: 3 additions & 1 deletion backend/db/migrations/2.group.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ VALUES
(5, 'mPeo3d3MiXfnpPJADWgFD9ZcB2M2', 'SECONDARY'),
(5, 'onrQs8HVGBVMPNz4Fk1uE94bSxg1', 'SECONDARY'),
(5, '8Sy7xBkGiGQv4ZKphcQfY8PxAqw1', 'SECONDARY'),
(5, 'iL7PnjS4axQffmlPceobjUUZ9DF2', 'SECONDARY')
(5, 'iL7PnjS4axQffmlPceobjUUZ9DF2', 'SECONDARY'),
(5, '9rIMSUo6qNf8ToTABkCfNqnByRv1', 'SECONDARY')

-- End Care-Wallet Team
;
6 changes: 6 additions & 0 deletions client/assets/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useNavigation } from '@react-navigation/native';
import { IconButton } from 'react-native-paper';

import BackArrow from '../../assets/back-arrow.svg';
import { AppStackNavigation } from '../../navigation/AppNavigation';
import { AppStackNavigation } from '../../navigation/types';

export function BackButton() {
const navigation = useNavigation<AppStackNavigation>();
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion client/navigation/AppStackBottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Bell from '../assets/bottom-nav/bell.svg';
import Calendar from '../assets/bottom-nav/calendar.svg';
import Home from '../assets/bottom-nav/home.svg';
import User from '../assets/bottom-nav/user.svg';
import TimelineCalendarScreen from '../screens/Calendar';
import MedicationList from '../screens/MedicationList';
import PatientView from '../screens/Profile/PatientView';
import Profile from '../screens/Profile/Profile';
Expand Down Expand Up @@ -39,7 +40,7 @@ export function AppStackBottomTabNavigator() {
tabBarIcon: ({ color }) => <Calendar color={color} />,
tabBarLabel: () => <Text></Text>
}}
component={QuickTasks}
component={TimelineCalendarScreen}
/>
<AppStackBottomTab.Screen
name="Notifications"
Expand Down
6 changes: 6 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@
"@types/react": "^18.2.55",
"axios": "^1.6.4",
"clsx": "^2.1.0",
"date-fns": "^3.3.1",
"expo": "50.0.6",
"expo": "^50.0.11",
"expo-document-picker": "~11.10.1",
"expo-file-system": "~16.0.6",
"expo-status-bar": "~1.11.1",
"firebase": "^10.7.2",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"nativewind": "^2.0.11",
"react": "18.2.0",
"react-native": "0.73.4",
"react-native-calendars": "^1.1303.0",
"react-native-dropdown-picker": "^5.4.6",
"react-native-gesture-handler": "~2.14.0",
"react-native-paper": "^5.12.3",
Expand All @@ -43,6 +48,7 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/lodash": "^4.14.202",
"@types/react-native": "^0.73.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "6.18.0",
Expand Down
155 changes: 155 additions & 0 deletions client/screens/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import React, { useState } from 'react';
import { Alert } from 'react-native';

import _ from 'lodash';
import {
CalendarProvider,
CalendarUtils,
DateData,
ExpandableCalendar,
TimelineEventProps,
TimelineList,
TimelineProps
} from 'react-native-calendars';
import { UpdateSources } from 'react-native-calendars/src/expandableCalendar/commons';

import { getDate, timelineEvents } from './timelineEvents';

const INITIAL_TIME = { hour: 9, minutes: 0 };
const EVENTS: TimelineEventProps[] = timelineEvents;

export default function TimelineCalendarScreen() {
const [currentDate, setCurrentDate] = useState(getDate());
const [eventsByDate, setEventsByDate] = useState(
_.groupBy(EVENTS, (e) => CalendarUtils.getCalendarDateString(e.start))
);

const marked = {
[`${getDate(-1)}`]: { marked: true },
[`${getDate()}`]: { marked: true },
[`${getDate(1)}`]: { marked: true },
[`${getDate(2)}`]: { marked: true },
[`${getDate(4)}`]: { marked: true }
};

const onDateChanged = (date: string, source: string) => {
console.log('TimelineCalendarScreen onDateChanged: ', date, source);
setCurrentDate(date);
};

const onMonthChange = (month: DateData, updateSource: UpdateSources) => {
console.log('TimelineCalendarScreen onMonthChange: ', month, updateSource);
};

const createNewEvent: TimelineProps['onBackgroundLongPress'] = (
timeString,
timeObject
) => {
const hourString = `${(timeObject.hour + 1).toString().padStart(2, '0')}`;
const minutesString = `${timeObject.minutes.toString().padStart(2, '0')}`;

const newEvent = {
id: 'draft',
start: `${timeString}`,
end: `${timeObject.date} ${hourString}:${minutesString}:00`,
title: 'New Event',
color: 'white'
};

if (timeObject.date) {
if (eventsByDate[timeObject.date]) {
setEventsByDate((prevEvents) => ({
...prevEvents,
[timeObject.date as string]: [
...prevEvents[timeObject.date as string],
newEvent
]
}));
} else {
setEventsByDate((prevEvents) => ({
...prevEvents,
[timeObject.date as string]: [newEvent]
}));
}
}
};

const approveNewEvent: TimelineProps['onBackgroundLongPressOut'] = (
_timeString,
timeObject
) => {
Alert.prompt('New Event', 'Enter event title', [
{
text: 'Cancel',
onPress: () => {
if (timeObject.date) {
setEventsByDate((prevEvents) => ({
...prevEvents,
[timeObject.date as string]: _.filter(
prevEvents[timeObject.date as string],
(e) => e.id !== 'draft'
)
}));
}
}
},
{
text: 'Create',
onPress: (eventTitle) => {
if (timeObject.date) {
const draftEvent = _.find(eventsByDate[timeObject.date], {
id: 'draft'
});
if (draftEvent) {
draftEvent.id = undefined;
draftEvent.title = eventTitle ?? 'New Event';
draftEvent.color = 'lightgreen';
setEventsByDate((prevEvents) => ({
...prevEvents,
[timeObject.date as string]: [
...prevEvents[timeObject.date as string]
]
}));
}
}
}
}
]);
};

const timelineProps: Partial<TimelineProps> = {
format24h: false,
onBackgroundLongPress: createNewEvent,
onBackgroundLongPressOut: approveNewEvent,
unavailableHours: [
{ start: 0, end: 6 },
{ start: 22, end: 24 }
],
onEventPress: (e) => expandEvent(e),
overlapEventsSpacing: 8,
rightEdgeSpacing: 24
};

return (
<CalendarProvider
date={currentDate}
onDateChanged={onDateChanged}
onMonthChange={onMonthChange}
showTodayButton
disabledOpacity={0.6}
>
<ExpandableCalendar firstDay={1} markedDates={marked} />
<TimelineList
events={eventsByDate}
timelineProps={timelineProps}
showNowIndicator
scrollToFirst
initialTime={INITIAL_TIME}
/>
</CalendarProvider>
);
}

function expandEvent(e: TimelineEventProps): void {
console.log('expand event', e.title);
}
4 changes: 2 additions & 2 deletions client/screens/TaskType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import DropDownPicker from 'react-native-dropdown-picker';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Button, Text } from 'react-native-paper';

import { BackButton } from '../components/TaskType/BackButton';
import { CloseButton } from '../components/TaskType/CloseButton';
import { BackButton } from '../components/task-type/BackButton';
import { CloseButton } from '../components/task-type/CloseButton';
import { AppStackNavigation } from '../navigation/types';
import { Category, categoryToTypeMap, TypeOfTask } from '../types/type';

Expand Down
123 changes: 123 additions & 0 deletions client/screens/timelineEvents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { CalendarUtils, TimelineEventProps } from 'react-native-calendars';

const EVENT_COLOR = '#e6add8';
const today = new Date();
export const getDate = (offset = 0) =>
CalendarUtils.getCalendarDateString(
new Date().setDate(today.getDate() + offset)
);

export const timelineEvents: TimelineEventProps[] = [
{
start: `${getDate(-1)} 09:20:00`,
end: `${getDate(-1)} 12:00:00`,
title: 'Merge Request to React Native Calendars',
summary: 'Merge Timeline Calendar to React Native Calendars'
},
{
start: `${getDate()} 01:15:00`,
end: `${getDate()} 02:30:00`,
title: 'Meeting A',
summary: 'Summary for meeting A',
color: EVENT_COLOR
},
{
start: `${getDate()} 01:30:00`,
end: `${getDate()} 02:30:00`,
title: 'Meeting B',
summary: 'Summary for meeting B',
color: EVENT_COLOR
},
{
start: `${getDate()} 01:45:00`,
end: `${getDate()} 02:45:00`,
title: 'Meeting C',
summary: 'Summary for meeting C',
color: EVENT_COLOR
},
{
start: `${getDate()} 02:40:00`,
end: `${getDate()} 03:10:00`,
title: 'Meeting D',
summary: 'Summary for meeting D',
color: EVENT_COLOR
},
{
start: `${getDate()} 02:50:00`,
end: `${getDate()} 03:20:00`,
title: 'Meeting E',
summary: 'Summary for meeting E',
color: EVENT_COLOR
},
{
start: `${getDate()} 04:30:00`,
end: `${getDate()} 05:30:00`,
title: 'Meeting F',
summary: 'Summary for meeting F',
color: EVENT_COLOR
},
{
start: `${getDate(1)} 00:30:00`,
end: `${getDate(1)} 01:30:00`,
title: 'Visit Grand Mother',
summary: 'Visit Grand Mother and bring some fruits.',
color: 'lightblue'
},
{
start: `${getDate(1)} 02:30:00`,
end: `${getDate(1)} 03:20:00`,
title: 'Meeting with Prof. Behjet Zuhaira',
summary: 'Meeting with Prof. Behjet at 130 in her office.',
color: EVENT_COLOR
},
{
start: `${getDate(1)} 04:10:00`,
end: `${getDate(1)} 04:40:00`,
title: 'Tea Time with Dr. Hasan',
summary: 'Tea Time with Dr. Hasan, Talk about Project'
},
{
start: `${getDate(1)} 01:05:00`,
end: `${getDate(1)} 01:35:00`,
title: 'Dr. Mariana Joseph',
summary: '3412 Piedmont Rd NE, GA 3032'
},
{
start: `${getDate(1)} 14:30:00`,
end: `${getDate(1)} 16:30:00`,
title: 'Meeting Some Friends in ARMED',
summary: 'Arsalan, Hasnaat, Talha, Waleed, Bilal',
color: 'pink'
},
{
start: `${getDate(2)} 01:40:00`,
end: `${getDate(2)} 02:25:00`,
title: 'Meet Sir Khurram Iqbal',
summary: 'Computer Science Dept. Comsats Islamabad',
color: 'orange'
},
{
start: `${getDate(2)} 04:10:00`,
end: `${getDate(2)} 04:40:00`,
title: 'Tea Time with Colleagues',
summary: 'WeRplay'
},
{
start: `${getDate(2)} 00:45:00`,
end: `${getDate(2)} 01:45:00`,
title: 'Lets Play Apex Legends',
summary: 'with Boys at Work'
},
{
start: `${getDate(2)} 11:30:00`,
end: `${getDate(2)} 12:30:00`,
title: 'Dr. Mariana Joseph',
summary: '3412 Piedmont Rd NE, GA 3032'
},
{
start: `${getDate(4)} 12:10:00`,
end: `${getDate(4)} 13:45:00`,
title: 'Merge Request to React Native Calendars',
summary: 'Merge Timeline Calendar to React Native Calendars'
}
];

0 comments on commit 32a8be4

Please sign in to comment.