mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
Added way to access Add page and default module.
This commit is contained in:
1 parent
1f296314f4
commit
8511afddcd
2 files changed
+41
-4
No files matched your search
@@ -1,14 +1,36 @@
|
|||||||
import {StyleSheet, Text} from "react-native";
|
import {StyleSheet, Text} from "react-native";
|
||||||
import Screen from "../layout/Screen";
|
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 -------------
|
// Initialisation -------------
|
||||||
|
const { onAdd } = route.params;
|
||||||
|
|
||||||
// State ----------------------
|
// State ----------------------
|
||||||
// Handlers -------------------
|
// Handlers -------------------
|
||||||
|
|
||||||
|
const handleAdd = () => onAdd(defaultModule);
|
||||||
|
const handleCancel = navigation.goBack;
|
||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
return (
|
return (
|
||||||
<Screen style={styles.container}>
|
<Screen style={styles.container}>
|
||||||
<Text>Add</Text>
|
<Text>Add</Text>
|
||||||
|
<ButtonTray>
|
||||||
|
<Button label='Cancel' onClick={handleCancel} />
|
||||||
|
<Button label='Add' icon={<Icons.Add/>} onClick={handleAdd} />
|
||||||
|
</ButtonTray>
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import {LogBox, StyleSheet} from "react-native";
|
|||||||
import Screen from "../layout/Screen";
|
import Screen from "../layout/Screen";
|
||||||
import ModuleList from "../entity/modules/ModuleList";
|
import ModuleList from "../entity/modules/ModuleList";
|
||||||
import initialModules from "../../data/modules.js";
|
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}) => {
|
const ModuleListScreen = ({navigation}) => {
|
||||||
// Initialisation -------------
|
// Initialisation -------------
|
||||||
@@ -25,14 +27,27 @@ const ModuleListScreen = ({navigation}) => {
|
|||||||
navigation.goBack();
|
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});
|
navigation.navigate('ModuleViewScreen', {module, onDelete});
|
||||||
|
|
||||||
|
const goToAddScreen = () => navigation.navigate('ModuleAddScreen', {onAdd});
|
||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Screen>
|
<Screen>
|
||||||
{/*<RenderCount/>*/}
|
{/*<RenderCount/>*/}
|
||||||
<ModuleList modules={modules} onSelect={handleSelect}/>
|
<ButtonTray>
|
||||||
|
<Button label='Add' icon={<Icons.Add/>} onClick={goToAddScreen} />
|
||||||
|
</ButtonTray>
|
||||||
|
<ModuleList modules={modules} onSelect={goToViewScreen} />
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user