Skip to content

Commit

Permalink
feat: Improve vc details #2894
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Sep 19, 2024
1 parent 1a2a30a commit 4e00b3c
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import 'dart:convert';

import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/selective_disclosure/selective_disclosure.dart';
import 'package:flutter/material.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:oidc4vc/oidc4vc.dart';

class DeveloperDetails extends StatelessWidget {
const DeveloperDetails({
Expand Down Expand Up @@ -29,6 +34,38 @@ class DeveloperDetails extends StatelessWidget {
final titleColor = Theme.of(context).colorScheme.onSurface;
final valueColor = Theme.of(context).colorScheme.onSurface;

final jwtDecode = JWTDecode();

String? header;
String? payload;
String? data;

if (credentialModel.jwt != null) {
final jsonheader = decodeHeader(
jwtDecode: jwtDecode,
token: credentialModel.jwt!,
);
header = const JsonEncoder.withIndent(' ').convert(jsonheader);
final jsonPayload = decodePayload(
jwtDecode: jwtDecode,
token: credentialModel.jwt!,
);
payload = const JsonEncoder.withIndent(' ').convert(jsonPayload);

if (credentialModel.getFormat == VCFormatType.vcSdJWT.vcValue) {
final selectiveDisclosure = SelectiveDisclosure(credentialModel);

final data = createJsonByDecryptingSDValues(
encryptedJson: credentialModel.data,
selectiveDisclosure: selectiveDisclosure,
);

payload = const JsonEncoder.withIndent(' ').convert(data);
}
} else {
data = const JsonEncoder.withIndent(' ').convert(credentialModel.data);
}

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -67,7 +104,7 @@ class DeveloperDetails extends StatelessWidget {
valueColor: valueColor,
showVertically: showVertically,
),
if (statusListUri != null) ...[
if (statusListUri != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusList,
Expand All @@ -76,8 +113,7 @@ class DeveloperDetails extends StatelessWidget {
valueColor: valueColor,
showVertically: false,
),
],
if (statusListIndex != null) ...[
if (statusListIndex != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusListIndex,
Expand All @@ -86,7 +122,33 @@ class DeveloperDetails extends StatelessWidget {
valueColor: valueColor,
showVertically: false,
),
],
if (header != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.header,
value: header,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
if (payload != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.payload,
value: payload,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
if (data != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.data,
value: data,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
],
);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1068,5 +1068,8 @@
"notificationTitle": "Welcome to the Notifications!\nStay informed with important updates.",
"chatRoom": "Chat room",
"notificationRoom": "Notification room",
"notificationSubtitle": "Enable to get the notification"
"notificationSubtitle": "Enable to get the notification",
"header": "Header",
"payload": "Payload",
"data": "Data"
}
15 changes: 12 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"notificationTitle",
"chatRoom",
"notificationRoom",
"notificationSubtitle"
"notificationSubtitle",
"header",
"payload",
"data"
],

"es": [
Expand Down Expand Up @@ -80,7 +83,10 @@
"notificationTitle",
"chatRoom",
"notificationRoom",
"notificationSubtitle"
"notificationSubtitle",
"header",
"payload",
"data"
],

"fr": [
Expand Down Expand Up @@ -127,6 +133,9 @@
"notificationTitle",
"chatRoom",
"notificationRoom",
"notificationSubtitle"
"notificationSubtitle",
"header",
"payload",
"data"
]
}

0 comments on commit 4e00b3c

Please sign in to comment.