DEV Community

Nadim Chowdhury
Nadim Chowdhury

Posted on • Edited on

How to create School Management System Mobile App with React native

Creating a school management system using React Native involves several steps, from planning the features to implementing and testing the app. Here's a high-level guide to get you started:

1. Define the Features

First, outline the features you want in your school management system. Common features include:

  • User Authentication: Admin, Teachers, Students, Parents
  • Dashboard: For quick overview and access
  • Student Management: Enrollments, attendance, grades, assignments
  • Teacher Management: Schedule, classes, attendance
  • Parent Portal: Access to student information, grades, and communication
  • Timetable Management: Class schedules
  • Notifications: Announcements, reminders
  • Communication: Messaging between teachers, students, and parents
  • Reports: Progress reports, attendance reports

2. Set Up Your Development Environment

Ensure you have the necessary tools installed:

  • Node.js
  • React Native CLI or Expo CLI (Expo is simpler for beginners)
  • Android Studio and Xcode (for Android and iOS development, respectively)

3. Initialize Your React Native Project

Using Expo CLI:

npx expo-cli init SchoolManagementSystem
cd SchoolManagementSystem
npx expo start
Enter fullscreen mode Exit fullscreen mode

Using React Native CLI:

npx react-native init SchoolManagementSystem
cd SchoolManagementSystem
npx react-native run-android
npx react-native run-ios
Enter fullscreen mode Exit fullscreen mode

4. Set Up Navigation

Install React Navigation for handling navigation within the app:

npm install @react-navigation/native
npm install @react-navigation/stack
npm install @react-navigation/bottom-tabs
npm install react-native-screens react-native-safe-area-context
Enter fullscreen mode Exit fullscreen mode

Set up the navigation structure (e.g., for a simple stack and tab navigation):

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

// Import your screens here
import HomeScreen from './screens/HomeScreen';
import ProfileScreen from './screens/ProfileScreen';
import LoginScreen from './screens/LoginScreen';

const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();

function HomeTabs() {
  return (
    <Tab.Navigator>
      <Tab.Screen name="Home" component={HomeScreen} />
      <Tab.Screen name="Profile" component={ProfileScreen} />
    </Tab.Navigator>
  );
}

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="HomeTabs" component={HomeTabs} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

5. Implement User Authentication

You can use Firebase for easy authentication:

npm install @react-native-firebase/app @react-native-firebase/auth
Enter fullscreen mode Exit fullscreen mode

Set up Firebase in your project and use it for user authentication. Here’s an example of how to handle user login:

// screens/LoginScreen.js
import React, { useState } from 'react';
import { View, TextInput, Button, Text } from 'react-native';
import auth from '@react-native-firebase/auth';

export default function LoginScreen({ navigation }) {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const handleLogin = () => {
    auth().signInWithEmailAndPassword(email, password)
      .then(() => {
        navigation.navigate('HomeTabs');
      })
      .catch(error => {
        console.error(error);
      });
  };

  return (
    <View>
      <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
      <TextInput placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry />
      <Button title="Login" onPress={handleLogin} />
    </View>
  );
}
Enter fullscreen mode Exit fullscreen mode

6. Implement Core Features

Student Management Example

// screens/StudentList.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList } from 'react-native';

export default function StudentList() {
  const [students, setStudents] = useState([]);

  useEffect(() => {
    // Fetch students from the database
    const fetchStudents = async () => {
      // Replace with your data fetching logic
      const studentsData = await fetch('https://your-api/students').then(res => res.json());
      setStudents(studentsData);
    };

    fetchStudents();
  }, []);

  return (
    <View>
      <FlatList
        data={students}
        keyExtractor={item => item.id}
        renderItem={({ item }) => <Text>{item.name}</Text>}
      />
    </View>
  );
}
Enter fullscreen mode Exit fullscreen mode

7. Integrate Backend

You can use Firebase Firestore, a custom Node.js/Express backend, or any other backend service for data management. Ensure to handle CRUD operations for all entities (students, teachers, classes, etc.).

8. Testing

Test your app thoroughly on both Android and iOS devices. Use tools like Jest for unit testing and Detox for end-to-end testing.

9. Deployment

Once everything is set up and tested, you can deploy your app to the Google Play Store and Apple App Store.

10. Maintain and Improve

Regularly update your app with new features, improvements, and bug fixes based on user feedback.

This is a basic overview. Depending on your specific requirements, you might need to implement additional features or integrate other services.

User Authentication: Admin, Teachers, Students, Parents

To implement user authentication for different roles (Admin, Teachers, Students, Parents) in a React Native app, you can use Firebase Authentication along with Firebase Firestore to manage user roles. Here’s a step-by-step guide:

1. Set Up Firebase

First, set up Firebase for your project. Go to the Firebase Console, create a new project, and set up Firebase Authentication and Firestore.

2. Install Firebase in Your React Native Project

Install the necessary Firebase packages:

npm install @react-native-firebase/app @react-native-firebase/auth @react-native-firebase/firestore
Enter fullscreen mode Exit fullscreen mode

3. Initialize Firebase in Your Project

Create a file firebase.js to initialize Firebase:

// firebase.js
import firebase from '@react-native-firebase/app';
import auth from '@react-native-firebase/auth';
import firestore from '@react-native-firebase/firestore';

const firebaseConfig = {
  apiKey: "YOUR_API_KEY",
  authDomain: "YOUR_AUTH_DOMAIN",
  projectId: "YOUR_PROJECT_ID",
  storageBucket: "YOUR_STORAGE_BUCKET",
  messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
  appId: "YOUR_APP_ID",
};

if (!firebase.apps.length) {
  firebase.initializeApp(firebaseConfig);
}

export { firebase, auth, firestore };
Enter fullscreen mode Exit fullscreen mode

4. User Registration and Role Assignment

Create a registration screen where users can sign up and select their role:

// screens/RegistrationScreen.js
import React, { useState } from 'react';
import { View, TextInput, Button, Picker, Text } from 'react-native';
import { auth, firestore } from '../firebase';

export default function RegistrationScreen({ navigation }) {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [role, setRole] = useState('Student');

  const handleRegister = () => {
    auth()
      .createUserWithEmailAndPassword(email, password)
      .then((userCredential) => {
        // Save user role in Firestore
        return firestore()
          .collection('users')
          .doc(userCredential.user.uid)
          .set({ role });
      })
      .then(() => {
        navigation.navigate('Login');
      })
      .catch(error => {
        console.error(error);
      });
  };

  return (
    <View>
      <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
      <TextInput placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry />
      <Picker selectedValue={role} onValueChange={setRole}>
        <Picker.Item label="Admin" value="Admin" />
        <Picker.Item label="Teacher" value="Teacher" />
        <Picker.Item label="Student" value="Student" />
        <Picker.Item label="Parent" value="Parent" />
      </Picker>
      <Button title="Register" onPress={handleRegister} />
    </View>
  );
}
Enter fullscreen mode Exit fullscreen mode

