-
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
dbfe8d6
commit 054a189
Showing
20 changed files
with
756 additions
and
466 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,183 @@ | ||
import React, { useState } from 'react'; | ||
import { ImageBackground, StyleSheet,View, Dimensions , Text, Button, Alert, Pressable, TextInput} from 'react-native'; | ||
import { Table, TableWrapper, Row, Rows, Col, Cols, Cell } from 'react-native-table-component'; | ||
import MapView, {PROVIDER_GOOGLE} from 'react-native-maps'; | ||
import {NavigationContainer} from '@react-navigation/native'; | ||
import {createNativeStackNavigator, NativeStackScreenProps} from '@react-navigation/native-stack'; | ||
import { RootStackParamList } from './types'; | ||
import { Header } from 'react-native/Libraries/NewAppScreen'; | ||
import { Image } from 'expo-image'; | ||
import RiderMain from './src/screens/Rider/RiderMain'; | ||
import DriverMain from './src/screens/Driver/screens/DriverMain'; | ||
import AdminMain from './src/screens/Admin/screens/AdminMain' | ||
|
||
import React, { useState } from "react"; | ||
import { | ||
ImageBackground, | ||
StyleSheet, | ||
View, | ||
Dimensions, | ||
Text, | ||
Button, | ||
Alert, | ||
Pressable, | ||
TextInput, | ||
} from "react-native"; | ||
import { | ||
Table, | ||
TableWrapper, | ||
Row, | ||
Rows, | ||
Col, | ||
Cols, | ||
Cell, | ||
} from "react-native-table-component"; | ||
import MapView, { PROVIDER_GOOGLE } from "react-native-maps"; | ||
import { NavigationContainer } from "@react-navigation/native"; | ||
import { | ||
createNativeStackNavigator, | ||
NativeStackScreenProps, | ||
} from "@react-navigation/native-stack"; | ||
import { RootStackParamList } from "./types"; | ||
import { Header } from "react-native/Libraries/NewAppScreen"; | ||
import { Image } from "expo-image"; | ||
import RiderMain from "./src/screens/Rider/RiderMain"; | ||
import DriverMain from "./src/screens/Driver/screens/DriverMain"; | ||
import AdminMain from "./src/screens/Admin/screens/AdminMain"; | ||
import { loadedShuttleData } from "./src/datasource/dataLoader"; | ||
import { Shuttle } from "./src/models/Shuttle"; | ||
|
||
const Stack = createNativeStackNavigator<RootStackParamList>(); | ||
const { width, height } = Dimensions.get("window"); | ||
const bImage = '../shuttleu/src/assets/vecteezy_minimal-background-purple-color-and-there-are-two-lines-on_12847530_386.jpg'; | ||
const bImage = | ||
"../shuttleu/src/assets/vecteezy_minimal-background-purple-color-and-there-are-two-lines-on_12847530_386.jpg"; | ||
|
||
export default function App() { | ||
|
||
|
||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator screenOptions={{headerShown: false}}> | ||
<Stack.Screen name="Login" component={Login} options={{title: 'Login'}} /> | ||
<Stack.Screen name="RiderMain" component={RiderMain} options={{title: 'RiderMain'}} /> | ||
<Stack.Screen name="DriverMain" component={DriverMain} options={{title: 'DriverMain'}} /> | ||
<Stack.Screen name="AdminMain" component={AdminMain} options={{title: 'DriverMain'}} /> | ||
|
||
<Stack.Navigator screenOptions={{ headerShown: false }}> | ||
<Stack.Screen | ||
name="Login" | ||
component={Login} | ||
options={{ title: "Login" }} | ||
/> | ||
<Stack.Screen | ||
name="RiderMain" | ||
component={RiderMain} | ||
options={{ title: "RiderMain" }} | ||
/> | ||
<Stack.Screen | ||
name="DriverMain" | ||
component={DriverMain} | ||
options={{ title: "DriverMain" }} | ||
/> | ||
<Stack.Screen | ||
name="AdminMain" | ||
component={AdminMain} | ||
options={{ title: "DriverMain" }} | ||
/> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
|
||
|
||
); | ||
} | ||
|
||
type LoginProps = NativeStackScreenProps<RootStackParamList, "Login">; | ||
|
||
const Login: React.FC<LoginProps> = (props) =>{ | ||
const [shuttleCode, setShuttleCode] = useState<string>(''); | ||
const Login: React.FC<LoginProps> = (props) => { | ||
const [shuttleCode, setShuttleCode] = React.useState<string>(""); | ||
|
||
const handleDriverMainClick = () => { | ||
if (shuttleCode === '') { | ||
// Show an alert if the shuttle code is empty | ||
Alert.alert('Please enter a shuttle code'); | ||
if (shuttleCode && isShuttleCodeValid(shuttleCode)) { | ||
const selectedShuttle = loadedShuttleData.find( | ||
(shuttle) => shuttle.code === shuttleCode | ||
); | ||
if (selectedShuttle) { | ||
props.navigation.push("DriverMain"); | ||
} else { | ||
Alert.alert("Shuttle not found"); | ||
} | ||
} else { | ||
// Navigate to DriverMain with the shuttleCode | ||
props.navigation.push('DriverMain'); | ||
Alert.alert("Please enter a valid shuttle code"); | ||
} | ||
}; | ||
|
||
return( | ||
<View style={styles.container}> | ||
<ImageBackground source={require(bImage)} resizeMode="stretch" style={styles.bImage}> | ||
<Image | ||
style={styles.image} | ||
source={require('./src/assets/Control-V-removebg-preview.png')} | ||
contentFit="cover" | ||
placeholder="Logo" | ||
></Image> | ||
|
||
|
||
<Pressable style={styles.button} onPress={() => props.navigation.push("RiderMain")}><Text style={styles.text}>Rider Main</Text></Pressable> | ||
|
||
<Pressable style={styles.button} onPress={() => props.navigation.push("DriverMain")}><Text style={styles.text}>Driver Main </Text></Pressable> | ||
<TextInput | ||
style={styles.input} | ||
placeholder="Enter Shuttle Code" | ||
onChangeText={(text) => setShuttleCode(text)} | ||
value={shuttleCode} | ||
/> | ||
<Pressable style={styles.button} onPress={() => props.navigation.push("AdminMain")}><Text style={styles.text}>Admin Main</Text></Pressable> | ||
const isShuttleCodeValid = (code: string): boolean => { | ||
return loadedShuttleData.some((shuttle) => shuttle.code === code); | ||
}; | ||
return ( | ||
<View style={styles.container}> | ||
<ImageBackground | ||
source={require(bImage)} | ||
resizeMode="stretch" | ||
style={styles.bImage} | ||
> | ||
<Image | ||
style={styles.image} | ||
source={require("./src/assets/Control-V-removebg-preview.png")} | ||
contentFit="cover" | ||
placeholder="Logo" | ||
></Image> | ||
|
||
|
||
<Pressable | ||
style={styles.button} | ||
onPress={() => props.navigation.push("RiderMain")} | ||
> | ||
<Text style={styles.text}>Rider Main</Text> | ||
</Pressable> | ||
|
||
</ImageBackground> | ||
</View> | ||
);}; | ||
<Pressable style={styles.button} onPress={handleDriverMainClick}> | ||
<Text style={styles.text}>Driver Main </Text> | ||
</Pressable> | ||
<TextInput | ||
style={styles.input} | ||
placeholder="Enter Shuttle Code" | ||
onChangeText={(text) => setShuttleCode(text)} | ||
value={shuttleCode} | ||
/> | ||
<Pressable | ||
style={styles.button} | ||
onPress={() => props.navigation.push("AdminMain")} | ||
> | ||
<Text style={styles.text}>Admin Main</Text> | ||
</Pressable> | ||
</ImageBackground> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container:{ | ||
alignItems: 'center', | ||
container: { | ||
alignItems: "center", | ||
backgroundColor: "#f1f1f1", | ||
flex: 1, | ||
|
||
}, | ||
header:{ | ||
}, | ||
header: { | ||
fontSize: 30, | ||
marginTop: 50, | ||
textAlign: 'center' | ||
|
||
|
||
textAlign: "center", | ||
}, | ||
image:{ | ||
image: { | ||
width: 342, | ||
height: 116 , | ||
resizeMode: 'cover', | ||
marginTop: 100 | ||
|
||
}, | ||
button:{ | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
height: 116, | ||
resizeMode: "cover", | ||
marginTop: 100, | ||
}, | ||
button: { | ||
alignItems: "center", | ||
justifyContent: "center", | ||
paddingVertical: 12, | ||
paddingHorizontal: 32, | ||
borderRadius: 25, | ||
borderColor: 'grey', | ||
borderColor: "grey", | ||
borderWidth: 2.5, | ||
elevation: 3, | ||
width: 300, | ||
marginTop: 50, | ||
|
||
}, | ||
text: { | ||
fontSize: 36, | ||
lineHeight: 50, | ||
fontWeight: '400', | ||
fontWeight: "400", | ||
letterSpacing: 0.25, | ||
color: 'black', | ||
color: "black", | ||
}, | ||
bImage:{ | ||
bImage: { | ||
height: height, | ||
width: width, | ||
alignItems:'center', | ||
|
||
|
||
alignItems: "center", | ||
}, | ||
input: { | ||
height: 40, // Adjust the height as needed | ||
borderColor: 'gray', // Border color | ||
borderWidth: 1, // Border width | ||
height: 40, // Adjust the height as needed | ||
borderColor: "gray", // Border color | ||
borderWidth: 1, // Border width | ||
paddingHorizontal: 10, // Horizontal padding | ||
marginTop: 10, | ||
} | ||
|
||
|
||
marginTop: 10, | ||
}, | ||
}); |
File renamed without changes.
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ export class Trip { | |
this.pax = pax; | ||
this.dur = dur; | ||
} | ||
|
||
} |
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
Oops, something went wrong.