Skip to content

Commit

Permalink
send whole json when nested json instead of claims
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Aug 22, 2024
1 parent 97940e6 commit 7db94c4
Showing 1 changed file with 89 additions and 43 deletions.
132 changes: 89 additions & 43 deletions lib/selective_disclosure/widget/display_selective_disclosure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,37 @@ class DisplaySelectiveDisclosure extends StatelessWidget {
late Widget nestedChild;
value.remove('_sd');
if (value.isEmpty) {
nestedChild = DisplaySelectiveDisclosure(
credentialModel: credentialModel,
claims: const {},
showVertically: showVertically,
selectiveDisclosureState: selectiveDisclosureState,
parentKeyId: element.key.toString(),
onPressed: (nestedKey, _, threeDotValue) {
onPressed?.call(
nestedKey,
'${element.key}-$nestedKey',
threeDotValue,
);
},
nestedChild = Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 10),
child: Text(
element.key.toString(),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 10),
child: DisplaySelectiveDisclosure(
credentialModel: credentialModel,
claims: const {},
showVertically: showVertically,
selectiveDisclosureState: selectiveDisclosureState,
parentKeyId: element.key.toString(),
onPressed: (nestedKey, _, threeDotValue) {
onPressed?.call(
nestedKey,
'${element.key}-$nestedKey',
threeDotValue,
);
},
),
),
],
);
} else {
final limitDisclosure = selectiveDisclosureState?.limitDisclosure;
Expand All @@ -217,39 +235,61 @@ class DisplaySelectiveDisclosure extends StatelessWidget {
limitDisclosure != null && limitDisclosure == 'required';

final bool isDisabled = isCompulsary;
final selectedKeyId = selectiveDisclosureState?.selectedClaimsKeyIds
.firstWhereOrNull((ele) => ele.keyId == element.key.toString());

nestedChild = TransparentInkWell(
onTap: () {
if (isDisabled || isCompulsary) {
return;
}

onPressed?.call(element.key.toString(), element.key.toString(),
element.value.toString());
onPressed?.call(
element.key.toString(),
element.key.toString(),
null,
);
},
child: DisplayNestedMap(value, context),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 10),
child: Row(
children: [
Text(
element.key.toString(),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (!isDisabled && selectiveDisclosureState != null) ...[
const Spacer(),
Padding(
padding: const EdgeInsets.only(top: 0, right: 10),
child: Icon(
(selectedKeyId != null && selectedKeyId.isSelected)
? Icons.check_box
: Icons.check_box_outline_blank,
size: 25,
color: Theme.of(context).colorScheme.onSurface,
),
),
],
],
),
),
Padding(
padding: const EdgeInsets.only(left: 10),
child: DisplayNestedMap(value, context),
),
],
),
);
}

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 10),
child: Text(
element.key.toString(),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 10),
child: nestedChild,
),
],
);
return nestedChild;
}

Widget displayClaimData(String mapKey, String? title, BuildContext context) {
Expand Down Expand Up @@ -429,7 +469,7 @@ class DisplaySelectiveDisclosure extends StatelessWidget {
}

class DisplayNestedMap extends StatelessWidget {
const DisplayNestedMap(this.value, this.context);
const DisplayNestedMap(this.value, this.context, {super.key});

final Map<String, dynamic> value;
final BuildContext context;
Expand All @@ -438,13 +478,19 @@ class DisplayNestedMap extends StatelessWidget {
Widget build(BuildContext context) {
final list = value.entries.map(
(MapEntry<String, dynamic> e) {
return CredentialField(
padding: const EdgeInsets.only(top: 10),
title: e.key,
value: e.value.toString(),
titleColor: Theme.of(context).colorScheme.onSurface,
valueColor: Theme.of(context).colorScheme.onSurface,
showVertically: true,
return Row(
children: [
Expanded(
child: CredentialField(
padding: const EdgeInsets.only(top: 10),
title: e.key,
value: e.value.toString(),
titleColor: Theme.of(context).colorScheme.onSurface,
valueColor: Theme.of(context).colorScheme.onSurface,
showVertically: true,
),
),
],
);
},
).toList();
Expand Down

0 comments on commit 7db94c4

Please sign in to comment.