SMS Screen Modifiaction
This commit is contained in:
@@ -151,7 +151,7 @@
|
||||
import 'package:simcards/simcards.dart';
|
||||
|
||||
// This enum provides detailed status back to the UI layer.
|
||||
enum PermissionStatusResult { granted, denied, permanentlyDenied }
|
||||
enum PermissionStatusResult { granted, denied, permanentlyDenied, restricted }
|
||||
|
||||
class SmsService {
|
||||
final Simcards _simcards = Simcards();
|
||||
@@ -162,29 +162,37 @@
|
||||
var smsStatus = await Permission.sms.status;
|
||||
var phoneStatus = await Permission.phone.status;
|
||||
|
||||
// Check if permissions are already granted
|
||||
// Check initial status
|
||||
if (smsStatus.isGranted && phoneStatus.isGranted) {
|
||||
return PermissionStatusResult.granted;
|
||||
}
|
||||
|
||||
// Check if they have been permanently denied
|
||||
if (smsStatus.isPermanentlyDenied || phoneStatus.isPermanentlyDenied) {
|
||||
return PermissionStatusResult.permanentlyDenied;
|
||||
}
|
||||
if (smsStatus.isRestricted || phoneStatus.isRestricted) {
|
||||
return PermissionStatusResult.restricted;
|
||||
}
|
||||
|
||||
// If not granted and not permanently denied, request them
|
||||
// Request permissions if not granted
|
||||
print("Requesting SMS and Phone permissions...");
|
||||
await [Permission.phone, Permission.sms].request();
|
||||
|
||||
// Re-check status after the request attempt
|
||||
// Re-check status after request
|
||||
smsStatus = await Permission.sms.status;
|
||||
phoneStatus = await Permission.phone.status;
|
||||
|
||||
if (smsStatus.isGranted && phoneStatus.isGranted) {
|
||||
return PermissionStatusResult.granted;
|
||||
} else {
|
||||
return PermissionStatusResult.denied;
|
||||
}
|
||||
if (smsStatus.isPermanentlyDenied || phoneStatus.isPermanentlyDenied) {
|
||||
return PermissionStatusResult.permanentlyDenied;
|
||||
}
|
||||
if (smsStatus.isRestricted || phoneStatus.isRestricted) {
|
||||
return PermissionStatusResult.restricted;
|
||||
}
|
||||
|
||||
// If none of the above, it's denied
|
||||
return PermissionStatusResult.denied;
|
||||
}
|
||||
|
||||
/// Tries to send a single verification SMS.
|
||||
|
||||
@@ -15,7 +15,6 @@ import 'di/injection.dart';
|
||||
import 'features/auth/controllers/auth_cubit.dart';
|
||||
import 'features/card/screens/card_management_screen.dart';
|
||||
import 'features/auth/screens/splash_screen.dart';
|
||||
import 'features/auth/screens/login_screen.dart';
|
||||
import 'features/service/screens/service_screen.dart';
|
||||
import 'features/dashboard/screens/dashboard_screen.dart';
|
||||
import 'features/auth/screens/mpin_screen.dart';
|
||||
|
||||
@@ -76,6 +76,32 @@
|
||||
// Wait for user to return from settings
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
break;
|
||||
case PermissionStatusResult.restricted:
|
||||
if (mounted) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text("Permission Restricted"),
|
||||
content: const Text(
|
||||
"SMS and Phone permissions are restricted on this device. Please check your device settings or parental controls and enable them for this app."),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("Cancel"),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text("Open Settings"),
|
||||
onPressed: () {
|
||||
openAppSettings();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
final storage = getIt<SecureStorage>();
|
||||
final isEnabled = await storage.read('biometric_enabled');
|
||||
setState(() {
|
||||
_isBiometricEnabled = isEnabled == 'true';
|
||||
_isBiometricEnabled = isEnabled == true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user