-
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
1 parent
5cb2b67
commit f088c0a
Showing
4 changed files
with
117 additions
and
59 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
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 |
---|---|---|
@@ -1,79 +1,130 @@ | ||
import React, { useState } from 'react'; | ||
import React, { | ||
useCallback, | ||
useEffect, | ||
useMemo, | ||
useRef, | ||
useState | ||
} from 'react'; | ||
import { ScrollView, View } from 'react-native'; | ||
|
||
import BottomSheet, { BottomSheetBackdrop } 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 { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
import { BackButton } from '../components/BackButton'; | ||
import { BackButton } from '../components/TaskType/BackButton'; | ||
import { AppStackNavigation } from '../navigation/AppNavigation'; | ||
import { TypeOfTask } from '../types/type'; | ||
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] = useState<TypeOfTask[]>(Object.values(TypeOfTask)); | ||
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]); | ||
useEffect(() => { | ||
setSelectedTypes( | ||
selectedCategory | ||
? categoryToTypeMap[selectedCategory] | ||
: Object.values(TypeOfTask) | ||
); | ||
}, [selectedCategory]); | ||
|
||
// const filters = Object.values(Category).map((filter) => ({ | ||
// label: filter, | ||
// value: filter | ||
// })); | ||
const filters = Object.values(Category).map((filter) => ({ | ||
label: filter, | ||
value: filter | ||
})); | ||
|
||
return ( | ||
<SafeAreaView> | ||
<View className="my-0 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> | ||
const snapPoints = useMemo(() => ['50%'], []); | ||
|
||
<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" | ||
> | ||
Filter | ||
</Button> | ||
</View> | ||
const bottomSheetRef = useRef<BottomSheet>(null); | ||
|
||
const snapToIndex = (index: number) => | ||
bottomSheetRef.current?.snapToIndex(index); | ||
const renderBackdrop = useCallback( | ||
(props: BottomSheetDefaultBackdropProps) => ( | ||
<BottomSheetBackdrop | ||
appearsOnIndex={0} | ||
disappearsOnIndex={-1} | ||
{...props} | ||
/> | ||
), | ||
[] | ||
); | ||
|
||
{/* <DropDownPicker | ||
open={open} | ||
value={selectedCategory} | ||
items={filters} | ||
setOpen={setOpen} | ||
setValue={setSelectedCategory} | ||
/> */} | ||
return ( | ||
<GestureHandlerRootView> | ||
<SafeAreaView> | ||
<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> | ||
|
||
<ScrollView style={{ marginTop: 10, marginBottom: 150 }}> | ||
{selectedTypes.map((type) => ( | ||
<Text className="text-center text-2xl font-bold">Type of Task</Text> | ||
<View className="mr-2 flex flex-row justify-end"> | ||
<Button | ||
className="m-2 h-[50px] items-center justify-center rounded-xl" | ||
className="h-[40px] items-center justify-center rounded-xl text-sm" | ||
textColor="black" | ||
key={type} | ||
mode="outlined" | ||
onPress={() => navigation.navigate('New ' + type)} // TODO other screens should have this name | ||
onPress={() => snapToIndex(0)} | ||
> | ||
{type} | ||
Filter | ||
</Button> | ||
))} | ||
</ScrollView> | ||
</SafeAreaView> | ||
</View> | ||
|
||
<ScrollView style={{ height: 850 }}> | ||
{selectedTypes.map((type) => ( | ||
<Button | ||
className="m-2 h-[50px] items-center justify-center rounded-xl" | ||
textColor="black" | ||
key={type} | ||
mode="outlined" | ||
onPress={() => navigation.navigate('New ' + type)} // TODO other screens should have this name | ||
> | ||
{type} | ||
</Button> | ||
))} | ||
</ScrollView> | ||
<BottomSheet | ||
ref={bottomSheetRef} | ||
index={0} | ||
snapPoints={snapPoints} | ||
enablePanDownToClose={true} | ||
backdropComponent={renderBackdrop} | ||
> | ||
<View> | ||
<Text className="m-5 text-2xl font-bold">Filter</Text> | ||
<DropDownPicker | ||
open={open} | ||
value={selectedCategory} | ||
items={filters} | ||
setOpen={setOpen} | ||
setValue={setSelectedCategory} | ||
placeholder="Category" | ||
style={{ | ||
width: '95%', | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
borderRadius: 0, | ||
borderColor: 'transparent', | ||
borderBottomColor: 'black' | ||
}} | ||
/> | ||
</View> | ||
</BottomSheet> | ||
</SafeAreaView> | ||
</GestureHandlerRootView> | ||
); | ||
} |