diff --git a/App.js b/App.js
index 4dcda0b..d8f34a8 100644
--- a/App.js
+++ b/App.js
@@ -1,5 +1,5 @@
-import { NavigationContainer } from "@react-navigation/native";
-import { createNativeStackNavigator } from "@react-navigation/native-stack";
+import {NavigationContainer} from "@react-navigation/native";
+import {createNativeStackNavigator} from "@react-navigation/native-stack";
import ModuleListScreen from "./src/components/screens/ModuleListScreen";
import ModuleModifyScreen from "./src/components/screens/ModuleModifyScreen";
import ModuleViewScreen from "./src/components/screens/ModuleViewScreen";
@@ -14,38 +14,38 @@ export const App = () => {
// View -----------------------
return (
-
-
+
+
-
+
-
+
-
+
-
+
);
diff --git a/package-lock.json b/package-lock.json
index de487a8..57d4335 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,7 +13,8 @@
"expo": "^54.0.20",
"expo-status-bar": "~3.0.8",
"react": "19.1.0",
- "react-native": "^0.81.5"
+ "react-native": "^0.81.5",
+ "react-native-fullwidth-image": "^0.1.3"
}
},
"node_modules/@0no-co/graphql.web": {
@@ -7756,6 +7757,11 @@
}
}
},
+ "node_modules/react-native-fullwidth-image": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/react-native-fullwidth-image/-/react-native-fullwidth-image-0.1.3.tgz",
+ "integrity": "sha512-nFe5EAEPlPaT1vw1abwnNmSZN9oLMzNXJAKKxeuWqPI9L7rGhXhpZH4KEBUzbqkk+58TjdT9d2bf070/GB4PGQ=="
+ },
"node_modules/react-native-is-edge-to-edge": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/react-native-is-edge-to-edge/-/react-native-is-edge-to-edge-1.2.1.tgz",
diff --git a/package.json b/package.json
index da46ec1..4ec2b31 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,8 @@
"expo": "^54.0.20",
"expo-status-bar": "~3.0.8",
"react": "19.1.0",
- "react-native": "^0.81.5"
+ "react-native": "^0.81.5",
+ "react-native-fullwidth-image": "^0.1.3"
},
"private": true
}
diff --git a/src/components/UI/RenderCount.js b/src/components/UI/RenderCount.js
new file mode 100644
index 0000000..1fdce24
--- /dev/null
+++ b/src/components/UI/RenderCount.js
@@ -0,0 +1,24 @@
+import { useRef } from "react";
+import { Text, StyleSheet } from "react-native";
+
+const RenderCount = ({backgroundColor = 'dodgerblue', fontColor = 'white'}) => {
+// Initialisation -------------
+// State ----------------------
+ const renderCount = useRef(0);
+ renderCount.current += 1;
+// Handlers -------------------
+// View -----------------------
+ return (
+
+ Number of renders: {renderCount.current}
+
+ );
+};
+
+const styles = StyleSheet.create({
+ count: {
+ padding: 5,
+ },
+});
+
+export default RenderCount;
\ No newline at end of file
diff --git a/src/components/entity/modules/ModuleItem.js b/src/components/entity/modules/ModuleItem.js
new file mode 100644
index 0000000..cd3bc33
--- /dev/null
+++ b/src/components/entity/modules/ModuleItem.js
@@ -0,0 +1,32 @@
+import {StyleSheet, Text, View, Pressable} from "react-native";
+
+const ModuleItem = ({module, onSelect}) => {
+ // Initialisation -------------
+ // State ----------------------
+ // Handlers -------------------
+ // View -----------------------
+
+ return (
+ onSelect(module)}>
+
+
+ {module.ModuleCode} {module.ModuleName}
+
+
+
+ );
+};
+
+
+const styles = StyleSheet.create({
+ modulesItem: {
+ paddingVertical: 15,
+ borderBottomWidth: 1,
+ borderBottomColor: "lightgray",
+ },
+ text: {
+ fontSize: 18,
+ },
+});
+
+export default ModuleItem;
\ No newline at end of file
diff --git a/src/components/entity/modules/ModuleList.js b/src/components/entity/modules/ModuleList.js
new file mode 100644
index 0000000..2245405
--- /dev/null
+++ b/src/components/entity/modules/ModuleList.js
@@ -0,0 +1,32 @@
+import {StyleSheet, ScrollView} from "react-native";
+import ModuleItem from "./ModuleItem";
+import React from "react";
+
+const ModuleList = ({modules, onSelect}) => {
+ // Initialisation -------------
+ // State ----------------------
+ // Handlers -------------------
+ // View -----------------------
+
+ return (
+
+ {modules.map((module) => {
+ return (
+
+ )
+ })
+ }
+
+ );
+};
+
+
+const styles = StyleSheet.create({
+ modulesContainer: {},
+});
+
+export default ModuleList;
\ No newline at end of file
diff --git a/src/components/entity/modules/ModuleView.js b/src/components/entity/modules/ModuleView.js
new file mode 100644
index 0000000..1319949
--- /dev/null
+++ b/src/components/entity/modules/ModuleView.js
@@ -0,0 +1,42 @@
+import {StyleSheet, Text, View } from "react-native";
+import FullWidthImage from "react-native-fullwidth-image";
+
+const ModuleView = ({module}) => {
+ // Initialisation -------------
+ // State ----------------------
+ // Handlers -------------------
+ // View -----------------------
+
+ return (
+
+
+
+ View {module.ModuleCode} {module.ModuleName}
+ Level {module.ModuleLevel}
+
+ {module.ModuleLeaderName} (Module Leader)
+
+
+
+ );
+};
+
+
+const styles = StyleSheet.create({
+ container: {
+ gap: 15,
+ }, infoTray: {
+ gap: 5,
+ }, image: {
+ borderRadius: 3,
+ }, text: {
+ fontSize: 16,
+ }, boldText: {
+ fontSize: 16, fontWeight: 'bold',
+ }, dimText: {
+ color: "grey",
+ }
+
+});
+
+export default ModuleView;
\ No newline at end of file
diff --git a/src/components/layout/Screen.js b/src/components/layout/Screen.js
index cb30888..cb4683e 100644
--- a/src/components/layout/Screen.js
+++ b/src/components/layout/Screen.js
@@ -1,5 +1,5 @@
-import { StatusBar } from "expo-status-bar";
-import { StyleSheet, View } from "react-native";
+import {StatusBar} from "expo-status-bar";
+import {StyleSheet, View} from "react-native";
const Screen = ({children}) => {
// Initialisation -------------
@@ -9,7 +9,7 @@ const Screen = ({children}) => {
return (
{children}
-
+
);
};
diff --git a/src/components/screens/ModuleAddScreen.js b/src/components/screens/ModuleAddScreen.js
index ebd9ebf..73adf8f 100644
--- a/src/components/screens/ModuleAddScreen.js
+++ b/src/components/screens/ModuleAddScreen.js
@@ -1,4 +1,4 @@
-import { StyleSheet, Text } from "react-native";
+import {StyleSheet, Text} from "react-native";
import Screen from "../layout/Screen";
export const ModuleAddScreen = () => {
@@ -6,11 +6,11 @@ export const ModuleAddScreen = () => {
// State ----------------------
// Handlers -------------------
// View -----------------------
- return (
-
- Add
-
- );
+ return (
+
+ Add
+
+ );
};
const styles = StyleSheet.create({});
diff --git a/src/components/screens/ModuleListScreen.js b/src/components/screens/ModuleListScreen.js
index e201f43..2b3f3bf 100644
--- a/src/components/screens/ModuleListScreen.js
+++ b/src/components/screens/ModuleListScreen.js
@@ -1,51 +1,36 @@
-import {StyleSheet, Text, ScrollView, View, Pressable} from "react-native";
+import {useState} from "react";
+import {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";
-
-export const ModuleListScreen = () => {
+const ModuleListScreen = ({navigation}) => {
// Initialisation -------------
- const modules = initialModules;
+// let modules = initialModules;
// State ----------------------
-// Handlers -------------------
- const handleSelect = () => alert("Item selected");
+ const [modules, setModules] = useState(initialModules);
+
+// Handlers -------------------
+
+ const handleDelete = (module) =>
+ setModules(modules.filter((item) => item.ModuleID !== module.ModuleID));
+
+ const handleSelect = (module) => navigation.navigate('ModuleViewScreen', {module});
// View -----------------------
- return (
-
-
- {modules.map((module) => {
- return(
-
-
-
- {module.ModuleCode} {module.ModuleName}
-
-
-
- )
- })
- }
-
-
- );
+
+ return (
+
+
+
+
+ );
};
-const styles = StyleSheet.create({
- modulesContainer: {
- marginTop: 20,
- },
- modulesItem: {
- padding: 15,
- marginBottom: 10,
- borderTopWidth: 1,
- borderTopColor: "light grey",
- // borderRadius: 15,
- },
- text: {
- },
-});
+const styles = StyleSheet.create({});
+
+export default ModuleListScreen;
+
-export default ModuleListScreen;
\ No newline at end of file
diff --git a/src/components/screens/ModuleModifyScreen.js b/src/components/screens/ModuleModifyScreen.js
index 6f1e973..ae2ccec 100644
--- a/src/components/screens/ModuleModifyScreen.js
+++ b/src/components/screens/ModuleModifyScreen.js
@@ -1,4 +1,4 @@
-import { StyleSheet, Text } from "react-native";
+import {StyleSheet, Text} from "react-native";
import Screen from "../layout/Screen";
export const ModuleModifyScreen = () => {
@@ -6,11 +6,11 @@ export const ModuleModifyScreen = () => {
// State ----------------------
// Handlers -------------------
// View -----------------------
- return (
-
- Modify
-
- );
+ return (
+
+ Modify
+
+ );
};
const styles = StyleSheet.create({});
diff --git a/src/components/screens/ModuleViewScreen.js b/src/components/screens/ModuleViewScreen.js
index f3796c8..6cd2918 100644
--- a/src/components/screens/ModuleViewScreen.js
+++ b/src/components/screens/ModuleViewScreen.js
@@ -1,16 +1,19 @@
-import { StyleSheet, Text } from "react-native";
+import {StyleSheet} from "react-native";
import Screen from "../layout/Screen";
+import ModuleView from "../entity/modules/ModuleView";
-export const ModuleViewScreen = () => {
+
+export const ModuleViewScreen = ({ route }) => {
// Initialisation -------------
+
+ const {module} = route.params;
+
// State ----------------------
// Handlers -------------------
// View -----------------------
- return (
-
- View
-
- );
+ return (
+
+ );
};
const styles = StyleSheet.create({});