api integration

This commit is contained in:
2025-06-02 10:29:32 +05:30
parent 7c9e089c62
commit 805aa5e015
289 changed files with 40017 additions and 1082 deletions

View File

@@ -1,13 +1,14 @@
import 'package:bloc/bloc.dart';
import 'package:local_auth/local_auth.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:kmobile/api/services/user_service.dart';
import 'package:kmobile/core/errors/exceptions.dart';
import '../../../data/repositories/auth_repository.dart';
import 'auth_state.dart';
class AuthCubit extends Cubit<AuthState> {
final AuthRepository _authRepository;
final UserService _userService;
AuthCubit(this._authRepository) : super(AuthInitial()) {
AuthCubit(this._authRepository, this._userService) : super(AuthInitial()) {
checkAuthStatus();
}
@@ -16,12 +17,8 @@ class AuthCubit extends Cubit<AuthState> {
try {
final isLoggedIn = await _authRepository.isLoggedIn();
if (isLoggedIn) {
final user = await _authRepository.getCurrentUser();
if (user != null) {
emit(Authenticated(user));
} else {
emit(Unauthenticated());
}
final users = await _userService.getUserDetails();
emit(Authenticated(users));
} else {
emit(Unauthenticated());
}
@@ -30,79 +27,24 @@ class AuthCubit extends Cubit<AuthState> {
}
}
Future<void> login(String username, String password) async {
Future<void> refreshUserData() async {
try {
// emit(AuthLoading());
final users = await _userService.getUserDetails();
emit(Authenticated(users));
} catch (e) {
emit(AuthError('Failed to refresh user data: ${e.toString()}'));
// Optionally, re-emit the previous state or handle as needed
}
}
Future<void> login(String customerNo, String password) async {
emit(AuthLoading());
try {
final user = await _authRepository.login(username, password);
emit(Authenticated(user));
final users = await _authRepository.login(customerNo, password);
emit(Authenticated(users));
} catch (e) {
emit(AuthError(e.toString()));
}
}
Future<void> logout() async {
emit(AuthLoading());
try {
await _authRepository.logout();
emit(Unauthenticated());
} catch (e) {
emit(AuthError(e.toString()));
}
}
Future<void> checkFirstLaunch() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final isFirstLaunch = prefs.getBool('isFirstLaunch') ?? true;
if (isFirstLaunch) {
emit(ShowBiometricPermission());
} else {
// Continue to authentication logic (e.g., check token)
emit(AuthLoading()); // or Unauthenticated/Authenticated
}
}
Future<void> handleBiometricChoice(bool enabled) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setBool('biometric_opt_in', enabled);
await prefs.setBool('isFirstLaunch', false);
// Then continue to auth logic or home
if (enabled) {
authenticateBiometric(); // implement biometric logic
} else {
emit(Unauthenticated());
}
}
Future<void> authenticateBiometric() async {
final LocalAuthentication auth = LocalAuthentication();
try {
final isAvailable = await auth.canCheckBiometrics;
final isDeviceSupported = await auth.isDeviceSupported();
if (isAvailable && isDeviceSupported) {
final authenticated = await auth.authenticate(
localizedReason: 'Touch the fingerprint sensor',
options: const AuthenticationOptions(
biometricOnly: true,
stickyAuth: true,
),
);
if (authenticated) {
// Continue to normal auth logic (e.g., auto login)
emit(AuthLoading());
await checkAuthStatus(); // Your existing method to verify token/session
} else {
emit(Unauthenticated());
}
} else {
emit(Unauthenticated());
}
} catch (e) {
emit(Unauthenticated());
emit(AuthError(e is AuthException ? e.message : e.toString()));
}
}
}

View File

@@ -10,15 +10,13 @@ class AuthInitial extends AuthState {}
class AuthLoading extends AuthState {}
class ShowBiometricPermission extends AuthState {}
class Authenticated extends AuthState {
final User user;
final List<User> users;
Authenticated(this.user);
Authenticated(this.users);
@override
List<Object?> get props => [user];
List<Object?> get props => [users];
}
class Unauthenticated extends AuthState {}

View File

@@ -1,11 +1,11 @@
class AuthCredentials {
final String username;
final String customerNo;
final String password;
AuthCredentials({required this.username, required this.password});
AuthCredentials({required this.customerNo, required this.password});
Map<String, dynamic> toJson() => {
'customer_no': username,
'customerNo': customerNo,
'password': password,
};
}

View File

@@ -1,26 +1,48 @@
import 'dart:convert';
import 'dart:developer';
import 'package:equatable/equatable.dart';
class AuthToken extends Equatable {
final String accessToken;
final String refreshToken;
final DateTime expiresAt;
const AuthToken({
required this.accessToken,
required this.refreshToken,
required this.expiresAt,
});
factory AuthToken.fromJson(Map<String, dynamic> json) {
return AuthToken(
accessToken: json['access_token'],
refreshToken: json['refresh_token'],
expiresAt: DateTime.parse(json['expires_at']),
accessToken: json['token'],
expiresAt: _decodeExpiryFromToken(json['token']),
);
}
static DateTime _decodeExpiryFromToken(String token) {
try {
final parts = token.split('.');
if (parts.length != 3) {
throw Exception('Invalid JWT');
}
final payload = parts[1];
// Pad the payload if necessary
String normalized = base64Url.normalize(payload);
final payloadMap = json.decode(utf8.decode(base64Url.decode(normalized)));
if (payloadMap is! Map<String, dynamic> || !payloadMap.containsKey('exp')) {
throw Exception('Invalid payload');
}
final exp = payloadMap['exp'];
return DateTime.fromMillisecondsSinceEpoch(exp * 1000);
} catch (e) {
// Fallback: 1 hour from now if decoding fails
log(e.toString());
return DateTime.now().add(const Duration(hours: 1));
}
}
bool get isExpired => DateTime.now().isAfter(expiresAt);
@override
List<Object> get props => [accessToken, refreshToken, expiresAt];
List<Object> get props => [accessToken, expiresAt];
}

View File

@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/features/auth/screens/mpin_screen.dart';
import 'package:kmobile/security/secure_storage.dart';
import '../../../app.dart';
import '../controllers/auth_cubit.dart';
import '../controllers/auth_state.dart';
@@ -27,16 +28,12 @@ class LoginScreenState extends State<LoginScreen> {
}
void _submitForm() {
// if (_formKey.currentState!.validate()) {
// context.read<AuthCubit>().login(
// _customerNumberController.text.trim(),
// _passwordController.text,
// );
// }
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const MPinScreen()),
);
if (_formKey.currentState!.validate()) {
context.read<AuthCubit>().login(
_customerNumberController.text.trim(),
_passwordController.text,
);
}
}
@override
@@ -44,11 +41,30 @@ class LoginScreenState extends State<LoginScreen> {
return Scaffold(
// appBar: AppBar(title: const Text('Login')),
body: BlocConsumer<AuthCubit, AuthState>(
listener: (context, state) {
listener: (context, state) async {
if (state is Authenticated) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const NavigationScaffold()),
);
final storage = getIt<SecureStorage>();
final mpin = await storage.read('mpin');
if (mpin == null) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => MPinScreen(
mode: MPinMode.set,
onCompleted: (_) {
Navigator.of(context, rootNavigator: true)
.pushReplacement(
MaterialPageRoute(
builder: (_) => const NavigationScaffold()),
);
},
),
),
);
} else {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
);
}
} else if (state is AuthError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.message)),
@@ -62,18 +78,23 @@ class LoginScreenState extends State<LoginScreen> {
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Bank logo or app branding
SvgPicture.asset('assets/images/kccb_logo.svg', width: 100, height: 100,),
Image.asset('assets/images/logo.png', width: 150, height: 150,
errorBuilder: (context, error, stackTrace) {
return const Icon(Icons.account_balance,
size: 100, color: Colors.blue);
}),
const SizedBox(height: 16),
// Title
const Text(
'KCCB',
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Colors.blue),
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.blue),
),
const SizedBox(height: 48),
TextFormField(
controller: _customerNumberController,
decoration: const InputDecoration(
@@ -99,8 +120,8 @@ class LoginScreenState extends State<LoginScreen> {
return null;
},
),
const SizedBox(height: 16),
const SizedBox(height: 24),
TextFormField(
controller: _passwordController,
decoration: InputDecoration(
@@ -118,8 +139,8 @@ class LoginScreenState extends State<LoginScreen> {
),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword
? Icons.visibility
_obscurePassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
@@ -138,40 +159,29 @@ class LoginScreenState extends State<LoginScreen> {
return null;
},
),
// Align(
// alignment: Alignment.centerRight,
// child: TextButton(
// onPressed: () {
// // Navigate to forgot password screen
// },
// child: const Text('Forgot Password?'),
// ),
// ),
const SizedBox(height: 24),
SizedBox(
width: 250,
child: ElevatedButton(
onPressed: state is AuthLoading ? null : _submitForm,
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
padding: const EdgeInsets.symmetric(vertical: 16),
backgroundColor: Colors.white,
foregroundColor: Colors.blueAccent,
side: const BorderSide(color: Colors.black, width: 1),
elevation: 0
),
shape: const StadiumBorder(),
padding: const EdgeInsets.symmetric(vertical: 16),
backgroundColor: Colors.white,
foregroundColor: Colors.blueAccent,
side: const BorderSide(color: Colors.black, width: 1),
elevation: 0),
child: state is AuthLoading
? const CircularProgressIndicator()
: const Text('Login', style: TextStyle(fontSize: 16),),
: const Text(
'Login',
style: TextStyle(fontSize: 16),
),
),
),
const SizedBox(height: 15),
// OR Divider
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Row(
@@ -185,26 +195,22 @@ class LoginScreenState extends State<LoginScreen> {
],
),
),
const SizedBox(height: 25),
// Register Button
SizedBox(
width: 250,
child: ElevatedButton(
onPressed: () {
// Handle register
},
//disable until registration is implemented
onPressed: null,
style: OutlinedButton.styleFrom(
shape: const StadiumBorder(),
padding: const EdgeInsets.symmetric(vertical: 16),
backgroundColor: Colors.lightBlue[100],
foregroundColor: Colors.black
),
shape: const StadiumBorder(),
padding: const EdgeInsets.symmetric(vertical: 16),
backgroundColor: Colors.lightBlue[100],
foregroundColor: Colors.black),
child: const Text('Register'),
),
),
],
),
),
@@ -213,4 +219,4 @@ class LoginScreenState extends State<LoginScreen> {
),
);
}
}
}

