-
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 'main' into feature/quick-task-screen-frontend
- Loading branch information
Showing
11 changed files
with
276 additions
and
5 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,20 @@ | ||
import React from 'react'; | ||
|
||
import { useNavigation } from '@react-navigation/native'; | ||
import { IconButton } from 'react-native-paper'; | ||
|
||
import BackArrow from '../../assets/back-arrow.svg'; | ||
import { AppStackNavigation } from '../../navigation/AppNavigation'; | ||
|
||
export function BackButton() { | ||
const navigation = useNavigation<AppStackNavigation>(); | ||
|
||
return ( | ||
<IconButton | ||
className="align-center m-2 flex h-[50px] w-[52px] justify-center rounded-xl bg-carewallet-gray" | ||
mode="contained" | ||
icon={({ color }) => <BackArrow fill={color} />} | ||
onPress={() => navigation.goBack()} | ||
/> | ||
); | ||
} |
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,16 @@ | ||
import React from 'react'; | ||
|
||
import { IconButton } from 'react-native-paper'; | ||
|
||
import Close from '../../assets/close.svg'; | ||
|
||
export function CloseButton({ onPress }: { onPress: () => void }) { | ||
return ( | ||
<IconButton | ||
className="align-center m-2 flex h-[50px] w-[52px] justify-center rounded-xl bg-carewallet-gray" | ||
mode="contained" | ||
icon={Close} | ||
onPress={onPress} | ||
/> | ||
); | ||
} |
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,151 @@ | ||
import React, { | ||
useCallback, | ||
useEffect, | ||
useMemo, | ||
useRef, | ||
useState | ||
} from 'react'; | ||
import { FlatList, View } from 'react-native'; | ||
|
||
import BottomSheet, { | ||
BottomSheetBackdrop, | ||
TouchableOpacity | ||
} from '@gorhom/bottom-sheet'; | ||
import { BottomSheetDefaultBackdropProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetBackdrop/types'; | ||
import { useNavigation } from '@react-navigation/native'; | ||
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 { AppStackNavigation } from '../navigation/AppNavigation'; | ||
import { Category, categoryToTypeMap, TypeOfTask } from '../types/type'; | ||
|
||
export function TaskType() { | ||
const navigation = useNavigation<AppStackNavigation>(); | ||
|
||
const [open, setOpen] = useState(false); | ||
const [selectedCategory, setSelectedCategory] = useState<null | Category>( | ||
null | ||
); | ||
const [selectedTypes, setSelectedTypes] = useState<TypeOfTask[]>( | ||
Object.values(TypeOfTask) | ||
); | ||
|
||
useEffect(() => { | ||
setSelectedTypes( | ||
selectedCategory | ||
? categoryToTypeMap[selectedCategory] | ||
: Object.values(TypeOfTask) | ||
); | ||
}, [selectedCategory]); | ||
|
||
const filters = Object.values(Category).map((filter) => ({ | ||
label: filter, | ||
value: filter | ||
})); | ||
|
||
const bottomSheetSnapPoints = useMemo(() => ['60%'], []); | ||
|
||
const bottomSheetRef = useRef<BottomSheet>(null); | ||
|
||
const closeBottomSheet = () => { | ||
if (bottomSheetRef.current) { | ||
bottomSheetRef.current.close(); // Close the BottomSheet | ||
} | ||
}; | ||
|
||
const snapToIndex = (index: number) => | ||
bottomSheetRef.current?.snapToIndex(index); | ||
|
||
const renderBackdrop = useCallback( | ||
(props: BottomSheetDefaultBackdropProps) => ( | ||
<BottomSheetBackdrop | ||
appearsOnIndex={0} | ||
disappearsOnIndex={-1} | ||
{...props} | ||
/> | ||
), | ||
[] | ||
); | ||
|
||
return ( | ||
<GestureHandlerRootView className="mt-10"> | ||
<View className="flex w-full flex-row items-center justify-center"> | ||
<View className="mr-[95px]"> | ||
<BackButton /> | ||
</View> | ||
<Text className="mr-auto self-center text-center text-carewallet-gray"> | ||
Step 1 of 2 | ||
</Text> | ||
</View> | ||
|
||
<Text className="text-center text-2xl font-bold">Type of Task</Text> | ||
<View className="mr-2 flex flex-row justify-end"> | ||
<Button | ||
className="h-[40px] items-center justify-center rounded-xl text-sm" | ||
textColor="black" | ||
mode="outlined" | ||
onPress={() => snapToIndex(0)} | ||
> | ||
Filter | ||
</Button> | ||
</View> | ||
|
||
<FlatList | ||
className="h-full" | ||
data={selectedTypes} | ||
renderItem={({ item }) => ( | ||
<TouchableOpacity | ||
className="m-2 h-[50px] overflow-hidden rounded-xl" | ||
onPress={() => navigation.navigate('New ' + item + ' Task')} | ||
> | ||
<Button | ||
className="m-2 h-[50px] items-center justify-center rounded-xl" | ||
textColor="black" | ||
mode="outlined" | ||
> | ||
{item} | ||
</Button> | ||
</TouchableOpacity> | ||
)} | ||
/> | ||
|
||
<BottomSheet | ||
ref={bottomSheetRef} | ||
index={-1} | ||
snapPoints={bottomSheetSnapPoints} | ||
enablePanDownToClose={true} | ||
backdropComponent={renderBackdrop} | ||
> | ||
<View> | ||
<View className="flex flex-row justify-between"> | ||
<Text className="m-5 text-2xl font-bold">Filter</Text> | ||
<CloseButton onPress={closeBottomSheet} /> | ||
</View> | ||
|
||
<DropDownPicker | ||
open={open} | ||
value={selectedCategory} | ||
items={filters} | ||
setOpen={setOpen} | ||
setValue={setSelectedCategory} | ||
placeholder="Category" | ||
onSelectItem={() => { | ||
closeBottomSheet(); | ||
}} | ||
style={{ | ||
width: '95%', | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
borderRadius: 0, | ||
borderColor: 'transparent', | ||
borderBottomColor: 'black' | ||
}} | ||
/> | ||
</View> | ||
</BottomSheet> | ||
</GestureHandlerRootView> | ||
); | ||
} |
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,66 @@ | ||
export enum TypeOfTask { | ||
MEDICATION = 'Medication Management', | ||
APPOINTMENT = 'Physician Appointment', | ||
// LABS = 'Labs & Outpatient Services', | ||
// REHAB = 'Rehab & Home Therapies', | ||
// TRANSITIONAL = 'Transitional Care', | ||
GROOMING = 'Grooming', | ||
CONVERSATIONS = 'Family Conversations', | ||
// TRANSPORTATION = 'Transportation', | ||
// RESPITE = 'Respite', | ||
ERRANDS = 'Groceries, Shopping, & Errands', | ||
BILLS = 'Pay Bills', | ||
// PRESCRIPTION = 'Prescription Management', | ||
// SAFETY = 'Home Safety', | ||
DIET = 'Diet & Nutrition', | ||
ACTIVITIES = 'Activities', | ||
INSURANCE = 'Health Insurance', | ||
// FINANCIAL = 'Financial', | ||
// LEGAL = 'Legal', | ||
OTHER = 'Other' | ||
} | ||
|
||
export enum Category { | ||
ALL = '', | ||
HEALTH = 'Health & Medical', | ||
PERSONAL = 'Personal', | ||
HOME = 'Home & Lifestyle', | ||
FINANCIAL = 'Financial & Legal', | ||
OTHER = 'Other' | ||
} | ||
|
||
export const categoryToTypeMap: Record<Category, TypeOfTask[]> = { | ||
[Category.ALL]: [], | ||
[Category.HEALTH]: [ | ||
TypeOfTask.MEDICATION, | ||
TypeOfTask.APPOINTMENT, | ||
// TypeOfTask.LABS, | ||
// TypeOfTask.REHAB, | ||
// TypeOfTask.TRANSITIONAL, | ||
TypeOfTask.GROOMING, | ||
// TypeOfTask.PRESCRIPTION, | ||
TypeOfTask.DIET | ||
], | ||
[Category.PERSONAL]: [ | ||
TypeOfTask.GROOMING, | ||
TypeOfTask.CONVERSATIONS, | ||
// TypeOfTask.TRANSPORTATION, | ||
// TypeOfTask.RESPITE, | ||
TypeOfTask.ERRANDS, | ||
// TypeOfTask.SAFETY, | ||
TypeOfTask.BILLS | ||
], | ||
[Category.HOME]: [ | ||
// TypeOfTask.REHAB, | ||
// TypeOfTask.SAFETY, | ||
TypeOfTask.DIET, | ||
TypeOfTask.ACTIVITIES | ||
], | ||
[Category.FINANCIAL]: [ | ||
TypeOfTask.BILLS, | ||
TypeOfTask.INSURANCE | ||
// TypeOfTask.FINANCIAL, | ||
// TypeOfTask.LEGAL | ||
], | ||
[Category.OTHER]: [TypeOfTask.OTHER] | ||
}; |