5. User Login and Role-Based Navigation

Create a login screen and handle role-based navigation:

// screens/LoginScreen.js
import React, { useState, useEffect } from 'react';
import { View, TextInput, Button, Text } from 'react-native';
import { auth, firestore } from '../firebase';

export default function LoginScreen({ navigation }) {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const handleLogin = () => {
    auth()
      .signInWithEmailAndPassword(email, password)
      .then((userCredential) => {
        // Fetch user role from Firestore
        return firestore()
          .collection('users')
          .doc(userCredential.user.uid)
          .get();
      })
      .then((userDoc) => {
        const role = userDoc.data().role;
        // Navigate based on user role
        if (role === 'Admin') {
          navigation.navigate('AdminHome');
        } else if (role === 'Teacher') {
          navigation.navigate('TeacherHome');
        } else if (role === 'Student') {
          navigation.navigate('StudentHome');
        } else if (role === 'Parent') {
          navigation.navigate('ParentHome');
        }
      })
      .catch(error => {
        console.error(error);
      });
  };

  return (
    <View>
      <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
      <TextInput placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry />
      <Button title="Login" onPress={handleLogin} />
    </View>
  );
}
Enter fullscreen mode Exit fullscreen mode

6. Role-Based Home Screens

Create different home screens for each role:

// screens/AdminHome.js
import React from 'react';
import { View, Text } from 'react-native';

export default function AdminHome() {
  return (
    <View>
      <Text>Admin Home Screen</Text>
    </View>
  );
}

// screens/TeacherHome.js
import React from 'react';
import { View, Text } from 'react-native';

export default function TeacherHome() {
  return (
    <View>
      <Text>Teacher Home Screen</Text>
    </View>
  );
}

// screens/StudentHome.js
import React from 'react';
import { View, Text } from 'react-native';

export default function StudentHome() {
  return (
    <View>
      <Text>Student Home Screen</Text>
    </View>
  );
}

// screens/ParentHome.js
import React from 'react';
import { View, Text } from 'react-native';

export default function ParentHome() {
  return (
    <View>
      <Text>Parent Home Screen</Text>
    </View>
  );
}
Enter fullscreen mode Exit fullscreen mode

7. Set Up Navigation

Update your App.js to include role-based navigation:

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic framework for user authentication and role-based navigation in your school management system app. You can expand on this by adding more features and improving the user interface and experience as needed.

Dashboard: For quick overview and access

To create a dashboard for a school management system in a React Native app, you'll need to display an overview of key information and provide quick access to various functionalities. Below is a step-by-step guide to create a simple dashboard with navigation to different sections like student management, teacher management, notifications, and reports.

1. Set Up the Dashboard Screen

First, create a new screen component for the dashboard.

DashboardScreen.js

// screens/DashboardScreen.js
import React from 'react';
import { View, Text, Button, StyleSheet, ScrollView } from 'react-native';

