Skip to content

Commit

Permalink
Merge pull request #57 from IamMuuo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
IamMuuo authored Feb 12, 2024
2 parents 08f8752 + fbcbd37 commit 3419e4e
Show file tree
Hide file tree
Showing 43 changed files with 187 additions and 174 deletions.
16 changes: 16 additions & 0 deletions lib/constants/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:academia/models/user.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:magnet/magnet.dart';
import 'package:get/get.dart';

const String urlPrefix = "https://daystar-backend.onrender.com";
const String dbName = "appDB";
Expand Down Expand Up @@ -77,3 +78,18 @@ const TextStyle h6 = TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
);

void showCustomSnackbar(
String title,
String message, {
IconData? icon,
Color? iconColor,
}) {
Get.snackbar(
title,
message,
colorText: Colors.black,
backgroundColor: Colors.white,
icon: Icon(icon ?? Icons.info),
);
}
37 changes: 14 additions & 23 deletions lib/constants/tools.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import 'package:academia/controllers/settings_controller.dart';
import 'package:academia/pages/attendance_page.dart';
import 'package:academia/pages/exams_timetable_page.dart';
import 'package:academia/pages/fees_page.dart';
import 'package:academia/pages/gpacalculator_page.dart';
import 'package:academia/pages/pdf_viewer.dart';
import 'package:academia/pages/tasks_pages/taskmanager_page.dart';
import 'package:academia/pages/webview_page.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:academia/constants/common.dart';
import 'package:academia/exports/barrel.dart';

