@procivis/one-react-native-components 0.3.50 → 0.3.62

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.
Files changed (109) hide show
  1. package/lib/commonjs/components/credential/credential.js +6 -3
  2. package/lib/commonjs/components/credential/credential.js.map +1 -1
  3. package/lib/commonjs/components/history/history-list-item-icon.js +3 -1
  4. package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
  5. package/lib/commonjs/components/history/history-list-screen.js +4 -3
  6. package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
  7. package/lib/commonjs/components/proof-request/select-credential.js +7 -3
  8. package/lib/commonjs/components/proof-request/select-credential.js.map +1 -1
  9. package/lib/commonjs/components/proof-request/share-credential.js +6 -9
  10. package/lib/commonjs/components/proof-request/share-credential.js.map +1 -1
  11. package/lib/commonjs/ui-components/credential/card/credential-card.js +14 -29
  12. package/lib/commonjs/ui-components/credential/card/credential-card.js.map +1 -1
  13. package/lib/commonjs/ui-components/credential/card/credential-details-card.js +27 -28
  14. package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
  15. package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js +10 -6
  16. package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js.map +1 -1
  17. package/lib/commonjs/ui-components/header/header.js +7 -5
  18. package/lib/commonjs/ui-components/header/header.js.map +1 -1
  19. package/lib/commonjs/ui-components/history/history-details.js +3 -1
  20. package/lib/commonjs/ui-components/history/history-details.js.map +1 -1
  21. package/lib/commonjs/ui-components/icons/icons.js +131 -1
  22. package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
  23. package/lib/commonjs/ui-components/searchbar/animated-search-bar.js +10 -8
  24. package/lib/commonjs/ui-components/searchbar/animated-search-bar.js.map +1 -1
  25. package/lib/commonjs/utils/hooks/core/backup.js +4 -3
  26. package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
  27. package/lib/commonjs/utils/hooks/core/core-init.js +23 -4
  28. package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
  29. package/lib/commonjs/utils/hooks/core/credentials.js +35 -5
  30. package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
  31. package/lib/commonjs/utils/hooks/core/proofs.js +3 -1
  32. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  33. package/lib/commonjs/utils/parsers/credential-sharing.js +18 -1
  34. package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
  35. package/lib/commonjs/utils/parsers/credential.js.map +1 -1
  36. package/lib/commonjs/utils/parsers/query.js +6 -6
  37. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  38. package/lib/module/components/credential/credential.js +5 -3
  39. package/lib/module/components/credential/credential.js.map +1 -1
  40. package/lib/module/components/history/history-list-item-icon.js +3 -1
  41. package/lib/module/components/history/history-list-item-icon.js.map +1 -1
  42. package/lib/module/components/history/history-list-screen.js +4 -3
  43. package/lib/module/components/history/history-list-screen.js.map +1 -1
  44. package/lib/module/components/proof-request/select-credential.js +5 -2
  45. package/lib/module/components/proof-request/select-credential.js.map +1 -1
  46. package/lib/module/components/proof-request/share-credential.js +7 -10
  47. package/lib/module/components/proof-request/share-credential.js.map +1 -1
  48. package/lib/module/ui-components/credential/card/credential-card.js +15 -30
  49. package/lib/module/ui-components/credential/card/credential-card.js.map +1 -1
  50. package/lib/module/ui-components/credential/card/credential-details-card.js +27 -28
  51. package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
  52. package/lib/module/ui-components/credential/card/credential-details-list-item.js +10 -6
  53. package/lib/module/ui-components/credential/card/credential-details-list-item.js.map +1 -1
  54. package/lib/module/ui-components/header/header.js +7 -5
  55. package/lib/module/ui-components/header/header.js.map +1 -1
  56. package/lib/module/ui-components/history/history-details.js +4 -2
  57. package/lib/module/ui-components/history/history-details.js.map +1 -1
  58. package/lib/module/ui-components/icons/icons.js +125 -0
  59. package/lib/module/ui-components/icons/icons.js.map +1 -1
  60. package/lib/module/ui-components/searchbar/animated-search-bar.js +10 -8
  61. package/lib/module/ui-components/searchbar/animated-search-bar.js.map +1 -1
  62. package/lib/module/utils/hooks/core/backup.js +5 -4
  63. package/lib/module/utils/hooks/core/backup.js.map +1 -1
  64. package/lib/module/utils/hooks/core/core-init.js +21 -3
  65. package/lib/module/utils/hooks/core/core-init.js.map +1 -1
  66. package/lib/module/utils/hooks/core/credentials.js +32 -4
  67. package/lib/module/utils/hooks/core/credentials.js.map +1 -1
  68. package/lib/module/utils/hooks/core/proofs.js +3 -1
  69. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  70. package/lib/module/utils/parsers/credential-sharing.js +18 -1
  71. package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
  72. package/lib/module/utils/parsers/credential.js.map +1 -1
  73. package/lib/module/utils/parsers/query.js +6 -6
  74. package/lib/module/utils/parsers/query.js.map +1 -1
  75. package/lib/typescript/components/proof-request/share-credential.d.ts +4 -5
  76. package/lib/typescript/ui-components/credential/card/credential-card.d.ts +1 -0
  77. package/lib/typescript/ui-components/header/header.d.ts +1 -1
  78. package/lib/typescript/ui-components/icons/icons.d.ts +5 -0
  79. package/lib/typescript/ui-components/searchbar/animated-search-bar.d.ts +2 -2
  80. package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
  81. package/lib/typescript/utils/hooks/core/core-init.d.ts +4 -1
  82. package/lib/typescript/utils/hooks/core/credentials.d.ts +4 -6
  83. package/lib/typescript/utils/parsers/credential-sharing.d.ts +6 -6
  84. package/lib/typescript/utils/parsers/credential.d.ts +6 -3
  85. package/lib/typescript/utils/parsers/query.d.ts +1 -1
  86. package/package.json +3 -3
  87. package/src/components/credential/credential.tsx +4 -2
  88. package/src/components/history/history-list-item-icon.tsx +2 -0
  89. package/src/components/history/history-list-screen.tsx +10 -8
  90. package/src/components/proof-request/select-credential.tsx +4 -2
  91. package/src/components/proof-request/share-credential.tsx +10 -10
  92. package/src/ui-components/credential/card/credential-card.stories.tsx +14 -2
  93. package/src/ui-components/credential/card/credential-card.tsx +16 -23
  94. package/src/ui-components/credential/card/credential-details-card.stories.tsx +14 -4
  95. package/src/ui-components/credential/card/credential-details-card.tsx +32 -34
  96. package/src/ui-components/credential/card/credential-details-list-item.tsx +10 -6
  97. package/src/ui-components/detail/detail.stories.tsx +3 -3
  98. package/src/ui-components/header/header.stories.tsx +8 -6
  99. package/src/ui-components/header/header.tsx +7 -5
  100. package/src/ui-components/history/history-details.tsx +3 -1
  101. package/src/ui-components/icons/icons.tsx +98 -0
  102. package/src/ui-components/searchbar/animated-search-bar.tsx +11 -9
  103. package/src/utils/hooks/core/backup.ts +8 -2
  104. package/src/utils/hooks/core/core-init.ts +28 -2
  105. package/src/utils/hooks/core/credentials.ts +38 -4
  106. package/src/utils/hooks/core/proofs.ts +3 -1
  107. package/src/utils/parsers/credential-sharing.tsx +34 -11
  108. package/src/utils/parsers/credential.ts +8 -4
  109. package/src/utils/parsers/query.ts +31 -4
