2020-03-20 11:15:54 +01:00
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import {
|
2020-03-20 15:35:50 +01:00
|
|
|
Portal,
|
2020-03-29 10:15:27 +02:00
|
|
|
Text,
|
2020-03-20 11:15:54 +01:00
|
|
|
} from "react-native-paper";
|
|
|
|
import { createStackNavigator } from "@react-navigation/stack";
|
|
|
|
|
2020-03-20 15:35:50 +01:00
|
|
|
import HomeScreen from "./timetable/HomeScreen";
|
|
|
|
import AddEntry from "./timetable/AddEntry";
|
2020-03-20 11:15:54 +01:00
|
|
|
|
|
|
|
const Stack = createStackNavigator();
|
|
|
|
|
2020-03-24 19:17:54 +01:00
|
|
|
export default function Timetable({ addTimetableEntry, removeTimetableEntry, timetable, subjects }) {
|
2020-03-20 11:15:54 +01:00
|
|
|
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
2020-03-29 10:15:27 +02:00
|
|
|
if (subjects.length === 0) {
|
|
|
|
return (
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
textAlign: "center",
|
|
|
|
marginTop: 12,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
No Subjects added. Add Subjects first.
|
|
|
|
</Text>);
|
|
|
|
}
|
2020-03-20 11:15:54 +01:00
|
|
|
return (
|
2020-03-20 15:35:50 +01:00
|
|
|
<Portal.Host><Stack.Navigator headerMode="none">
|
2020-03-20 11:15:54 +01:00
|
|
|
<Stack.Screen name="Timetable">
|
|
|
|
{(props) => (
|
|
|
|
<HomeScreen
|
|
|
|
{...props}
|
|
|
|
timetable={timetable}
|
|
|
|
subjects={subjects}
|
|
|
|
days={days}
|
2020-03-24 19:17:54 +01:00
|
|
|
removeTimetableEntry={removeTimetableEntry}
|
2020-03-20 11:15:54 +01:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Stack.Screen>
|
|
|
|
{days.map((day, idx) => (
|
|
|
|
<Stack.Screen name={`New Entry ${day}`} key={idx}>
|
|
|
|
{(props) => (
|
2020-03-20 15:35:50 +01:00
|
|
|
<AddEntry
|
2020-03-20 11:15:54 +01:00
|
|
|
{...props}
|
2020-03-20 15:35:50 +01:00
|
|
|
subjects={subjects}
|
|
|
|
day={idx}
|
|
|
|
days={days}
|
2020-03-21 10:17:10 +01:00
|
|
|
addTimetableEntry={addTimetableEntry}
|
2020-03-20 15:35:50 +01:00
|
|
|
/>
|
2020-03-20 11:15:54 +01:00
|
|
|
)}
|
|
|
|
</Stack.Screen>
|
|
|
|
))}
|
2020-03-20 15:35:50 +01:00
|
|
|
</Stack.Navigator></Portal.Host>
|
2020-03-20 11:15:54 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Timetable.propTypes = {
|
|
|
|
timetable: PropTypes.array,
|
|
|
|
subjects: PropTypes.array,
|
|
|
|
addTimetableEntry: PropTypes.func,
|
|
|
|
removeTimetableEntry: PropTypes.func,
|
|
|
|
};
|