Skip to content

Commit

Permalink
Merge pull request #93 from IamMuuo/local-auth
Browse files Browse the repository at this point in the history
feat: implemented local authentication for privacy
  • Loading branch information
IamMuuo authored Oct 2, 2024
2 parents 1fc8c28 + 6385726 commit f051414
Show file tree
Hide file tree
Showing 40 changed files with 407 additions and 504 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="android.permission.VIBRATE" />
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/kotlin/com/dita/academia/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dita.academia

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterActivity()
class MainActivity: FlutterFragmentActivity()
Binary file removed assets/images/askMe_Home.jpeg
Binary file not shown.
Binary file removed assets/images/calculator.png
Binary file not shown.
Binary file removed assets/images/chill.png
Binary file not shown.
34 changes: 0 additions & 34 deletions assets/images/chill.png.import

This file was deleted.

Binary file removed assets/images/doodle-character-holding-money.png
Binary file not shown.
Binary file removed assets/images/exam_timetable.png
Binary file not shown.
Binary file removed assets/images/fees.png
Binary file not shown.
Binary file removed assets/images/food.png
Binary file not shown.
Binary file removed assets/images/graduate_girl.png
Binary file not shown.
34 changes: 0 additions & 34 deletions assets/images/graduate_girl.png.import

This file was deleted.

Binary file removed assets/images/graduating.png
Binary file not shown.
34 changes: 0 additions & 34 deletions assets/images/graduating.png.import

This file was deleted.

Binary file removed assets/images/having_coffee.png
Binary file not shown.
34 changes: 0 additions & 34 deletions assets/images/having_coffee.png.import

This file was deleted.

34 changes: 0 additions & 34 deletions assets/images/holding_back.png.import

This file was deleted.

Binary file removed assets/images/khaby-lame-shrug.png
Binary file not shown.
Binary file removed assets/images/man-and-woman-searching.png
Binary file not shown.
Binary file removed assets/images/man-with-glass.png
Binary file not shown.
Binary file removed assets/images/no_task.png
Binary file not shown.
34 changes: 0 additions & 34 deletions assets/images/no_task.png.import

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 0 additions & 34 deletions assets/images/smiley.png.import

This file was deleted.

Binary file removed assets/images/star_trek.png
Binary file not shown.
Binary file removed assets/images/think.jpeg
Binary file not shown.
Binary file removed assets/images/view.png
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions assets/lotties/studying.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions lib/controllers/controller_ready_mixin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:async';
import 'package:get/get.dart';

mixin ReadyMixin on GetxController {
final isControllerReady = false.obs;
FutureOr<void> initController();
FutureOr<void> controllerReady() {}

@override
void onInit() async {
await initController();
super.onInit();
}

@override
void onReady() async {
await controllerReady();
super.onReady();
isControllerReady.value = true;
}
}
1 change: 1 addition & 0 deletions lib/controllers/controllers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export 'network_controller.dart';
export 'reward_controller.dart';
export 'settings_controller.dart';
export 'notifications_controller.dart';
export 'controller_ready_mixin.dart';
45 changes: 39 additions & 6 deletions lib/controllers/settings_controller.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,56 @@
import 'package:academia/controllers/controllers.dart';
import 'dart:async';

import 'package:academia/exports/barrel.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:academia/models/models.dart';
import 'package:academia/storage/storage.dart';
import 'package:local_auth/local_auth.dart';

class SettingsController extends GetxController {
class SettingsController extends GetxController with StateMixin {
Rx<Settings> settings = Settings.empty().obs;

final LocalAuthentication localAuthentication = LocalAuthentication();

@override
void onInit() async {
super.onInit();
ever(settings, (value) {
saveSettings(value);
});

change(null, status: RxStatus.loading());
await SettingsHelper().init();

settings.value = SettingsHelper().getSettings();
// print(settings.value.toJson());
debugPrint("[+] Settings Loaded!");

ever(settings, (value) {
saveSettings(value);
});
change(null, status: RxStatus.success());
}

Future<bool> performLocalAuthentication(String reason) async {
bool authenticated = false;

try {
authenticated = await localAuthentication.authenticate(
localizedReason: reason,
options: const AuthenticationOptions(
stickyAuth: true,
sensitiveTransaction: true,
),
);
} on PlatformException catch (e) {
authenticated = false;
debugPrint(e.toString());
} catch (e) {
debugPrint(e.toString());
}

return authenticated;
}

Future<bool> deviceSupportsLocalAuth() async {
return localAuthentication.isDeviceSupported();
}

/// Saves the current settings
Expand Down
Loading

0 comments on commit f051414

Please sign in to comment.