Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOAPPX-428] Add the new useScaleAnimation and useListItemAnimation hooks + Add support for the reducedMotion a11y setting #358

Merged
merged 21 commits into from
Dec 10, 2024

Conversation

dmnplb
Copy link
Collaborator

@dmnplb dmnplb commented Nov 14, 2024

Short description

This PR improves the overall code quality by removing a lot of repeated code. This change is possible thanks to the new useScaleAnimation and useListItemAnimation hooks. This PR also adds support for the Reduce motion a11y setting.

  • useScaleAnimation should be used when you want a simple scale effect, like the one applied to Button… or Module… components
  • useListItemAnimation should be used when you want to build another ListItem… component and you can't use PressableListItemBase for various reasons

Both hooks use the useSpringPressProgressValue hook at their core.

List of changes proposed in this pull request

  • Add and export the new useScaleAnimation and useListItemAnimation hooks
  • Rename IOScaleValues to IOScaleEffect, improve naming of its keys
  • Apply the new useScaleAnimation hook to the following components:
    • All the buttons
    • PressableModuleBase, so all the Module… components
    • Alert… components
    • Banner
    • TabItem
    • NumberButton
  • Apply the new useListItemAnimation hook to all the interactive ListItem… components
  • Add support for the Reduce Motion setting: when it's enabled, the scaling effect won't be applied when you press, except for the Module… components where it's still applied, but with a less pronounced effect
  • Replace useListItemSpringAnimation with useListItemAnimation
  • Replace useModuleSpringAnimation with useScaleAnimation

Preview

When reducedMotion is enabled, the scale effect won't be applied:

disabled-scale-effect.mp4

How to test

Go to all the components that use a scale effect and check that there are no regressions.

@dmnplb dmnplb changed the title [IOAPPX-428] Refactor scale effect to avoid code repetition + Add support for the 'Reduce Motion' a11y setting [IOAPPX-428] Refactor scale and bg effect to avoid code repetition in all the components + Add support for the 'Reduce Motion' a11y setting Nov 15, 2024
@dmnplb dmnplb changed the title [IOAPPX-428] Refactor scale and bg effect to avoid code repetition in all the components + Add support for the 'Reduce Motion' a11y setting [IOAPPX-428] Add the new useScaleAnimation and useListItemAnimation hooks + Add support for the 'Reduce Motion' a11y setting Nov 15, 2024
@dmnplb dmnplb changed the title [IOAPPX-428] Add the new useScaleAnimation and useListItemAnimation hooks + Add support for the 'Reduce Motion' a11y setting [IOAPPX-428] Add the new useScaleAnimation and useListItemAnimation hooks + Add support for the reducedMotion a11y setting Nov 15, 2024
@dmnplb dmnplb marked this pull request as ready for review November 15, 2024 15:05
@dmnplb dmnplb requested review from a team as code owners November 15, 2024 15:05
mastro993 added a commit to pagopa/io-app that referenced this pull request Nov 25, 2024
…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
Copy link
Contributor

@LeleDallas LeleDallas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests on the iOS simulator look promising. I haven’t noticed significant differences compared to the default behavior. It would be great if someone else could test as well to confirm.

Copy link
Contributor

@LeleDallas LeleDallas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test on real devices, works as expected!

@dmnplb dmnplb merged commit bedb09d into main Dec 10, 2024
6 checks passed
@dmnplb dmnplb deleted the IOAPPX-428-refactor-scale-effect-reduce-motion branch December 10, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants