Skip to content

Commit

Permalink
5 create resources sub pages (#15)
Browse files Browse the repository at this point in the history
* seek help to resource list

* seek help to resource list

* fixed some things

* removed unused import

---------

Co-authored-by: Philip Ye <97428041+philipye314@users.noreply.github.com>
Co-authored-by: philipye314 <philipye@berkeley.edu>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent cf3304b commit 96e9e4c
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 29 deletions.
2 changes: 2 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Home from '@/screens/Home';
import LegalRights from '@/screens/LegalRights/index';
import VideoPage from '@/screens/LegalRights/VideoPage';
import SeekHelp from '@/screens/SeekHelp';
import resourceList from '@/screens/SeekHelp/ResourceList';

const Stack = createNativeStackNavigator();

Expand All @@ -17,6 +18,7 @@ export default function App() {
<Stack.Screen name="Healing Resources" component={HealingResources} />
<Stack.Screen name="Legal Rights" component={LegalRights} />
<Stack.Screen name="Seek Help" component={SeekHelp} />
<Stack.Screen name="Resource List" component={resourceList} />
<Stack.Screen name="Video Page" component={VideoPage} />
</Stack.Navigator>
</NavigationContainer>
Expand Down
14 changes: 14 additions & 0 deletions src/navigation/seekHelpNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as React from 'react';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import SeekHelp from '@/screens/SeekHelp';
import ResourceList from '@/screens/SeekHelp/ResourceList';

const Stack = createNativeStackNavigator();
export default function seekHelpNav() {
return (
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Resource List" component={ResourceList} />
<Stack.Screen name="Seek Help" component={SeekHelp} />
</Stack.Navigator>
);
}
51 changes: 51 additions & 0 deletions src/screens/SeekHelp/ResourceList/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useEffect, useState } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { getSeekHelpData } from '@/supabase/queries/generalQueries';
import { Resource } from '@/types/types';
import { styles } from './styles';

export default function ResourceList() {
const filters = [
'General Resources',
'Health Organizations',
'LGBT Organizations',
'Legal Services',
'Government Resources',
];
const [summaries, setSummaries] = useState<Resource[]>([]);

useEffect(() => {
fetchData();
}, []);

const fetchData = async () => {
try {
const data = await getSeekHelpData();
setSummaries(data);
} catch (error) {
console.error('Error fetching data:', error);
}
};
return (
<View style={styles.container}>
<View style={styles.leftPanel}>
{filters.map((filter, index) => (
<TouchableOpacity key={index} style={styles.filterButton}>
<Text>{filter}</Text>
</TouchableOpacity>
))}
</View>
<View style={styles.rightPanel}>
<View>
{summaries.length > 0 ? (
summaries.map((resource, index) => (
<Text key={index}>{resource.summary}</Text>
))
) : (
<Text>Loading...</Text>
)}
</View>
</View>
</View>
);
}
37 changes: 37 additions & 0 deletions src/screens/SeekHelp/ResourceList/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
container: {
display: 'flex',
flexDirection: 'row',
marginTop: 10,
padding: 30,
},
leftPanel: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'flex-start',
width: '25%',
paddingRight: 20,
},
rightPanel: {
display: 'flex',
flexDirection: 'column',
width: '75%',
backgroundColor: '#f8f8f8',
padding: 10,
},
filterButton: {
backgroundColor: '#e8e8e8',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 5,
marginVertical: 10,
paddingVertical: 15,
width: '100%',
},
buttonText: {
fontSize: 16,
color: '#333',
},
});
46 changes: 17 additions & 29 deletions src/screens/SeekHelp/index.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
import React, { useEffect, useState } from 'react';
import { Button, Text, View } from 'react-native';
import { getSeekHelpData } from '@/supabase/queries/generalQueries';
import { Resource } from '@/types/types';

export default function SeekHelp() {
const [summaries, setSummaries] = useState<Resource[]>([]);

useEffect(() => {
fetchData();
}, []);

const fetchData = async () => {
try {
const data = await getSeekHelpData();
setSummaries(data);
} catch (error) {
console.error('Error fetching data:', error);
}
};
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { styles } from './styles';

export default function SeekHelp({ navigation }: { navigation: any }) {
return (
<View>
<Button title="Fetch Data" onPress={fetchData} />
{summaries.length > 0 ? (
summaries.map((resource, index) => (
<Text key={index}>{resource.summary}</Text>
))
) : (
<Text>Loading...</Text>
)}
<View style={styles.container}>
<TouchableOpacity
style={styles.button}
onPress={() => navigation.navigate('Resource List')}
>
<Text style={styles.buttonText}>California</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={() => navigation.navigate('Resource List')}
>
<Text style={styles.buttonText}>National</Text>
</TouchableOpacity>
</View>
);
}
25 changes: 25 additions & 0 deletions src/screens/SeekHelp/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: 10,
padding: 30,
},
button: {
backgroundColor: '#e8e8e8',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 5,
marginVertical: 10,
paddingVertical: 15,
width: '100%',
},
buttonText: {
fontSize: 18,
color: '#333',
fontWeight: '500',
},
});
4 changes: 4 additions & 0 deletions src/types/types 2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Resource {
summary: string;
[key: string]: any;
}

0 comments on commit 96e9e4c

Please sign in to comment.