Skip to content

Commit

Permalink
feat(app): Add support of attachment object in the claims (#794)
Browse files Browse the repository at this point in the history
Signed-off-by: Talwinder Kaur <[email protected]>
  • Loading branch information
talwinder50 authored Jul 4, 2024
1 parent 9333100 commit 135d024
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,16 @@ class MainActivity : FlutterActivity() {
claims["rawValue"] = claim.rawValue()
claims["valueType"] = claim.valueType()
claims["label"] = claim.label()

if (claim.valueType() == "attachment") {
// For type=attachment, ignore the RawValue() and Value(), instead use Attachment() method.
claims["rawValue"] = ""
claims["value"] = ""
val attachmentResp = claim.attachment()
claims["uri"] = attachmentResp.uri()
}


claimList.addAll(listOf(claims))
}
var overview = credentialDisplay.overview()
Expand Down
10 changes: 10 additions & 0 deletions demo/app/ios/Runner/flutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,15 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin {
claims["rawValue"] = claim.rawValue()
claims["valueType"] = claim.valueType()
claims["label"] = claim.label()


if claim.valueType() == "attachment" {
// For type=attachment, ignore the RawValue() and Value(), instead use Attachment() method.
claims["rawValue"] = ""
claims["value"] = ""
let attachmentResp = claim.attachment()
claims["uri"] = attachmentResp!.uri()
}
claimList.append(claims)
}
}
Expand All @@ -1116,6 +1125,7 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin {
result(resolveDisplayResp)
}


public func parseIssuerDisplay(arguments: Dictionary<String, Any>, result: @escaping FlutterResult) {
guard let issuerDisplayData = arguments["issuerDisplayData"] as? String else{
return result(FlutterError.init(code: "NATIVE_ERR",
Expand Down
11 changes: 9 additions & 2 deletions demo/app/lib/wallet_sdk/wallet_sdk_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ class CredentialDisplayData {
class CredentialDisplayClaim {
final String rawValue;
final String valueType;
final String? uri;
final String label;
final String? value;
final int? order;
Expand All @@ -395,6 +396,7 @@ class CredentialDisplayClaim {
const CredentialDisplayClaim({
required this.rawValue,
required this.valueType,
required this.uri,
required this.label,
this.value,
this.order,
Expand All @@ -407,29 +409,32 @@ class CredentialDisplayClaim {
runtimeType == other.runtimeType &&
rawValue == other.rawValue &&
valueType == other.valueType &&
uri == other.uri &&
label == other.label &&
value == other.value &&
order == other.order);

@override
int get hashCode => rawValue.hashCode ^ valueType.hashCode ^ label.hashCode ^ value.hashCode ^ order.hashCode;
int get hashCode => rawValue.hashCode ^ valueType.hashCode ^ label.hashCode ^ value.hashCode ^ order.hashCode ^ uri.hashCode;

@override
String toString() {
return 'CredentialDisplayClaim{ rawValue: $rawValue, valueType: $valueType, label: $label, value: $value, order: $order,}';
return 'CredentialDisplayClaim{ rawValue: $rawValue, valueType: $valueType, label: $label, value: $value, order: $order, uri: $uri}';
}

CredentialDisplayClaim copyWith({
String? rawValue,
String? valueType,
String? label,
String? uri,
String? value,
int? order,
}) {
return CredentialDisplayClaim(
rawValue: rawValue ?? this.rawValue,
valueType: valueType ?? this.valueType,
label: label ?? this.label,
uri: uri ?? this.uri,
value: value ?? this.value,
order: order ?? this.order,
);
Expand All @@ -441,6 +446,7 @@ class CredentialDisplayClaim {
'valueType': valueType,
'label': label,
'value': value,
'uri': uri,
'order': order,
};
}
Expand All @@ -450,6 +456,7 @@ class CredentialDisplayClaim {
rawValue: map['rawValue'] as String,
valueType: map['valueType'] as String,
label: map['label'] as String,
uri: map['uri'] as String?,
value: map['value'] as String?,
order: map['order'] as int?,
);
Expand Down
18 changes: 12 additions & 6 deletions demo/app/lib/widgets/credential_verified_information_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CredentialVerifiedState extends State<CredentialVerifiedInformation> {
controller: credDataController,
shrinkWrap: true,
itemBuilder: (context, position) {
if (credPrev[position].valueType != 'image') {
if (credPrev[position].valueType == 'string') {
return Row(
children: [
const Divider(
Expand Down Expand Up @@ -138,11 +138,17 @@ class CredentialVerifiedState extends State<CredentialVerifiedInformation> {
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.memory(
const Base64Decoder().convert(credPrev[position].rawValue.split(',').last),
width: 80,
height: 80,
),
credPrev[position].uri == null ?
Image.memory(
const Base64Decoder().convert(credPrev[position].rawValue.split(',').last),
width: 80,
height: 80,
):
Image.memory(
const Base64Decoder().convert(credPrev[position].uri!.split(',').last),
width: 80,
height: 80,
)
],
),
),
Expand Down

0 comments on commit 135d024

Please sign in to comment.