mikesplore / Uni-Connect

A comprehensive student management app that facilitates resource sharing, discussions, attendance tracking, announcements, and access to course materials.
https://github.com/mikesplore/Uni-Admin
6 stars 0 forks source link
firebase-auth firebase-realtime-database jetpack-compose kotlin mvvm-android mvvm-architecture

UNI ADMIN Documentation

Table of Contents

Firebase Setup Guide for Uni Admin

This guide will help you set up Firebase for the project you've cloned. The necessary Firebase dependencies are already included. Follow these steps to create signing keys, generate SHA-1 keys, and configure Firebase.

1. Create a Firebase Project

  1. Go to the Firebase Console: Firebase Console.
  2. Create a New Project:
    • Click on "Add Project" and follow the prompts.
    • Once the project is created, click "Continue" to go to the project overview.
  3. Add an Android App:
    • In your project overview, click the Android icon.
    • Enter the Android package name found in the build.gradle file under applicationId.
    • Leave the SHA-1 key field blank for now.
    • Click "Register App" and download the google-services.json file.
  4. Add the google-services.json File:
    • Place the google-services.json file in the app/ directory of your cloned project.

2. Generate Debug and Release Signing Keys

Step 1: Generate the Debug Signing Key

  1. Open your terminal and navigate to the root directory of your cloned project.
  2. Run the following command to generate the debug signing key:

./gradlew signingReport

Locate the SHA-1 key: The SHA-1 key will be listed under Variant: debug. Copy this key for use in the Firebase Console.

Step 2: Generate the Release Signing Key

  1. Generate a release keystore by running the following command:

 keytool -genkey -v -keystore release-key.keystore -alias release-key -keyalg RSA -keysize 2048 -validity 10000

You'll be prompted to provide information like your name, organization, and location. After completing this step, a release-key.keystore file will be created.

  1. Extract the SHA-1 key from the release keystore:

keytool -list -v -keystore release-key.keystore -alias release-key

you can replace the release-key with your preferred name Enter the password you set during the keystore creation. Copy the displayed SHA-1 key for use in Firebase.

3. Add SHA-1 Keys to Firebase

  1. Return to the Firebase Console.
  2. Go to Project Settings:
    • In your project overview, click the gear icon next to "Project Overview" and select "Project settings".
  3. Under the "Your apps" section, select your Android app.
  4. Add the SHA-1 keys:
    • Add both the debug and release SHA-1 keys that you generated.
  5. Save the changes.

4. Run the Project

With the google-services.json file in place and the SHA-1 keys added to Firebase, you can now build and run the project as intended.

If you are lost, you can refer Generating Signing Key for android project for detailed instructions


Authentication

Overview

This section provides a detailed overview of the components and functionality related to user authentication within Uni Admin. It covers different authentication methods, including email/password login, third-party authentication using Google and GitHub, and password reset functionality. The documentation outlines the UI components, state management, and backend logic involved in each authentication process. It also includes references to relevant code files and visual representations of the user interface.

Google Authentication

File: GoogleAuth.kt

Functionality

The GoogleAuth composable function handles Google authentication using Firebase. It initiates the Google sign-in process and provides visual feedback to the user.

Parameters

Behavior

  1. When the box is clicked, the function starts the Google sign-in process using Firebase Authentication.
  2. While the sign-in process is ongoing, a circular progress indicator is displayed.
  3. If the sign-in is successful, a check icon is displayed and onSignInSuccess is called.
  4. If the sign-in fails, an error message is displayed and onSignInFailure is called.

GitHub Authentication

File: GithubAuth.kt

Functionality

The GitAuth composable function handles GitHub authentication using Firebase. It initiates the GitHub sign-in process and provides visual feedback to the user.

Parameters

Behavior

  1. When the box is clicked, the function starts the GitHub sign-in process using Firebase Authentication.
  2. While the sign-in process is ongoing, a circular progress indicator is displayed.
  3. If the sign-in is successful, a check icon is displayed and onSignInSuccess is called.
  4. If the sign-in fails, an error message is displayed and onSignInFailure is called.

Authentication Screen

File: Login.kt

Initialization

UI Components

Authentication Handlers

LaunchedEffect

This structure ensures the screen dynamically handles both sign-in and sign-up processes, manages third-party authentication, and updates the user interface accordingly based on user interactions and authentication states.

MoreDetails Composable

File: MoreDetails.kt

Description

The MoreDetails composable function displays a form for users to enter additional details like their first and last names after signing in. It also allows saving these details to the local database and notifies other users about the new user joining.

Parameters

Functionality

Important Notes

Password Reset

File: PasswordReset.kt

Description

The PasswordReset composable function provides a screen for users to reset their forgotten passwords. It allows users to enter their email address and sends a password reset email using Firebase Authentication.

Parameters

Functionality

Important Notes

Visuals

Sign In Screen

Sign In

Sign Up Screen

Sign Up

Password Reset Screen

Password Reset

Modules


Announcements

FileAnnouncements.kt

Overview

The AnnouncementsScreen Composable function is responsible for displaying a screen where users can view, add, and manage announcements. It utilizes a top app bar with buttons for adding new announcements and refreshing the list. The screen presents a list of announcements retrieved from a repository and offers functionality to edit or delete them.

Components and Logic

State Management

Effect and Data Fetching

Scaffold and Top App Bar

Content

AnimatedVisibility