View File

@@ -1,24 +1,72 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
import '../../../app.dart';
import 'package:kmobile/app.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/security/secure_storage.dart';
import 'package:local_auth/local_auth.dart';
enum MPinMode { enter, set, confirm }
class MPinScreen extends StatefulWidget {
const MPinScreen({super.key});
final MPinMode mode;
final String? initialPin;
final void Function(String pin)? onCompleted;
const MPinScreen({
super.key,
required this.mode,
this.initialPin,
this.onCompleted,
});
@override
MPinScreenState createState() => MPinScreenState();
State<MPinScreen> createState() => _MPinScreenState();
}
class MPinScreenState extends State<MPinScreen> {
class _MPinScreenState extends State<MPinScreen> {
List<String> mPin = [];
String? errorText;
@override
void initState() {
super.initState();
if (widget.mode == MPinMode.enter) {
_tryBiometricBeforePin();
}
}
Future<void> _tryBiometricBeforePin() async {
final storage = getIt<SecureStorage>();
final enabled = await storage.read('biometric_enabled');
log('biometric_enabled: $enabled');
if (enabled) {
final auth = LocalAuthentication();
if (await auth.canCheckBiometrics) {
final didAuth = await auth.authenticate(
localizedReason: 'Authenticate to access kMobile',
options: const AuthenticationOptions(biometricOnly: true),
);
if (didAuth && mounted) {
// success → directly “complete” your flow
widget.onCompleted?.call('');
// or navigate yourself:
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(builder: (_) => const NavigationScaffold()));
}
}
}
}
void addDigit(String digit) {
if (mPin.length < 4) {
setState(() {
mPin.add(digit);
errorText = null;
});
if (mPin.length == 4) {
_handleComplete();
}
}
}
@@ -26,10 +74,63 @@ class MPinScreenState extends State<MPinScreen> {
if (mPin.isNotEmpty) {
setState(() {
mPin.removeLast();
errorText = null;
});
}
}
Future<void> _handleComplete() async {
final pin = mPin.join();
final storage = SecureStorage();
switch (widget.mode) {
case MPinMode.enter:
final storedPin = await storage.read('mpin');
log('storedPin: $storedPin');
if (storedPin == int.tryParse(pin)) {
widget.onCompleted?.call(pin);
} else {
setState(() {
errorText = "Incorrect mPIN. Try again.";
mPin.clear();
});
}
break;
case MPinMode.set:
// propagate parent onCompleted into confirm step
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => MPinScreen(
mode: MPinMode.confirm,
initialPin: pin,
onCompleted: widget.onCompleted, // <-- use parent callback
),
),
);
break;
case MPinMode.confirm:
if (widget.initialPin == pin) {
// 1) persist the pin
await storage.write('mpin', pin);
// 3) now clear the entire navigation stack and go to your main scaffold
if (mounted) {
Navigator.of(context, rootNavigator: true).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
(route) => false,
);
}
} else {
setState(() {
errorText = "Pins do not match. Try again.";
mPin.clear();
});
}
break;
}
}
Widget buildMPinDots() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
@@ -63,24 +164,16 @@ class MPinScreenState extends State<MPinScreen> {
return Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () async {
onTap: () {
if (key == '<') {
deleteDigit();
} else if (key == 'Enter') {
if (mPin.length == 4) {
// String storedMpin = await SecureStorage().read("mpin");
// if(!mounted) return;
// if(storedMpin == mPin.join()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const NavigationScaffold()),
);
// }
_handleComplete();
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Please enter 4 digits")),
);
setState(() {
errorText = "Please enter 4 digits";
});
}
} else if (key.isNotEmpty) {
addDigit(key);
@@ -94,15 +187,15 @@ class MPinScreenState extends State<MPinScreen> {
color: Colors.grey[200],
),
alignment: Alignment.center,
child: key == 'Enter' ? const Icon(Symbols.check) : Text(
key == '<' ? '' : key,
style: TextStyle(
fontSize: 20,
fontWeight: key == 'Enter' ?
FontWeight.normal : FontWeight.normal,
color: key == 'Enter' ? Colors.blue : Colors.black,
),
),
child: key == 'Enter'
? const Icon(Icons.check)
: Text(
key == '<' ? '' : key,
style: TextStyle(
fontSize: 20,
color: key == 'Enter' ? Colors.blue : Colors.black,
),
),
),
),
);
@@ -112,34 +205,40 @@ class MPinScreenState extends State<MPinScreen> {
);
}
String getTitle() {
switch (widget.mode) {
case MPinMode.enter:
return "Enter your mPIN";
case MPinMode.set:
return "Set your new mPIN";
case MPinMode.confirm:
return "Confirm your mPIN";
}
}
@override
Widget build(BuildContext context) {
final cubit = context.read<AuthCubit>();
return Scaffold(
body: SafeArea(
child: Column(
children: [
const Spacer(),
// Logo
const FlutterLogo(size: 100),
Image.asset('assets/images/logo.png', height: 100),
const SizedBox(height: 20),
const Text(
"Enter your mPIN",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
Text(
getTitle(),
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
const SizedBox(height: 20),
buildMPinDots(),
if (errorText != null)
Padding(
padding: const EdgeInsets.only(top: 8.0),
child:
Text(errorText!, style: const TextStyle(color: Colors.red)),
),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(onPressed: () {
cubit.authenticateBiometric();
}, child: const Text("Try another way")),
TextButton(onPressed: () {}, child: const Text("Register?")),
],
),
buildNumberPad(),
const Spacer(),
],
@@ -147,4 +246,4 @@ class MPinScreenState extends State<MPinScreen> {
),
);
}
}
}

