Merge pull request #52 from yaso-meth/BUG-Graphical-flicker-post-bio-auth

BUG-Graphical-flicker-post-bio-auth
This commit is contained in:
yaso-meth
2025-01-28 11:59:08 +02:00
committed by GitHub
6 changed files with 67 additions and 69 deletions

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../main.dart'; import '../../main.dart';
import 'package:gif/gif.dart'; import 'package:gif_view/gif_view.dart';
class Mihloadingcircle extends StatefulWidget { class Mihloadingcircle extends StatefulWidget {
const Mihloadingcircle({super.key}); const Mihloadingcircle({super.key});
@@ -9,9 +9,8 @@ class Mihloadingcircle extends StatefulWidget {
State<Mihloadingcircle> createState() => _MihloadingcircleState(); State<Mihloadingcircle> createState() => _MihloadingcircleState();
} }
class _MihloadingcircleState extends State<Mihloadingcircle> class _MihloadingcircleState extends State<Mihloadingcircle> {
with TickerProviderStateMixin { // final GifController _controller = GifController();
late final GifController _controller;
late double popUpPaddingSize; late double popUpPaddingSize;
late double popUpWidth; late double popUpWidth;
late double? popUpheight; late double? popUpheight;
@@ -37,60 +36,37 @@ class _MihloadingcircleState extends State<Mihloadingcircle>
@override @override
void initState() { void initState() {
_controller = GifController(vsync: this);
//_controller.animateTo(26); //_controller.animateTo(26);
super.initState(); super.initState();
} }
@override @override
void dispose() { void dispose() {
_controller.dispose(); // _controller.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ImageProvider loading =
MzanziInnovationHub.of(context)!.theme.loadingImage();
var size = MediaQuery.of(context).size;
setState(() {
width = size.width;
height = size.height;
});
checkScreenSize(); checkScreenSize();
return Dialog( return Dialog(
//backgroundColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
child: Container( child: Container(
padding: EdgeInsets.all(popUpPaddingSize), padding: EdgeInsets.all(popUpPaddingSize),
width: 250, width: 250,
height: 250, height: 250,
decoration: BoxDecoration( decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(), color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0), borderRadius: BorderRadius.circular(25.0),
border: Border.all( border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(), color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
width: 5.0), width: 5.0),
),
child: Gif(
image: loading,
controller:
_controller, // if duration and fps is null, original gif fps will be used.
fps: 15,
//duration: const Duration(seconds: 3),
autostart: Autostart.loop,
placeholder: (context) => const Center(
child: CircularProgressIndicator(),
), ),
onFetchCompleted: () { child: GifView.asset(
_controller.reset(); MzanziInnovationHub.of(context)!.theme.loadingImageLocation(),
_controller.forward(); height: 200,
}, width: 200,
), frameRate: 30,
), )),
// Center(
// child: MzanziInnovationHub.of(context)!.theme.loadingImage()),
// ),
); );
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import 'package:Mzansi_Innovation_Hub/mih_packages/authentication/biometric_check.dart'; import 'package:Mzansi_Innovation_Hub/mih_packages/authentication/biometric_check.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -62,8 +63,9 @@ class _AuthCheckState extends State<AuthCheck> {
} else if (snapshot.data == false) { } else if (snapshot.data == false) {
return const SignInOrRegister(); return const SignInOrRegister();
} else { } else {
return const SizedBox(width: 5, height: 5); return
// const Mihloadingcircle(); // const SizedBox(width: 5, height: 5);
const Mihloadingcircle();
} }
}); });
}, },

View File