Loading and Empty State

LazyColumn

AnnouncementCard

Visuals

Announcements

Announcements

The AnnouncementsScreen presents a visually appealing and user-friendly interface for managing announcements. The top app bar provides easy access to actions for adding new announcements and refreshing the list. The announcements are displayed in a clear and organized manner within the LazyColumn, with each AnnouncementCard offering options for editing or deleting. Loading states and potential empty states are handled gracefully, providing appropriate feedback to the user.

Important Notes

By leveraging these components and logic, the AnnouncementsScreen provides a robust and intuitive experience for managing announcements within the Uni Admin.

AddAnnouncement Composable

Overview

AddAnnouncement is a Composable function that provides a UI for adding a new announcement. It includes input fields for the announcement title and description, and displays the user's profile image or initials, along with the current date.

Parameters

State

UI Components

Logic

Announcements Add

Announcements Add

EditAnnouncement Composable

Overview

EditAnnouncement is a Composable function that provides a UI for editing an existing announcement. It allows users to modify the title and description of an announcement.

Parameters

State

UI Components

Logic

Announcements Edit

Announcements Edit

AnnouncementTextField Composable

Overview

AnnouncementTextField is a Composable function that provides a styled text input field used within the AddAnnouncement and EditAnnouncement Composable.

Parameters

UI Components

Customization

AnnouncementCard Composable

Overview

AnnouncementCard is a Composable function that displays an announcement in a card format. It allows users to view, edit, and delete announcements, with the ability to expand or collapse the announcement details.

Parameters

State

UI Components

Logic

Customization

AssignmentScreen Composable

Overview

AssignmentScreen is a Composable function that displays a list of assignments for modules. It allows users to navigate between modules using tabs and view assignments specific to the selected module.

Dependencies

Parameters

State

UI Components

Logic

Customization

AssignmentCard Composable

Overview

AssignmentCard is a Composable function that displays the details of a single assignment in a card format.

Parameters

UI Components

Customization

ManageAttendanceScreen Composable

Overview

ManageAttendanceScreen is a Composable function that allows users to manage attendance for modules. Users can view a list of modules and toggle attendance states using switches.

Dependencies

Parameters

State

UI Components

Logic

Animations

Customization

ModuleContent Composable

The ModuleContent composable is responsible for displaying detailed information about a specific module, including announcements, assignments, timetables, and other details. It dynamically fetches and displays data from various repositories based on the provided module ID.

Key Components

1. Repositories and ViewModels Initialization

2. State Observers

3. Data Fetching

4. UI Layout

5. Tab Navigation

6. Content Rendering

Summary

The ModuleContent composable effectively manages and displays various aspects of a module's content, providing a tabbed interface for users to easily navigate between announcements, assignments, timetables, and other details. It uses ViewModels to handle data fetching and observes loading states to update the UI dynamically.

AnnouncementsItem Composable

The AnnouncementsItem composable displays a list of module announcements and provides an option to add new announcements. It leverages various UI components and state management to provide an interactive user experience.

Key Components

1. State Management

2. UI Layout

3. Announcement List

AnnouncementItemCard Composable

The AnnouncementCard composable represents a single announcement in a card format.

1. UI Layout

AddAnnouncementItem Composable

The AddAnnouncementItem composable provides a form for users to add new announcements.

1. State Management

2. Form Layout

3. Form Submission

AddTextField Composable

The AddTextField composable creates a reusable text field with customizable properties.

1. UI Layout

AssignmentsItem Composable

The AssignmentsItem composable displays a list of module assignments and provides an option to add new assignments. It uses various UI components and state management to provide an interactive user experience.

Key Components

1. State Management

2. UI Layout

3. Assignment List

AssignmentCardItem Composable

The AssignmentCard composable represents a single assignment in a card format.

1. UI Layout

AddAssignmentItem Composable

The AddAssignmentItem composable provides a form for users to add new assignments.

1. State Management

2. Form Layout

3. Form Submission

UNI CHAT

UniChat Composable Function Overview

The UniChat composable function is the main component for the chat screen in the Uni Admin app. It provides a user interface for viewing messages, searching users, and navigating between different sections, such as Chats and Groups. The function leverages Jetpack Compose for UI rendering, a ViewModel for managing state, and a real-time database for fetching and displaying messages.

Key Components

Interaction Flow

  1. Users can switch between "Chats" and "Groups" using the tab row.
  2. The "Chats" section allows searching for users by name, with the list filtering in real-time.
  3. Clicking a user in the list navigates to their detailed chat screen.
  4. Documentation can be accessed by clicking the book icon, which opens a modal bottom sheet.

This overview provides insight into how the UniChat composable function and its related components work together to create a dynamic chat interface in the Uni Admin app.

UserChatScreen Composable

The UserChatScreen composable function is designed to display a chat interface between the current user and a target user. It utilizes Jetpack Compose for UI rendering, handles state management through ViewModel, and integrates with Firebase for user authentication and message storage.

Key Components

Interaction Flow

  1. The user views the chat interface, which is initialized with messages and user details.
  2. The user can search through the messages using the search bar.
  3. Messages are grouped and displayed by date, with the most recent messages automatically scrolled into view.
  4. The user can type and send new messages using the input field at the bottom of the screen.

This composable function encapsulates the logic and UI for a dynamic chat screen, handling user interactions, message sending, and real-time updates.