mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
Added delete functionality, and navigate to go back to previous page after module deletion
This commit is contained in:
1 parent
8164fab184
commit
3ad1ef5c32
3 files changed
+23
-10
No files matched your search
@@ -1,15 +1,18 @@
|
|||||||
import {MaterialIcons} from '@expo/vector-icons'
|
import {MaterialIcons} from '@expo/vector-icons';
|
||||||
|
|
||||||
const Icons = {};
|
const Icons = {};
|
||||||
|
|
||||||
const Edit = () => <MaterialIcons name='edit' size={16}/>;
|
|
||||||
const Delete = () => <MaterialIcons name='delete' size={16}/>;
|
|
||||||
const Add = () => <MaterialIcons name='add' size={16}/>;
|
const Add = () => <MaterialIcons name='add' size={16}/>;
|
||||||
|
const Close = () => <MaterialIcons name='close' size={16}/>;
|
||||||
|
const Delete = () => <MaterialIcons name='delete' size={16}/>;
|
||||||
|
const Edit = () => <MaterialIcons name='edit' size={16}/>;
|
||||||
|
const Submit = () => <MaterialIcons name='check' size={16}/>;
|
||||||
|
|
||||||
//compose
|
// Compose
|
||||||
Icons.Edit = Edit;
|
|
||||||
Icons.Delete = Delete;
|
|
||||||
Icons.Add = Add;
|
Icons.Add = Add;
|
||||||
|
Icons.Close = Close;
|
||||||
|
Icons.Delete = Delete;
|
||||||
|
Icons.Edit = Edit;
|
||||||
|
Icons.Submit = Submit;
|
||||||
|
|
||||||
|
export default Icons;
|
||||||
export default Icons;
|
|
||||||
@@ -3,10 +3,13 @@ import FullWidthImage from "react-native-fullwidth-image";
|
|||||||
import {Button, ButtonTray} from "../../UI/Button";
|
import {Button, ButtonTray} from "../../UI/Button";
|
||||||
import Icons from "../../UI/Icons.js"
|
import Icons from "../../UI/Icons.js"
|
||||||
|
|
||||||
const ModuleView = ({module}) => {
|
const ModuleView = ({module, onDelete}) => {
|
||||||
// Initialisation -------------
|
// Initialisation -------------
|
||||||
// State ----------------------
|
// State ----------------------
|
||||||
// Handlers -------------------
|
// Handlers -------------------
|
||||||
|
|
||||||
|
const handleDelete = () => onDelete(module);
|
||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
|
|
||||||
return (<View style={styles.container}>
|
return (<View style={styles.container}>
|
||||||
@@ -27,6 +30,7 @@ const ModuleView = ({module}) => {
|
|||||||
label={"Delete"}
|
label={"Delete"}
|
||||||
styleButton={{backgroundColor: 'mistyrose'}}
|
styleButton={{backgroundColor: 'mistyrose'}}
|
||||||
styleLabel={{color: 'red'}}
|
styleLabel={{color: 'red'}}
|
||||||
|
onClick={handleDelete}
|
||||||
/>
|
/>
|
||||||
</ButtonTray>
|
</ButtonTray>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,13 @@ const ModuleListScreen = ({navigation}) => {
|
|||||||
const handleDelete = (module) =>
|
const handleDelete = (module) =>
|
||||||
setModules(modules.filter((item) => item.ModuleID !== module.ModuleID));
|
setModules(modules.filter((item) => item.ModuleID !== module.ModuleID));
|
||||||
|
|
||||||
const handleSelect = (module) => navigation.navigate('ModuleViewScreen', {module});
|
|
||||||
|
const onDelete = (module) => {
|
||||||
|
handleDelete(module);
|
||||||
|
navigation.goBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSelect = (module) => navigation.navigate('ModuleViewScreen', { module, handleDelete });
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user