Change TPIn #2
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:kmobile/data/repositories/auth_repository.dart';
|
||||
import 'package:kmobile/features/profile/change_password/change_password_screen.dart';
|
||||
import 'package:kmobile/features/profile/daily_transaction_limit.dart';
|
||||
import 'package:kmobile/features/profile/logout_dialog.dart';
|
||||
import 'package:kmobile/features/profile/tpin/change_tpin_screen.dart';
|
||||
import 'package:kmobile/security/secure_storage.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
@@ -12,6 +13,9 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../di/injection.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import 'package:kmobile/features/profile/preferences/preference_screen.dart';
|
||||
import 'package:kmobile/api/services/auth_service.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
|
||||
|
||||
|
||||
class ProfileScreen extends StatefulWidget {
|
||||
final String mobileNumber;
|
||||
@@ -190,11 +194,55 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.password),
|
||||
title: const Text("Change TPIN"),
|
||||
onTap: () async {
|
||||
},
|
||||
),
|
||||
title: Text('Change TPIN'),
|
||||
onTap: () async {
|
||||
// 1. Get the AuthService instance
|
||||
final authService = getIt<AuthService>();
|
||||
|
||||
// 2. Call checkTpin() to see if TPIN is set
|
||||
final isTpinSet = await authService.checkTpin();
|
||||
|
||||
// 3. If TPIN is not set, show the dialog
|
||||
if (!isTpinSet) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('TPIN Not Set'),
|
||||
content: Text('You have not set a TPIN yet. Please set a TPIN to proceed.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Back'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text('Proceed'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Dismiss the dialog
|
||||
// Navigate to the TPIN set screen
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TpinSetScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// Case 2: TPIN is set
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ChangeTpinScreen(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
// ListTile(
|
||||
// leading: const Icon(Icons.password),
|
||||
// title: const Text("Change Login MPIN"),
|
||||
|
||||
Reference in New Issue
Block a user