Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
will comeplete tonight
  • Loading branch information
jasmineguru committed Dec 9, 2023
1 parent e419c2e commit 994404c
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 130 deletions.
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@react-native-community/slider": "^4.4.2",
"@react-native-firebase/auth": "^18.6.0",
"@react-native-firebase/firestore": "^18.6.0",
"@react-native-picker/picker": "^2.5.1",
"@react-native-picker/picker": "2.4.10",
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.15",
Expand All @@ -38,7 +38,9 @@
"react-native-circular-progress-indicator": "^4.4.2",
"react-native-elements": "^3.4.3",
"react-native-gesture-handler": "^2.13.3",
"react-native-modal-dropdown": "^1.0.2",
"react-native-paper": "^5.11.3",
"react-native-picker-select": "^9.0.0",
"react-native-reanimated": "~3.3.0",
"react-native-safe-area-context": "^4.6.3",
"react-native-screens": "~3.22.0",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/APIs/FLASK_API.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";
import firebaseService from "../utilities/firebase";
const FLASK_LOCAL_ADDRESS: string = "http://100.112.45.130:6050";
const FLASK_LOCAL_ADDRESS: string = "http://192.168.2.12:6050";

// Function to get the Firebase authentication token
const getFirebaseAuthToken = async (): Promise<string | null> => {
Expand Down
98 changes: 98 additions & 0 deletions frontend/src/components/dropDown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React, { useState, useRef, useEffect } from 'react';
import {
View,
Text,
TouchableOpacity,
StyleSheet,
ScrollView,
} from 'react-native';
import { Colors } from 'react-native/Libraries/NewAppScreen';

interface DropdownProps {
items: string[];
placeholder: string;
onValueChange: (value: string) => void;
}

const Dropdown: React.FC<DropdownProps> = ({ items, placeholder, onValueChange }) => {
const [isDropdownVisible, setDropdownVisible] = useState(false);
const [selectedValue, setSelectedValue] = useState<string | null>(null);
const [dropdownPosition, setDropdownPosition] = useState({ top: 0, left: 0 });
const dropdownRef = useRef<View>(null); // Change null to View

useEffect(() => {
if (dropdownRef.current != null) {
dropdownRef.current.measure((x, y, width, height, pageX, pageY) => {
setDropdownPosition({ top: pageY + height, left: pageX });
});
}
}, [isDropdownVisible]);

const handleOptionPress = (value: string): void => {
setSelectedValue(value);
onValueChange(value);
setDropdownVisible(false);
};

return (
<View style={styles.container}>
<TouchableOpacity
onPress={() => setDropdownVisible(!isDropdownVisible)}
ref={dropdownRef as React.RefObject<TouchableOpacity>}
>
<View style={styles.selectedValueContainer}>
<Text style={styles.selectedValue}>{selectedValue ?? placeholder}</Text>
</View>
</TouchableOpacity>

{isDropdownVisible && (
<View style={[styles.modalContainer, { top: dropdownPosition.top + 10, left: dropdownPosition.left }]}>
<ScrollView>
{items.map((item) => (
<TouchableOpacity key={item} onPress={() => handleOptionPress(item)}>
<Text style={styles.optionText}>{item}</Text>
</TouchableOpacity>
))}
</ScrollView>
</View>
)}
</View>
);
};

const styles = StyleSheet.create({
container: {
zIndex: 1,

},
selectedValueContainer: {
borderWidth: 1,
borderColor: Colors.GREY,
padding: 10,
borderRadius: 5,
},
selectedValue: {
fontSize: 16,
},
modalContainer: {
position: 'absolute',
backgroundColor: Colors.WHITE,
zIndex: 2,
borderRadius: 5,
borderWidth: 1,
borderColor: Colors.DARKLIMEGREEN,
maxHeight: 150,
overflow: 'scroll',
top: 0,
},
optionText: {
fontSize: 18,
padding: 15,
borderBottomWidth: 1,
borderBottomColor: Colors.DARKLIMEGREEN,
width: '100%',
textAlign: 'center',
},
});

export default Dropdown;
3 changes: 2 additions & 1 deletion frontend/src/screens/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default function LogInScreen({ navigation }: LoginScreenProps): JSX.Eleme
await firebaseService.signInUser(email, password).then(async () => {
await UsersAPI.GetLoggedInUser().then((res) => {
if (res != null) {
navigation.navigate('MainApp', { screen: 'DashBoard' });
// navigation.navigate('MainApp', { screen: 'DashBoard' });
navigation.navigate('SignUpQuestions');
} else {
console.warn('User was not logged in: ' + res);
}
Expand Down
Loading

0 comments on commit 994404c

Please sign in to comment.