Added way to access Add page and default module.

This commit is contained in:
bobbert committed 2025-12-04 14:18:12 +00:00
1 parent 1f296314f4
commit 8511afddcd
2 files changed
+41 -4

No files matched your search

+23 -1
View File
@@ -1,14 +1,36 @@
import {StyleSheet, Text} from "react-native";
import Screen from "../layout/Screen";
import {Button, ButtonTray} from "../UI/Button";
import Icons from "../UI/Icons";
export const ModuleAddScreen = () => {
const defaultModule = {
ModuleID: Math.floor(100000 + Math.random()*900000),
ModuleCode: "CI6330",
ModuleName: "Mobile Application Development",
ModuleLevel: 6,
ModuleLeaderID: 1,
ModuleLeaderName: "Graeme Jones",
ModuleImage: 'https://images.freeimages.com/images/small-preview/cf5/cellphone-1313194.jpg',
};
export const ModuleAddScreen = ({navigation, route}) => {
// Initialisation -------------
const { onAdd } = route.params;
// State ----------------------
// Handlers -------------------
const handleAdd = () => onAdd(defaultModule);
const handleCancel = navigation.goBack;
// View -----------------------
return (
<Screen style={styles.container}>
<Text>Add</Text>
<ButtonTray>
<Button label='Cancel' onClick={handleCancel} />
<Button label='Add' icon={<Icons.Add/>} onClick={handleAdd} />
</ButtonTray>
</Screen>
);
};
+18 -3
View File
@@ -3,7 +3,9 @@ import {LogBox, StyleSheet} from "react-native";
import Screen from "../layout/Screen";
import ModuleList from "../entity/modules/ModuleList";
import initialModules from "../../data/modules.js";
import RenderCount from "../UI/RenderCount";
// import RenderCount from "../UI/RenderCount";
import {Button, ButtonTray} from "../UI/Button";
import Icons from "../UI/Icons";
const ModuleListScreen = ({navigation}) => {
// Initialisation -------------
@@ -25,14 +27,27 @@ const ModuleListScreen = ({navigation}) => {
navigation.goBack();
}
const handleSelect = (module) =>
const handleAdd = (module) => setModules([ ...modules, module]);
const onAdd = (module) => {
handleAdd(module);
navigation.goBack();
};
const goToViewScreen = (module) =>
navigation.navigate('ModuleViewScreen', {module, onDelete});
const goToAddScreen = () => navigation.navigate('ModuleAddScreen', {onAdd});
// View -----------------------
return (
<Screen>
{/*<RenderCount/>*/}
<ModuleList modules={modules} onSelect={handleSelect}/>
<ButtonTray>
<Button label='Add' icon={<Icons.Add/>} onClick={goToAddScreen} />
</ButtonTray>
<ModuleList modules={modules} onSelect={goToViewScreen} />
</Screen>
);
};