refactor: Clean up code formatting and improve logging in liveness detection and registration form

This commit is contained in:
vergiLgood1 2025-05-24 15:09:35 +07:00
parent 64c9f233a1
commit 790eb4325d
3 changed files with 13 additions and 16 deletions

View File

@ -469,7 +469,7 @@ class FaceLivenessController extends GetxController {
// Capture image with retry logic // Capture image with retry logic
int retryCount = 0; int retryCount = 0;
const maxRetries = 3; const maxRetries = 3;
while (retryCount < maxRetries) { while (retryCount < maxRetries) {
try { try {
capturedImage = await cameraController!.takePicture(); capturedImage = await cameraController!.takePicture();
@ -480,11 +480,11 @@ class FaceLivenessController extends GetxController {
'Capture attempt $retryCount failed: $e', 'Capture attempt $retryCount failed: $e',
name: 'LIVENESS_CONTROLLER', name: 'LIVENESS_CONTROLLER',
); );
if (retryCount >= maxRetries) { if (retryCount >= maxRetries) {
rethrow; rethrow;
} }
// Wait before retry // Wait before retry
await Future.delayed(Duration(milliseconds: 500)); await Future.delayed(Duration(milliseconds: 500));
} }

View File

@ -13,7 +13,7 @@ class LivenessDetectionPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
dev.log('Building LivenessDetectionPage', name: 'LIVENESS_DEBUG'); dev.log('Building LivenessDetectionPage', name: 'LIVENESS_DEBUG');
// Ensure controllers are registered // Ensure controllers are registered
final bool hasController = Get.isRegistered<FaceLivenessController>(); final bool hasController = Get.isRegistered<FaceLivenessController>();
final bool hasSelfieController = final bool hasSelfieController =
@ -73,7 +73,7 @@ class LivenessDetectionPage extends StatelessWidget {
dev.log( dev.log(
'Controller state: ' 'Controller state: '
'Camera initialized: ${controller.cameraController?.value.isInitialized}, ' 'Camera initialized: ${controller.cameraController?.value.isInitialized}, '
'Is captured: ${controller.isCaptured.value}', 'Is captured: ${controller.isCaptured}',
name: 'LIVENESS_DEBUG', name: 'LIVENESS_DEBUG',
); );
@ -145,13 +145,13 @@ class LivenessDetectionPage extends StatelessWidget {
'Steps: ${controller.successfulSteps.length}', 'Steps: ${controller.successfulSteps.length}',
name: 'LIVENESS_DEBUG', name: 'LIVENESS_DEBUG',
); );
// Show loading indicator while camera initializes // Show loading indicator while camera initializes
if (controller.cameraController == null) { if (controller.cameraController == null) {
dev.log('Camera controller is null', name: 'LIVENESS_DEBUG'); dev.log('Camera controller is null', name: 'LIVENESS_DEBUG');
return _buildErrorState('Camera initialization failed'); return _buildErrorState('Camera initialization failed');
} }
if (!controller.cameraController!.value.isInitialized) { if (!controller.cameraController!.value.isInitialized) {
dev.log('Camera not initialized yet', name: 'LIVENESS_DEBUG'); dev.log('Camera not initialized yet', name: 'LIVENESS_DEBUG');
return Center( return Center(
@ -262,7 +262,7 @@ class LivenessDetectionPage extends StatelessWidget {
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
), ),
), ),
// Camera preview // Camera preview
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
@ -574,7 +574,7 @@ class LivenessDetectionPage extends StatelessWidget {
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
Text( Text(
'Verification Successful!', 'Verification Successful!',
style: TextStyle( style: TextStyle(
@ -583,7 +583,7 @@ class LivenessDetectionPage extends StatelessWidget {
color: Colors.green.shade700, color: Colors.green.shade700,
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Text( Text(
@ -812,10 +812,7 @@ class LivenessDetectionPage extends StatelessWidget {
'Ready For Photo', 'Ready For Photo',
'${controller.isFaceReadyForPhoto.value}', '${controller.isFaceReadyForPhoto.value}',
), ),
_debugItem( _debugItem('Captured', '${controller.isCaptured}'),
'Captured',
'${controller.isCaptured.value}',
),
_debugItem( _debugItem(
'Steps Completed', 'Steps Completed',
'${controller.successfulSteps.length}', '${controller.successfulSteps.length}',

View File

@ -4,8 +4,8 @@ import 'package:get/get.dart';
import 'package:sigap/src/features/auth/presentasion/controllers/basic/registration_form_controller.dart'; import 'package:sigap/src/features/auth/presentasion/controllers/basic/registration_form_controller.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/id_card_verification_step.dart'; import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/id_card_verification_step.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/identity_verification_step.dart'; import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/identity_verification_step.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/liveness_detection_screen.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/personal_info_step.dart'; import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/personal_info_step.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/basic/selfie_verification_step.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/officer/officer_info_step.dart'; import 'package:sigap/src/features/auth/presentasion/pages/registration-form/officer/officer_info_step.dart';
import 'package:sigap/src/features/auth/presentasion/pages/registration-form/officer/unit_info_step.dart'; import 'package:sigap/src/features/auth/presentasion/pages/registration-form/officer/unit_info_step.dart';
import 'package:sigap/src/features/auth/presentasion/widgets/auth_button.dart'; import 'package:sigap/src/features/auth/presentasion/widgets/auth_button.dart';
@ -169,7 +169,7 @@ class FormRegistrationScreen extends StatelessWidget {
case 1: case 1:
return const IdCardVerificationStep(); return const IdCardVerificationStep();
case 2: case 2:
return const LivenessDetectionPage(); return const SelfieVerificationStep();
case 3: case 3:
return isOfficer return isOfficer
? const OfficerInfoStep() ? const OfficerInfoStep()