From c3b0d301162a02d96386bbfc75473fa54f40b7f0 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 4 Dec 2024 11:27:56 +0545 Subject: [PATCH] feat: By pass selection process if one sd-jwt VC is present #3149 --- ...l_manifest_credential_offer_pick_page.dart | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/view/credential_manifest_credential_offer_pick_page.dart b/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/view/credential_manifest_credential_offer_pick_page.dart index 35c6bd36d..43c4cc1cb 100644 --- a/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/view/credential_manifest_credential_offer_pick_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/present/pick/credential_manifest/view/credential_manifest_credential_offer_pick_page.dart @@ -96,6 +96,57 @@ class CredentialManifestOfferPickView extends StatefulWidget { class _CredentialManifestOfferPickViewState extends State { + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + final isVcSdJWT = context + .read() + .state + .filteredCredentialList + .firstOrNull + ?.getFormat == + VCFormatType.vcSdJWT.vcValue; + if (isVcSdJWT) { + final element = context + .read() + .state + .filteredCredentialList; + final containsSingleElement = element.isNotEmpty && element.length == 1; + if (containsSingleElement) { + final PresentationDefinition? presentationDefinition = context + .read() + .state + .presentationDefinition; + if (presentationDefinition != null) { + context.read().toggle( + index: 0, + inputDescriptor: presentationDefinition + .inputDescriptors[widget.inputDescriptorIndex], + isVcSdJWT: isVcSdJWT, + ); + + final credentialManifestState = + context.read().state; + final firstOne = credentialManifestState + .filteredCredentialList[credentialManifestState.selected.first]; + + Navigator.of(context).pushReplacement( + SelectiveDisclosurePickPage.route( + uri: widget.uri, + issuer: widget.issuer, + credential: widget.credential, + inputDescriptorIndex: widget.inputDescriptorIndex, + credentialsToBePresented: widget.credentialsToBePresented, + presentationDefinition: presentationDefinition, + selectedCredential: firstOne, + ), + ); + } + } + } + }); + } @override Widget build(BuildContext context) {