final List<Map<String, dynamic>> allTools = [
{
Expand Down Expand Up @@ -41,19 +32,18 @@ final List<Map<String, dynamic>> allTools = [
"ontap": () async {
var controller = Get.find<SettingsController>();
if (!controller.showFees.value) {
Get.snackbar("Tool locked",
showCustomSnackbar("Tool locked",
"Fees functionality is locked in the settings page, please unlock it to view your fees statement",
icon: const Icon(Icons.lock));
icon: Icons.lock);
} else {
try {
var statements = await magnet.fetchFeeStatement();
Get.to(FeesPage(allStatements: statements));
} catch (e) {
Get.snackbar(
showCustomSnackbar(
"Error",
"Please check your internet connection and try again!",
icon: const Icon(Icons.network_check),
backgroundColor: Colors.white,
icon: Icons.network_check,
);
}
}
Expand All @@ -73,11 +63,10 @@ final List<Map<String, dynamic>> allTools = [
content: Text("Your Token is ${token['message'] ?? ''}"),
);
} catch (e) {
Get.snackbar(
showCustomSnackbar(
"Error",
"Please check your internet connection and try again!",
icon: const Icon(Icons.network_check),
backgroundColor: Colors.white,
icon: Icons.network_check,
);
}
},
Expand All @@ -91,9 +80,11 @@ final List<Map<String, dynamic>> allTools = [
"ontap": () async {
var controller = Get.find<SettingsController>();
if (controller.showAudit.value) {
Get.snackbar("Tool locked",
"Student Audit functionality is locked in the settings page, please unlock it to view your student audit",
icon: const Icon(Icons.lock));
showCustomSnackbar(
"Tool locked",
"Student Audit functionality is locked in the settings page, please unlock it to view your student audit",
icon: Icons.lock,
);
} else {
Get.to(PdfViewer(
title: "Your audit",
Expand All @@ -112,10 +103,10 @@ final List<Map<String, dynamic>> allTools = [
"ontap": () async {
var controller = Get.find<SettingsController>();
if (controller.showTranscript.value) {
Get.snackbar(
showCustomSnackbar(
"Tool locked",
"Transcript functionality is locked in the settings page, please unlock it to view your transcript",
icon: const Icon(Icons.lock),
icon: Icons.lock,
);
} else {
Get.to(PdfViewer(
Expand Down
2 changes: 2 additions & 0 deletions lib/controllers/courses_page_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class CoursesPageController extends GetxController {
hasCourses.value = false;
return false;
}
await appDB.delete("timetable");
userCourses.clear();

for (var i = 0; i < courses.length; i++) {
userCourses.add(Courses.fromJson(courses[i]));
Expand Down
4 changes: 2 additions & 2 deletions lib/controllers/dashboard_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DashboardController extends GetxController {
} else if (daypercent > 0.25) {
return "Its almost midday☀️";
}
return "Make it or break it while its young!";
return "The early bird..!";
}

String get getWeekPercentQuote {
Expand All @@ -60,7 +60,7 @@ class DashboardController extends GetxController {
} else if (semesterPercent > 0.25) {
return "CATS CATS, cats all the way";
}
return "Ready, aim shoot for the sky";
return "Ready, aim shoot!";
}

double get daypercent {
Expand Down
21 changes: 21 additions & 0 deletions lib/controllers/settings_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:academia/constants/common.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shorebird_code_push/shorebird_code_push.dart';

class SettingsController extends GetxController {
Rx<bool> showGPA = true.obs;
Expand All @@ -10,7 +11,10 @@ class SettingsController extends GetxController {
Rx<bool> showAudit = false.obs;
Rx<bool> showFees = true.obs;
Rx<bool> birthdayNotify = true.obs;
Rx<bool> hasUpdates = false.obs;
Rx<String> patch = "0.0.0".obs;
late Map<dynamic, dynamic> settings;
final ShorebirdCodePush shorebirdCodePush = ShorebirdCodePush();

@override
void onInit() async {
Expand All @@ -25,6 +29,13 @@ class SettingsController extends GetxController {

debugPrint("Settings loaded!");
super.onInit();

shorebirdCodePush.currentPatchNumber().then((value) {
patch.value = value.toString();
debugPrint("Current patch number is: $value");
});

checkForUpdates();
}

Future<void> saveSettings() async {
Expand All @@ -37,4 +48,14 @@ class SettingsController extends GetxController {
settings["birthday_notify"] = birthdayNotify.value;
await appDB.put("settings", settings);
}

Future<void> checkForUpdates() async {
// Check whether a patch is available to install.
hasUpdates.value = await shorebirdCodePush.isNewPatchAvailableForDownload();

if (hasUpdates.value) {
// Download the new patch if it's available.
await shorebirdCodePush.downloadUpdateIfAvailable();
}
}
}
53 changes: 53 additions & 0 deletions lib/exports/barrel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export 'package:flutter/material.dart';
export 'package:academia/constants/common.dart';
export 'package:academia/widgets/academia_app_bar.dart';
export 'package:academia/controllers/notifications_controller.dart';
export 'package:percent_indicator/percent_indicator.dart';
export 'package:academia/widgets/count_down_widget.dart';
export 'package:academia/widgets/exam_course_card.dart';
export 'package:academia/controllers/settings_controller.dart';
export 'package:academia/controllers/taskmanager_controller.dart';
export 'package:academia/models/courses.dart';
export 'package:academia/models/schedule.dart';
export 'package:academia/models/tasks.dart';
export 'package:academia/models/user.dart';
export 'package:academia/notifications/notification_service.dart';
export 'package:academia/pages/home_page.dart';
export 'package:academia/pages/intro_page.dart';
export 'package:academia/themes/theme.dart';
export 'package:hive_flutter/hive_flutter.dart';
export 'package:magnet/magnet.dart';
export 'package:loading_animation_widget/loading_animation_widget.dart';
export 'package:screenshot/screenshot.dart';
export 'package:path_provider/path_provider.dart';
export 'dart:convert';
export 'dart:io';
export 'dart:typed_data';
export 'package:academia/controllers/courses_page_controller.dart';
export 'package:academia/controllers/dashboard_controller.dart';
export 'package:academia/pages/attendance_page.dart';
export 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
export 'package:connectivity_plus/connectivity_plus.dart';
export 'package:academia/pages/exams_timetable_page.dart';
export 'package:academia/pages/fees_page.dart';
export 'package:academia/pages/gpacalculator_page.dart';
export 'package:academia/pages/pdf_viewer.dart';
export 'package:academia/pages/tasks_pages/taskmanager_page.dart';
export 'package:academia/pages/webview_page.dart';
export 'package:academia/controllers/gpacalculator_controller.dart';
export 'package:academia/pages/courses_page.dart';
export 'package:academia/pages/dashboard.dart';
export 'package:academia/pages/settings_page.dart';
export 'package:academia/pages/tool_page.dart';
export 'package:academia/pages/login_page.dart';
export 'package:academia/controllers/login_controller.dart';
export 'package:flutter_pdfview/flutter_pdfview.dart';
export 'package:academia/widgets/info_card.dart';
export 'package:cached_network_image/cached_network_image.dart';
export 'package:academia/widgets/semester_timeline_tile.dart';
export 'package:academia/constants/tools.dart';
export 'package:academia/pages/birthday_page.dart';
export 'package:academia/widgets/tool_card.dart';
export 'package:academia/pages/tasks_pages/edittask_page.dart';
export 'package:academia/pages/tasks_pages/newtask_page.dart';
export 'package:academia/pages/tasks_pages/taskinfo_page.dart';
16 changes: 1 addition & 15 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/notifications_controller.dart';
import 'package:academia/controllers/settings_controller.dart';
import 'package:academia/controllers/taskmanager_controller.dart';
import 'package:academia/models/courses.dart';
import 'package:academia/models/schedule.dart';
import 'package:academia/models/tasks.dart';
import 'package:academia/models/user.dart';
import 'package:academia/notifications/notification_service.dart';
import 'package:academia/pages/home_page.dart';
import 'package:academia/pages/intro_page.dart';
import 'package:academia/themes/theme.dart';
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:academia/exports/barrel.dart';
import 'package:get/get.dart';
import 'package:magnet/magnet.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand Down
3 changes: 1 addition & 2 deletions lib/pages/attendance_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:academia/controllers/courses_page_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:academia/exports/barrel.dart';

class AttendancePage extends StatefulWidget {
const AttendancePage({super.key});
Expand Down
11 changes: 2 additions & 9 deletions lib/pages/birthday_page.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/settings_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:screenshot/screenshot.dart';
import 'package:path_provider/path_provider.dart';
import 'package:academia/exports/barrel.dart';
import 'package:flutter/cupertino.dart';

class BirthDayPage extends StatelessWidget {
const BirthDayPage({super.key});
Expand Down
7 changes: 1 addition & 6 deletions lib/pages/courses_page.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/courses_page_controller.dart';
import 'package:academia/controllers/dashboard_controller.dart';
import 'package:academia/pages/attendance_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
import 'package:get/get.dart';
import 'package:academia/exports/barrel.dart';
import 'package:liquid_pull_to_refresh/liquid_pull_to_refresh.dart';

class CoursesPage extends StatelessWidget {
Expand Down
10 changes: 2 additions & 8 deletions lib/pages/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/dashboard_controller.dart';
import 'package:academia/controllers/settings_controller.dart';
import 'package:academia/widgets/academia_app_bar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
import 'package:academia/exports/barrel.dart';
import 'package:get/get.dart';
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
import 'package:percent_indicator/percent_indicator.dart';

class DashBoard extends StatelessWidget {
const DashBoard({super.key});
Expand Down
9 changes: 1 addition & 8 deletions lib/pages/exams_timetable_page.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import 'package:academia/constants/common.dart';
import 'package:academia/models/courses.dart';
import 'package:academia/widgets/academia_app_bar.dart';
import 'package:academia/widgets/count_down_widget.dart';
import 'package:academia/widgets/exam_course_card.dart';
import 'package:academia/exports/barrel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';

class ExamTimeTablePage extends StatefulWidget {
const ExamTimeTablePage({super.key});
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/fees_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:academia/constants/common.dart';
import 'package:academia/exports/barrel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';

class FeesPage extends StatefulWidget {
const FeesPage({super.key, required this.allStatements});
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/gpacalculator_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/gpacalculator_controller.dart';
import 'package:flutter/material.dart';
import 'package:academia/exports/barrel.dart';
import 'package:get/get.dart';

class GpaCalculator extends StatelessWidget {
Expand Down
8 changes: 2 additions & 6 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import 'package:academia/controllers/settings_controller.dart';
import 'package:academia/pages/courses_page.dart';
import 'package:academia/pages/dashboard.dart';
import 'package:academia/pages/settings_page.dart';
import 'package:academia/pages/tool_page.dart';
import 'package:flutter/material.dart';
import 'package:academia/exports/barrel.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

Expand All @@ -25,6 +20,7 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
Get.put(SettingsController());
Get.put(TaskManagerController());
return Scaffold(
backgroundColor: Colors.blueGrey,
extendBodyBehindAppBar: true,
Expand Down
5 changes: 1 addition & 4 deletions lib/pages/intro_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import 'package:academia/constants/common.dart';
import 'package:academia/pages/login_page.dart';
import 'package:academia/exports/barrel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';

class IntroPage extends StatelessWidget {
const IntroPage({super.key});
Expand Down
5 changes: 1 addition & 4 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/login_controller.dart';
import 'package:academia/exports/barrel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';

class LoginPage extends StatelessWidget {
const LoginPage({super.key});
Expand Down
Loading

0 comments on commit 3419e4e

Please sign in to comment.