Skip to content

Commit

Permalink
Issuer metadata / display / type as "uri" to display as a link in the…
Browse files Browse the repository at this point in the history
… wallet

#2907
  • Loading branch information
hawkbee1 committed Sep 26, 2024
1 parent 4a2fdcf commit 5291192
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
22 changes: 21 additions & 1 deletion lib/app/shared/widget/base/credential_field.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:altme/app/shared/launch_url/launch_url.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class CredentialField extends StatelessWidget {
Expand All @@ -9,6 +11,7 @@ class CredentialField extends StatelessWidget {
this.titleColor,
this.valueColor,
this.padding = const EdgeInsets.all(8),
this.type = 'string',
});

final String value;
Expand All @@ -17,6 +20,7 @@ class CredentialField extends StatelessWidget {
final Color? valueColor;
final EdgeInsetsGeometry padding;
final bool showVertically;
final String type;

@override
Widget build(BuildContext context) {
Expand All @@ -29,6 +33,7 @@ class CredentialField extends StatelessWidget {
valueColor: valueColor,
padding: padding,
showVertically: showVertically,
type: type,
),
);
}
Expand All @@ -43,6 +48,7 @@ class DisplayCredentialField extends StatelessWidget {
this.valueColor,
required this.padding,
required this.showVertically,
this.type = 'string',
});

final String? title;
Expand All @@ -51,6 +57,7 @@ class DisplayCredentialField extends StatelessWidget {
final Color? valueColor;
final EdgeInsetsGeometry padding;
final bool showVertically;
final String type;

@override
Widget build(BuildContext context) {
Expand All @@ -74,7 +81,20 @@ class DisplayCredentialField extends StatelessWidget {
],
TextSpan(
text: value,
style: textTheme.bodyMedium!.copyWith(color: valueColor),
style: textTheme.bodyMedium!.copyWith(
color: (type == 'uri' || type == 'email')
? Theme.of(context).colorScheme.primary
: valueColor,
),
recognizer: TapGestureRecognizer()
..onTap = () async {
if (type == 'uri') {
await LaunchUrl.launch(value);
}
if (type == 'email') {
await LaunchUrl.launch('mailto:$value');
}
},
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class SelectiveDisclosureDisplayMap {

if (display == null) return;
title = display['name'].toString();

/// Getting value_type if defined in the claim
final type = mapValue['value_type'] as String?;
final bool hasNestedData =
mapValue.values.any((element) => element is Map<String, dynamic>);

Expand All @@ -69,11 +70,11 @@ class SelectiveDisclosureDisplayMap {
builtMap[title] = nestedMap;
} else {
builtMap.addAll(
claimData(mapKey, title),
claimData(mapKey, title, type),
);
}
} else {
builtMap.addAll(claimData(mapKey, title));
builtMap.addAll(claimData(mapKey, title, type));
}
});
final Map<String, dynamic> mapFromJwtEntries = fileterdMapFromJwt(
Expand Down Expand Up @@ -161,6 +162,7 @@ class SelectiveDisclosureDisplayMap {
claimData(
element.key.toString(),
element.key.toString(),
null,
),
);
}
Expand Down Expand Up @@ -219,7 +221,11 @@ class SelectiveDisclosureDisplayMap {
return builtMap;
}

Map<String, dynamic> claimData(String mapKey, String? title) {
Map<String, dynamic> claimData(
String mapKey,
String? title,
String? type,
) {
final claimDataMap = <String, dynamic>{};
final List<ClaimsData> claimsData =
SelectiveDisclosure(credentialModel).getClaimsData(
Expand Down Expand Up @@ -302,6 +308,7 @@ class SelectiveDisclosureDisplayMap {
'value': value,
'hasCheckbox': !isDisabled && isPresentation,
'isCompulsary': isCompulsary,
'type': type,
};
if (claimsData.length > 1) {
if (index == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class DisclosureLine extends StatelessWidget {
titleColor: Theme.of(context).colorScheme.onSurface,
valueColor: Theme.of(context).colorScheme.onSurface,
showVertically: showVertically,
type: elementValue['type'].toString(),
),
),
if (elementValue['hasCheckbox'] == true) ...[
Expand Down

0 comments on commit 5291192

Please sign in to comment.