Skip to content

Commit

Permalink
feat: By pass selection process if one sd-jwt VC is present #3149
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Dec 4, 2024
1 parent d0c43e5 commit c3b0d30
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,57 @@ class CredentialManifestOfferPickView extends StatefulWidget {

class _CredentialManifestOfferPickViewState
extends State<CredentialManifestOfferPickView> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
final isVcSdJWT = context
.read<CredentialManifestPickCubit>()
.state
.filteredCredentialList
.firstOrNull
?.getFormat ==
VCFormatType.vcSdJWT.vcValue;
if (isVcSdJWT) {
final element = context
.read<CredentialManifestPickCubit>()
.state
.filteredCredentialList;
final containsSingleElement = element.isNotEmpty && element.length == 1;
if (containsSingleElement) {
final PresentationDefinition? presentationDefinition = context
.read<CredentialManifestPickCubit>()
.state
.presentationDefinition;
if (presentationDefinition != null) {
context.read<CredentialManifestPickCubit>().toggle(
index: 0,
inputDescriptor: presentationDefinition
.inputDescriptors[widget.inputDescriptorIndex],
isVcSdJWT: isVcSdJWT,
);

final credentialManifestState =
context.read<CredentialManifestPickCubit>().state;
final firstOne = credentialManifestState
.filteredCredentialList[credentialManifestState.selected.first];

Navigator.of(context).pushReplacement<void, void>(
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) {
Expand Down

0 comments on commit c3b0d30

Please sign in to comment.