@@ -68,7 +68,7 @@ class _BiometricCheckState extends State<BiometricCheck> {
void authenticateUser() async { void authenticateUser() async {
final bool canAuthWithBio = await _auth.canCheckBiometrics; final bool canAuthWithBio = await _auth.canCheckBiometrics;
print("Biomentric Available: $canAuthWithBio"); // print("Biomentric Available: $canAuthWithBio");
if (canAuthWithBio) { if (canAuthWithBio) {
try { try {
final bool didBioAuth = await _auth.authenticate( final bool didBioAuth = await _auth.authenticate(
@@ -82,7 +82,7 @@ class _BiometricCheckState extends State<BiometricCheck> {
_isBioAuthenticated = true; _isBioAuthenticated = true;
}); });
} }
print("Authenticated: $didBioAuth"); // print("Authenticated: $didBioAuth");
} catch (error) { } catch (error) {
print(error); print(error);
} }
@@ -123,22 +123,21 @@ class _BiometricCheckState extends State<BiometricCheck> {
), ),
//spacer //spacer
const SizedBox(height: 25), const SizedBox(height: 25),
if (!_isBioAuthenticated) // if (!_isBioAuthenticated)
Icon( Icon(
Icons.lock, Icons.lock,
size: 200, size: 200,
color: MzanziInnovationHub.of(context)! color:
.theme MzanziInnovationHub.of(context)!.theme.secondaryColor(),
.secondaryColor(), ),
), // if (_isBioAuthenticated)
if (_isBioAuthenticated) // Icon(
Icon( // Icons.lock_open,
Icons.lock_open, // size: 200,
size: 200, // color: MzanziInnovationHub.of(context)!
color: MzanziInnovationHub.of(context)! // .theme
.theme // .secondaryColor(),
.secondaryColor(), // ),
),
const SizedBox(height: 30), const SizedBox(height: 30),
Container( Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
@@ -187,7 +186,7 @@ class _BiometricCheckState extends State<BiometricCheck> {
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
if (widget.firstBoot == true) authenticateUser(); // if (widget.firstBoot == true) authenticateUser();
} }
@override @override
@@ -206,6 +205,7 @@ class _BiometricCheckState extends State<BiometricCheck> {
personalSelected: widget.personalSelected, personalSelected: widget.personalSelected,
); );
} else { } else {
authenticateUser();
return getBiomentricAuthScreen(); return getBiomentricAuthScreen();
} }
} }

View File

@@ -10,6 +10,7 @@ class MyTheme {
late String mode; late String mode;
late String screenType; late String screenType;
late AssetImage loading; late AssetImage loading;
late String loadingAssetText;
late TargetPlatform platform; late TargetPlatform platform;
bool kIsWeb = const bool.fromEnvironment('dart.library.js_util'); bool kIsWeb = const bool.fromEnvironment('dart.library.js_util');
// Options:- // Options:-
@@ -227,6 +228,24 @@ class MyTheme {
return loading; return loading;
} }
String loadingImageLocation() {
if (mode == "Dark") {
loadingAssetText = 'images/loading_light.gif';
} else {
loadingAssetText = 'images/loading_dark.gif';
}
return loadingAssetText;
}
String altLoadingImageLocation() {
if (mode == "Dark") {
loadingAssetText = 'images/loading_dark.gif';
} else {
loadingAssetText = 'images/loading_light.gif';
}
return loadingAssetText;
}
AssetImage aiLogoImage() { AssetImage aiLogoImage() {
if (mode == "Dark") { if (mode == "Dark") {
return const AssetImage( return const AssetImage(

View File

@@ -584,14 +584,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.3" version: "0.2.3"
gif: gif_view:
dependency: "direct main" dependency: "direct main"
description: description:
name: gif name: gif_view
sha256: ade95694f1471da737922806818ffade2814d1d7f8d10af38ebcf36ace012bc0 sha256: d2441d98bcd56b3fd00e869513aeaefa56849ab62f63675e7d55f5fa4517f27e
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.0" version: "1.0.0"
glob: glob:
dependency: transitive dependency: transitive
description: description:

View File

@@ -46,7 +46,8 @@ dependencies:
google_nav_bar: ^5.0.6 google_nav_bar: ^5.0.6
mysql_client: ^0.0.27 mysql_client: ^0.0.27
args: 2.5.0 args: 2.5.0
gif: ^2.3.0 # gif: ^2.3.0
gif_view: ^1.0.0
intl: ^0.19.0 intl: ^0.19.0
flutter_native_splash: ^2.4.1 flutter_native_splash: ^2.4.1
#google_maps_flutter_web: ^0.5.10 #google_maps_flutter_web: ^0.5.10