View File

@@ -1,144 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
import 'package:kmobile/features/auth/screens/mpin_setup_confirm.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
class MPinSetupScreen extends StatefulWidget {
const MPinSetupScreen({super.key});
@override
MPinSetupScreenState createState() => MPinSetupScreenState();
}
class MPinSetupScreenState extends State<MPinSetupScreen> {
List<String> mPin = [];
void addDigit(String digit) {
if (mPin.length < 4) {
setState(() {
mPin.add(digit);
});
}
}
void deleteDigit() {
if (mPin.isNotEmpty) {
setState(() {
mPin.removeLast();
});
}
}
Widget buildMPinDots() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(4, (index) {
return Container(
margin: const EdgeInsets.all(8),
width: 15,
height: 15,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: index < mPin.length ? Colors.black : Colors.grey[400],
),
);
}),
);
}
Widget buildNumberPad() {
List<List<String>> keys = [
['1', '2', '3'],
['4', '5', '6'],
['7', '8', '9'],
['Enter', '0', '<']
];
return Column(
children: keys.map((row) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: row.map((key) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () {
if (key == '<') {
deleteDigit();
} else if (key == 'Enter') {
if (mPin.length == 4) {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => MPinSetupConfirmScreen(mPin: mPin,)),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Please enter 4 digits")),
);
}
} else if (key.isNotEmpty) {
addDigit(key);
}
},
child: Container(
width: 70,
height: 70,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey[200],
),
alignment: Alignment.center,
child: key == 'Enter' ? const Icon(Symbols.check) : Text(
key == '<' ? '' : key,
style: TextStyle(
fontSize: 20,
fontWeight: key == 'Enter' ?
FontWeight.normal : FontWeight.normal,
color: key == 'Enter' ? Colors.blue : Colors.black,
),
),
),
),
);
}).toList(),
);
}).toList(),
);
}
@override
Widget build(BuildContext context) {
final cubit = context.read<AuthCubit>();
return Scaffold(
body: SafeArea(
child: Column(
children: [
const Spacer(),
// Logo
const FlutterLogo(size: 100),
const SizedBox(height: 20),
const Text(
"Enter your mPIN",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
const SizedBox(height: 20),
buildMPinDots(),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(onPressed: () {
cubit.authenticateBiometric();
}, child: const Text("Try another way")),
TextButton(onPressed: () {}, child: const Text("Register?")),
],
),
buildNumberPad(),
const Spacer(),
],
),
),
);
}
}

