-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from IamMuuo/dev
Dev
- Loading branch information
Showing
28 changed files
with
1,363 additions
and
301 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.