Skip to content

Commit

Permalink
Add UI updates for NFC transmission.
Browse files Browse the repository at this point in the history
  • Loading branch information
gannan08 committed Sep 12, 2024
1 parent 7e8fda1 commit dea7e1e
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 87 deletions.
29 changes: 24 additions & 5 deletions components/CredentialCardBundle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@
:credential="credentialRecord.credential"
:name-override="credentialOverrides.title"
:image-override="credentialOverrides.image"
:description-override="credentialOverrides.subtitle" />
:description-override="credentialOverrides.subtitle">
<template
v-if="hasNFCPayload({credential: credentialRecord.credential})"
#image>
<div class="row justify-between">
<dynamic-image
class="q-mr-auto"
:src="credentialOverrides.image"
size="md" />
<span v-html="conctactlessSvg" />

Check warning on line 26 in components/CredentialCardBundle.vue

View workflow job for this annotation

GitHub Actions / lint (20.x)

'v-html' directive can lead to XSS attack
</div>
</template>
</credential-switch>
</q-card>
<!-- Details dialog -->
<q-dialog
Expand Down Expand Up @@ -75,23 +87,28 @@
* Copyright (c) 2015-2024 Digital Bazaar, Inc. All rights reserved.
*/
// FIXME: do not import any of these, parameterize / use events instead
import {ageCredentialHelpers, getCredentialStore} from '@bedrock/web-wallet';
import {
ageCredentialHelpers, getCredentialStore, helpers
} from '@bedrock/web-wallet';
import {computed, onBeforeMount, reactive, ref} from 'vue';
import {CredentialSwitch, DynamicImage} from '@bedrock/vue-vc';
import {formatString, getValueFromPointer} from '../lib/helpers.js';
import {svg as conctactlessSvg} from './contactless.js';
import {config} from '@bedrock/web';
import {createEmitExtendable} from '@digitalbazaar/vue-extendable-event';
import CredentialDetails from './CredentialDetails.vue';
import {CredentialSwitch} from '@bedrock/vue-vc';
import {useQuasar} from 'quasar';
// Constants
const {generateQrCodeDataUrl, reissue} = ageCredentialHelpers;
const {hasNFCPayload} = helpers;
export default {
name: 'CredentialCardBundle',
components: {
CredentialSwitch,
CredentialDetails
CredentialDetails,
DynamicImage,
},
props: {
credentialRecord: {
Expand Down Expand Up @@ -357,7 +374,9 @@ export default {
credentialOverrides,
toggleDetailsWindow,
credentialHighlights,
credentialHolderName
credentialHolderName,
conctactlessSvg,
hasNFCPayload
};
}
};
Expand Down
120 changes: 101 additions & 19 deletions components/CredentialDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<div class="row full-height">
<!-- Close button -->
<q-btn
v-if="!nfcSharing"
v-close-popup
flat
round
Expand All @@ -14,7 +15,9 @@
style="font-size: 0.75em; z-index: 1;" />
<!-- Left side details -->
<div class="col-xs-12 col-md-5 bg-white q-pt-xl q-pb-md q-px-xl">
<div class="row justify-center items-start full-height">
<div
class="row justify-center full-height"
:class="nfcClass">
<q-card-section class="q-pa-none text-body1 text-left">
<q-card
class="card q-mx-auto"
Expand All @@ -24,26 +27,76 @@
:text-color="cardStyles.textColor"
:name-override="credentialOverrides.title"
:image-override="credentialOverrides.image"
:description-override="credentialOverrides.subtitle" />
:description-override="credentialOverrides.subtitle">
<template
v-if="hasNFCPayload({credential})"
#image>
<div class="row justify-between">
<dynamic-image
class="q-mr-auto"
:src="credentialOverrides.image"
size="md" />
<span v-html="conctactlessSvg" />

Check warning on line 39 in components/CredentialDetails.vue

View workflow job for this annotation

GitHub Actions / lint (20.x)

'v-html' directive can lead to XSS attack
</div>
</template>
</credential-switch>
</q-card>
<div
v-if="nfcSharing"
class="row justify-center items-center text-body2 disabled q-mt-md">

Check failure on line 46 in components/CredentialDetails.vue

View workflow job for this annotation

GitHub Actions / lint (20.x)

This line has a length of 82. Maximum allowed is 80
<q-spinner-ios
size="1em"
style="height: 24px; margin-right: 7px;" />
<div>
Sharing
</div>
</div>
<div
v-if="nfcSharing"
class="text-center q-pt-md">
<div class="text-body1">
Hold your device near a reader to share your credential.
</div>
<div>
<q-btn
outline
rounded
no-caps
class="q-mt-sm"
@click="cancelWrite">
Cancel
</q-btn>
</div>
</div>
<q-card-section

v-if="hasNFCPayload({credential})"
class="q-px-none q-pb-none flex full-width justify-center">
<NfcShare :credential="credential" />
<NfcShare
ref="nfcShareComponent"
:credential="credential"
@sharing="nfcSharing = $event" />
</q-card-section>
<div class="text-grey q-mt-lg text-body2">
Description
</div>
<div class="text-body1">
{{description}}
</div>
<div class="text-grey q-mt-md text-body2">
Issued for
</div>
<div class="text-body1">
{{credentialHolderName}}
<div v-if="!nfcSharing">
<div>
<div class="text-grey q-mt-lg text-body2">
Description
</div>
<div class="text-body1">
{{description}}
</div>
<div class="text-grey q-mt-md text-body2">
Issued for
</div>
<div class="text-body1">
{{credentialHolderName}}
</div>
</div>
</div>
</q-card-section>
<q-card-section class="flex full-width q-mt-auto">
<q-card-section
v-if="!nfcSharing"
class="flex full-width q-mt-auto">
<q-btn
flat
no-caps
Expand All @@ -57,6 +110,7 @@
</div>
<!-- Right side details -->
<CredentialDetailsViews
v-if="!nfcSharing"
:credential="credential"
:credential-overrides="credentialOverrides"
:credential-highlights="credentialHighlights" />
Expand All @@ -69,16 +123,21 @@
* Copyright (c) 2015-2024 Digital Bazaar, Inc. All rights reserved.
*/
import {computed, ref} from 'vue';
import {CredentialSwitch, DynamicImage} from '@bedrock/vue-vc';
import {svg as conctactlessSvg} from './contactless.js';
import CredentialDetailsViews from './CredentialDetailsViews.vue';
import {CredentialSwitch} from '@bedrock/vue-vc';
import {helpers} from '@bedrock/web-wallet';
import NfcShare from './NfcShare.vue';
const {hasNFCPayload} = helpers;
export default {
name: 'CredentialDetails',
components: {
CredentialSwitch,
CredentialDetailsViews,
NfcShare
DynamicImage,
NfcShare,
},
props: {
toggleDeleteWindow: {
Expand Down Expand Up @@ -118,9 +177,18 @@ export default {
setup(props) {
// Local state
const showDelete = ref(false);
const nfcSharing = ref(false);
const nfcShareComponent = ref(null);
console.log('Credential details', props.credential);
const nfcClass = computed(() => {
const isNfcSharing = nfcSharing.value;
if(!isNfcSharing) {
return ['items-start'];
}
return ['items-center', 'nfc-card-position'];
});
// Credential description
const description = computed(() => {
if(props.credentialOverrides.description) {
Expand All @@ -131,9 +199,19 @@ export default {
}
});
function cancelWrite() {
nfcShareComponent.value.cancelWrite();
}
return {
cancelWrite,
conctactlessSvg,
showDelete,
description
description,
hasNFCPayload,
nfcSharing,
nfcClass,
nfcShareComponent
};
}
};
Expand All @@ -160,4 +238,8 @@ $breakpoint-sm: 767px;
background-color: #FFFFFF;
border: 1px solid rgba(0, 0, 0, 0.1);
}
.nfc-card-position {
margin-top: -16vh;
}
</style>
Loading

0 comments on commit dea7e1e

Please sign in to comment.