@@ -1,15 +1,11 @@
1
- import { CredentialListQuery, InvitationResult } from '@procivis/react-native-one-core';
2
- import { Transport } from '../connectivity/connectivity';
1
+ import { CredentialListQuery, HandleInvitationRequest, InitiateIssuanceRequest, InvitationResult } from '@procivis/react-native-one-core';
3
2
  export declare const CREDENTIAL_LIST_QUERY_KEY = "credential-list";
4
3
  export declare const CREDENTIAL_LIST_PAGED_QUERY_KEY = "credential-list-paged";
5
4
  export declare const CREDENTIAL_DETAIL_QUERY_KEY = "credential-detail";
6
5
  export declare const useCredentials: (queryParams?: Partial<CredentialListQuery>) => import("react-query").UseQueryResult<import("@procivis/react-native-one-core").CredentialListItem[], unknown>;
7
6
  export declare const usePagedCredentials: (queryParams?: Partial<CredentialListQuery>) => import("react-query").UseInfiniteQueryResult<import("@procivis/react-native-one-core").ItemList<import("@procivis/react-native-one-core").CredentialListItem>, unknown>;
8
7
  export declare const useCredentialDetail: (credentialId: string | undefined, active?: boolean) => import("react-query").UseQueryResult<import("@procivis/react-native-one-core").CredentialDetail | undefined, unknown>;
