@procivis/one-react-native-components 0.3.71 → 0.3.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/entity/entity-attributes.js +3 -1
- package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +2 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/commonjs/components/proof-request/index.js +23 -12
- package/lib/commonjs/components/proof-request/index.js.map +1 -1
- package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js +37 -0
- package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js.map +1 -0
- package/lib/commonjs/components/proof-request/share-credential-card-notice.js +36 -0
- package/lib/commonjs/components/proof-request/share-credential-card-notice.js.map +1 -0
- package/lib/commonjs/components/proof-request/{group.js → v1/group.js} +1 -1
- package/lib/commonjs/components/proof-request/v1/group.js.map +1 -0
- package/lib/commonjs/components/proof-request/v1/index.js +39 -0
- package/lib/commonjs/components/proof-request/v1/index.js.map +1 -0
- package/lib/commonjs/components/proof-request/{select-credential.js → v1/select-credential.js} +4 -4
- package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -0
- package/lib/commonjs/components/proof-request/{share-credential.js → v1/share-credential.js} +25 -60
- package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/index.js +39 -0
- package/lib/commonjs/components/proof-request/v2/index.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +51 -0
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js +164 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js +131 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -0
- package/lib/commonjs/ui-components/buttons/share-button.js +1 -1
- package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -1
- package/lib/commonjs/ui-components/camera/qr-code-scanner.js +5 -1
- package/lib/commonjs/ui-components/camera/qr-code-scanner.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js +16 -42
- package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js.map +1 -1
- package/lib/commonjs/ui-components/credential/credential-attribute-item.js +3 -1
- package/lib/commonjs/ui-components/credential/credential-attribute-item.js.map +1 -1
- package/lib/commonjs/ui-components/credential/group/credential-group-header.js +72 -0
- package/lib/commonjs/ui-components/credential/group/credential-group-header.js.map +1 -0
- package/lib/commonjs/ui-components/credential/group/index.js +14 -0
- package/lib/commonjs/ui-components/credential/group/index.js.map +1 -0
- package/lib/commonjs/ui-components/credential/index.js +12 -0
- package/lib/commonjs/ui-components/credential/index.js.map +1 -1
- package/lib/commonjs/ui-components/header/foldable-header.js +29 -17
- package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
- package/lib/commonjs/ui-components/index.js +11 -0
- package/lib/commonjs/ui-components/index.js.map +1 -1
- package/lib/commonjs/ui-components/loader/loading-result.js +1 -1
- package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
- package/lib/commonjs/ui-components/pin/pin-lock-animation.js +477 -475
- package/lib/commonjs/ui-components/pin/pin-lock-animation.js.map +1 -1
- package/lib/commonjs/ui-components/proof-request/index.js +13 -0
- package/lib/commonjs/ui-components/proof-request/index.js.map +1 -0
- package/lib/commonjs/ui-components/proof-request/proof-request-set.js +47 -0
- package/lib/commonjs/ui-components/proof-request/proof-request-set.js.map +1 -0
- package/lib/commonjs/ui-components/screens/section-list-screen.js +17 -3
- package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/commonjs/utils/array.js.map +1 -1
- package/lib/commonjs/utils/hooks/app-state.js +33 -0
- package/lib/commonjs/utils/hooks/app-state.js.map +1 -0
- package/lib/commonjs/utils/hooks/core/backup.js +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/cache.js +4 -1
- package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +11 -10
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/index.js +11 -0
- package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +41 -15
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +76 -0
- package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -0
- package/lib/commonjs/utils/hooks/index.js +11 -0
- package/lib/commonjs/utils/hooks/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/revocation/credential-status.js +1 -1
- package/lib/commonjs/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/commonjs/utils/index.js +12 -12
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js +190 -0
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -0
- package/lib/commonjs/utils/parsers/credential-sharing.js +25 -12
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +89 -57
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/index.js +11 -0
- package/lib/commonjs/utils/parsers/index.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +4 -4
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/module/components/entity/entity-attributes.js +3 -1
- package/lib/module/components/entity/entity-attributes.js.map +1 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +2 -1
- package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/module/components/proof-request/index.js +4 -3
- package/lib/module/components/proof-request/index.js.map +1 -1
- package/lib/module/components/proof-request/select-share-credential-card-notice.js +29 -0
- package/lib/module/components/proof-request/select-share-credential-card-notice.js.map +1 -0
- package/lib/module/components/proof-request/share-credential-card-notice.js +28 -0
- package/lib/module/components/proof-request/share-credential-card-notice.js.map +1 -0
- package/lib/module/components/proof-request/{group.js → v1/group.js} +1 -1
- package/lib/module/components/proof-request/v1/group.js.map +1 -0
- package/lib/module/components/proof-request/v1/index.js +4 -0
- package/lib/module/components/proof-request/v1/index.js.map +1 -0
- package/lib/module/components/proof-request/{select-credential.js → v1/select-credential.js} +4 -4
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -0
- package/lib/module/components/proof-request/{share-credential.js → v1/share-credential.js} +26 -61
- package/lib/module/components/proof-request/v1/share-credential.js.map +1 -0
- package/lib/module/components/proof-request/v2/index.js +4 -0
- package/lib/module/components/proof-request/v2/index.js.map +1 -0
- package/lib/module/components/proof-request/v2/select-credential-v2.js +42 -0
- package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -0
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js +154 -0
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
- package/lib/module/components/proof-request/v2/share-credential-v2.js +122 -0
- package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -0
- package/lib/module/ui-components/buttons/share-button.js +1 -1
- package/lib/module/ui-components/buttons/share-button.js.map +1 -1
- package/lib/module/ui-components/camera/qr-code-scanner.js +5 -1
- package/lib/module/ui-components/camera/qr-code-scanner.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-list-item.js +19 -45
- package/lib/module/ui-components/credential/card/credential-details-list-item.js.map +1 -1
- package/lib/module/ui-components/credential/credential-attribute-item.js +3 -1
- package/lib/module/ui-components/credential/credential-attribute-item.js.map +1 -1
- package/lib/module/ui-components/credential/group/credential-group-header.js +64 -0
- package/lib/module/ui-components/credential/group/credential-group-header.js.map +1 -0
- package/lib/module/ui-components/credential/group/index.js +3 -0
- package/lib/module/ui-components/credential/group/index.js.map +1 -0
- package/lib/module/ui-components/credential/index.js +1 -0
- package/lib/module/ui-components/credential/index.js.map +1 -1
- package/lib/module/ui-components/header/foldable-header.js +29 -17
- package/lib/module/ui-components/header/foldable-header.js.map +1 -1
- package/lib/module/ui-components/index.js +1 -0
- package/lib/module/ui-components/index.js.map +1 -1
- package/lib/module/ui-components/loader/loading-result.js +1 -1
- package/lib/module/ui-components/loader/loading-result.js.map +1 -1
- package/lib/module/ui-components/pin/pin-lock-animation.js +477 -475
- package/lib/module/ui-components/pin/pin-lock-animation.js.map +1 -1
- package/lib/module/ui-components/proof-request/index.js +3 -0
- package/lib/module/ui-components/proof-request/index.js.map +1 -0
- package/lib/module/ui-components/proof-request/proof-request-set.js +39 -0
- package/lib/module/ui-components/proof-request/proof-request-set.js.map +1 -0
- package/lib/module/ui-components/screens/section-list-screen.js +15 -3
- package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/module/utils/array.js.map +1 -1
- package/lib/module/utils/hooks/app-state.js +27 -0
- package/lib/module/utils/hooks/app-state.js.map +1 -0
- package/lib/module/utils/hooks/core/backup.js +1 -1
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/cache.js +4 -1
- package/lib/module/utils/hooks/core/cache.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +12 -11
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/identifiers.js +5 -5
- package/lib/module/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/module/utils/hooks/core/index.js +1 -0
- package/lib/module/utils/hooks/core/index.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +42 -16
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/wallet-unit.js +66 -0
- package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -0
- package/lib/module/utils/hooks/index.js +1 -0
- package/lib/module/utils/hooks/index.js.map +1 -1
- package/lib/module/utils/hooks/revocation/credential-status.js +1 -1
- package/lib/module/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js +177 -0
- package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -0
- package/lib/module/utils/parsers/credential-sharing.js +25 -12
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +89 -57
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/index.js +1 -0
- package/lib/module/utils/parsers/index.js.map +1 -1
- package/lib/module/utils/parsers/query.js +4 -4
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/typescript/components/entity/entity-attributes.d.ts +1 -0
- package/lib/typescript/components/proof-request/index.d.ts +4 -3
- package/lib/typescript/components/proof-request/select-share-credential-card-notice.d.ts +7 -0
- package/lib/typescript/components/proof-request/share-credential-card-notice.d.ts +6 -0
- package/lib/typescript/components/proof-request/v1/index.d.ts +3 -0
- package/lib/typescript/components/proof-request/{select-credential.d.ts → v1/select-credential.d.ts} +1 -1
- package/lib/typescript/components/proof-request/{share-credential.d.ts → v1/share-credential.d.ts} +1 -1
- package/lib/typescript/components/proof-request/v2/index.d.ts +3 -0
- package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +14 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +24 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +23 -0
- package/lib/typescript/ui-components/credential/group/credential-group-header.d.ts +10 -0
- package/lib/typescript/ui-components/credential/group/index.d.ts +3 -0
- package/lib/typescript/ui-components/credential/index.d.ts +1 -0
- package/lib/typescript/ui-components/header/foldable-header.d.ts +1 -0
- package/lib/typescript/ui-components/index.d.ts +1 -0
- package/lib/typescript/ui-components/loader/loading-result.d.ts +1 -1
- package/lib/typescript/ui-components/pin/pin-lock-animation.d.ts +311 -311
- package/lib/typescript/ui-components/proof-request/index.d.ts +3 -0
- package/lib/typescript/ui-components/proof-request/proof-request-set.d.ts +7 -0
- package/lib/typescript/ui-components/screens/section-list-screen.d.ts +4 -2
- package/lib/typescript/utils/array.d.ts +1 -0
- package/lib/typescript/utils/hooks/app-state.d.ts +5 -0
- package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/credentials.d.ts +2 -1
- package/lib/typescript/utils/hooks/core/identifiers.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/proofs.d.ts +6 -10
- package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +9 -0
- package/lib/typescript/utils/hooks/index.d.ts +1 -0
- package/lib/typescript/utils/index.d.ts +1 -1
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +10 -0
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +7 -2
- package/lib/typescript/utils/parsers/credential.d.ts +1 -2
- package/lib/typescript/utils/parsers/index.d.ts +1 -0
- package/lib/typescript/utils/parsers/query.d.ts +2 -2
- package/package.json +13 -7
- package/src/components/entity/entity-attributes.tsx +3 -0
- package/src/components/entity/entity-details-with-buttons.tsx +1 -0
- package/src/components/proof-request/index.ts +4 -3
- package/src/components/proof-request/select-share-credential-card-notice.tsx +37 -0
- package/src/components/proof-request/share-credential-card-notice.tsx +33 -0
- package/src/components/proof-request/{group.tsx → v1/group.tsx} +1 -1
- package/src/components/proof-request/v1/index.ts +3 -0
- package/src/components/proof-request/{select-credential.tsx → v1/select-credential.tsx} +7 -4
- package/src/components/proof-request/{share-credential.tsx → v1/share-credential.tsx} +30 -51
- package/src/components/proof-request/v2/index.ts +3 -0
- package/src/components/proof-request/v2/select-credential-v2.tsx +52 -0
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +258 -0
- package/src/components/proof-request/v2/share-credential-v2.tsx +202 -0
- package/src/ui-components/buttons/share-button.tsx +1 -1
- package/src/ui-components/camera/qr-code-scanner.tsx +11 -2
- package/src/ui-components/credential/card/credential-details-list-item.tsx +27 -49
- package/src/ui-components/credential/credential-attribute-item.tsx +2 -0
- package/src/ui-components/credential/group/credential-group-header.tsx +70 -0
- package/src/ui-components/credential/group/index.ts +4 -0
- package/src/ui-components/credential/index.ts +1 -0
- package/src/ui-components/header/foldable-header.tsx +31 -16
- package/src/ui-components/index.ts +1 -0
- package/src/ui-components/loader/loading-result.tsx +1 -1
- package/src/ui-components/pin/pin-lock-animation.tsx +240 -278
- package/src/ui-components/proof-request/index.ts +4 -0
- package/src/ui-components/proof-request/proof-request-set.tsx +46 -0
- package/src/ui-components/screens/section-list-screen.tsx +18 -4
- package/src/utils/array.ts +4 -0
- package/src/utils/hooks/app-state.ts +29 -0
- package/src/utils/hooks/core/backup.ts +2 -5
- package/src/utils/hooks/core/cache.ts +3 -0
- package/src/utils/hooks/core/credentials.ts +14 -6
- package/src/utils/hooks/core/identifiers.ts +15 -14
- package/src/utils/hooks/core/index.ts +2 -1
- package/src/utils/hooks/core/proofs.ts +40 -22
- package/src/utils/hooks/core/wallet-unit.ts +71 -0
- package/src/utils/hooks/index.ts +1 -0
- package/src/utils/hooks/revocation/credential-status.ts +1 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/parsers/credential-sharing-v2.tsx +278 -0
- package/src/utils/parsers/credential-sharing.tsx +63 -40
- package/src/utils/parsers/credential.ts +100 -57
- package/src/utils/parsers/index.ts +1 -0
- package/src/utils/parsers/query.ts +6 -5
- package/lib/commonjs/components/proof-request/group.js.map +0 -1
- package/lib/commonjs/components/proof-request/select-credential.js.map +0 -1
- package/lib/commonjs/components/proof-request/share-credential.js.map +0 -1
- package/lib/module/components/proof-request/group.js.map +0 -1
- package/lib/module/components/proof-request/select-credential.js.map +0 -1
- package/lib/module/components/proof-request/share-credential.js.map +0 -1
- /package/lib/typescript/components/proof-request/{group.d.ts → v1/group.d.ts} +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CredentialListItem,
|
|
3
|
+
PresentationDefinitionV2,
|
|
4
|
+
PresentationDefinitionV2CredentialClaim,
|
|
5
|
+
PresentationSubmitV2CredentialRequest,
|
|
6
|
+
} from '@procivis/react-native-one-core';
|
|
7
|
+
import React, { FC, useCallback, useMemo } from 'react';
|
|
8
|
+
import { ImageSourcePropType, StyleProp, StyleSheet, ViewStyle } from 'react-native';
|
|
9
|
+
import Animated, { LinearTransition } from 'react-native-reanimated';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
BlurView,
|
|
13
|
+
CredentialCardShadow,
|
|
14
|
+
DownIcon,
|
|
15
|
+
Selector,
|
|
16
|
+
SelectorStatus,
|
|
17
|
+
TouchableOpacity,
|
|
18
|
+
UpIcon,
|
|
19
|
+
} from '../../../ui-components';
|
|
20
|
+
import CredentialGroupHeader from '../../../ui-components/credential/group/credential-group-header';
|
|
21
|
+
import { concatTestID, useCredentialListExpandedCard } from '../../../utils';
|
|
22
|
+
import { ShareCredentialLabels } from '../v1/share-credential';
|
|
23
|
+
import { GroupedShareCredentialV2Padding, ShareCredentialV2 } from './share-credential-v2';
|
|
24
|
+
|
|
25
|
+
export type CredentialQuerySelection = Record<
|
|
26
|
+
string,
|
|
27
|
+
PresentationSubmitV2CredentialRequest | PresentationSubmitV2CredentialRequest[]
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
export type ShareCredentialGroupLabels = ShareCredentialLabels & {
|
|
31
|
+
groupHeader: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ShareCredentialV2GroupProps = {
|
|
35
|
+
labels: ShareCredentialGroupLabels;
|
|
36
|
+
lastGroup: boolean;
|
|
37
|
+
onGroupSelect?: (selected: boolean) => void;
|
|
38
|
+
onImagePreview: (title: string, image: ImageSourcePropType) => void;
|
|
39
|
+
onSelectCredential: (requestCredentialId: string) => () => void;
|
|
40
|
+
onSelectField: (
|
|
41
|
+
requestCredentialId: string,
|
|
42
|
+
) => (
|
|
43
|
+
credentialId: CredentialListItem['id'],
|
|
44
|
+
fieldPath: PresentationDefinitionV2CredentialClaim['path'],
|
|
45
|
+
selected: boolean,
|
|
46
|
+
) => void;
|
|
47
|
+
presentationDefinition: PresentationDefinitionV2;
|
|
48
|
+
requestGroup: string[];
|
|
49
|
+
selected?: boolean;
|
|
50
|
+
selectedCredentials?: CredentialQuerySelection;
|
|
51
|
+
style?: StyleProp<ViewStyle>;
|
|
52
|
+
testID: string;
|
|
53
|
+
valid: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const multipleCredentialsSelected = (
|
|
57
|
+
selectedCredentials: CredentialQuerySelection | undefined,
|
|
58
|
+
credentialRequestId: string,
|
|
59
|
+
) => {
|
|
60
|
+
return (
|
|
61
|
+
selectedCredentials &&
|
|
62
|
+
selectedCredentials[credentialRequestId] &&
|
|
63
|
+
Array.isArray(selectedCredentials[credentialRequestId]) &&
|
|
64
|
+
(selectedCredentials[credentialRequestId] as PresentationSubmitV2CredentialRequest[]).length > 1
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const numberOfCardsForRequest = (
|
|
69
|
+
selectedCredentials: CredentialQuerySelection | undefined,
|
|
70
|
+
credentialRequestId: string,
|
|
71
|
+
) => {
|
|
72
|
+
if (!selectedCredentials || !selectedCredentials[credentialRequestId]) {
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
const selection = selectedCredentials[credentialRequestId];
|
|
76
|
+
if (Array.isArray(selection)) {
|
|
77
|
+
return selection.length;
|
|
78
|
+
}
|
|
79
|
+
return 1;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const heightForNumberOfCards = (numberOfCards: number) => 60 * (numberOfCards + 1) + 12 * numberOfCards;
|
|
83
|
+
|
|
84
|
+
export const ShareCredentialV2Group: FC<ShareCredentialV2GroupProps> = ({
|
|
85
|
+
labels,
|
|
86
|
+
lastGroup,
|
|
87
|
+
onGroupSelect,
|
|
88
|
+
onImagePreview,
|
|
89
|
+
onSelectCredential,
|
|
90
|
+
onSelectField,
|
|
91
|
+
presentationDefinition,
|
|
92
|
+
requestGroup,
|
|
93
|
+
selected,
|
|
94
|
+
selectedCredentials = {},
|
|
95
|
+
style,
|
|
96
|
+
testID,
|
|
97
|
+
valid,
|
|
98
|
+
}) => {
|
|
99
|
+
const { expandedCredential, onHeaderPress } = useCredentialListExpandedCard();
|
|
100
|
+
const numberOfCards = requestGroup.reduce(
|
|
101
|
+
(acc, groupId) => acc + numberOfCardsForRequest(selectedCredentials, groupId),
|
|
102
|
+
0,
|
|
103
|
+
);
|
|
104
|
+
const singleCredentialGroup =
|
|
105
|
+
requestGroup.length === 1 && !multipleCredentialsSelected(selectedCredentials, requestGroup[0]);
|
|
106
|
+
|
|
107
|
+
const headerPressHandler = useCallback(() => {
|
|
108
|
+
onGroupSelect?.(!selected);
|
|
109
|
+
}, [selected, onGroupSelect]);
|
|
110
|
+
|
|
111
|
+
const onNestedCardHeaderPress = useCallback(
|
|
112
|
+
(credentialId: string) => () => {
|
|
113
|
+
if (!selected) {
|
|
114
|
+
onGroupSelect?.(true);
|
|
115
|
+
}
|
|
116
|
+
onHeaderPress(credentialId);
|
|
117
|
+
},
|
|
118
|
+
[selected, onGroupSelect, onHeaderPress],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const credentialCards = useMemo(() => {
|
|
122
|
+
return requestGroup.flatMap((credentialRequestId, credentialRequestIndex, { length: credentialRequestsLength }) => {
|
|
123
|
+
const lastQuery = credentialRequestIndex === credentialRequestsLength - 1;
|
|
124
|
+
|
|
125
|
+
const credentialQuery = presentationDefinition.credentialQueries[credentialRequestId];
|
|
126
|
+
let defaultSelection: PresentationSubmitV2CredentialRequest;
|
|
127
|
+
if ('applicableCredentials' in credentialQuery) {
|
|
128
|
+
defaultSelection = credentialQuery.applicableCredentials?.[0]
|
|
129
|
+
? {
|
|
130
|
+
credentialId: credentialQuery.applicableCredentials[0].id,
|
|
131
|
+
userSelections: [],
|
|
132
|
+
}
|
|
133
|
+
: {
|
|
134
|
+
credentialId: '',
|
|
135
|
+
userSelections: [],
|
|
136
|
+
};
|
|
137
|
+
} else {
|
|
138
|
+
defaultSelection = {
|
|
139
|
+
credentialId: '',
|
|
140
|
+
userSelections: [],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const request = selectedCredentials[credentialRequestId];
|
|
144
|
+
const credentialSelections = request ? (Array.isArray(request) ? request : [request]) : [defaultSelection];
|
|
145
|
+
|
|
146
|
+
return credentialSelections?.flatMap((credentialRequest, credentialIndex, { length: credentialsLength }) => {
|
|
147
|
+
const selectedFields = credentialRequest.userSelections;
|
|
148
|
+
const cardId = `${credentialRequestId}-${credentialRequest.credentialId}`;
|
|
149
|
+
const lastItem = singleCredentialGroup ? lastGroup : lastQuery && credentialIndex === credentialsLength - 1;
|
|
150
|
+
const cardExpanded = selected && (singleCredentialGroup || expandedCredential === cardId);
|
|
151
|
+
const headerAccessory =
|
|
152
|
+
singleCredentialGroup && valid ? (
|
|
153
|
+
<Selector status={selected ? SelectorStatus.SelectedRadio : SelectorStatus.Empty} />
|
|
154
|
+
) : cardExpanded ? (
|
|
155
|
+
UpIcon
|
|
156
|
+
) : (
|
|
157
|
+
DownIcon
|
|
158
|
+
);
|
|
159
|
+
return (
|
|
160
|
+
<ShareCredentialV2
|
|
161
|
+
credentialQuery={credentialQuery}
|
|
162
|
+
credentialRequestId={credentialRequestId}
|
|
163
|
+
expanded={cardExpanded}
|
|
164
|
+
grouped={!singleCredentialGroup}
|
|
165
|
+
headerAccessory={headerAccessory}
|
|
166
|
+
key={credentialRequestId}
|
|
167
|
+
labels={labels}
|
|
168
|
+
lastItem={lastItem}
|
|
169
|
+
onHeaderPress={singleCredentialGroup ? headerPressHandler : onNestedCardHeaderPress(cardId)}
|
|
170
|
+
onImagePreview={onImagePreview}
|
|
171
|
+
onSelectCredential={onSelectCredential?.(credentialRequestId)}
|
|
172
|
+
onSelectField={onSelectField(credentialRequestId)}
|
|
173
|
+
selectedCredentialId={credentialRequest.credentialId}
|
|
174
|
+
selectedFields={selectedFields}
|
|
175
|
+
style={[!singleCredentialGroup && styles.requestedCredential, lastItem && styles.requestedCredentialLast]}
|
|
176
|
+
testID={concatTestID(testID, credentialRequestId)}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}, [
|
|
182
|
+
expandedCredential,
|
|
183
|
+
labels,
|
|
184
|
+
lastGroup,
|
|
185
|
+
headerPressHandler,
|
|
186
|
+
onImagePreview,
|
|
187
|
+
onNestedCardHeaderPress,
|
|
188
|
+
onSelectCredential,
|
|
189
|
+
onSelectField,
|
|
190
|
+
presentationDefinition.credentialQueries,
|
|
191
|
+
requestGroup,
|
|
192
|
+
selected,
|
|
193
|
+
selectedCredentials,
|
|
194
|
+
singleCredentialGroup,
|
|
195
|
+
testID,
|
|
196
|
+
valid,
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
if (singleCredentialGroup) {
|
|
200
|
+
return credentialCards[0];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const groupHeaderAccessory = valid ? (
|
|
204
|
+
<Selector status={selected ? SelectorStatus.SelectedRadio : SelectorStatus.Empty} />
|
|
205
|
+
) : selected ? (
|
|
206
|
+
UpIcon
|
|
207
|
+
) : (
|
|
208
|
+
DownIcon
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<Animated.View
|
|
213
|
+
layout={LinearTransition}
|
|
214
|
+
style={[
|
|
215
|
+
styles.animatedWrapper,
|
|
216
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
217
|
+
{
|
|
218
|
+
height: selected || lastGroup ? 'auto' : heightForNumberOfCards(numberOfCards),
|
|
219
|
+
},
|
|
220
|
+
style,
|
|
221
|
+
]}>
|
|
222
|
+
<Animated.View
|
|
223
|
+
layout={LinearTransition}
|
|
224
|
+
style={[
|
|
225
|
+
singleCredentialGroup ? undefined : styles.groupedCredentialsWrapper,
|
|
226
|
+
!singleCredentialGroup && styles.requestedCredential,
|
|
227
|
+
lastGroup && styles.requestedCredentialLast,
|
|
228
|
+
style,
|
|
229
|
+
]}>
|
|
230
|
+
<BlurView blurStyle="strong" darkMode={true} style={StyleSheet.absoluteFill} />
|
|
231
|
+
<TouchableOpacity onPress={headerPressHandler}>
|
|
232
|
+
<CredentialGroupHeader accessory={groupHeaderAccessory} name={labels.groupHeader} style={styles.header} />
|
|
233
|
+
</TouchableOpacity>
|
|
234
|
+
{credentialCards}
|
|
235
|
+
</Animated.View>
|
|
236
|
+
</Animated.View>
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const styles = StyleSheet.create({
|
|
241
|
+
animatedWrapper: {
|
|
242
|
+
...CredentialCardShadow,
|
|
243
|
+
},
|
|
244
|
+
groupedCredentialsWrapper: {
|
|
245
|
+
borderRadius: 10 + GroupedShareCredentialV2Padding,
|
|
246
|
+
overflow: 'hidden',
|
|
247
|
+
paddingBottom: GroupedShareCredentialV2Padding,
|
|
248
|
+
},
|
|
249
|
+
header: {
|
|
250
|
+
marginBottom: GroupedShareCredentialV2Padding,
|
|
251
|
+
},
|
|
252
|
+
requestedCredential: {
|
|
253
|
+
marginBottom: 12,
|
|
254
|
+
},
|
|
255
|
+
requestedCredentialLast: {
|
|
256
|
+
marginBottom: 0,
|
|
257
|
+
},
|
|
258
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CredentialListItem,
|
|
3
|
+
PresentationDefinitionV2CredentialClaim,
|
|
4
|
+
PresentationDefinitionV2CredentialQuery,
|
|
5
|
+
} from '@procivis/react-native-one-core';
|
|
6
|
+
import React, { FunctionComponent, useCallback, useMemo } from 'react';
|
|
7
|
+
import { Dimensions, ImageSourcePropType, StyleProp, StyleSheet, ViewStyle } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { CredentialDetailsCardListItem, useAppColorScheme } from '../../../ui-components';
|
|
10
|
+
import { concatTestID, getValidityState, useCoreConfig, ValidityState } from '../../../utils';
|
|
11
|
+
import { shareCredentialCardFromV2PresentationCredential } from '../../../utils/parsers/credential-sharing-v2';
|
|
12
|
+
import { SelectShareCredentialCardNotice } from '../select-share-credential-card-notice';
|
|
13
|
+
import { ShareCredentialCardNotice } from '../share-credential-card-notice';
|
|
14
|
+
import { ShareCredentialLabels } from '../v1';
|
|
15
|
+
|
|
16
|
+
export type ShareCredentialV2Props = {
|
|
17
|
+
credentialQuery: PresentationDefinitionV2CredentialQuery;
|
|
18
|
+
credentialRequestId: string;
|
|
19
|
+
expanded?: boolean;
|
|
20
|
+
grouped?: boolean;
|
|
21
|
+
headerAccessory?: React.ComponentType<any> | React.ReactElement;
|
|
22
|
+
labels: ShareCredentialLabels;
|
|
23
|
+
lastItem?: boolean;
|
|
24
|
+
onHeaderPress?: (_credentialId?: string) => void;
|
|
25
|
+
onImagePreview: (title: string, image: ImageSourcePropType) => void;
|
|
26
|
+
onSelectCredential?: () => void;
|
|
27
|
+
onSelectField: (
|
|
28
|
+
credentialId: CredentialListItem['id'],
|
|
29
|
+
fieldPath: PresentationDefinitionV2CredentialClaim['path'],
|
|
30
|
+
selected: boolean,
|
|
31
|
+
) => void;
|
|
32
|
+
selectedCredentialId?: CredentialListItem['id'];
|
|
33
|
+
selectedFields?: Array<PresentationDefinitionV2CredentialClaim['path']>;
|
|
34
|
+
style?: StyleProp<ViewStyle>;
|
|
35
|
+
testID: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const GroupedShareCredentialV2Padding = 4;
|
|
39
|
+
|
|
40
|
+
export const ShareCredentialV2: FunctionComponent<ShareCredentialV2Props> = ({
|
|
41
|
+
credentialQuery,
|
|
42
|
+
credentialRequestId,
|
|
43
|
+
expanded,
|
|
44
|
+
grouped,
|
|
45
|
+
headerAccessory,
|
|
46
|
+
labels,
|
|
47
|
+
lastItem,
|
|
48
|
+
onHeaderPress,
|
|
49
|
+
onImagePreview,
|
|
50
|
+
onSelectCredential,
|
|
51
|
+
onSelectField,
|
|
52
|
+
selectedCredentialId,
|
|
53
|
+
selectedFields,
|
|
54
|
+
style,
|
|
55
|
+
testID,
|
|
56
|
+
}) => {
|
|
57
|
+
const colorScheme = useAppColorScheme();
|
|
58
|
+
const applicableCredentials =
|
|
59
|
+
'applicableCredentials' in credentialQuery ? credentialQuery.applicableCredentials : undefined;
|
|
60
|
+
const failureHint = 'failureHint' in credentialQuery ? credentialQuery.failureHint : undefined;
|
|
61
|
+
const credential = applicableCredentials?.find((c) => c.id === selectedCredentialId) ?? applicableCredentials?.[0];
|
|
62
|
+
const { data: config } = useCoreConfig();
|
|
63
|
+
const cardWidth = useMemo(
|
|
64
|
+
() => Dimensions.get('window').width - 32 - (grouped ? GroupedShareCredentialV2Padding * 2 : 0),
|
|
65
|
+
[grouped],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const multipleCredentialsAvailable = Boolean(applicableCredentials?.length && applicableCredentials.length > 1);
|
|
69
|
+
|
|
70
|
+
const validityState = getValidityState(
|
|
71
|
+
credential
|
|
72
|
+
? {
|
|
73
|
+
...credential,
|
|
74
|
+
issuer: credential?.issuer?.id,
|
|
75
|
+
}
|
|
76
|
+
: undefined,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const footer = useMemo(() => {
|
|
80
|
+
if (!expanded) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (validityState === ValidityState.Revoked) {
|
|
84
|
+
return (
|
|
85
|
+
<ShareCredentialCardNotice
|
|
86
|
+
testID={concatTestID(testID, 'notice.revoked')}
|
|
87
|
+
text={labels.revokedCredentialNotice}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (validityState === ValidityState.Suspended) {
|
|
92
|
+
return (
|
|
93
|
+
<ShareCredentialCardNotice
|
|
94
|
+
testID={concatTestID(testID, 'notice.suspended')}
|
|
95
|
+
text={labels.suspendedCredentialNotice}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (failureHint?.reason === 'VALIDITY') {
|
|
101
|
+
return (
|
|
102
|
+
<ShareCredentialCardNotice
|
|
103
|
+
testID={concatTestID(testID, 'notice.invalid')}
|
|
104
|
+
text={labels.invalidCredentialNotice}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (multipleCredentialsAvailable) {
|
|
110
|
+
return (
|
|
111
|
+
<SelectShareCredentialCardNotice
|
|
112
|
+
buttonTitle={labels.multipleCredentialsSelect}
|
|
113
|
+
onPress={onSelectCredential}
|
|
114
|
+
testID={concatTestID(testID, 'notice.multiple')}
|
|
115
|
+
text={labels.multipleCredentialsNotice}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}, [
|
|
120
|
+
expanded,
|
|
121
|
+
failureHint?.reason,
|
|
122
|
+
labels.invalidCredentialNotice,
|
|
123
|
+
labels.multipleCredentialsNotice,
|
|
124
|
+
labels.multipleCredentialsSelect,
|
|
125
|
+
labels.revokedCredentialNotice,
|
|
126
|
+
labels.suspendedCredentialNotice,
|
|
127
|
+
multipleCredentialsAvailable,
|
|
128
|
+
onSelectCredential,
|
|
129
|
+
testID,
|
|
130
|
+
validityState,
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
const onAttributeSelected = useCallback(
|
|
134
|
+
(fieldPath: PresentationDefinitionV2CredentialClaim['path'], selected: boolean) => {
|
|
135
|
+
if (!selectedCredentialId) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
onSelectField(selectedCredentialId, fieldPath, selected);
|
|
139
|
+
},
|
|
140
|
+
[onSelectField, selectedCredentialId],
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
if (!config) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const {
|
|
148
|
+
card: { header, ...card },
|
|
149
|
+
attributes,
|
|
150
|
+
} = shareCredentialCardFromV2PresentationCredential(
|
|
151
|
+
credential,
|
|
152
|
+
failureHint,
|
|
153
|
+
Boolean(expanded),
|
|
154
|
+
multipleCredentialsAvailable,
|
|
155
|
+
selectedFields,
|
|
156
|
+
config,
|
|
157
|
+
testID,
|
|
158
|
+
labels,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if (headerAccessory) {
|
|
162
|
+
header.accessory = headerAccessory;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<CredentialDetailsCardListItem
|
|
167
|
+
attributes={attributes}
|
|
168
|
+
card={{
|
|
169
|
+
...card,
|
|
170
|
+
credentialId: credentialRequestId,
|
|
171
|
+
header,
|
|
172
|
+
onHeaderPress,
|
|
173
|
+
width: cardWidth,
|
|
174
|
+
}}
|
|
175
|
+
expanded={expanded}
|
|
176
|
+
footer={footer}
|
|
177
|
+
lastItem={lastItem}
|
|
178
|
+
onAttributeSelected={onAttributeSelected}
|
|
179
|
+
onImagePreview={onImagePreview}
|
|
180
|
+
style={[
|
|
181
|
+
styles.credential,
|
|
182
|
+
grouped ? styles.groupedCredential : styles.bordered,
|
|
183
|
+
{ borderColor: colorScheme.background },
|
|
184
|
+
style,
|
|
185
|
+
]}
|
|
186
|
+
testID={testID}
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const styles = StyleSheet.create({
|
|
192
|
+
bordered: {
|
|
193
|
+
borderWidth: 1,
|
|
194
|
+
},
|
|
195
|
+
credential: {
|
|
196
|
+
borderRadius: 10,
|
|
197
|
+
marginBottom: 8,
|
|
198
|
+
},
|
|
199
|
+
groupedCredential: {
|
|
200
|
+
marginHorizontal: GroupedShareCredentialV2Padding,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
@@ -3,9 +3,9 @@ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { concatTestID } from '../../utils';
|
|
5
5
|
import { TouchableHighlight } from '../accessibility';
|
|
6
|
+
import { LinkIcon } from '../icons';
|
|
6
7
|
import { Typography } from '../text';
|
|
7
8
|
import { useAppColorScheme } from '../theme';
|
|
8
|
-
import { LinkIcon } from '../icons';
|
|
9
9
|
|
|
10
10
|
export type ShareButtonProps = {
|
|
11
11
|
onPress?: () => void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { useIsFocused } from '@react-navigation/native';
|
|
1
2
|
import React, { FunctionComponent, useMemo } from 'react';
|
|
2
3
|
import { StyleSheet, View, ViewProps } from 'react-native';
|
|
3
4
|
import { Camera, Code, CodeType, useCameraDevice, useCodeScanner } from 'react-native-vision-camera';
|
|
4
5
|
|
|
6
|
+
import { useIsAppActive } from '../../utils';
|
|
5
7
|
import CameraOverlay from './camera-overlay';
|
|
6
8
|
|
|
7
9
|
export type QRCodeScannerProps = ViewProps & {
|
|
@@ -18,6 +20,8 @@ const QRCodeScanner: FunctionComponent<QRCodeScannerProps> = ({
|
|
|
18
20
|
noCameraView = null,
|
|
19
21
|
...viewProps
|
|
20
22
|
}) => {
|
|
23
|
+
const isFocused = useIsFocused();
|
|
24
|
+
const isAppActive = useIsAppActive();
|
|
21
25
|
const qrCodeScanner = useCodeScanner({
|
|
22
26
|
codeTypes,
|
|
23
27
|
onCodeScanned: onQRCodeRead,
|
|
@@ -25,7 +29,7 @@ const QRCodeScanner: FunctionComponent<QRCodeScannerProps> = ({
|
|
|
25
29
|
|
|
26
30
|
const device = useCameraDevice('back');
|
|
27
31
|
|
|
28
|
-
const cameraOverlayView
|
|
32
|
+
const cameraOverlayView = useMemo(() => {
|
|
29
33
|
if (!cameraOverlay) {
|
|
30
34
|
return <CameraOverlay />;
|
|
31
35
|
}
|
|
@@ -43,7 +47,12 @@ const QRCodeScanner: FunctionComponent<QRCodeScannerProps> = ({
|
|
|
43
47
|
|
|
44
48
|
return (
|
|
45
49
|
<View {...viewProps}>
|
|
46
|
-
<Camera
|
|
50
|
+
<Camera
|
|
51
|
+
codeScanner={qrCodeScanner}
|
|
52
|
+
device={device}
|
|
53
|
+
isActive={isFocused && isAppActive !== false}
|
|
54
|
+
style={StyleSheet.absoluteFill}
|
|
55
|
+
/>
|
|
47
56
|
{cameraOverlayView}
|
|
48
57
|
</View>
|
|
49
58
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { FC, useCallback,
|
|
2
|
-
import { LayoutChangeEvent, StyleProp, StyleSheet,
|
|
3
|
-
import Animated, {
|
|
1
|
+
import React, { FC, useCallback, useState } from 'react';
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, StyleSheet, ViewStyle } from 'react-native';
|
|
3
|
+
import Animated, { LinearTransition } from 'react-native-reanimated';
|
|
4
4
|
|
|
5
5
|
import { CredentialCardRatio, CredentialCardShadow } from './credential-card';
|
|
6
6
|
import CredentialDetailsCard, { CredentialDetailsCardProps } from './credential-details-card';
|
|
@@ -17,64 +17,43 @@ const CredentialDetailsCardListItem: FC<CredentialDetailsCardListItemProps> = ({
|
|
|
17
17
|
style,
|
|
18
18
|
...props
|
|
19
19
|
}) => {
|
|
20
|
-
const [cardWidth, setCardWidth] = useState<number>();
|
|
21
|
-
const [minHeight, setMinHeight] = useState<number>();
|
|
22
20
|
const [detailsCardHeight, setDetailsCardHeight] = useState<number>();
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!detailsCardHeight || !minHeight) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const newValue = expanded ? detailsCardHeight : minHeight;
|
|
31
|
-
if (cardListItemHeight.value === undefined) {
|
|
32
|
-
cardListItemHeight.value = newValue;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
cardListItemHeight.value = withTiming(newValue, {
|
|
36
|
-
duration: 250,
|
|
37
|
-
});
|
|
38
|
-
}, [cardListItemHeight, detailsCardHeight, minHeight, expanded]);
|
|
39
|
-
|
|
40
|
-
const animatedCardWrapperStyle = useAnimatedStyle(() => {
|
|
41
|
-
if (cardListItemHeight.value !== undefined) {
|
|
42
|
-
return {
|
|
43
|
-
height: cardListItemHeight.value,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (lastItem || expanded) {
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
height: 60,
|
|
51
|
-
};
|
|
52
|
-
}, [cardListItemHeight, lastItem, expanded]);
|
|
53
|
-
|
|
54
|
-
const cardWrapperStyle: ViewStyle = {
|
|
55
|
-
minHeight: cardWidth ? Math.ceil(cardWidth / CredentialCardRatio) : undefined,
|
|
56
|
-
}
|
|
21
|
+
const cardWidth = props.card.width;
|
|
22
|
+
const minHeight = lastItem ? Math.ceil(cardWidth / CredentialCardRatio) : 60;
|
|
57
23
|
|
|
58
24
|
const onContentLayout = useCallback(
|
|
59
25
|
(event: LayoutChangeEvent) => {
|
|
60
|
-
const {
|
|
26
|
+
const { height } = event.nativeEvent.layout;
|
|
61
27
|
const borderWidth = StyleSheet.flatten(style)?.borderWidth ?? 0;
|
|
62
28
|
const cardHeight = Math.round(height) + 2 * borderWidth;
|
|
63
29
|
if (cardHeight === detailsCardHeight) {
|
|
64
30
|
return;
|
|
65
31
|
}
|
|
66
|
-
setCardWidth(width);
|
|
67
|
-
if (!minHeight) {
|
|
68
|
-
setMinHeight(lastItem ? Math.ceil(width / CredentialCardRatio) : 60);
|
|
69
|
-
}
|
|
70
32
|
setDetailsCardHeight(cardHeight);
|
|
71
33
|
},
|
|
72
|
-
[
|
|
34
|
+
[style, detailsCardHeight],
|
|
73
35
|
);
|
|
74
36
|
|
|
75
37
|
return (
|
|
76
|
-
<Animated.View
|
|
77
|
-
|
|
38
|
+
<Animated.View
|
|
39
|
+
layout={LinearTransition}
|
|
40
|
+
style={[
|
|
41
|
+
styles.animatedWrapper,
|
|
42
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
43
|
+
{
|
|
44
|
+
height: expanded ? 'auto' : minHeight,
|
|
45
|
+
},
|
|
46
|
+
style,
|
|
47
|
+
]}>
|
|
48
|
+
<Animated.View
|
|
49
|
+
layout={LinearTransition}
|
|
50
|
+
style={[
|
|
51
|
+
styles.cardWrapper,
|
|
52
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
53
|
+
{
|
|
54
|
+
height: expanded ? 'auto' : Math.ceil(cardWidth / CredentialCardRatio),
|
|
55
|
+
},
|
|
56
|
+
]}>
|
|
78
57
|
<CredentialDetailsCard
|
|
79
58
|
animate={false}
|
|
80
59
|
expanded={true}
|
|
@@ -82,7 +61,7 @@ const CredentialDetailsCardListItem: FC<CredentialDetailsCardListItemProps> = ({
|
|
|
82
61
|
style={detailsCardStyle}
|
|
83
62
|
{...props}
|
|
84
63
|
/>
|
|
85
|
-
</View>
|
|
64
|
+
</Animated.View>
|
|
86
65
|
</Animated.View>
|
|
87
66
|
);
|
|
88
67
|
};
|
|
@@ -93,7 +72,6 @@ const styles = StyleSheet.create({
|
|
|
93
72
|
},
|
|
94
73
|
cardWrapper: {
|
|
95
74
|
borderRadius: 10,
|
|
96
|
-
height: '100%',
|
|
97
75
|
overflow: 'hidden',
|
|
98
76
|
},
|
|
99
77
|
});
|