View File

@@ -1,154 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
import 'package:kmobile/security/secure_storage.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../app.dart';
class MPinSetupConfirmScreen extends StatefulWidget {
final List<String> mPin;
const MPinSetupConfirmScreen({super.key, required this.mPin});
@override
MPinSetupConfirmScreenState createState() => MPinSetupConfirmScreenState();
}
class MPinSetupConfirmScreenState extends State<MPinSetupConfirmScreen> {
List<String> mPin = [];
void addDigit(String digit) {
if (mPin.length < 4) {
setState(() {
mPin.add(digit);
});
}
}
void deleteDigit() {
if (mPin.isNotEmpty) {
setState(() {
mPin.removeLast();
});
}
}
Widget buildMPinDots() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(4, (index) {
return Container(
margin: const EdgeInsets.all(8),
width: 15,
height: 15,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: index < mPin.length ? Colors.black : Colors.grey[400],
),
);
}),
);
}
Widget buildNumberPad() {
List<List<String>> keys = [
['1', '2', '3'],
['4', '5', '6'],
['7', '8', '9'],
['Enter', '0', '<']
];
return Column(
children: keys.map((row) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: row.map((key) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () async {
if (key == '<') {
deleteDigit();
} else if (key == 'Enter') {
if (mPin.length == 4 && mPin.join() == widget.mPin.join()) {
await SecureStorage().write("mpin", mPin.join());
await SharedPreferences.getInstance()
.then((prefs) => prefs.setBool('mpin_set', true));
if(!mounted) return;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const NavigationScaffold()),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Please enter 4 digits")),
);
}
} else if (key.isNotEmpty) {
addDigit(key);
}
},
child: Container(
width: 70,
height: 70,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey[200],
),
alignment: Alignment.center,
child: key == 'Enter' ? const Icon(Symbols.check) : Text(
key == '<' ? '' : key,
style: TextStyle(
fontSize: 20,
fontWeight: key == 'Enter' ?
FontWeight.normal : FontWeight.normal,
color: key == 'Enter' ? Colors.blue : Colors.black,
),
),
),
),
);
}).toList(),
);
}).toList(),
);
}
@override
Widget build(BuildContext context) {
final cubit = context.read<AuthCubit>();
return Scaffold(
body: SafeArea(
child: Column(
children: [
const Spacer(),
// Logo
const FlutterLogo(size: 100),
const SizedBox(height: 20),
const Text(
"Enter your mPIN",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
const SizedBox(height: 20),
buildMPinDots(),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(onPressed: () {
cubit.authenticateBiometric();
}, child: const Text("Try another way")),
TextButton(onPressed: () {}, child: const Text("Register?")),
],
),
buildNumberPad(),
const Spacer(),
],
),
),
);
}
}