From f1cfbe7713de03911e795200fca3d45391596a5f Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Tue, 15 Apr 2025 13:32:34 +0200 Subject: [PATCH] add error message if auth is not set up already --- .../authentication/biometric_check.dart | 48 ++++++++++++++++++- .../Flutter/GeneratedPluginRegistrant.swift | 2 + Frontend/pubspec.lock | 8 ++++ Frontend/pubspec.yaml | 1 + 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Frontend/lib/mih_packages/authentication/biometric_check.dart b/Frontend/lib/mih_packages/authentication/biometric_check.dart index de17c637..46b99f69 100644 --- a/Frontend/lib/mih_packages/authentication/biometric_check.dart +++ b/Frontend/lib/mih_packages/authentication/biometric_check.dart @@ -4,11 +4,13 @@ import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_action.dart' import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_body.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_header.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_layout_builder.dart'; +import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_alert.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart'; import 'package:mzansi_innovation_hub/mih_packages/mih_home/mih_profile_getter.dart'; import 'package:flutter/material.dart'; import 'package:local_auth/local_auth.dart'; import 'package:supertokens_flutter/supertokens.dart'; +import 'package:app_settings/app_settings.dart'; class BiometricCheck extends StatefulWidget { final bool personalSelected; @@ -92,7 +94,8 @@ class _BiometricCheckState extends State { } // print("Authenticated: $didBioAuth"); } catch (error) { - print(error); + print("Auth Error: $error"); + authErrorPopUp(); } } // else { @@ -118,6 +121,49 @@ class _BiometricCheckState extends State { // } } + void authErrorPopUp() { + Widget alertpopUp = MihAppAlert( + alertIcon: Icon( + Icons.fingerprint, + color: MzanziInnovationHub.of(context)!.theme.errorColor(), + size: 100, + ), + alertTitle: "Biometric Authentication Error", + alertBody: Column( + children: [ + Text( + "Hi there! To jump into the MIH Home Package, you'll need to set up biometric authentication (like fingerprint or face ID) on your device first. It looks like it's not quite ready yet.\n\nPlease head over to your device's settings to enable it, or press the button below to start the set up process now.", + style: TextStyle( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ), + ), + const SizedBox(height: 20), + SizedBox( + width: 300, + child: MIHButton( + onTap: () { + AppSettings.openAppSettings( + type: AppSettingsType.security, + ); + }, + buttonText: "Set Up Authentication", + buttonColor: + MzanziInnovationHub.of(context)!.theme.successColor(), + textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + ), + ) + ], + ), + alertColour: MzanziInnovationHub.of(context)!.theme.errorColor(), + ); + showDialog( + context: context, + builder: (context) { + return alertpopUp; + }, + ); + } + MIHBody getBody() { return MIHBody( borderOn: false, diff --git a/Frontend/macos/Flutter/GeneratedPluginRegistrant.swift b/Frontend/macos/Flutter/GeneratedPluginRegistrant.swift index cea5ee1a..66bdd02e 100644 --- a/Frontend/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/Frontend/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,7 @@ import FlutterMacOS import Foundation +import app_settings import device_info_plus import file_picker import flutter_tts @@ -20,6 +21,7 @@ import url_launcher_macos import webview_flutter_wkwebview func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AppSettingsPlugin.register(with: registry.registrar(forPlugin: "AppSettingsPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin")) FlutterTtsPlugin.register(with: registry.registrar(forPlugin: "FlutterTtsPlugin")) diff --git a/Frontend/pubspec.lock b/Frontend/pubspec.lock index ee9ca4cb..878a811d 100644 --- a/Frontend/pubspec.lock +++ b/Frontend/pubspec.lock @@ -25,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" + app_settings: + dependency: "direct main" + description: + name: app_settings + sha256: "3e46c561441e5820d3a25339bf8b51b9e45a5f686873851a20c257a530917795" + url: "https://pub.dev" + source: hosted + version: "6.1.1" archive: dependency: transitive description: diff --git a/Frontend/pubspec.yaml b/Frontend/pubspec.yaml index cd5d93ae..5a29506e 100644 --- a/Frontend/pubspec.yaml +++ b/Frontend/pubspec.yaml @@ -75,6 +75,7 @@ dependencies: flutter_tts: ^4.2.2 flutter_speed_dial: ^7.0.0 share_plus: ^10.1.4 + app_settings: ^6.1.1 dev_dependencies: flutter_test: