diff --git a/lib/app/shared/alert_message/alert_message.dart b/lib/app/shared/alert_message/alert_message.dart index 521c31e5d..8400af103 100644 --- a/lib/app/shared/alert_message/alert_message.dart +++ b/lib/app/shared/alert_message/alert_message.dart @@ -45,7 +45,7 @@ class AlertMessage { } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - duration: const Duration(milliseconds: 2 * 800), + duration: stateMessage.duration, content: SnackBarContent( message: message, iconPath: stateMessage.type.iconPath, diff --git a/lib/app/shared/models/state_message/state_message.dart b/lib/app/shared/models/state_message/state_message.dart index 02ac84650..3cd4224b0 100644 --- a/lib/app/shared/models/state_message/state_message.dart +++ b/lib/app/shared/models/state_message/state_message.dart @@ -12,6 +12,7 @@ class StateMessage extends Equatable { this.stringMessage, this.injectedMessage, this.showDialog = false, + this.duration = const Duration(milliseconds: 2 * 800), }); factory StateMessage.fromJson(Map json) => @@ -22,6 +23,7 @@ class StateMessage extends Equatable { this.stringMessage, this.injectedMessage, this.showDialog = false, + this.duration = const Duration(milliseconds: 2 * 800), }) : type = MessageType.error; const StateMessage.warning({ @@ -29,6 +31,7 @@ class StateMessage extends Equatable { this.stringMessage, this.injectedMessage, this.showDialog = false, + this.duration = const Duration(milliseconds: 2 * 800), }) : type = MessageType.warning; const StateMessage.info({ @@ -36,6 +39,7 @@ class StateMessage extends Equatable { this.stringMessage, this.injectedMessage, this.showDialog = false, + this.duration = const Duration(milliseconds: 2 * 800), }) : type = MessageType.info; const StateMessage.success({ @@ -43,6 +47,7 @@ class StateMessage extends Equatable { this.stringMessage, this.injectedMessage, this.showDialog = false, + this.duration = const Duration(milliseconds: 2 * 800), }) : type = MessageType.success; final MessageType type; @@ -51,10 +56,17 @@ class StateMessage extends Equatable { final String? stringMessage; final String? injectedMessage; final bool showDialog; + final Duration duration; Map toJson() => _$StateMessageToJson(this); @override - List get props => - [type, messageHandler, stringMessage, injectedMessage, showDialog]; + List get props => [ + type, + messageHandler, + stringMessage, + injectedMessage, + showDialog, + duration, + ]; } diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index dc6a74f73..17bfc76f5 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -246,8 +246,8 @@ class QRCodeScanCubit extends Cubit { // ), // ), // ); - } else if (state.uri.toString().startsWith('openid://?client_id') || - state.uri.toString().startsWith('openid-vc://?client_id')) { + } else if (state.uri.toString().startsWith('openid://') || + state.uri.toString().startsWith('openid-vc://')) { /// ebsi v2 presentation /// verifier side (siopv2) with request_uri @@ -292,14 +292,17 @@ class QRCodeScanCubit extends Cubit { ResponseString .RESPONSE_STRING_pleaseSwitchToCorrectOIDC4VCProfile, ), - showDialog: true, + showDialog: false, + duration: const Duration(seconds: 20), ), ), ); return; } - if (!await isOIDC4VPAndSiopV2WithRequestURIValid(state.uri!)) { + final isRequestValid = + await isOIDC4VPAndSiopV2WithRequestURIValid(state.uri!); + if (!isRequestValid) { emit( state.copyWith( qrScanStatus: QrScanStatus.success, @@ -328,7 +331,8 @@ class QRCodeScanCubit extends Cubit { ResponseString .RESPONSE_STRING_pleaseSwitchToCorrectOIDC4VCProfile, ), - showDialog: true, + showDialog: false, + duration: const Duration(seconds: 20), ), ), ); @@ -398,13 +402,13 @@ class QRCodeScanCubit extends Cubit { return; } - if (state.uri.toString().startsWith('openid://?client_id')) { + if (state.uri.toString().startsWith('openid://')) { /// verifier side (OIDC4VP And siopv2) with request_uri await launchOIDC4VPAndSiopV2WithRequestUriFlow(state.uri); return; } - if (state.uri.toString().startsWith('openid-vc://?client_id')) { + if (state.uri.toString().startsWith('openid-vc://')) { /// verifier side (siopv2) with request_uri await launchSiopV2WithRequestUriFlow(state.uri); return; @@ -831,24 +835,23 @@ class QRCodeScanCubit extends Cubit { } Future isOIDC4VPAndSiopV2WithRequestURIValid(Uri uri) async { - bool isValid = true; - ///credential should not be empty since we have to present if (credentialsCubit.state.credentials.isEmpty) { - emitError( - ResponseMessage(ResponseString.RESPONSE_STRING_CREDENTIAL_EMPTY_ERROR), - ); - isValid = false; + // emitError( + // ResponseMessage(ResponseString.RESPONSE_STRING_CREDENTIAL_EMPTY_ERROR), + // ); + + return false; } ///request attribute check - if (requestAttributeExists(uri) && isValid) { - isValid = false; - emitError( - ResponseMessage( - ResponseString.RESPONSE_STRING_SCAN_UNSUPPORTED_MESSAGE, - ), - ); + if (requestAttributeExists(uri)) { + // emitError( + // ResponseMessage( + // ResponseString.RESPONSE_STRING_SCAN_UNSUPPORTED_MESSAGE, + // ), + // ); + return false; } ///request_uri attribute check @@ -861,14 +864,14 @@ class QRCodeScanCubit extends Cubit { final sIOPV2Param = await getSIOPV2Parameters(uri); ///check if claims exists - if (sIOPV2Param.claims == null && isValid) { - emitError( - ResponseMessage( - ResponseString.RESPONSE_STRING_SCAN_UNSUPPORTED_MESSAGE, - ), - ); - isValid = false; + if (sIOPV2Param.claims == null) { + // emitError( + // ResponseMessage( + // ResponseString.RESPONSE_STRING_SCAN_UNSUPPORTED_MESSAGE, + // ), + // ); + return false; } - return isValid; + return true; } } diff --git a/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart b/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart index dbb3bf32d..d21560ccc 100644 --- a/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart +++ b/lib/dashboard/qr_code/qr_code_scan/view/qr_code_scan_page.dart @@ -42,8 +42,7 @@ class _QrCodeScanPageState extends State { listener: (context, state) async { if (state.status == QrScanStatus.error) { if (state.message != null) { - final Route? currentRoute = ModalRoute.of(context); - currentRoute!.didPop(true); + Navigator.of(context).pop(); } }