-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(IT Wallet): [SIW-1868] Add full screen skeumorphic card modal (#…
…6447) ## Short description This PR introduces a feature that allows users to view a credential's skeuomorphic card in full-screen mode. This mode can be activated by tapping the card on the credential details screen. ## List of changes proposed in this pull request - Added `useScaleAnimation` hook (to be removed once this PR is merged: pagopa/io-app-design-system#358) - Added `FlipGestureDetector` component, which handles swipe gestures to flip the skeumorphic cards in the credential details screen - Updated `FlippableCard` component in order to handle an optional `orientation` prop, which changes the axis type for the flip animation - Updated `ItwSkeumorphicCard` component in roder to handle an optional `orientation` prop, which rotates the card and adjust its scale to fit the screen correctly. - Refactored `getCredentialStatus` and `itwCredentialStatusSelector`: - Extracted logic from `itwCredentialStatusSelector` and moved it to `getCredentialStatusObject`, `getCredentialStatusObject` can be freely used without relying to the redux store and `itwCredentialStatusSelector` for the memoized value - Moved `getCredentialStatus` and `getCredentialStatusObject` to `itwCredentialStatusUtils.ts` file - Added `ItwPresentationCredentialCardModal` in the IT Wallet navigation stack - Updated IT Wallet playgrounds to test the new feature ## How to test 1. Navigate to the credential details screen or the IT Wallet playground in the settings screen. 2. Tap on a skeuomorphic credential card to view it in full-screen mode. 3. Verify the following: - The card is rendered correctly in full-screen mode. - The screen brightness gently increases when entering full-screen mode. - The screen brightness reverts to its original value upon exiting full-screen mode. ## Preview https://github.com/user-attachments/assets/66743a6f-ea96-4de3-a150-f88ccfa30eea
- Loading branch information
Showing
30 changed files
with
967 additions
and
599 deletions.
There are no files selected for viewing
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,56 @@ | ||
/** | ||
* Remove this once this is merged: https://github.com/pagopa/io-app-design-system/pull/358 | ||
*/ | ||
import { IOSpringValues } from "@pagopa/io-app-design-system"; | ||
import { GestureResponderEvent, ViewStyle } from "react-native"; | ||
import { | ||
AnimatedStyle, | ||
Extrapolation, | ||
interpolate, | ||
SharedValue, | ||
useAnimatedStyle | ||
} from "react-native-reanimated"; | ||
import { useSpringPressProgressValue } from "./useSpringPressProgressValue"; | ||
|
||
export const IOScaleEffect = { | ||
// Slight scale effect | ||
slight: 0.99, | ||
// Medium scale effect | ||
medium: 0.97, | ||
// Exaggerated scale effect | ||
exaggerated: 0.95 | ||
}; | ||
|
||
export type IOScaleEffect = keyof typeof IOScaleEffect; | ||
|
||
export const useScaleAnimation = ( | ||
magnitude: IOScaleEffect = "slight" | ||
): { | ||
progress: SharedValue<number>; | ||
onPressIn: (event: GestureResponderEvent) => void; | ||
onPressOut: (event: GestureResponderEvent) => void; | ||
scaleAnimatedStyle: AnimatedStyle<ViewStyle>; | ||
} => { | ||
const { progress, onPressIn, onPressOut } = useSpringPressProgressValue( | ||
IOSpringValues.button | ||
); | ||
|
||
// Scaling transformation applied when the button is pressed | ||
const animationScaleValue = IOScaleEffect[magnitude]; | ||
|
||
const scaleAnimatedStyle = useAnimatedStyle(() => { | ||
// Scale down button slightly when pressed | ||
const scale = interpolate( | ||
progress.value, | ||
[0, 1], | ||
[1, animationScaleValue], | ||
Extrapolation.CLAMP | ||
); | ||
|
||
return { | ||
transform: [{ scale }] | ||
}; | ||
}); | ||
|
||
return { progress, onPressIn, onPressOut, scaleAnimatedStyle }; | ||
}; |
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
35 changes: 35 additions & 0 deletions
35
ts/features/itwallet/common/components/ItwSkeumorphicCard/FlipGestureDetector.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,35 @@ | ||
import React from "react"; | ||
import { | ||
Directions, | ||
Gesture, | ||
GestureDetector | ||
} from "react-native-gesture-handler"; | ||
import { runOnJS } from "react-native-reanimated"; | ||
|
||
const directions = { | ||
updown: Directions.UP + Directions.DOWN, | ||
leftright: Directions.LEFT + Directions.RIGHT | ||
}; | ||
|
||
type FlipsGestureDetectorProps = { | ||
isFlipped: boolean; | ||
setIsFlipped: (isFlipped: boolean) => void; | ||
children: React.ReactNode; | ||
direction?: keyof typeof directions; | ||
}; | ||
|
||
/** | ||
* This component wraps the children in a GestureDetector that flips the card when the user flicks left or right. | ||
*/ | ||
export const FlipGestureDetector = ({ | ||
isFlipped, | ||
setIsFlipped, | ||
children, | ||
direction = "leftright" | ||
}: FlipsGestureDetectorProps) => { | ||
const flipGesture = Gesture.Fling() | ||
.direction(directions[direction]) | ||
.onEnd(() => runOnJS(setIsFlipped)(!isFlipped)); | ||
|
||
return <GestureDetector gesture={flipGesture}>{children}</GestureDetector>; | ||
}; |
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
3 changes: 3 additions & 0 deletions
3
ts/features/itwallet/common/components/ItwSkeumorphicCard/types.ts
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
/** | ||
* This type represents the side of the card that should be shown | ||
*/ | ||
export type CardSide = "front" | "back"; |
Oops, something went wrong.