Compare commits
No commits in common. "1ad1cd07cc7d16dcee453d29184d3048a4b20ed4" and "83ad2b2e5200594b8c3cb03ff15b9c87529e416b" have entirely different histories.
1ad1cd07cc
...
83ad2b2e52
@ -53,7 +53,7 @@ class KMobile extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
// Handle different authentication states
|
// Handle different authentication states
|
||||||
if (state is AuthInitial || state is AuthLoading) {
|
if (state is AuthInitial || state is AuthLoading) {
|
||||||
return const SplashScreen();
|
return const _SplashScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state is ShowBiometricPermission){
|
if(state is ShowBiometricPermission){
|
||||||
@ -73,8 +73,8 @@ class KMobile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simple splash screens component
|
// Simple splash screens component
|
||||||
class SplashScreen extends StatelessWidget {
|
class _SplashScreen extends StatelessWidget {
|
||||||
const SplashScreen();
|
const _SplashScreen();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -31,8 +31,6 @@ class AppRoutes {
|
|||||||
// Route generator
|
// Route generator
|
||||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
case splash:
|
|
||||||
return MaterialPageRoute(builder: (_) => const SplashScreen());
|
|
||||||
case login:
|
case login:
|
||||||
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ class AuthRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<User?> getCurrentUser() async {
|
Future<User?> getCurrentUser() async {
|
||||||
final userJson = await _secureStorage.read(_userKey);
|
final userJson = await _secureStorage.read(_userKey);
|
||||||
if (userJson != null) {
|
if (userJson != null) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:kmobile/features/auth/controllers/auth_cubit.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:material_symbols_icons/material_symbols_icons.dart';
|
||||||
|
|
||||||
import '../../../app.dart';
|
import '../../../app.dart';
|
||||||
|
|
||||||
class MPinScreen extends StatefulWidget {
|
class MPinScreen extends StatefulWidget {
|
||||||
@ -64,20 +64,15 @@ class MPinScreenState extends State<MPinScreen> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () async {
|
onTap: () {
|
||||||
if (key == '<') {
|
if (key == '<') {
|
||||||
deleteDigit();
|
deleteDigit();
|
||||||
} else if (key == 'Enter') {
|
} else if (key == 'Enter') {
|
||||||
if (mPin.length == 4) {
|
if (mPin.length == 4) {
|
||||||
String storedMpin = await SecureStorage().read("mpin");
|
|
||||||
if(!mounted) return;
|
|
||||||
if(storedMpin == mPin.join()) {
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(builder: (context) => const NavigationScaffold()),
|
||||||
builder: (context) => const NavigationScaffold()),
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text("Please enter 4 digits")),
|
const SnackBar(content: Text("Please enter 4 digits")),
|
||||||
|
@ -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(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user