Skip to content

Commit

Permalink
navigation set up for future screens (#15)
Browse files Browse the repository at this point in the history
* navigation set up for future screens

---------

Co-authored-by: Matt McCoy <[email protected]>
  • Loading branch information
haleymartin-6 and MattCMcCoy authored Jan 30, 2024
1 parent e457aab commit 582d85a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 21 deletions.
56 changes: 39 additions & 17 deletions client/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
import * as React from 'react';
import { View, Text } from 'react-native';
import { getAllMedications } from './services/medication';
import UnionSvg from './assets/Union.svg';
import { Text } from 'react-native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { NavigationContainer, NavigationProp } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Medication from './screens/Medication';
import Home from './assets/home.svg';

export type ScreenNames = ['BottomNav', 'Landing'];
export type RootStackParamList = Record<ScreenNames[number], any>;
export type StackNavigation = NavigationProp<RootStackParamList>;

const Stack = createNativeStackNavigator<RootStackParamList>();
const Tab = createBottomTabNavigator();

// TODO: figure out a way to do this better, I didnt enjoy this way of doing it in SaluTemp there HAS to be a better way
export default function App() {
const [medications, setMedications] = React.useState<Medication[]>();
React.useEffect(() => {
getAllMedications().then((med) => setMedications(med));
}, []);
// Adding the UnionSvg component here to show that it's able to be displayed here
return (
<View className="flex-1 items-center w-[100vw] justify-center bg-white">
{medications &&
medications.map((med, index) => (
<Text key={index} className="pb-2">
{`Name: ${med.medication_name} id: ${med.medication_id}`}
</Text>
))}
<UnionSvg/>
</View>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="BottomNav"
options={{ headerShown: false }}
component={Tabs}
/>
</Stack.Navigator>
</NavigationContainer>
);
}

function Tabs() {
return (
<Tab.Navigator>
<Tab.Screen
name="Landing"
options={{
headerShown: true,
tabBarIcon: () => <Home color={'gray'} />,
tabBarLabel: () => <Text>Landing</Text>
}}
component={Medication}
/>
</Tab.Navigator>
);
}
3 changes: 0 additions & 3 deletions client/assets/Union.svg

This file was deleted.

6 changes: 6 additions & 0 deletions client/assets/home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@
"format": "prettier --write ."
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-brands-svg-icons": "^6.5.1",
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-native-fontawesome": "^0.3.0",
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"axios": "^1.6.4",
"expo": "~49.0.15",
"expo-status-bar": "~1.6.0",
"nativewind": "^2.0.11",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-safe-area-context": "4.6.3"
"react-native-svg-transformer": "^1.3.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
21 changes: 21 additions & 0 deletions client/screens/Medication.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { View, Text } from 'react-native';
import { getAllMedications } from '../services/medication';

export default function Medication() {
const [medications, setMedications] = React.useState<Medication[]>();
React.useEffect(() => {
getAllMedications().then((med) => setMedications(med));
}, []);

return (
<View className="flex-1 items-center w-[100vw] justify-center bg-white">
{medications &&
medications.map((med, index) => (
<Text key={index} className="pb-2">
{`Name: ${med.medication_name} id: ${med.medication_id}`}
</Text>
))}
</View>
);
}

0 comments on commit 582d85a

Please sign in to comment.