Skip to content

Commit

Permalink
Merge pull request #37 from IamMuuo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
IamMuuo authored Jan 1, 2024
2 parents e9c8574 + ab34ad7 commit 8679ad9
Show file tree
Hide file tree
Showing 28 changed files with 1,363 additions and 301 deletions.
Binary file added assets/images/calculator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/corn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/exam_timetable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/fees.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/food.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/grade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion lib/constants/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ var settings = {
"show_profile_pic": true,
"delete_older_todos": false,
"show_gpa": true,
"allow_push_notifications": true
"allow_push_notifications": true,

// Exam timetable features
"show_exam_timetable": true,
};
12 changes: 10 additions & 2 deletions lib/controllers/courses_page_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class CoursesPageController extends GetxController {
backGround: DateFormat("EEEE").format(DateTime.now()) ==
course.dayOfTheWeek!.title()
? Colors.blueGrey
: Colors.white,
: Colors.transparent,
titleColor: DateFormat("EEEE").format(DateTime.now()) ==
course.dayOfTheWeek!.title()
? Colors.white
? Colors.transparent
: Colors.blueGrey,
borderColor: DateFormat("EEEE").format(DateTime.now()) ==
course.dayOfTheWeek!.title()
Expand Down Expand Up @@ -104,6 +104,14 @@ class CoursesPageController extends GetxController {
return progressList;
}

int get numOfClasses {
if (appDB.containsKey("timetable")) {
var courses = appDB.get("timetable") ?? [];
return courses.length;
}
return 0;
}

Future<bool> updateProgress() async {
var courseProgress = await magnet.fetchUserClassAttendance();
await appDB.put("attendance", courseProgress);
Expand Down
62 changes: 62 additions & 0 deletions lib/controllers/dashboard_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,55 @@ class DashboardController extends GetxController {
debugPrint("${user.name}");
}

double get weekPercent {
int weekDay = DateTime.now().weekday;
return weekDay / 7;
}

double get semesterPercent {
return 1;
}

String get getDayPercentQuote {
if (daypercent > 0.75) {
return "Perhaps much is already done!";
} else if (daypercent > 0.5) {
return "The day is halfway done strive to make a change";
} else if (daypercent > 0.25) {
return "Its almost midday";
}
return "Make it or break it while its young!";
}

String get getWeekPercentQuote {
if (weekPercent > 0.75) {
return "Its probably on a Friday!";
} else if (daypercent > 0.5) {
return "Stay strong weekend is coming";
} else if (daypercent > 0.25) {
return "Focus, its tough we get it";
}
return "Its Monday, are your asignments done?";
}

String get getSemesterPercentQuote {
if (semesterPercent > 0.90) {
return "Relax, it was a tough one!";
} else if (semesterPercent > 0.75) {
return "Projects, exams panic!";
} else if (semesterPercent > 0.5) {
return "Its about to get real messy";
} else if (semesterPercent > 0.25) {
return "CATS CATS CATS, cats all the way";
}
return "Ready, aim shoot for the sky";
}

double get daypercent {
int hours = DateTime.now().hour;
return (hours / 24);
}

int get classesToday {
int classes = 0;
var courses = appDB.get("timetable") ?? [];
Expand All @@ -23,4 +72,17 @@ class DashboardController extends GetxController {
}
return classes;
}

int get classesTommorrow {
int classes = 0;
var courses = appDB.get("timetable") ?? [];
for (Courses course in courses) {
if (course.dayOfTheWeek!.title() ==
DateFormat("EEEE")
.format(DateTime.now().add(const Duration(hours: 24)))) {
classes++;
}
}
return classes;
}
}
61 changes: 61 additions & 0 deletions lib/controllers/exams_timetable_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:academia/constants/common.dart';
import 'package:academia/models/courses.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class ExamsTimeTableController extends GetxController {
var hasExams = false.obs;
var isLoading = false.obs;

Future<List<dynamic>> fetchExamTimeTable(String units,
{bool athi = true}) async {
isLoading.value = true;

try {
var fetchedUnits = await magnet.fetchExamTimeTabale(units);
isLoading.value = false;

return fetchedUnits;
} catch (e) {
Get.snackbar(
"Oh Snap!",
"Something went wrong while attempting to fetch your exam timetable, please check your network connection and try again",
icon: const Icon(
Icons.network_ping,
),
maxWidth: 500,
);
debugPrint(e.toString());
}

isLoading.value = false;
return [];
}

Future<void> addFetchedUnits(List<dynamic> fetchedUnits) async {
await appDB.put("exam_timetable", fetchedUnits);
}

@override
void onInit() async {
debugPrint(appDB.get("exam_timetable").toString());

if (true) {
var courses = appDB.get("timetable");
String payload = "";
for (Courses c in courses) {
payload =
"$payload ${c.name!.replaceAll("-", " ")}${c.section!.split('-')[0]},";
}

debugPrint(payload);
var fetchedUnits = await fetchExamTimeTable(payload.trim());
await addFetchedUnits(fetchedUnits);
hasExams.value = fetchedUnits.isNotEmpty;
}

debugPrint("do I have exams : ${hasExams.value}");

super.onInit();
}
}
24 changes: 24 additions & 0 deletions lib/controllers/notifications_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:academia/constants/common.dart';
import 'package:get/get.dart';

class NotificationsController extends GetxController {
var isLoading = false.obs;
// fetches the event calendar
Future<void> fetchAcademicCalendar() async {
var events = await magnet.fetchAcademicCalendar();
if (events.isNotEmpty) {
await appDB.put("academic_calendar", events);
}
}

bool get hasCalendar {
return appDB.containsKey("academic_calendar") ? true : false;
}

Future<List<Map<String, dynamic>>> get events async {
if (appDB.containsKey("academic_calendar")) {
return await appDB.get("academic_calendar");
}
return [];
}
}
3 changes: 3 additions & 0 deletions lib/controllers/settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import 'package:get/get.dart';
class SettingsController extends GetxController {
Rx<bool> showGPA = true.obs;
Rx<bool> showProfilePic = true.obs;
Rx<bool> showExamTimeTable = false.obs;
late Map<dynamic, dynamic> settings;

@override
void onInit() async {
settings = await appDB.get("settings");
showGPA.value = settings["show_gpa"] ?? true;
showProfilePic.value = settings["show_profile_pic"] ?? true;
showExamTimeTable.value = settings["show_exam_timetable"] ?? true;

debugPrint("Settings loaded!");
super.onInit();
Expand All @@ -20,6 +22,7 @@ class SettingsController extends GetxController {
Future<void> saveSettings() async {
settings["show_profile_pic"] = showProfilePic.value;
settings["show_gpa"] = showGPA.value;
settings["show_exam_timetable"] = showExamTimeTable.value;
await appDB.put("settings", settings);
}
}
2 changes: 0 additions & 2 deletions lib/pages/attendance_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:academia/controllers/courses_page_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_connect/http/src/utils/utils.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';

class AttendancePage extends StatefulWidget {
Expand Down
Loading

0 comments on commit 8679ad9

Please sign in to comment.