9
- export declare const useInvitationHandler: () => import("react-query").UseMutationResult<InvitationResult, unknown, {
10
- invitationUrl: string;
11
- transport: Transport;
12
- }, unknown>;
8
+ export declare const useInvitationHandler: () => import("react-query").UseMutationResult<InvitationResult, unknown, Omit<HandleInvitationRequest, "organisationId">, unknown>;
13
9
  export declare const useCredentialAccept: () => import("react-query").UseMutationResult<void, unknown, {
14
10
  didId?: string | undefined;
15
11
  identifierId?: string | undefined;
@@ -21,3 +17,5 @@ export declare const useCredentialReject: () => import("react-query").UseMutatio
21
17
  export declare const useCredentialRevocationCheck: (forceRefresh: boolean) => import("react-query").UseMutationResult<import("@procivis/react-native-one-core").CredentialRevocationCheckResponse[], unknown, string[], unknown>;
22
18
  export declare const useCredentialDelete: () => import("react-query").UseMutationResult<void, unknown, string, unknown>;
23
19
  export declare const useInvalidateCredentialDetails: () => (credentialId: string | undefined) => Promise<void>;
20
+ export declare const useInitiateIssuance: () => import("react-query").UseMutationResult<import("@procivis/react-native-one-core").InitiateIssuanceResponse, unknown, Omit<InitiateIssuanceRequest, "organisationId">, unknown>;
21
+ export declare const useContinueIssuance: () => import("react-query").UseMutationResult<import("@procivis/react-native-one-core").ContinueIssuanceResponse, unknown, string, unknown>;
@@ -1,9 +1,9 @@
1
1
  import { Claim, Config, CredentialDetail, PresentationDefinitionField, PresentationDefinitionRequestedCredential } from '@procivis/react-native-one-core';
2
- import { CredentialAttribute, CredentialCardProps, CredentialDetailsCardProps } from '../../ui-components/credential';
2
+ import { CredentialAttribute, CredentialCardProps } from '../../ui-components/credential';
3
3
  import { CredentialCardNotice } from '../../ui-components/credential/card/credential-card';
4
- import { CardLabels } from './credential';
5
- export declare const validityCheckedCardFromCredential: (credential: CredentialDetail, invalidLVVC: boolean, expanded: boolean, multipleCredentialsAvailable: boolean, config: Config, notice: CredentialCardNotice | undefined, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID'>;
6
- export declare const missingCredentialCardFromRequest: (request: PresentationDefinitionRequestedCredential, notice: CredentialCardNotice | undefined, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style'>;
4
+ import { CardLabels, CredentialDetailsCardPropsWithoutWidth } from './credential';
5
+ export declare const validityCheckedCardFromCredential: (credential: CredentialDetail, invalidLVVC: boolean, expanded: boolean, multipleCredentialsAvailable: boolean, config: Config, notice: CredentialCardNotice | undefined, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID' | 'width'>;
6
+ export declare const missingCredentialCardFromRequest: (request: PresentationDefinitionRequestedCredential, notice: CredentialCardNotice | undefined, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'>;
7
7
  export declare const shareCredentialCardAttributeFromClaim: (id: string, config: Config, testID: string, labels: ShareCredentialCardLabels, claim?: Claim, field?: PresentationDefinitionField) => CredentialAttribute;
8
8
  export type ShareCredentialCardLabels = CardLabels & {
9
9
  selectiveDisclosureNotice: string;
@@ -11,6 +11,6 @@ export type ShareCredentialCardLabels = CardLabels & {
11
11
  missingCredential: string;
12
12
  multipleCredentials: string;
13
13
  };
14
- export declare const shareCredentialCardFromCredential: (credential: CredentialDetail | undefined, invalidLVVC: boolean, expanded: boolean, multipleCredentialsAvailable: boolean, request: PresentationDefinitionRequestedCredential, selectedFields: string[] | undefined, config: Config, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialDetailsCardProps, 'expanded'>;
14
+ export declare const shareCredentialCardFromCredential: (credential: CredentialDetail | undefined, invalidLVVC: boolean, expanded: boolean, multipleCredentialsAvailable: boolean, request: PresentationDefinitionRequestedCredential, selectedFields: string[] | undefined, config: Config, testID: string, labels: ShareCredentialCardLabels) => CredentialDetailsCardPropsWithoutWidth;
15
15
  export declare const selectCredentialCardAttributeFromClaim: (id: string, config: Config, testID: string, labels: ShareCredentialCardLabels, claim?: Claim, field?: PresentationDefinitionField) => CredentialAttribute;
16
- export declare const selectCredentialCardFromCredential: (credential: CredentialDetail, selected: boolean, request: PresentationDefinitionRequestedCredential, config: Config, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialDetailsCardProps, 'expanded'>;
16
+ export declare const selectCredentialCardFromCredential: (credential: CredentialDetail, selected: boolean, request: PresentationDefinitionRequestedCredential, config: Config, testID: string, labels: ShareCredentialCardLabels) => CredentialDetailsCardPropsWithoutWidth;
@@ -41,10 +41,13 @@ export declare const cardHeaderFromCredential: (credential: CredentialDetail, cl
41
41
  export type CardLabels = CardHeaderLabels & {
42
42
  validityIssuesNotice: string;
43
43
  };
44
- export declare const getCredentialCardPropsFromCredential: (credential: CredentialDetail, claims: Claim[] | undefined, config: Config, notice: CredentialCardNotice | undefined, testID: string, labels: CardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style'>;
44
+ export declare const getCredentialCardPropsFromCredential: (credential: CredentialDetail, claims: Claim[] | undefined, config: Config, notice: CredentialCardNotice | undefined, testID: string, labels: CardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'>;
45
45
  export declare const detailsCardAttributeFromClaim: (claim: Claim, config: Config, testID: string) => CredentialAttribute;
46
- export declare const detailsCardFromCredential: (credential: CredentialDetail, config: Config, testID: string, labels: CardLabels) => Omit<CredentialDetailsCardProps, 'expanded'>;
47
- export declare const detailsCardFromCredentialWithClaims: (credential: CredentialDetail, claims: Claim[], config: Config, testID: string, labels: CardLabels) => Omit<CredentialDetailsCardProps, 'expanded'>;
46
+ export type CredentialDetailsCardPropsWithoutWidth = Omit<CredentialDetailsCardProps, 'expanded' | 'card'> & {
47
+ card: Omit<CredentialCardProps, 'width'>;
48
+ };
49
+ export declare const detailsCardFromCredential: (credential: CredentialDetail, config: Config, testID: string, labels: CardLabels) => CredentialDetailsCardPropsWithoutWidth;
50
+ export declare const detailsCardFromCredentialWithClaims: (credential: CredentialDetail, claims: Claim[], config: Config, testID: string, labels: CardLabels) => CredentialDetailsCardPropsWithoutWidth;
48
51
  export declare const nestAttributes: (attributes: CredentialAttribute[]) => CredentialAttribute[];
49
52
  export declare function getCredentialSchemaWithoutImages(credentialSchema: CredentialSchema): {
50
53
  layoutProperties: {
@@ -1,6 +1,6 @@
1
1
  import { CredentialListQuery, CredentialSchemaListQuery, DidListQuery, HistoryListQuery, IdentifierListQuery, ProofListQuery, ProofSchemaListQuery } from '@procivis/react-native-one-core';
2
2
  export declare const getQueryKeyFromCredentialListQueryParams: (queryParams?: Partial<CredentialListQuery>) => (string | number | string[] | import("@procivis/react-native-one-core").CredentialListQueryExactColumnEnum[] | import("@procivis/react-native-one-core").CredentialStateEnum[] | import("@procivis/react-native-one-core").CredentialListIncludeEntityType[] | import("@procivis/react-native-one-core").CredentialListSearchType[] | undefined)[];
3
- export declare const getQueryKeyFromHistoryListQueryParams: (queryParams?: Partial<HistoryListQuery>) => (string | number | import("@procivis/react-native-one-core").HistoryActionEnum[] | import("@procivis/react-native-one-core").HistoryEntityTypeEnum[] | undefined)[];
3
+ export declare const getQueryKeyFromHistoryListQueryParams: (queryParams?: Partial<HistoryListQuery>) => (string | number | import("@procivis/react-native-one-core").HistoryListSearch | import("@procivis/react-native-one-core").HistoryActionEnum[] | import("@procivis/react-native-one-core").HistoryEntityTypeEnum[] | undefined)[];
4
4
  export declare const getQueryKeyFromCredentialSchemaListQueryParams: (queryParams?: Partial<CredentialSchemaListQuery>) => (string | number | string[] | import("@procivis/react-native-one-core").ExactCredentialSchemaFilterColumnEnum[] | import("@procivis/react-native-one-core").CredentialSchemaListIncludeEntityType[] | undefined)[];
5
5
  export declare const getQueryKeyFromProofSchemaListQueryParams: (queryParams?: Partial<ProofSchemaListQuery>) => (string | number | string[] | import("@procivis/react-native-one-core").ExactProofSchemaFilterColumnEnum[] | undefined)[];
6
6
  export declare const getQueryKeyFromProofListQueryParams: (queryParams?: Partial<ProofListQuery>) => (string | number | string[] | import("@procivis/react-native-one-core").ExactProofFilterColumnEnum[] | import("@procivis/react-native-one-core").ProofStateEnum[] | import("@procivis/react-native-one-core").ProofRoleEnum[] | undefined)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procivis/one-react-native-components",
3
- "version": "0.3.50",
3
+ "version": "0.3.62",
4
4
  "author": "Procivis AG (https://procivis.ch)",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Common Procivis ONE UI components for react-native",
@@ -51,7 +51,7 @@
51
51
  "@babel/runtime": "^7.25.0",
52
52
  "@commitlint/config-conventional": "^11.0.0",
53
53
  "@gorhom/bottom-sheet": "^5.1.2",
54
- "@procivis/react-native-one-core": "1.55028.0",
54
+ "@procivis/react-native-one-core": "1.58284.0",
55
55
  "@procivis/react-native-picker": "5.0.3",
56
56
  "@react-native-async-storage/async-storage": "^1.17.3",
57
57
  "@react-native-community/blur": "^4.4.0",
@@ -138,7 +138,7 @@
138
138
  "vite": "^6.2.2"
139
139
  },
140
140
  "peerDependencies": {
141
- "@procivis/react-native-one-core": "^1.55028.0",
141
+ "@procivis/react-native-one-core": "^1.58284.0",
142
142
  "@procivis/react-native-picker": "*",
143
143
  "@react-native-community/blur": "*",
144
144
  "@react-native-community/netinfo": "^11.4.1",
@@ -1,6 +1,6 @@
1
1
  import { Claim } from '@procivis/react-native-one-core';
2
- import React, { FC } from 'react';
3
- import { ImageSourcePropType, StyleSheet } from 'react-native';
2
+ import React, { FC, useMemo } from 'react';
3
+ import { Dimensions, ImageSourcePropType, StyleSheet } from 'react-native';
4
4
 
5
5
  import { CredentialDetailsCardListItem, CredentialHeaderProps } from '../../ui-components/credential/card';
6
6
  import { concatTestID } from '../../utils';
@@ -31,6 +31,7 @@ export const CredentialDetails: FC<CredentialDetailsProps> = ({
31
31
  }) => {
32
32
  const { data: credential } = useCredentialDetail(credentialId);
33
33
  const { data: config } = useCoreConfig();
34
+ const cardWidth = useMemo(() => Dimensions.get('window').width - 32, []);
34
35
 
35
36
  if (!credential || !config) {
36
37
  return null;
@@ -55,6 +56,7 @@ export const CredentialDetails: FC<CredentialDetailsProps> = ({
55
56
  ...card,
56
57
  credentialId,
57
58
  onHeaderPress,
59
+ width: cardWidth,
58
60
  }}
59
61
  expanded={expanded}
60
62
  lastItem={lastItem}
@@ -68,6 +68,8 @@ const defaultIcons: {
68
68
  PROOF_SCHEMA: HistorySchemaIcon,
69
69
  TRUST_ANCHOR: HistoryTrustAnchorIcon,
70
70
  TRUST_ENTITY: HistoryTrustedEntityIcon,
71
+ WALLET_UNIT: HistoryTrustedEntityIcon,
72
+ WALLET_UNIT_ATTESTATION: HistoryTrustedEntityIcon,
71
73
  },
72
74
  };
73
75
 
@@ -52,7 +52,7 @@ export const HistoryListScreen: FC<PropsWithChildren<HistoryListScreenProps>> =
52
52
  const [scrollOffset] = useState(() => new Animated.Value(0));
53
53
 
54
54
  const [searchPhrase, setSearchPhrase] = useState<string>('');
55
- const searchBarVisible = !empty || Boolean(queryParams.searchText);
55
+ const searchBarVisible = !empty || Boolean(queryParams.search?.text);
56
56
 
57
57
  const handleSearchPhraseChange = useMemo(() => debounce(onSearchPhraseChange, 500), [onSearchPhraseChange]);
58
58
  useEffect(() => {
@@ -118,13 +118,15 @@ export const HistoryListScreen: FC<PropsWithChildren<HistoryListScreenProps>> =
118
118
  !searchBarVisible
119
119
  ? undefined
120
120
  : {
121
- rightButton: onOpenFilter ? (
122
- <FilterButton
123
- active={Boolean(queryParams.credentialSchemaId)}
124
- onPress={onOpenFilter}
125
- testID={concatTestID(testID, 'filter')}
126
- />
127
- ) : undefined,
121
+ rightButtons: onOpenFilter
122
+ ? [
123
+ <FilterButton
124
+ active={Boolean(queryParams.credentialSchemaId)}
125
+ onPress={onOpenFilter}
126
+ testID={concatTestID(testID, 'filter')}
127
+ />,
128
+ ]
129
+ : undefined,
128
130
  rightButtonAlwaysVisible: true,
129
131
  searchBarProps: {
130
132
  onSearchPhraseChange: setSearchPhrase,
@@ -1,6 +1,6 @@
1
1
  import { PresentationDefinitionRequestedCredential } from '@procivis/react-native-one-core';
2
- import React, { FC } from 'react';
3
- import { ImageSourcePropType } from 'react-native';
2
+ import React, { FC, useMemo } from 'react';
3
+ import { Dimensions, ImageSourcePropType } from 'react-native';
4
4
 
5
5
  import { CredentialDetailsCardListItem } from '../../ui-components';
6
6
  import { useCoreConfig } from '../../utils/hooks/core/core-config';
@@ -19,6 +19,7 @@ export const SelectCredential: FC<{
19
19
  }> = ({ credentialId, labels, lastItem, onImagePreview, onPress, request, selected, testID }) => {
20
20
  const { data: credential } = useCredentialDetail(credentialId);
21
21
  const { data: config } = useCoreConfig();
22
+ const cardWidth = useMemo(() => Dimensions.get('window').width - 32, []);
22
23
 
23
24
  if (!credential || !config) {
24
25
  return null;
@@ -39,6 +40,7 @@ export const SelectCredential: FC<{
39
40
  card={{
40
41
  ...card,
41
42
  onHeaderPress: onPress,
43
+ width: cardWidth,
42
44
  }}
43
45
  expanded={selected}
44
46
  lastItem={lastItem}
@@ -1,30 +1,29 @@
1
1
  import {
2
+ CredentialDetail,
2
3
  CredentialListItem,
3
4
  CredentialStateEnum,
4
5
  PresentationDefinitionField,
5
6
  PresentationDefinitionRequestedCredential,
6
7
  } from '@procivis/react-native-one-core';
7
8
  import React, { FunctionComponent, useMemo } from 'react';
8
- import { ImageSourcePropType, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
9
+ import { Dimensions, ImageSourcePropType, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
9
10
 
10
11
  import { Button, ButtonType, CredentialDetailsCardListItem, Typography, useAppColorScheme } from '../../ui-components';
11
12
  import { concatTestID } from '../../utils';
12
13
  import { useCoreConfig } from '../../utils/hooks/core/core-config';
13
- import { useCredentialDetail } from '../../utils/hooks/core/credentials';
14
14
  import { getValidityState, ValidityState } from '../../utils/parsers/credential';
15
15
  import { shareCredentialCardFromCredential, ShareCredentialCardLabels } from '../../utils/parsers/credential-sharing';
16
16
 
17
17
  export type ShareCredentialLabels = ShareCredentialCardLabels & {
18
- revokedCredentialNotice: string;
19
- suspendedCredentialNotice: string;
20
18
  invalidCredentialNotice: string;
21
19
  multipleCredentialsNotice: string;
22
20
  multipleCredentialsSelect: string;
21
+ revokedCredentialNotice: string;
22
+ suspendedCredentialNotice: string;
23
23
  };
24
24
 
25
25
  export const ShareCredential: FunctionComponent<{
26
- allCredentials: CredentialListItem[];
27
- credentialId: string;
26
+ allCredentials: CredentialDetail[];
28
27
  expanded?: boolean;
29
28
  labels: ShareCredentialLabels;
30
29
  lastItem?: boolean;
@@ -39,7 +38,6 @@ export const ShareCredential: FunctionComponent<{
39
38
  testID: string;
40
39
  }> = ({
41
40
  allCredentials,
42
- credentialId,
43
41
  expanded,
44
42
  labels,
45
43
  lastItem,
@@ -54,8 +52,9 @@ export const ShareCredential: FunctionComponent<{
54
52
  testID,
55
53
  }) => {
56
54
  const colorScheme = useAppColorScheme();
57
- const { data: credential, isLoading } = useCredentialDetail(selectedCredentialId);
55
+ const credential = allCredentials.find((c) => c.id === selectedCredentialId);
58
56
  const { data: config } = useCoreConfig();
57
+ const cardWidth = useMemo(() => Dimensions.get('window').width - 32, []);
59
58
 
60
59
  const selectionOptions = useMemo(
61
60
  () =>
@@ -141,7 +140,7 @@ export const ShareCredential: FunctionComponent<{
141
140
  }
142
141
  }, [colorScheme, expanded, invalid, labels, multipleCredentialsAvailable, onSelectCredential, testID, validityState]);
143
142
 
144
- if (isLoading || !config) {
143
+ if (!config) {
145
144
  return null;
146
145
  }
147
146
 
@@ -162,8 +161,9 @@ export const ShareCredential: FunctionComponent<{
162
161
  attributes={attributes}
163
162
  card={{
164
163
  ...card,
165
- credentialId,
164
+ credentialId: request.id,
166
165
  onHeaderPress,
166
+ width: cardWidth,
167
167
  }}
168
168
  expanded={expanded}
169
169
  footer={footer}
@@ -1,9 +1,20 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
1
+ import type { Meta, StoryContext, StoryObj } from '@storybook/react';
2
+ import React from 'react';
2
3
 
3
4
  import CredentialCardBackground from '../../../../storybook/assets/CredentialCardBackground.png';
4
5
  import ColorSchemes from '../../../../storybook/colorScheme';
5
6
  import { CredentialNoticeWarningIcon, CredentialWarningIcon, RequiredAttributeIcon } from '../../icons/credential';
6
- import CredentialCard from './credential-card';
7
+ import CredentialCard, { CredentialCardProps } from './credential-card';
8
+
9
+ const Render = (args: CredentialCardProps, context: StoryContext<CredentialCardProps>) => {
10
+ const viewport = context.parameters.viewport.viewports[context.userGlobals.viewport];
11
+ const width = parseInt(viewport.styles.width.replace('px', ''), 10);
12
+ const props = {
13
+ ...args,
14
+ width,
15
+ };
16
+ return <CredentialCard {...props} />;
17
+ };
7
18
 
8
19
  const Basic: StoryObj<typeof CredentialCard> = {
9
20
  args: {
@@ -26,6 +37,7 @@ const Basic: StoryObj<typeof CredentialCard> = {
26
37
  noticeIcon: CredentialNoticeWarningIcon,
27
38
  },
28
39
  },
40
+ render: Render,
29
41
  };
30
42
 
31
43
  export { Basic as CredentialCard };
@@ -1,5 +1,5 @@
1
- import React, { FC, useCallback, useMemo, useState } from 'react';
2
- import { ColorValue, Image, LayoutChangeEvent, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
1
+ import React, { FC, useCallback, useMemo } from 'react';
2
+ import { ColorValue, Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
3
 
4
4
  import { concatTestID } from '../../../utils/testID';
5
5
  import { TouchableOpacity } from '../../accessibility/accessibilityHistoryWrappers';
@@ -39,6 +39,7 @@ export type CredentialCardProps = {
39
39
  onHeaderPress?: (credentialId?: string) => void;
40
40
  style?: StyleProp<ViewStyle>;
41
41
  testID?: string;
42
+ width: number;
42
43
  };
43
44
 
44
45
  const CredentialCard: FC<CredentialCardProps> = ({
@@ -52,19 +53,13 @@ const CredentialCard: FC<CredentialCardProps> = ({
52
53
  onHeaderPress,
53
54
  style,
54
55
  testID,
56
+ width,
55
57
  }) => {
56
58
  const colorScheme = useAppColorScheme();
57
- const [tappableHeaderHeight, setTappableHeaderHeight] = useState<number>();
58
- const [cardSize, setCardSize] = useState<{ height: number; width: number }>();
59
-
60
- const onCardLayoutChange = useCallback((event: LayoutChangeEvent) => {
61
- const { width, height } = event.nativeEvent.layout;
62
- setCardSize({ width, height });
63
- }, []);
64
-
65
- const onHeaderLayoutChange = useCallback((event: LayoutChangeEvent) => {
66
- setTappableHeaderHeight(event.nativeEvent.layout.height);
67
- }, []);
59
+ const cardSize = {
60
+ width,
61
+ height: Math.ceil(width / CredentialCardRatio),
62
+ };
68
63
 
69
64
  const headerPressHandler = useCallback(() => {
70
65
  onHeaderPress?.(credentialId);
@@ -88,35 +83,34 @@ const CredentialCard: FC<CredentialCardProps> = ({
88
83
 
89
84
  const shouldShowCarousel = cardSize?.width && cardSize.height;
90
85
  return (
91
- <View onLayout={onCardLayoutChange} style={[styles.card, style]} testID={testID}>
86
+ <View style={[styles.card, cardSize, style]} testID={testID}>
92
87
  {cardImage ? (
93
88
  'imageSource' in cardImage ? (
94
- <View style={styles.cardImage}>
89
+ <View style={cardSize}>
95
90
  <Image testID={concatTestID(testID, 'imageSource')} source={cardImage.imageSource} style={styles.image} />
96
91
  </View>
97
92
  ) : (
98
- <ImageOrComponent testID={concatTestID(testID, 'cardImage')} source={cardImage} style={styles.cardImage} />
93
+ <ImageOrComponent testID={concatTestID(testID, 'cardImage')} source={cardImage} style={cardSize} />
99
94
  )
100
95
  ) : (
101
96
  <View
102
97
  testID={concatTestID(testID, 'cardBackgroundColor', String(color))}
103
- style={[styles.cardImage, { backgroundColor: color }]}
98
+ style={[cardSize, { backgroundColor: color }]}
104
99
  />
105
100
  )}
106
101
  {onCardPress && <TouchableOpacity style={styles.cardButton} onPress={cardPressHandler} />}
107
102
  {shouldShowCarousel ? (
108
103
  <CarouselComponent
109
- style={{ marginTop: tappableHeaderHeight ?? 0 }}
104
+ style={styles.carousel}
110
105
  imagesToRender={cardCarouselImages ?? []}
111
106
  carouselSize={{
112
107
  width: cardSize.width,
113
- height: cardSize.height - (tappableHeaderHeight ?? 0),
108
+ height: cardSize.height - 60,
114
109
  }}
115
110
  testID={concatTestID(testID, 'carousel')}
116
111
  />
117
112
  ) : null}
118
113
  <TouchableOpacity
119
- onLayout={onHeaderLayoutChange}
120
114
  activeOpacity={0.9}
121
115
  disabled={!onHeaderPress}
122
116
  onPress={headerPressHandler}
@@ -151,9 +145,8 @@ const styles = StyleSheet.create({
151
145
  position: 'absolute',
152
146
  width: '100%',
153
147
  },
154
- cardImage: {
155
- aspectRatio: CredentialCardRatio,
156
- width: '100%',
148
+ carousel: {
149
+ marginTop: 60,
157
150
  },
158
151
  header: {
159
152
  position: 'absolute',
@@ -1,6 +1,6 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
1
+ import type { Meta, StoryContext, StoryObj } from '@storybook/react';
2
2
  import React from 'react';
3
- import { StyleSheet, Text, View } from 'react-native';
3
+ import { Dimensions, StyleSheet, Text, View } from 'react-native';
4
4
 
5
5
  import CredentialDetailsCardBackground from '../../../../storybook/assets/CredentialCardBackground.png';
6
6
  import { Placeholder } from '../../../../storybook/placeholder';
@@ -23,8 +23,17 @@ const style = StyleSheet.create({
23
23
  },
24
24
  });
25
25
 
26
- const Render = ({ ...args }: CredentialDetailsCardProps) => {
27
- return <CredentialDetailsCard {...args} style={style.card} />;
26
+ const Render = (args: CredentialDetailsCardProps, context: StoryContext<CredentialDetailsCardProps>) => {
27
+ const viewport = context.parameters.viewport.viewports[context.userGlobals.viewport];
28
+ const width = parseInt(viewport.styles.width.replace('px', ''), 10) - 32;
29
+ const props = {
30
+ ...args,
31
+ card: {
32
+ ...args.card,
33
+ width,
34
+ },
35
+ };
36
+ return <CredentialDetailsCard {...props} style={style.card} />;
28
37
  };
29
38
 
30
39
  const Basic: StoryObj<typeof CredentialDetailsCard> = {
@@ -270,6 +279,7 @@ const Basic: StoryObj<typeof CredentialDetailsCard> = {
270
279
  text: 'Notice related to the credential',
271
280
  noticeIcon: CredentialNoticeWarningIcon,
272
281
  },
282
+ width: Dimensions.get('screen').width - 32,
273
283
  },
274
284
  showAllButtonLabel: 'See all',
275
285
  expanded: true,
@@ -7,7 +7,7 @@ import { Button, ButtonType } from '../../buttons';
7
7
  import { DownIcon, UpIcon } from '../../icons/credential';
8
8
  import { useAppColorScheme } from '../../theme/color-scheme-context';
9
9
  import CredentialAttributeItem, { CredentialAttribute } from '../credential-attribute-item';
10
- import CredentialCard, { CredentialCardProps } from './credential-card';
10
+ import CredentialCard, { CredentialCardProps, CredentialCardRatio } from './credential-card';
11
11
 
12
12
  export type CredentialDetailsCardProps = ViewProps & {
13
13
  animate?: boolean;
@@ -21,6 +21,7 @@ export type CredentialDetailsCardProps = ViewProps & {
21
21
  };
22
22
 
23
23
  const PREVIEW_ATTRIBUTES_COUNT = 3;
24
+ const SEE_ALL_BUTTON_HEIGHT = 78;
24
25
 
25
26
  const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
26
27
  animate = true,
@@ -38,7 +39,6 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
38
39
  const colorScheme = useAppColorScheme();
39
40
  const [previewAttributesHeight, setPreviewAttributesHeight] = useState<number>();
40
41
  const [fullAttributesHeight, setFullAttributesHeight] = useState<number>();
41
- const [buttonViewHeight, setButtonViewHeight] = useState<number>();
42
42
 
43
43
  const [allAttributesRendered, setAllAttributesRendered] = useState<boolean>(
44
44
  (attributes && attributes.length <= PREVIEW_ATTRIBUTES_COUNT) || !showAllButtonLabel,
@@ -46,17 +46,12 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
46
46
 
47
47
  const CaretIcon = expanded ? UpIcon : DownIcon;
48
48
 
49
+ const cardHeight = Math.ceil(card.width / CredentialCardRatio);
49
50
  const currentHeight = useSharedValue<number | undefined>(undefined);
50
51
 
51
52
  const previewAttributes = attributes ? attributes.slice(0, PREVIEW_ATTRIBUTES_COUNT) : [];
52
53
  const extraAttributes = useMemo(() => (attributes ? attributes.slice(PREVIEW_ATTRIBUTES_COUNT) : []), [attributes]);
53
54
 
54
- useEffect(() => {
55
- if (!extraAttributes || allAttributesRendered) {
56
- setButtonViewHeight(0);
57
- }
58
- }, [extraAttributes, allAttributesRendered]);
59
-
60
55
  useEffect(() => {
61
56
  if (extraAttributes.length === 0) {
62
57
  const viewStyle = StyleSheet.flatten([
@@ -69,53 +64,56 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
69
64
  }, [extraAttributes, footer]);
70
65
 
71
66
  useEffect(() => {
72
- if (previewAttributesHeight === undefined || buttonViewHeight === undefined) {
67
+ if (previewAttributesHeight === undefined) {
73
68
  return;
74
69
  }
75
70
  if (allAttributesRendered && fullAttributesHeight === undefined) {
76
71
  return;
77
72
  }
78
73
 
74
+ const buttonViewHeight = !extraAttributes || allAttributesRendered ? 0 : SEE_ALL_BUTTON_HEIGHT;
79
75
  const additionalAttributesHeight = fullAttributesHeight ?? 0;
80
76
  const additionalHeight = allAttributesRendered ? additionalAttributesHeight : buttonViewHeight;
81
- const newHeight = expanded || !animate ? previewAttributesHeight + additionalHeight : 0;
77
+ const fullHeight = previewAttributesHeight + additionalHeight;
78
+
79
+ if (!animate) {
80
+ currentHeight.value = fullHeight;
81
+ return;
82
+ }
83
+
84
+ const newHeight = expanded ? fullHeight : 0;
82
85
 
83
86
  if (currentHeight.value === undefined || !animate) {
84
87
  currentHeight.value = newHeight;
85
88
  return;
86
89
  }
87
90
 
88
- const duration = !expanded
89
- ? 250
90
- : allAttributesRendered
91
- ? previewAttributes.length * 50
92
- : extraAttributes.length * 50;
91
+ const duration = fullHeight / 5;
93
92
  currentHeight.value = withTiming(newHeight, {
94
93
  duration,
95
94
  });
96
95
  }, [
97
96
  allAttributesRendered,
98
- buttonViewHeight,
99
97
  currentHeight,
100
98
  animate,
101
99
  expanded,
102
- extraAttributes.length,
100
+ extraAttributes,
103
101
  fullAttributesHeight,
104
102
  previewAttributes.length,
105
103
  previewAttributesHeight,
106
104
  ]);
107
105
 
108
- const credentialAttributesStyle = useAnimatedStyle(() => {
106
+ const animatedStyle = useAnimatedStyle(() => {
109
107
  if (currentHeight.value === undefined) {
110
108
  if (expanded) {
111
109
  return {};
112
110
  }
113
111
  return {
114
- height: 0,
112
+ height: cardHeight,
115
113
  };
116
114
  }
117
115
  return {
118
- height: currentHeight.value,
116
+ height: cardHeight + currentHeight.value,
119
117
  };
120
118
  }, [expanded, currentHeight]);
121
119
 
@@ -127,10 +125,6 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
127
125
  setFullAttributesHeight(event.nativeEvent.layout.height);
128
126
  }, []);
129
127
 
130
- const onButtonViewLayout = useCallback((event: LayoutChangeEvent) => {
131
- setButtonViewHeight(event.nativeEvent.layout.height);
132
- }, []);
133
-
134
128
  const footerView: ReactElement | undefined = useMemo(() => {
135
129
  if (!footer) {
136
130
  return undefined;
@@ -147,9 +141,11 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
147
141
 
148
142
  const renderExtraAttributes =
149
143
  allAttributesRendered || (previewAttributesHeight !== undefined && currentHeight.value !== undefined);
144
+
145
+ const ContainerComponent = animate ? Animated.View : View;
150
146
  return (
151
- <View
152
- style={[styles.detailsCard, { backgroundColor: colorScheme.white }, style]}
147
+ <ContainerComponent
148
+ style={[styles.detailsCard, { backgroundColor: colorScheme.white }, animate ? animatedStyle : undefined, style]}
153
149
  {...viewProps}
154
150
  testID={concatTestID(card.testID, expanded ? 'expanded' : 'collapsed')}>
155
151
  <CredentialCard
@@ -158,7 +154,7 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
158
154
  style={[styles.card, cardProps.style]}
159
155
  />
160
156
  {previewAttributes.length > 0 && (
161
- <Animated.View style={[styles.attributesAnimatedWrapper, credentialAttributesStyle]}>
157
+ <View>
162
158
  <View style={styles.attributesWrapper}>
163
159
  <View onLayout={onPreviewAttrContentLayout} style={styles.previewAttributesWrapper}>
164
160
  {previewAttributes.map((attribute, idx) => (
@@ -173,7 +169,7 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
173
169
  ))}
174
170
  </View>
175
171
  {!allAttributesRendered && extraAttributes.length > 0 && (
176
- <View style={styles.allAttributesWrapper} onLayout={onButtonViewLayout}>
172
+ <View style={styles.buttonWrapper}>
177
173
  <Button
178
174
  onPress={() => setAllAttributesRendered(true)}
179
175
  type={ButtonType.Secondary}
@@ -199,10 +195,10 @@ const CredentialDetailsCard: FC<CredentialDetailsCardProps> = ({
199
195
  </View>
200
196
  )}
201
197
  </View>
202
- </Animated.View>
198
+ </View>
203
199
  )}
204
200
  {footerView ? <View style={styles.footer}>{footerView}</View> : null}
205
- </View>
201
+ </ContainerComponent>
206
202
  );
207
203
  };
208
204
 
@@ -215,12 +211,14 @@ const styles = StyleSheet.create({
215
211
  allAttributesWrapperWithFooter: {
216
212
  paddingBottom: 0,
217
213
  },
218
- attributesAnimatedWrapper: {
219
- overflow: 'hidden',
220
- },
221
214
  attributesWrapper: {
222
215
  paddingTop: 7,
223
- position: 'absolute',
216
+ width: '100%',
217
+ },
218
+ buttonWrapper: {
219
+ height: SEE_ALL_BUTTON_HEIGHT,
220
+ paddingBottom: 12,
221
+ paddingHorizontal: 4,
224
222
  width: '100%',
225
223
  },
226
224
  card: {