Skip to content

Commit 775d54a

Browse files
committed
Add UI updates for NFC transmission.
1 parent 7c212a9 commit 775d54a

File tree

4 files changed

+179
-87
lines changed

4 files changed

+179
-87
lines changed

components/CredentialCardBundle.vue

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515
:credential="credentialRecord.credential"
1616
:name-override="credentialOverrides.title"
1717
:image-override="credentialOverrides.image"
18-
:description-override="credentialOverrides.subtitle" />
18+
:description-override="credentialOverrides.subtitle">
19+
<template
20+
v-if="hasNFCPayload({credential: credentialRecord.credential})"
21+
#image>
22+
<div class="row justify-between">
23+
<dynamic-image
24+
class="q-mr-auto"
25+
:src="credentialOverrides.image"
26+
size="md" />
27+
<span v-html="conctactlessSvg" />
28+
</div>
29+
</template>
30+
</credential-switch>
1931
</q-card>
2032
<!-- Details dialog -->
2133
<q-dialog
@@ -76,23 +88,28 @@
7688
* Copyright (c) 2015-2024 Digital Bazaar, Inc. All rights reserved.
7789
*/
7890
// FIXME: do not import any of these, parameterize / use events instead
79-
import {ageCredentialHelpers, getCredentialStore} from '@bedrock/web-wallet';
91+
import {
92+
ageCredentialHelpers, getCredentialStore, helpers
93+
} from '@bedrock/web-wallet';
8094
import {computed, onBeforeMount, reactive, ref} from 'vue';
95+
import {CredentialSwitch, DynamicImage} from '@bedrock/vue-vc';
8196
import {formatString, getValueFromPointer} from '../lib/helpers.js';
97+
import {svg as conctactlessSvg} from './contactless.js';
8298
import {config} from '@bedrock/web';
8399
import {createEmitExtendable} from '@digitalbazaar/vue-extendable-event';
84100
import CredentialDetails from './CredentialDetails.vue';
85-
import {CredentialSwitch} from '@bedrock/vue-vc';
86101
import {useQuasar} from 'quasar';
87102
88103
// Constants
89104
const {generateQrCodeDataUrl, reissue} = ageCredentialHelpers;
105+
const {hasNFCPayload} = helpers;
90106
91107
export default {
92108
name: 'CredentialCardBundle',
93109
components: {
94110
CredentialSwitch,
95-
CredentialDetails
111+
CredentialDetails,
112+
DynamicImage,
96113
},
97114
props: {
98115
credentialRecord: {
@@ -358,7 +375,9 @@ export default {
358375
credentialOverrides,
359376
toggleDetailsWindow,
360377
credentialHighlights,
361-
credentialHolderName
378+
credentialHolderName,
379+
conctactlessSvg,
380+
hasNFCPayload
362381
};
363382
}
364383
};

components/CredentialDetails.vue

Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<div class="row full-height">
66
<!-- Close button -->
77
<q-btn
8+
v-if="!nfcSharing"
89
v-close-popup
910
flat
1011
round
@@ -14,7 +15,9 @@
1415
style="font-size: 0.75em; z-index: 1;" />
1516
<!-- Left side details -->
1617
<div class="col-xs-12 col-md-5 bg-white q-pt-xl q-pb-md q-px-xl">
17-
<div class="row justify-center items-start full-height">
18+
<div
19+
class="row justify-center full-height"
20+
:class="nfcClass">
1821
<q-card-section class="q-pa-none text-body1 text-left">
1922
<q-card
2023
class="card q-mx-auto"
@@ -24,26 +27,76 @@
2427
:text-color="cardStyles.textColor"
2528
:name-override="credentialOverrides.title"
2629
:image-override="credentialOverrides.image"
27-
:description-override="credentialOverrides.subtitle" />
30+
:description-override="credentialOverrides.subtitle">
31+
<template
32+
v-if="hasNFCPayload({credential})"
33+
#image>
34+
<div class="row justify-between">
35+
<dynamic-image
36+
class="q-mr-auto"
37+
:src="credentialOverrides.image"
38+
size="md" />
39+
<span v-html="conctactlessSvg" />
40+
</div>
41+
</template>
42+
</credential-switch>
2843
</q-card>
44+
<div
45+
v-if="nfcSharing"
46+
class="row justify-center items-center text-body2 disabled q-mt-md">
47+
<q-spinner-ios
48+
size="1em"
49+
style="height: 24px; margin-right: 7px;" />
50+
<div>
51+
Sharing
52+
</div>
53+
</div>
54+
<div
55+
v-if="nfcSharing"
56+
class="text-center q-pt-md">
57+
<div class="text-body1">
58+
Hold your device near a reader to share your credential.
59+
</div>
60+
<div>
61+
<q-btn
62+
outline
63+
rounded
64+
no-caps
65+
class="q-mt-sm"
66+
@click="cancelWrite">
67+
Cancel
68+
</q-btn>
69+
</div>
70+
</div>
2971
<q-card-section
72+
73+
v-if="hasNFCPayload({credential})"
3074
class="q-px-none q-pb-none flex full-width justify-center">
31-
<NfcShare :credential="credential" />
75+
<NfcShare
76+
ref="nfcShareComponent"
77+
:credential="credential"
78+
@sharing="nfcSharing = $event" />
3279
</q-card-section>
33-
<div class="text-grey q-mt-lg text-body2">
34-
Description
35-
</div>
36-
<div class="text-body1">
37-
{{description}}
38-
</div>
39-
<div class="text-grey q-mt-md text-body2">
40-
Issued for
41-
</div>
42-
<div class="text-body1">
43-
{{credentialHolderName}}
80+
<div v-if="!nfcSharing">
81+
<div>
82+
<div class="text-grey q-mt-lg text-body2">
83+
Description
84+
</div>
85+
<div class="text-body1">
86+
{{description}}
87+
</div>
88+
<div class="text-grey q-mt-md text-body2">
89+
Issued for
90+
</div>
91+
<div class="text-body1">
92+
{{credentialHolderName}}
93+
</div>
94+
</div>
4495
</div>
4596
</q-card-section>
46-
<q-card-section class="flex full-width q-mt-auto">
97+
<q-card-section
98+
v-if="!nfcSharing"
99+
class="flex full-width q-mt-auto">
47100
<q-btn
48101
flat
49102
no-caps
@@ -57,6 +110,7 @@
57110
</div>
58111
<!-- Right side details -->
59112
<CredentialDetailsViews
113+
v-if="!nfcSharing"
60114
:credential="credential"
61115
:credential-overrides="credentialOverrides"
62116
:credential-highlights="credentialHighlights" />
@@ -69,16 +123,21 @@
69123
* Copyright (c) 2015-2024 Digital Bazaar, Inc. All rights reserved.
70124
*/
71125
import {computed, ref} from 'vue';
126+
import {CredentialSwitch, DynamicImage} from '@bedrock/vue-vc';
127+
import {svg as conctactlessSvg} from './contactless.js';
72128
import CredentialDetailsViews from './CredentialDetailsViews.vue';
73-
import {CredentialSwitch} from '@bedrock/vue-vc';
129+
import {helpers} from '@bedrock/web-wallet';
74130
import NfcShare from './NfcShare.vue';
75131
132+
const {hasNFCPayload} = helpers;
133+
76134
export default {
77135
name: 'CredentialDetails',
78136
components: {
79137
CredentialSwitch,
80138
CredentialDetailsViews,
81-
NfcShare
139+
DynamicImage,
140+
NfcShare,
82141
},
83142
props: {
84143
toggleDeleteWindow: {
@@ -118,9 +177,18 @@ export default {
118177
setup(props) {
119178
// Local state
120179
const showDelete = ref(false);
121-
180+
const nfcSharing = ref(false);
181+
const nfcShareComponent = ref(null);
122182
console.log('Credential details', props.credential);
123183
184+
const nfcClass = computed(() => {
185+
const isNfcSharing = nfcSharing.value;
186+
if(!isNfcSharing) {
187+
return ['items-start'];
188+
}
189+
190+
return ['items-center', 'nfc-card-position'];
191+
});
124192
// Credential description
125193
const description = computed(() => {
126194
if(props.credentialOverrides.description) {
@@ -131,9 +199,19 @@ export default {
131199
}
132200
});
133201
202+
function cancelWrite() {
203+
nfcShareComponent.value.cancelWrite();
204+
}
205+
134206
return {
207+
cancelWrite,
208+
conctactlessSvg,
135209
showDelete,
136-
description
210+
description,
211+
hasNFCPayload,
212+
nfcSharing,
213+
nfcClass,
214+
nfcShareComponent
137215
};
138216
}
139217
};
@@ -160,4 +238,8 @@ $breakpoint-sm: 767px;
160238
background-color: #FFFFFF;
161239
border: 1px solid rgba(0, 0, 0, 0.1);
162240
}
241+
242+
.nfc-card-position {
243+
margin-top: -16vh;
244+
}
163245
</style>

0 commit comments

Comments
 (0)