export default function DashboardScreen({ navigation }) {
  return (
    <ScrollView style={styles.container}>
      <View style={styles.section}>
        <Text style={styles.header}>Dashboard</Text>
        <Text style={styles.subheader}>Quick Overview</Text>
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionHeader}>Student Management</Text>
        <Button title="View Students" onPress={() => navigation.navigate('StudentList')} />
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionHeader}>Teacher Management</Text>
        <Button title="View Teachers" onPress={() => navigation.navigate('TeacherList')} />
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionHeader}>Notifications</Text>
        <Button title="View Notifications" onPress={() => navigation.navigate('Notifications')} />
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionHeader}>Reports</Text>
        <Button title="View Reports" onPress={() => navigation.navigate('Reports')} />
      </View>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  section: {
    marginVertical: 10,
  },
  header: {
    fontSize: 24,
    fontWeight: 'bold',
    textAlign: 'center',
    marginBottom: 10,
  },
  subheader: {
    fontSize: 18,
    textAlign: 'center',
    marginBottom: 20,
  },
  sectionHeader: {
    fontSize: 20,
    fontWeight: 'bold',
    marginBottom: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

2. Update Navigation

Add the new Dashboard screen to your navigation stack in App.js.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

3. Create Placeholder Screens for Navigation

Create placeholder screens for student list, teacher list, notifications, and reports.

StudentList.js

// screens/StudentList.js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

export default function StudentList() {
  return (
    <View style={styles.container}>
      <Text>Student List</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

TeacherList.js

// screens/TeacherList.js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

export default function TeacherList() {
  return (
    <View style={styles.container}>
      <Text>Teacher List</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

Notifications.js

// screens/Notifications.js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

export default function Notifications() {
  return (
    <View style={styles.container}>
      <Text>Notifications</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

Reports.js

// screens/Reports.js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

export default function Reports() {
  return (
    <View style={styles.container}>
      <Text>Reports</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

4. Access Control Based on Roles

Modify the login process to navigate to the dashboard if the user is an admin or to other role-specific screens if needed.

LoginScreen.js (Updated)

// screens/LoginScreen.js
import React, { useState, useEffect } from 'react';
import { View, TextInput, Button, Text } from 'react-native';
import { auth, firestore } from '../firebase';

export default function LoginScreen({ navigation }) {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const handleLogin = () => {
    auth()
      .signInWithEmailAndPassword(email, password)
      .then((userCredential) => {
        // Fetch user role from Firestore
        return firestore()
          .collection('users')
          .doc(userCredential.user.uid)
          .get();
      })
      .then((userDoc) => {
        const role = userDoc.data().role;
        // Navigate based on user role
        if (role === 'Admin') {
          navigation.navigate('Dashboard');
        } else if (role === 'Teacher') {
          navigation.navigate('TeacherHome');
        } else if (role === 'Student') {
          navigation.navigate('StudentHome');
        } else if (role === 'Parent') {
          navigation.navigate('ParentHome');
        }
      })
      .catch(error => {
        console.error(error);
      });
  };

  return (
    <View>
      <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
      <TextInput placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry />
      <Button title="Login" onPress={handleLogin} />
    </View>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic dashboard screen that serves as an entry point for admins to quickly access different sections of the app. You can expand the dashboard with more detailed overviews and additional functionalities as needed.

Student Management: Enrollments, attendance, grades, assignments

To create a comprehensive Student Management system within your React Native app, you will need to handle various functionalities such as enrollments, attendance, grades, and assignments. Below, I'll outline the implementation for each of these features.

1. Setup Firebase Firestore for Data Storage

Ensure you have the necessary collections and documents in Firestore to store information related to students, attendance, grades, and assignments.

2. Student Management Screen

Create a main screen for student management where you can navigate to different functionalities.

StudentManagementScreen.js

// screens/StudentManagementScreen.js
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';

export default function StudentManagementScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Button title="Enroll Students" onPress={() => navigation.navigate('EnrollStudent')} />
      <Button title="View Attendance" onPress={() => navigation.navigate('Attendance')} />
      <Button title="View Grades" onPress={() => navigation.navigate('Grades')} />
      <Button title="View Assignments" onPress={() => navigation.navigate('Assignments')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

3. Enrollments

Create a screen to enroll new students.

EnrollStudent.js

// screens/EnrollStudent.js
import React, { useState } from 'react';
import { View, TextInput, Button, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function EnrollStudent() {
  const [name, setName] = useState('');
  const [email, setEmail] = useState('');

  const handleEnroll = () => {
    firestore()
      .collection('students')
      .add({ name, email })
      .then(() => {
        Alert.alert('Student enrolled successfully');
        setName('');
        setEmail('');
      })
      .catch(error => {
        Alert.alert('Error enrolling student', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <TextInput placeholder="Name" value={name} onChangeText={setName} style={styles.input} />
      <TextInput placeholder="Email" value={email} onChangeText={setEmail} style={styles.input} />
      <Button title="Enroll Student" onPress={handleEnroll} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

4. Attendance

Create a screen to manage and view attendance.

Attendance.js

// screens/Attendance.js
import React, { useState, useEffect } from 'react';
import { View, Text, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function Attendance() {
  const [students, setStudents] = useState([]);
  const [attendance, setAttendance] = useState({});

  useEffect(() => {
    firestore()
      .collection('students')
      .get()
      .then(querySnapshot => {
        const studentsData = [];
        querySnapshot.forEach(documentSnapshot => {
          studentsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setStudents(studentsData);
      });
  }, []);

  const handleAttendance = (studentId, status) => {
    setAttendance({ ...attendance, [studentId]: status });
  };

  const handleSaveAttendance = () => {
    const today = new Date().toISOString().split('T')[0];
    const batch = firestore().batch();

    Object.keys(attendance).forEach(studentId => {
      const ref = firestore().collection('attendance').doc(`${studentId}_${today}`);
      batch.set(ref, { studentId, date: today, status: attendance[studentId] });
    });

    batch.commit()
      .then(() => {
        Alert.alert('Attendance saved successfully');
      })
      .catch(error => {
        Alert.alert('Error saving attendance', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <FlatList
        data={students}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.student}>
            <Text>{item.name}</Text>
            <Button title="Present" onPress={() => handleAttendance(item.id, 'Present')} />
            <Button title="Absent" onPress={() => handleAttendance(item.id, 'Absent')} />
          </View>
        )}
      />
      <Button title="Save Attendance" onPress={handleSaveAttendance} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  student: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    marginBottom: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Grades

Create a screen to manage and view grades.

Grades.js

// screens/Grades.js
import React, { useState, useEffect } from 'react';
import { View, Text, TextInput, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function Grades() {
  const [students, setStudents] = useState([]);
  const [grades, setGrades] = useState({});

  useEffect(() => {
    firestore()
      .collection('students')
      .get()
      .then(querySnapshot => {
        const studentsData = [];
        querySnapshot.forEach(documentSnapshot => {
          studentsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setStudents(studentsData);
      });
  }, []);

  const handleGradeChange = (studentId, grade) => {
    setGrades({ ...grades, [studentId]: grade });
  };

  const handleSaveGrades = () => {
    const batch = firestore().batch();

    Object.keys(grades).forEach(studentId => {
      const ref = firestore().collection('grades').doc(studentId);
      batch.set(ref, { studentId, grade: grades[studentId] });
    });

    batch.commit()
      .then(() => {
        Alert.alert('Grades saved successfully');
      })
      .catch(error => {
        Alert.alert('Error saving grades', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <FlatList
        data={students}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.student}>
            <Text>{item.name}</Text>
            <TextInput
              style={styles.input}
              placeholder="Grade"
              onChangeText={(grade) => handleGradeChange(item.id, grade)}
              value={grades[item.id] || ''}
            />
          </View>
        )}
      />
      <Button title="Save Grades" onPress={handleSaveGrades} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  student: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    marginBottom: 10,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    paddingHorizontal: 10,
    width: 100,
  },
});
Enter fullscreen mode Exit fullscreen mode

6. Assignments

Create a screen to manage and view assignments.

Assignments.js

// screens/Assignments.js
import React, { useState, useEffect } from 'react';
import { View, Text, TextInput, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function Assignments() {
  const [assignments, setAssignments] = useState([]);
  const [title, setTitle] = useState('');
  const [description, setDescription] = useState('');

  useEffect(() => {
    firestore()
      .collection('assignments')
      .get()
      .then(querySnapshot => {
        const assignmentsData = [];
        querySnapshot.forEach(documentSnapshot => {
          assignmentsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setAssignments(assignmentsData);
      });
  }, []);

  const handleAddAssignment = () => {
    firestore()
      .collection('assignments')
      .add({ title, description })
      .then(() => {
        Alert.alert('Assignment added successfully');
        setTitle('');
        setDescription('');
      })
      .catch(error => {
        Alert.alert('Error adding assignment', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <TextInput placeholder="Title" value={title} onChangeText={setTitle} style={styles.input} />
      <TextInput placeholder="Description" value={description} onChangeText={setDescription} style={styles.input} />
      <Button title="Add Assignment" onPress={handleAddAssignment} />

      <FlatList
        data={assignments}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.assignment}>
            <Text

>{item.title}</Text>
            <Text>{item.description}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
  assignment: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

7. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for managing student enrollments, attendance, grades, and assignments. You can expand and refine these features based on your specific requirements and use cases.

Teacher Management: Schedule, classes, attendance

To create a Teacher Management system within your React Native app, you will need to handle functionalities such as scheduling, managing classes, and tracking attendance. Below, I'll outline the implementation for each of these features.

1. Setup Firebase Firestore for Data Storage

Ensure you have the necessary collections and documents in Firestore to store information related to teachers, schedules, classes, and attendance.

2. Teacher Management Screen

Create a main screen for teacher management where you can navigate to different functionalities.

TeacherManagementScreen.js

// screens/TeacherManagementScreen.js
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';

export default function TeacherManagementScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Button title="Manage Schedule" onPress={() => navigation.navigate('ManageSchedule')} />
      <Button title="Manage Classes" onPress={() => navigation.navigate('ManageClasses')} />
      <Button title="Teacher Attendance" onPress={() => navigation.navigate('TeacherAttendance')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

3. Manage Schedule

Create a screen to manage the schedules of teachers.

ManageSchedule.js

// screens/ManageSchedule.js
import React, { useState, useEffect } from 'react';
import { View, TextInput, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function ManageSchedule() {
  const [teachers, setTeachers] = useState([]);
  const [schedule, setSchedule] = useState({});
  const [teacherId, setTeacherId] = useState('');
  const [classDetails, setClassDetails] = useState('');

  useEffect(() => {
    firestore()
      .collection('teachers')
      .get()
      .then(querySnapshot => {
        const teachersData = [];
        querySnapshot.forEach(documentSnapshot => {
          teachersData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setTeachers(teachersData);
      });
  }, []);

  const handleAddSchedule = () => {
    firestore()
      .collection('schedules')
      .add({ teacherId, classDetails })
      .then(() => {
        Alert.alert('Schedule added successfully');
        setTeacherId('');
        setClassDetails('');
      })
      .catch(error => {
        Alert.alert('Error adding schedule', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <TextInput
        placeholder="Teacher ID"
        value={teacherId}
        onChangeText={setTeacherId}
        style={styles.input}
      />
      <TextInput
        placeholder="Class Details"
        value={classDetails}
        onChangeText={setClassDetails}
        style={styles.input}
      />
      <Button title="Add Schedule" onPress={handleAddSchedule} />
      <FlatList
        data={teachers}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.teacher}>
            <Text>{item.name}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
  teacher: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

4. Manage Classes

Create a screen to manage classes assigned to teachers.

ManageClasses.js

// screens/ManageClasses.js
import React, { useState, useEffect } from 'react';
import { View, TextInput, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function ManageClasses() {
  const [teachers, setTeachers] = useState([]);
  const [classes, setClasses] = useState({});
  const [teacherId, setTeacherId] = useState('');
  const [className, setClassName] = useState('');

  useEffect(() => {
    firestore()
      .collection('teachers')
      .get()
      .then(querySnapshot => {
        const teachersData = [];
        querySnapshot.forEach(documentSnapshot => {
          teachersData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setTeachers(teachersData);
      });
  }, []);

  const handleAddClass = () => {
    firestore()
      .collection('classes')
      .add({ teacherId, className })
      .then(() => {
        Alert.alert('Class assigned successfully');
        setTeacherId('');
        setClassName('');
      })
      .catch(error => {
        Alert.alert('Error assigning class', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <TextInput
        placeholder="Teacher ID"
        value={teacherId}
        onChangeText={setTeacherId}
        style={styles.input}
      />
      <TextInput
        placeholder="Class Name"
        value={className}
        onChangeText={setClassName}
        style={styles.input}
      />
      <Button title="Assign Class" onPress={handleAddClass} />
      <FlatList
        data={teachers}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.teacher}>
            <Text>{item.name}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
  teacher: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Teacher Attendance

Create a screen to track teacher attendance.

TeacherAttendance.js

// screens/TeacherAttendance.js
import React, { useState, useEffect } from 'react';
import { View, Text, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function TeacherAttendance() {
  const [teachers, setTeachers] = useState([]);
  const [attendance, setAttendance] = useState({});

  useEffect(() => {
    firestore()
      .collection('teachers')
      .get()
      .then(querySnapshot => {
        const teachersData = [];
        querySnapshot.forEach(documentSnapshot => {
          teachersData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setTeachers(teachersData);
      });
  }, []);

  const handleAttendance = (teacherId, status) => {
    setAttendance({ ...attendance, [teacherId]: status });
  };

  const handleSaveAttendance = () => {
    const today = new Date().toISOString().split('T')[0];
    const batch = firestore().batch();

    Object.keys(attendance).forEach(teacherId => {
      const ref = firestore().collection('teacherAttendance').doc(`${teacherId}_${today}`);
      batch.set(ref, { teacherId, date: today, status: attendance[teacherId] });
    });

    batch.commit()
      .then(() => {
        Alert.alert('Attendance saved successfully');
      })
      .catch(error => {
        Alert.alert('Error saving attendance', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <FlatList
        data={teachers}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.teacher}>
            <Text>{item.name}</Text>
            <Button title="Present" onPress={() => handleAttendance(item.id, 'Present')} />
            <Button title="Absent" onPress={() => handleAttendance(item.id, 'Absent')} />
          </View>
        )}
      />
      <Button title="Save Attendance" onPress={handleSaveAttendance} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  teacher: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    marginBottom: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

6. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens

/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';
import TeacherManagementScreen from './screens/TeacherManagementScreen';
import ManageSchedule from './screens/ManageSchedule';
import ManageClasses from './screens/ManageClasses';
import TeacherAttendance from './screens/TeacherAttendance';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
        <Stack.Screen name="TeacherManagement" component={TeacherManagementScreen} />
        <Stack.Screen name="ManageSchedule" component={ManageSchedule} />
        <Stack.Screen name="ManageClasses" component={ManageClasses} />
        <Stack.Screen name="TeacherAttendance" component={TeacherAttendance} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for managing teacher schedules, classes, and attendance. You can expand and refine these features based on your specific requirements and use cases.

Parent Portal: Access to student information, grades, and communication

To create a Parent Portal within your React Native app, you will need to provide functionalities that allow parents to access student information, grades, and communicate with teachers. Here is a step-by-step guide to implement these features.

1. Setup Firebase Firestore for Data Storage

Ensure you have the necessary collections and documents in Firestore to store information related to students, grades, and messages.

2. Parent Portal Screen

Create a main screen for the Parent Portal where parents can navigate to different functionalities.

ParentPortalScreen.js

// screens/ParentPortalScreen.js
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';

export default function ParentPortalScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Button title="View Student Information" onPress={() => navigation.navigate('StudentInfo')} />
      <Button title="View Grades" onPress={() => navigation.navigate('ParentGrades')} />
      <Button title="Communicate with Teachers" onPress={() => navigation.navigate('Communicate')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

3. View Student Information

Create a screen to display student information.

StudentInfo.js

// screens/StudentInfo.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { firestore } from '../firebase';

export default function StudentInfo() {
  const [students, setStudents] = useState([]);

  useEffect(() => {
    // Assuming each parent is linked to a student
    firestore()
      .collection('students')
      .get()
      .then(querySnapshot => {
        const studentsData = [];
        querySnapshot.forEach(documentSnapshot => {
          studentsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setStudents(studentsData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <FlatList
        data={students}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.student}>
            <Text>Name: {item.name}</Text>
            <Text>Email: {item.email}</Text>
            <Text>Grade: {item.grade}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  student: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

4. View Grades

Create a screen to display grades of the students.

ParentGrades.js

// screens/ParentGrades.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { firestore } from '../firebase';

export default function ParentGrades() {
  const [grades, setGrades] = useState([]);

  useEffect(() => {
    firestore()
      .collection('grades')
      .get()
      .then(querySnapshot => {
        const gradesData = [];
        querySnapshot.forEach(documentSnapshot => {
          gradesData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setGrades(gradesData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <FlatList
        data={grades}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.grade}>
            <Text>Student ID: {item.studentId}</Text>
            <Text>Grade: {item.grade}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  grade: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Communicate with Teachers

Create a screen to handle communication between parents and teachers.

Communicate.js

// screens/Communicate.js
import React, { useState, useEffect } from 'react';
import { View, TextInput, Button, FlatList, Text, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function Communicate() {
  const [teachers, setTeachers] = useState([]);
  const [message, setMessage] = useState('');
  const [teacherId, setTeacherId] = useState('');

  useEffect(() => {
    firestore()
      .collection('teachers')
      .get()
      .then(querySnapshot => {
        const teachersData = [];
        querySnapshot.forEach(documentSnapshot => {
          teachersData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setTeachers(teachersData);
      });
  }, []);

  const handleSendMessage = () => {
    firestore()
      .collection('messages')
      .add({ teacherId, message, date: new Date().toISOString() })
      .then(() => {
        Alert.alert('Message sent successfully');
        setMessage('');
        setTeacherId('');
      })
      .catch(error => {
        Alert.alert('Error sending message', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <FlatList
        data={teachers}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.teacher}>
            <Text>{item.name}</Text>
            <Button title="Select" onPress={() => setTeacherId(item.id)} />
          </View>
        )}
      />
      <TextInput
        placeholder="Type your message"
        value={message}
        onChangeText={setMessage}
        style={styles.input}
      />
      <Button title="Send Message" onPress={handleSendMessage} disabled={!teacherId || !message} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  teacher: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    marginBottom: 10,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

6. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';
import TeacherManagementScreen from './screens/TeacherManagementScreen';
import ManageSchedule from './screens/ManageSchedule';
import ManageClasses from './screens/ManageClasses';
import TeacherAttendance from './screens/TeacherAttendance';
import ParentPortalScreen from './screens/ParentPortalScreen';
import StudentInfo from './screens/StudentInfo';
import ParentGrades from './screens/ParentGrades';
import Communicate from './screens/Communicate';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
        <Stack.Screen name="TeacherManagement" component={TeacherManagementScreen} />
        <Stack.Screen name="ManageSchedule" component={ManageSchedule} />
        <Stack.Screen name="ManageClasses" component={

ManageClasses} />
        <Stack.Screen name="TeacherAttendance" component={TeacherAttendance} />
        <Stack.Screen name="ParentPortal" component={ParentPortalScreen} />
        <Stack.Screen name="StudentInfo" component={StudentInfo} />
        <Stack.Screen name="ParentGrades" component={ParentGrades} />
        <Stack.Screen name="Communicate" component={Communicate} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for a Parent Portal where parents can access student information, view grades, and communicate with teachers. You can expand and refine these features based on your specific requirements and use cases.

Timetable Management: Class schedules

To implement timetable management for class schedules in your React Native app, you will need to provide functionality for adding, viewing, and managing class schedules. Below is a step-by-step guide to implement these features.

1. Setup Firebase Firestore for Data Storage

Ensure you have a collection in Firestore to store the class schedules.

2. Timetable Management Screen

Create a main screen for timetable management where users can navigate to different functionalities like viewing and managing class schedules.

TimetableManagementScreen.js

// screens/TimetableManagementScreen.js
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';

export default function TimetableManagementScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Button title="View Timetable" onPress={() => navigation.navigate('ViewTimetable')} />
      <Button title="Manage Timetable" onPress={() => navigation.navigate('ManageTimetable')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

3. View Timetable

Create a screen to display the timetable for classes.

ViewTimetable.js

// screens/ViewTimetable.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { firestore } from '../firebase';

export default function ViewTimetable() {
  const [timetable, setTimetable] = useState([]);

  useEffect(() => {
    firestore()
      .collection('timetable')
      .get()
      .then(querySnapshot => {
        const timetableData = [];
        querySnapshot.forEach(documentSnapshot => {
          timetableData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setTimetable(timetableData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <FlatList
        data={timetable}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.scheduleItem}>
            <Text>Class: {item.className}</Text>
            <Text>Teacher: {item.teacherName}</Text>
            <Text>Time: {item.time}</Text>
            <Text>Day: {item.day}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  scheduleItem: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

4. Manage Timetable

Create a screen to manage (add/edit/delete) class schedules.

ManageTimetable.js

// screens/ManageTimetable.js
import React, { useState, useEffect } from 'react';
import { View, TextInput, Button, FlatList, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';

export default function ManageTimetable() {
  const [className, setClassName] = useState('');
  const [teacherName, setTeacherName] = useState('');
  const [time, setTime] = useState('');
  const [day, setDay] = useState('');
  const [timetable, setTimetable] = useState([]);

  useEffect(() => {
    firestore()
      .collection('timetable')
      .get()
      .then(querySnapshot => {
        const timetableData = [];
        querySnapshot.forEach(documentSnapshot => {
          timetableData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setTimetable(timetableData);
      });
  }, []);

  const handleAddSchedule = () => {
    const newSchedule = { className, teacherName, time, day };
    firestore()
      .collection('timetable')
      .add(newSchedule)
      .then(() => {
        Alert.alert('Schedule added successfully');
        setTimetable([...timetable, { id: new Date().getTime().toString(), ...newSchedule }]);
        setClassName('');
        setTeacherName('');
        setTime('');
        setDay('');
      })
      .catch(error => {
        Alert.alert('Error adding schedule', error.message);
      });
  };

  const handleDeleteSchedule = (id) => {
    firestore()
      .collection('timetable')
      .doc(id)
      .delete()
      .then(() => {
        Alert.alert('Schedule deleted successfully');
        setTimetable(timetable.filter(item => item.id !== id));
      })
      .catch(error => {
        Alert.alert('Error deleting schedule', error.message);
      });
  };

  return (
    <View style={styles.container}>
      <TextInput placeholder="Class Name" value={className} onChangeText={setClassName} style={styles.input} />
      <TextInput placeholder="Teacher Name" value={teacherName} onChangeText={setTeacherName} style={styles.input} />
      <TextInput placeholder="Time" value={time} onChangeText={setTime} style={styles.input} />
      <TextInput placeholder="Day" value={day} onChangeText={setDay} style={styles.input} />
      <Button title="Add Schedule" onPress={handleAddSchedule} />
      <FlatList
        data={timetable}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.scheduleItem}>
            <Text>Class: {item.className}</Text>
            <Text>Teacher: {item.teacherName}</Text>
            <Text>Time: {item.time}</Text>
            <Text>Day: {item.day}</Text>
            <Button title="Delete" onPress={() => handleDeleteSchedule(item.id)} />
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
  scheduleItem: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';
import TeacherManagementScreen from './screens/TeacherManagementScreen';
import ManageSchedule from './screens/ManageSchedule';
import ManageClasses from './screens/ManageClasses';
import TeacherAttendance from './screens/TeacherAttendance';
import ParentPortalScreen from './screens/ParentPortalScreen';
import StudentInfo from './screens/StudentInfo';
import ParentGrades from './screens/ParentGrades';
import Communicate from './screens/Communicate';
import TimetableManagementScreen from './screens/TimetableManagementScreen';
import ViewTimetable from './screens/ViewTimetable';
import ManageTimetable from './screens/ManageTimetable';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
        <Stack.Screen name="TeacherManagement" component={TeacherManagementScreen} />
        <Stack.Screen name="ManageSchedule" component={ManageSchedule} />
        <Stack.Screen name="ManageClasses" component={ManageClasses} />
        <Stack.Screen name="TeacherAttendance" component={TeacherAttendance} />


        <Stack.Screen name="ParentPortal" component={ParentPortalScreen} />
        <Stack.Screen name="StudentInfo" component={StudentInfo} />
        <Stack.Screen name="ParentGrades" component={ParentGrades} />
        <Stack.Screen name="Communicate" component={Communicate} />
        <Stack.Screen name="TimetableManagement" component={TimetableManagementScreen} />
        <Stack.Screen name="ViewTimetable" component={ViewTimetable} />
        <Stack.Screen name="ManageTimetable" component={ManageTimetable} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for timetable management, allowing users to view and manage class schedules. You can expand and refine these features based on your specific requirements and use cases.

Notifications: Announcements, reminders

To implement notifications for announcements and reminders in your React Native app, you will need to create functionalities to add, view, and manage notifications. You can use Firebase Firestore to store notifications and React Native's local notifications library to handle displaying notifications.

1. Setup Firebase Firestore for Data Storage

Ensure you have a collection in Firestore to store notifications.

2. Install Required Libraries

Install React Native's local notifications library:

npm install @notifee/react-native
Enter fullscreen mode Exit fullscreen mode

Install the necessary pods for iOS:

cd ios
pod install
cd ..
Enter fullscreen mode Exit fullscreen mode

3. Notifications Management Screen

Create a main screen for managing notifications where users can navigate to different functionalities like viewing and adding notifications.

NotificationsManagementScreen.js

// screens/NotificationsManagementScreen.js
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';

export default function NotificationsManagementScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Button title="View Notifications" onPress={() => navigation.navigate('ViewNotifications')} />
      <Button title="Add Notification" onPress={() => navigation.navigate('AddNotification')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

4. View Notifications

Create a screen to display notifications.

ViewNotifications.js

// screens/ViewNotifications.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { firestore } from '../firebase';

export default function ViewNotifications() {
  const [notifications, setNotifications] = useState([]);

  useEffect(() => {
    firestore()
      .collection('notifications')
      .get()
      .then(querySnapshot => {
        const notificationsData = [];
        querySnapshot.forEach(documentSnapshot => {
          notificationsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setNotifications(notificationsData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <FlatList
        data={notifications}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.notificationItem}>
            <Text>Title: {item.title}</Text>
            <Text>Message: {item.message}</Text>
            <Text>Date: {item.date}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  notificationItem: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Add Notification

Create a screen to add new notifications.

AddNotification.js

// screens/AddNotification.js
import React, { useState } from 'react';
import { View, TextInput, Button, StyleSheet, Alert } from 'react-native';
import { firestore } from '../firebase';
import notifee from '@notifee/react-native';

export default function AddNotification() {
  const [title, setTitle] = useState('');
  const [message, setMessage] = useState('');
  const [date, setDate] = useState('');

  const handleAddNotification = async () => {
    try {
      await firestore().collection('notifications').add({
        title,
        message,
        date,
      });

      // Schedule local notification
      await notifee.createTriggerNotification(
        {
          title: title,
          body: message,
          android: {
            channelId: 'default',
          },
        },
        {
          type: notifee.TriggerType.TIMESTAMP,
          timestamp: new Date(date).getTime(), // Fire at specific date/time
        }
      );

      Alert.alert('Notification added successfully');
      setTitle('');
      setMessage('');
      setDate('');
    } catch (error) {
      Alert.alert('Error adding notification', error.message);
    }
  };

  return (
    <View style={styles.container}>
      <TextInput
        placeholder="Title"
        value={title}
        onChangeText={setTitle}
        style={styles.input}
      />
      <TextInput
        placeholder="Message"
        value={message}
        onChangeText={setMessage}
        style={styles.input}
      />
      <TextInput
        placeholder="Date (YYYY-MM-DD HH:MM:SS)"
        value={date}
        onChangeText={setDate}
        style={styles.input}
      />
      <Button title="Add Notification" onPress={handleAddNotification} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

6. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';
import TeacherManagementScreen from './screens/TeacherManagementScreen';
import ManageSchedule from './screens/ManageSchedule';
import ManageClasses from './screens/ManageClasses';
import TeacherAttendance from './screens/TeacherAttendance';
import ParentPortalScreen from './screens/ParentPortalScreen';
import StudentInfo from './screens/StudentInfo';
import ParentGrades from './screens/ParentGrades';
import Communicate from './screens/Communicate';
import TimetableManagementScreen from './screens/TimetableManagementScreen';
import ViewTimetable from './screens/ViewTimetable';
import ManageTimetable from './screens/ManageTimetable';
import NotificationsManagementScreen from './screens/NotificationsManagementScreen';
import ViewNotifications from './screens/ViewNotifications';
import AddNotification from './screens/AddNotification';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
        <Stack.Screen name="TeacherManagement" component={TeacherManagementScreen} />
        <Stack.Screen name="ManageSchedule" component={ManageSchedule} />
        <Stack.Screen name="ManageClasses" component={ManageClasses} />
        <Stack.Screen name="TeacherAttendance" component={TeacherAttendance} />
        <Stack.Screen name="ParentPortal" component={ParentPortalScreen} />
        <Stack.Screen name="StudentInfo" component={StudentInfo} />
        <Stack.Screen name="ParentGrades" component={ParentGrades} />
        <Stack.Screen name="Communicate" component={Communicate} />
        <Stack.Screen name="TimetableManagement" component={TimetableManagementScreen} />
        <Stack.Screen name="ViewTimetable" component={ViewTimetable} />
        <Stack.Screen name="ManageTimetable" component={ManageTimetable} />
        <Stack.Screen name="NotificationsManagement" component={NotificationsManagementScreen} />
        <Stack.Screen name="ViewNotifications" component={ViewNotifications} />
        <Stack.Screen name="AddNotification" component={AddNotification} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

7. Configure Notifee

To display local notifications, you need to configure Notifee in your project.

Create a notification channel for Android

// App.js
import notifee from '@notifee/react-native';

notifee.createChannel({
  id: 'default',
  name: 'Default Channel',
});
Enter fullscreen mode Exit fullscreen mode

8. Request Permissions

Request notification

permissions when the app starts:

// App.js
import notifee from '@notifee/react-native';
import React, { useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

useEffect(() => {
  async function requestPermission() {
    await notifee.requestPermission();
  }
  requestPermission();
}, []);
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for managing notifications, including viewing and adding announcements and reminders. You can expand and refine these features based on your specific requirements and use cases.

Communication: Messaging between teachers, students, and parents

To implement a messaging feature for communication between teachers, students, and parents in your React Native app, you will need to create functionalities to send, view, and manage messages. Firebase Firestore can be used to store messages, and Firebase Authentication can handle user roles.

1. Setup Firebase Firestore for Data Storage

Ensure you have a collection in Firestore to store messages.

2. Install Required Libraries

Install the necessary Firebase packages:

npm install @react-native-firebase/app @react-native-firebase/auth @react-native-firebase/firestore
Enter fullscreen mode Exit fullscreen mode

3. Communication Screen

Create a main screen for communication where users can navigate to different chat rooms or start a new conversation.

CommunicationScreen.js

// screens/CommunicationScreen.js
import React, { useState, useEffect } from 'react';
import { View, Button, FlatList, TextInput, StyleSheet } from 'react-native';
import { firestore, auth } from '../firebase';

export default function CommunicationScreen({ navigation }) {
  const [users, setUsers] = useState([]);
  const [searchQuery, setSearchQuery] = useState('');

  useEffect(() => {
    firestore()
      .collection('users')
      .get()
      .then(querySnapshot => {
        const usersData = [];
        querySnapshot.forEach(documentSnapshot => {
          usersData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setUsers(usersData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <TextInput
        placeholder="Search user by name"
        value={searchQuery}
        onChangeText={setSearchQuery}
        style={styles.input}
      />
      <FlatList
        data={users.filter(user => user.name.toLowerCase().includes(searchQuery.toLowerCase()))}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.userItem}>
            <Button
              title={item.name}
              onPress={() => navigation.navigate('Chat', { recipientId: item.id, recipientName: item.name })}
            />
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 20,
    paddingHorizontal: 10,
  },
  userItem: {
    marginVertical: 10,
  },
});
Enter fullscreen mode Exit fullscreen mode

4. Chat Screen

Create a screen to handle individual chat conversations.

ChatScreen.js

// screens/ChatScreen.js
import React, { useState, useEffect } from 'react';
import { View, Text, TextInput, Button, FlatList, StyleSheet } from 'react-native';
import { firestore, auth } from '../firebase';

export default function ChatScreen({ route }) {
  const { recipientId, recipientName } = route.params;
  const [message, setMessage] = useState('');
  const [messages, setMessages] = useState([]);
  const userId = auth().currentUser.uid;

  useEffect(() => {
    const unsubscribe = firestore()
      .collection('messages')
      .where('participants', 'array-contains', userId)
      .orderBy('createdAt', 'desc')
      .onSnapshot(querySnapshot => {
        const messagesData = [];
        querySnapshot.forEach(documentSnapshot => {
          const data = documentSnapshot.data();
          if (data.participants.includes(recipientId)) {
            messagesData.push({ id: documentSnapshot.id, ...data });
          }
        });
        setMessages(messagesData);
      });

    return () => unsubscribe();
  }, [recipientId, userId]);

  const handleSendMessage = () => {
    const newMessage = {
      text: message,
      senderId: userId,
      recipientId: recipientId,
      participants: [userId, recipientId],
      createdAt: firestore.FieldValue.serverTimestamp(),
    };

    firestore()
      .collection('messages')
      .add(newMessage)
      .then(() => {
        setMessage('');
      })
      .catch(error => {
        console.error('Error sending message: ', error);
      });
  };

  return (
    <View style={styles.container}>
      <Text style={styles.recipientName}>Chat with {recipientName}</Text>
      <FlatList
        data={messages}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={item.senderId === userId ? styles.sentMessage : styles.receivedMessage}>
            <Text>{item.text}</Text>
          </View>
        )}
        inverted
      />
      <TextInput
        placeholder="Type a message"
        value={message}
        onChangeText={setMessage}
        style={styles.input}
      />
      <Button title="Send" onPress={handleSendMessage} disabled={!message} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  recipientName: {
    fontSize: 18,
    marginBottom: 10,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    marginBottom: 10,
    paddingHorizontal: 10,
  },
  sentMessage: {
    alignSelf: 'flex-end',
    backgroundColor: '#DCF8C6',
    padding: 10,
    borderRadius: 10,
    marginVertical: 5,
  },
  receivedMessage: {
    alignSelf: 'flex-start',
    backgroundColor: '#E5E5EA',
    padding: 10,
    borderRadius: 10,
    marginVertical: 5,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';
import TeacherManagementScreen from './screens/TeacherManagementScreen';
import ManageSchedule from './screens/ManageSchedule';
import ManageClasses from './screens/ManageClasses';
import TeacherAttendance from './screens/TeacherAttendance';
import ParentPortalScreen from './screens/ParentPortalScreen';
import StudentInfo from './screens/StudentInfo';
import ParentGrades from './screens/ParentGrades';
import Communicate from './screens/Communicate';
import TimetableManagementScreen from './screens/TimetableManagementScreen';
import ViewTimetable from './screens/ViewTimetable';
import ManageTimetable from './screens/ManageTimetable';
import NotificationsManagementScreen from './screens/NotificationsManagementScreen';
import ViewNotifications from './screens/ViewNotifications';
import AddNotification from './screens/AddNotification';
import CommunicationScreen from './screens/CommunicationScreen';
import ChatScreen from './screens/ChatScreen';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={Reports} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
        <Stack.Screen name="TeacherManagement" component={TeacherManagementScreen} />
        <Stack.Screen name="ManageSchedule" component={ManageSchedule} />
        <Stack.Screen name="ManageClasses" component={ManageClasses} />
        <Stack.Screen name="TeacherAttendance" component={TeacherAttendance} />
        <Stack.Screen name="ParentPortal" component={ParentPortalScreen} />
        <Stack.Screen name="StudentInfo" component={StudentInfo} />
        <Stack.Screen name="ParentGrades" component={ParentGrades} />
        <Stack.Screen name="Communicate" component={Communicate} />
        <Stack.Screen name="TimetableManagement" component={TimetableManagementScreen} />
        <Stack

.Screen name="ViewTimetable" component={ViewTimetable} />
        <Stack.Screen name="ManageTimetable" component={ManageTimetable} />
        <Stack.Screen name="NotificationsManagement" component={NotificationsManagementScreen} />
        <Stack.Screen name="ViewNotifications" component={ViewNotifications} />
        <Stack.Screen name="AddNotification" component={AddNotification} />
        <Stack.Screen name="Communication" component={CommunicationScreen} />
        <Stack.Screen name="Chat" component={ChatScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for messaging between teachers, students, and parents. You can expand and refine these features based on your specific requirements and use cases, such as adding user authentication, improving the UI, and handling message deletion or updates.

Reports: Progress reports, attendance reports

To implement reports for progress and attendance in your React Native app, you will need to create functionalities to generate, view, and manage these reports. Firebase Firestore can be used to store and retrieve the necessary data.

1. Setup Firebase Firestore for Data Storage

Ensure you have collections in Firestore to store attendance and progress data.

2. Reports Management Screen

Create a main screen for managing reports where users can navigate to different report types like progress reports and attendance reports.

ReportsManagementScreen.js

// screens/ReportsManagementScreen.js
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';

export default function ReportsManagementScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Button title="Progress Reports" onPress={() => navigation.navigate('ProgressReports')} />
      <Button title="Attendance Reports" onPress={() => navigation.navigate('AttendanceReports')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
Enter fullscreen mode Exit fullscreen mode

3. Progress Reports

Create a screen to display progress reports of students.

ProgressReports.js

// screens/ProgressReports.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { firestore } from '../firebase';

export default function ProgressReports() {
  const [progressReports, setProgressReports] = useState([]);

  useEffect(() => {
    firestore()
      .collection('progressReports')
      .get()
      .then(querySnapshot => {
        const reportsData = [];
        querySnapshot.forEach(documentSnapshot => {
          reportsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setProgressReports(reportsData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <FlatList
        data={progressReports}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.reportItem}>
            <Text>Student: {item.studentName}</Text>
            <Text>Grade: {item.grade}</Text>
            <Text>Comments: {item.comments}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  reportItem: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

4. Attendance Reports

Create a screen to display attendance reports of students.

AttendanceReports.js

// screens/AttendanceReports.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { firestore } from '../firebase';

export default function AttendanceReports() {
  const [attendanceReports, setAttendanceReports] = useState([]);

  useEffect(() => {
    firestore()
      .collection('attendance')
      .get()
      .then(querySnapshot => {
        const reportsData = [];
        querySnapshot.forEach(documentSnapshot => {
          reportsData.push({ id: documentSnapshot.id, ...documentSnapshot.data() });
        });
        setAttendanceReports(reportsData);
      });
  }, []);

  return (
    <View style={styles.container}>
      <FlatList
        data={attendanceReports}
        keyExtractor={item => item.id}
        renderItem={({ item }) => (
          <View style={styles.reportItem}>
            <Text>Student ID: {item.studentId}</Text>
            <Text>Date: {item.date}</Text>
            <Text>Status: {item.status}</Text>
          </View>
        )}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  reportItem: {
    marginVertical: 10,
    padding: 10,
    borderColor: 'gray',
    borderWidth: 1,
  },
});
Enter fullscreen mode Exit fullscreen mode

5. Integrate Navigation

Update your App.js to include these new screens in the navigation stack.

App.js

// App.js
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

// Import your screens here
import RegistrationScreen from './screens/RegistrationScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';
import AdminHome from './screens/AdminHome';
import TeacherHome from './screens/TeacherHome';
import StudentHome from './screens/StudentHome';
import ParentHome from './screens/ParentHome';
import StudentList from './screens/StudentList';
import TeacherList from './screens/TeacherList';
import Notifications from './screens/Notifications';
import Reports from './screens/Reports';
import StudentManagementScreen from './screens/StudentManagementScreen';
import EnrollStudent from './screens/EnrollStudent';
import Attendance from './screens/Attendance';
import Grades from './screens/Grades';
import Assignments from './screens/Assignments';
import TeacherManagementScreen from './screens/TeacherManagementScreen';
import ManageSchedule from './screens/ManageSchedule';
import ManageClasses from './screens/ManageClasses';
import TeacherAttendance from './screens/TeacherAttendance';
import ParentPortalScreen from './screens/ParentPortalScreen';
import StudentInfo from './screens/StudentInfo';
import ParentGrades from './screens/ParentGrades';
import Communicate from './screens/Communicate';
import TimetableManagementScreen from './screens/TimetableManagementScreen';
import ViewTimetable from './screens/ViewTimetable';
import ManageTimetable from './screens/ManageTimetable';
import NotificationsManagementScreen from './screens/NotificationsManagementScreen';
import ViewNotifications from './screens/ViewNotifications';
import AddNotification from './screens/AddNotification';
import CommunicationScreen from './screens/CommunicationScreen';
import ChatScreen from './screens/ChatScreen';
import ReportsManagementScreen from './screens/ReportsManagementScreen';
import ProgressReports from './screens/ProgressReports';
import AttendanceReports from './screens/AttendanceReports';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Login">
        <Stack.Screen name="Registration" component={RegistrationScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
        <Stack.Screen name="AdminHome" component={AdminHome} />
        <Stack.Screen name="TeacherHome" component={TeacherHome} />
        <Stack.Screen name="StudentHome" component={StudentHome} />
        <Stack.Screen name="ParentHome" component={ParentHome} />
        <Stack.Screen name="StudentList" component={StudentList} />
        <Stack.Screen name="TeacherList" component={TeacherList} />
        <Stack.Screen name="Notifications" component={Notifications} />
        <Stack.Screen name="Reports" component={ReportsManagementScreen} />
        <Stack.Screen name="StudentManagement" component={StudentManagementScreen} />
        <Stack.Screen name="EnrollStudent" component={EnrollStudent} />
        <Stack.Screen name="Attendance" component={Attendance} />
        <Stack.Screen name="Grades" component={Grades} />
        <Stack.Screen name="Assignments" component={Assignments} />
        <Stack.Screen name="TeacherManagement" component={TeacherManagementScreen} />
        <Stack.Screen name="ManageSchedule" component={ManageSchedule} />
        <Stack.Screen name="ManageClasses" component={ManageClasses} />
        <Stack.Screen name="TeacherAttendance" component={TeacherAttendance} />
        <Stack.Screen name="ParentPortal" component={ParentPortalScreen} />
        <Stack.Screen name="StudentInfo" component={StudentInfo} />
        <Stack.Screen name="ParentGrades" component={ParentGrades} />
        <Stack.Screen name="Communicate" component={Communicate} />
        <Stack.Screen name="TimetableManagement" component={TimetableManagementScreen} />
        <Stack.Screen name="ViewTimetable" component={ViewTimetable} />
        <Stack.Screen name="ManageTimetable" component={ManageTimetable} />
        <Stack.Screen name="NotificationsManagement" component={NotificationsManagementScreen} />
        <Stack.Screen name="ViewNotifications" component={ViewNotifications} />
        <Stack.Screen name="AddNotification" component={AddNotification} />
        <Stack.Screen name="Communication" component={CommunicationScreen} />
        <Stack.Screen name="Chat" component={ChatScreen} />
        <Stack.Screen name="ReportsManagement" component={ReportsManagementScreen} />
        <Stack.Screen name="ProgressReports" component={ProgressReports} />
        <Stack.Screen name="AttendanceReports" component={AttendanceReports} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

6. Create Data in Firestore

Ensure you have some sample data in your Firestore collections for progressReports and attendance:

Sample Data Structure

// Firestore collection: progressReports
{
  studentName: 'John Doe',
  grade: 'A',
  comments: 'Excellent performance',
}

// Firestore collection: attendance
{
  studentId: 'student1',
  date: '2024-06-01',
  status: 'Present',
}
Enter fullscreen mode Exit fullscreen mode

This setup provides a basic structure for managing and viewing progress and attendance reports. You can expand and refine these features based on your specific requirements and use cases.

If you enjoy my content and would like to support my work, you can buy me a coffee. Your support is greatly appreciated!

Disclaimer: This content in generated by AI.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.