Skip to content

Commit

Permalink
feat: Display status list index correctly #2583
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Apr 11, 2024
1 parent 04345d6 commit 08e7d16
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
import 'package:flutter/material.dart';
import 'package:jwt_decode/jwt_decode.dart';

class DeveloperDetails extends StatelessWidget {
const DeveloperDetails({
Expand All @@ -23,23 +25,43 @@ class DeveloperDetails extends StatelessWidget {
credentialModel.credentialPreview.credentialSubjectModel.id ?? '';
final String type = credentialModel.credentialPreview.type.toString();

final jwt = credentialModel.jwt;

dynamic uri;
dynamic idx;

if (jwt != null) {
final payload = JWTDecode().parseJwt(jwt);
final status = payload['status'];
if (status != null && status is Map<String, dynamic>) {
final statusList = status['status_list'];
if (statusList != null && statusList is Map<String, dynamic>) {
uri = statusList['uri'];
idx = statusList['idx'];
}
}
}

final titleColor = Theme.of(context).colorScheme.titleColor;
final valueColor = Theme.of(context).colorScheme.valueColor;

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.format,
value: credentialModel.getFormat,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.issuerDID,
value: issuerDid,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
if (credentialModel.credentialPreview.credentialSubjectModel
Expand All @@ -49,18 +71,38 @@ class DeveloperDetails extends StatelessWidget {
padding: const EdgeInsets.only(top: 10),
title: l10n.subjectDID,
value: subjectDid,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.type,
value: type,
titleColor: Theme.of(context).colorScheme.titleColor,
valueColor: Theme.of(context).colorScheme.valueColor,
titleColor: titleColor,
valueColor: valueColor,
showVertically: showVertically,
),
if (uri != null) ...[
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusList,
value: uri.toString(),
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
],
if (idx != null) ...[
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusListIndex,
value: idx.toString(),
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
],
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:jwt_decode/jwt_decode.dart';

class WalletCredentialWidget extends StatelessWidget {
const WalletCredentialWidget({
Expand Down Expand Up @@ -50,23 +49,6 @@ class WalletCredentialetailsWidget extends StatelessWidget {
final walletCredential = credentialModel
.credentialPreview.credentialSubjectModel as WalletCredentialModel;

final walletAttestationData = credentialModel.jwt;

dynamic uri;
dynamic idx;

if (isDeveloperMode && walletAttestationData != null) {
final payload = JWTDecode().parseJwt(walletAttestationData);
final status = payload['status'];
if (status != null && status is Map<String, dynamic>) {
final statusList = status['status_list'];
if (statusList != null && statusList is Map<String, dynamic>) {
uri = statusList['uri'];
idx = statusList['idx'];
}
}
}

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -107,28 +89,6 @@ class WalletCredentialetailsWidget extends StatelessWidget {
valueColor: valueColor,
showVertically: false,
),
if (context.read<ProfileCubit>().state.model.isDeveloperMode) ...[
if (uri != null) ...[
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusList,
value: uri.toString(),
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
],
if (idx != null) ...[
CredentialField(
padding: const EdgeInsets.only(top: 10),
title: l10n.statusListIndex,
value: idx.toString(),
titleColor: titleColor,
valueColor: valueColor,
showVertically: false,
),
],
],
],
);
}
Expand Down

0 comments on commit 08e7d16

Please sign in to comment.