Skip to content

Commit

Permalink
refactor: remove ScrollView and non-Tailwind styling
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviaseds committed Mar 12, 2024
1 parent 8383ae5 commit 724465b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
3 changes: 3 additions & 0 deletions client/assets/close/close1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions client/assets/close/close2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions client/components/TaskType/CloseButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';

import { useNavigation } from '@react-navigation/native';
import { IconButton } from 'react-native-paper';

import Close1 from '../../assets/close/close1.svg';
import Close2 from '../../assets/close/close2.svg';
import { AppStackNavigation } from '../../navigation/AppNavigation';

export function CloseButton({onPress}: {onPress: () => void}) {

Check failure on line 10 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Replace `onPress}:·{onPress:·()·=>·void` with `·onPress·}:·{·onPress:·()·=>·void·`
const navigation = useNavigation<AppStackNavigation>();

Check failure on line 11 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Insert `··`

Check failure on line 11 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

'navigation' is assigned a value but never used

return (

Check failure on line 13 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Insert `··`
<IconButton
className="align-center m-2 flex h-[50px] w-[52px] justify-center rounded-xl bg-carewallet-gray"

Check failure on line 15 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `··`
mode="contained"

Check failure on line 16 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `··`
icon={() => (

Check failure on line 17 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `··`
<>

Check failure on line 18 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Replace `············` with `········`
<Close1 style={{ position: 'absolute', top: 20, left: 20 }} />

Check failure on line 19 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Replace `················` with `··········`
<Close2 style={{ position: 'absolute', top: 20, left: 20 }} />

Check failure on line 20 in client/components/TaskType/CloseButton.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `······`
</>
)}
onPress={onPress}
/>
);
}
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/react": "^18.2.55",
"axios": "^1.6.4",
"clsx": "^2.1.0",
"expo": "^50.0.7",
"expo": "^50.0.11",
"expo-document-picker": "~11.10.1",
"expo-file-system": "~16.0.6",
"expo-status-bar": "~1.11.1",
Expand Down
47 changes: 31 additions & 16 deletions client/screens/TaskType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useRef,
useState
} from 'react';
import { ScrollView, View } from 'react-native';
import { FlatList, View } from 'react-native';

import BottomSheet, { BottomSheetBackdrop } from '@gorhom/bottom-sheet';
import { BottomSheetDefaultBackdropProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetBackdrop/types';
Expand All @@ -18,6 +18,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';
import { BackButton } from '../components/TaskType/BackButton';
import { AppStackNavigation } from '../navigation/AppNavigation';
import { Category, categoryToTypeMap, TypeOfTask } from '../types/type';
import { CloseButton } from '../components/TaskType/CloseButton';

export function TaskType() {
const navigation = useNavigation<AppStackNavigation>();
Expand All @@ -43,10 +44,16 @@ export function TaskType() {
value: filter
}));

const snapPoints = useMemo(() => ['50%'], []);
const snapPoints = 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(
Expand Down Expand Up @@ -84,19 +91,23 @@ export function TaskType() {
</Button>
</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>
<FlatList
className="h-full"
data={selectedTypes}
renderItem={
({ item }) => (
<Button
className="m-2 h-[50px] items-center justify-center rounded-xl"
textColor="black"
mode="outlined"
onPress={() => navigation.navigate('New ' + item + "Task")}
>
{item}
</Button>
)
}
/>

<BottomSheet
ref={bottomSheetRef}
index={0}
Expand All @@ -105,7 +116,11 @@ export function TaskType() {
backdropComponent={renderBackdrop}
>
<View>
<Text className="m-5 text-2xl font-bold">Filter</Text>
<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}
Expand Down

0 comments on commit 724465b

Please sign in to comment.