mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
Merge pull request #4 from mudabbir-ahmad/Week2Act3
Week2Act3 completed
This commit is contained in:
8 files changed
+169
-44
No files matched your search
Generated
+7
-1
@@ -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",
|
||||
|
||||
+2
-1
@@ -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
|
||||
}
|
||||
@@ -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 (
|
||||
<Text style={[styles.count, { backgroundColor, color: fontColor}]}>
|
||||
Number of renders: {renderCount.current}
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
count: {
|
||||
padding: 5,
|
||||
},
|
||||
});
|
||||
|
||||
export default RenderCount;
|
||||
@@ -0,0 +1,32 @@
|
||||
import {StyleSheet, Text, View, Pressable} from "react-native";
|
||||
|
||||
const ModuleItem = ({module, onSelect}) => {
|
||||
// Initialisation -------------
|
||||
// State ----------------------
|
||||
// Handlers -------------------
|
||||
// View -----------------------
|
||||
|
||||
return (
|
||||
<Pressable key={module.ModuleCode} onPress={() => onSelect(module)}>
|
||||
<View style={styles.modulesItem}>
|
||||
<Text style={styles.text}>
|
||||
{module.ModuleCode} {module.ModuleName}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
modulesItem: {
|
||||
paddingVertical: 15,
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: "lightgray",
|
||||
},
|
||||
text: {
|
||||
fontSize: 18,
|
||||
},
|
||||
});
|
||||
|
||||
export default ModuleItem;
|
||||
@@ -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 (
|
||||
<ScrollView style={styles.modulesContainer}>
|
||||
{modules.map((module) => {
|
||||
return (
|
||||
<ModuleItem
|
||||
module={module}
|
||||
key={module.ModuleCode}
|
||||
onSelect={onSelect}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ScrollView>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
modulesContainer: {},
|
||||
});
|
||||
|
||||
export default ModuleList;
|
||||
@@ -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 style={styles.container}>
|
||||
<FullWidthImage source={{uri: module.ModuleImage}} style={styles.image}/>
|
||||
|
||||
<View style={styles.infoTray}>
|
||||
<Text style={styles.boldText}>View {module.ModuleCode} {module.ModuleName}</Text>
|
||||
<Text style={styles.text}>Level {module.ModuleLevel}</Text>
|
||||
<Text style={styles.Text}>
|
||||
{module.ModuleLeaderName} <Text style={styles.dimText}>(Module Leader)</Text>
|
||||
</Text>
|
||||
|
||||
</View>
|
||||
</View>);
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
@@ -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 (
|
||||
<Screen>
|
||||
<ScrollView style={styles.modulesContainer}>
|
||||
{modules.map((module) => {
|
||||
return(
|
||||
<Pressable key={module.ModuleCode} onPress={handleSelect}>
|
||||
<View style={styles.modulesItem}>
|
||||
<Text style={styles.text}>
|
||||
{module.ModuleCode} {module.ModuleName}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ScrollView>
|
||||
<RenderCount/>
|
||||
<ModuleList modules={modules} onSelect={handleSelect}/>
|
||||
</Screen>
|
||||
);
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<Screen style={styles.container}>
|
||||
<Text>View</Text>
|
||||
</Screen>
|
||||
);
|
||||
return (<Screen>
|
||||
<ModuleView module={module}></ModuleView>
|
||||
</Screen>);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
|
||||
Reference in new issue
Block a user