-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IT Wallet): [SIW-1029] Add IT Wallet credential preview screen (#…
…5841) > [!WARNING] > This PR depends on #5832 ## Short description This PR implements the IT Wallet credential preview screen which allows the user to see the data of a credential before it will be stored in the device. > [!NOTE] > This screen is currently using mocked **mDL** data and does not represent the final implementation of the component, which will come in a later PR. ## List of changes proposed in this pull request - Added `ItwIssuanceCredentialPreviewScreen` component - Added required routes, parameters and navigation components - Added `ItwCredentialPreviewScreenContent` component which renders the preview of a credential. This component will be used inside bot the eID and credential preview screen, which are two separate flows but share the same UI. ## How to test Navigate to **Profile > Playgrounds > IT Wallet > Credential preview**. Check that everything is being rendered correctly. ## Previews | iOS | Android | | --- | --- | | <video src="https://github.com/pagopa/io-app/assets/6160324/aae69f8a-eada-48dd-9332-e47e416ca259" /> | <video src="https://github.com/pagopa/io-app/assets/6160324/437a0b4d-863b-4e79-8772-0831d213a5ad" /> --------- Co-authored-by: LazyAfternoons <[email protected]>
- Loading branch information
1 parent
01ec4fa
commit 47d1dbb
Showing
7 changed files
with
204 additions
and
88 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
ts/features/itwallet/issuance/components/ItwCredentialPreviewScreenContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { IOColors, VSpacer, useIOTheme } from "@pagopa/io-app-design-system"; | ||
import React from "react"; | ||
import { ColorValue, StyleSheet, View } from "react-native"; | ||
import { FooterActions } from "../../../../components/ui/FooterActions"; | ||
import I18n from "../../../../i18n"; | ||
import { identificationRequest } from "../../../../store/actions/identification"; | ||
import { useIODispatch } from "../../../../store/hooks"; | ||
import { ItwCredentialClaimsList } from "../../common/components/ItwCredentialClaimList"; | ||
import { useItwDismissalDialog } from "../../common/hooks/useItwDismissalDialog"; | ||
import { StoredCredential } from "../../common/utils/itwTypesUtils"; | ||
import { ItwCredentialCard } from "../../common/components/ItwCredentialCard"; | ||
import { CredentialType } from "../../common/utils/itwMocksUtils"; | ||
|
||
type Props = { | ||
data: StoredCredential; | ||
onStoreSuccess: () => void; | ||
}; | ||
|
||
export const ItwCredentialPreviewScreenContent = ({ | ||
data, | ||
onStoreSuccess | ||
}: Props) => { | ||
const theme = useIOTheme(); | ||
const dispatch = useIODispatch(); | ||
const dismissDialog = useItwDismissalDialog(); | ||
|
||
const handleSaveToWallet = () => { | ||
dispatch( | ||
identificationRequest( | ||
false, | ||
true, | ||
undefined, | ||
{ | ||
label: I18n.t("global.buttons.cancel"), | ||
onCancel: () => undefined | ||
}, | ||
{ | ||
onSuccess: onStoreSuccess | ||
} | ||
) | ||
); | ||
}; | ||
|
||
const backgroundColor: ColorValue = IOColors[theme["appBackground-primary"]]; | ||
|
||
return ( | ||
<> | ||
<View style={styles.preview}> | ||
<ItwCredentialCard | ||
credentialType={data.credentialType as CredentialType} | ||
isPreview={true} | ||
/> | ||
</View> | ||
<View style={styles.dropShadow}> | ||
<VSpacer size={24} /> | ||
</View> | ||
<View style={[styles.content, { backgroundColor }]}> | ||
<ItwCredentialClaimsList data={data} /> | ||
</View> | ||
<FooterActions | ||
fixed={false} | ||
actions={{ | ||
type: "TwoButtons", | ||
primary: { | ||
icon: "add", | ||
iconPosition: "end", | ||
label: I18n.t( | ||
"features.itWallet.issuance.credentialPreview.actions.primary" | ||
), | ||
onPress: handleSaveToWallet | ||
}, | ||
secondary: { | ||
label: I18n.t( | ||
"features.itWallet.issuance.credentialPreview.actions.secondary" | ||
), | ||
onPress: dismissDialog.show | ||
} | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
preview: { | ||
paddingHorizontal: 24 | ||
}, | ||
dropShadow: { | ||
backgroundColor: IOColors.white, | ||
shadowColor: IOColors.black, | ||
shadowOffset: { width: 0, height: -4 }, | ||
shadowRadius: 20, | ||
shadowOpacity: 0.2, | ||
elevation: 5 | ||
}, | ||
content: { | ||
flex: 1, | ||
paddingHorizontal: 24 | ||
} | ||
}); |
71 changes: 71 additions & 0 deletions
71
ts/features/itwallet/issuance/screens/ItwIssuanceCredentialPreviewScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as O from "fp-ts/lib/Option"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import React from "react"; | ||
import { OperationResultScreenContent } from "../../../../components/screens/OperationResultScreenContent"; | ||
import { IOScrollViewWithLargeHeader } from "../../../../components/ui/IOScrollViewWithLargeHeader"; | ||
import I18n from "../../../../i18n"; | ||
import { useIONavigation } from "../../../../navigation/params/AppParamsList"; | ||
import { | ||
ItWalletError, | ||
getItwGenericMappedError | ||
} from "../../common/utils/itwErrorsUtils"; | ||
import { ItwCredentialsMocks } from "../../common/utils/itwMocksUtils"; | ||
import { StoredCredential } from "../../common/utils/itwTypesUtils"; | ||
import { ITW_ROUTES } from "../../navigation/routes"; | ||
import { ItwCredentialPreviewScreenContent } from "../components/ItwCredentialPreviewScreenContent"; | ||
|
||
export const ItwIssuanceCredentialPreviewScreen = () => { | ||
const navigation = useIONavigation(); | ||
const credentialOption = O.some(ItwCredentialsMocks.mdl); | ||
|
||
const handleStoreCredentialSuccess = () => { | ||
navigation.navigate(ITW_ROUTES.MAIN, { | ||
screen: ITW_ROUTES.ISSUANCE.RESULT | ||
}); | ||
}; | ||
|
||
/** | ||
* Renders the content of the screen if the credential is decoded. | ||
* @param credential - the decoded credential | ||
*/ | ||
const ContentView = ({ credential }: { credential: StoredCredential }) => { | ||
React.useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
headerShown: true | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<IOScrollViewWithLargeHeader | ||
excludeEndContentMargin | ||
title={{ | ||
label: I18n.t("features.itWallet.issuance.credentialPreview.title", { | ||
credential: credential.displayData.title | ||
}) | ||
}} | ||
> | ||
<ItwCredentialPreviewScreenContent | ||
data={credential} | ||
onStoreSuccess={handleStoreCredentialSuccess} | ||
/> | ||
</IOScrollViewWithLargeHeader> | ||
); | ||
}; | ||
|
||
/** | ||
* Error view component which currently displays a generic error. | ||
* @param error - optional ItWalletError to be displayed. | ||
*/ | ||
const ErrorView = ({ error: _ }: { error?: ItWalletError }) => { | ||
const mappedError = getItwGenericMappedError(() => navigation.goBack()); | ||
return <OperationResultScreenContent {...mappedError} />; | ||
}; | ||
|
||
return pipe( | ||
credentialOption, | ||
O.fold( | ||
() => <ErrorView />, | ||
cred => <ContentView credential={cred} /> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters