Skip to content

Commit

Permalink
chore: upgraded magnet + controllers not counting courses
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMuuo committed Feb 10, 2024
1 parent 483d998 commit fbcbd37
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/constants/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ void showCustomSnackbar(
message,
colorText: Colors.black,
backgroundColor: Colors.white,
icon: Icon(icon??Icons.info),
icon: Icon(icon ?? Icons.info),
);
}
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();
}
}
}
20 changes: 20 additions & 0 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,26 @@ class SettingsPage extends StatelessWidget {
),
const Divider(),

const Divider(),

ListTile(
title: Obx(
() => controller.hasUpdates.value
? const Text("Updating")
: Text("Update v 1.0.${controller.patch.value}"),
),
trailing: controller.hasUpdates.value
? LoadingAnimationWidget.beat(
color: Theme.of(context).primaryColor, size: 20)
: IconButton(
onPressed: () async {
await controller.checkForUpdates();
},
icon:
const Icon(CupertinoIcons.arrow_right_circle)),
),
const Divider(),

// button to refresh all content
Padding(
padding:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ dependencies:
timezone: ^0.9.2
network_info_plus: ^4.1.0+1
connectivity_plus: ^5.0.2
shorebird_code_push: ^1.1.3
story_view: ^0.16.0



Expand Down

0 comments on commit fbcbd37

Please sign in to comment.