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

chore(Cross): [IOAPPX-356] Add divider to first level sections when the user scrolls #6054

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

dmnplb
Copy link
Contributor

@dmnplb dmnplb commented Jul 26, 2024

Note

This change applies only to the Wallet (new), Services, Payments and Profile sections.

Short description

This PR adds the new divider transition to first level sections when the user scrolls. To get this behaviour, we need to define HeaderFirstLevelProps directly in the main screen through useLayoutEffect where the main ScrollView or FlatList is placed.

To avoid code duplication, there's a new useHeaderFirstLevelActionPropHelp's hook that returns a FAQ configuration object based on the provided route.

List of changes proposed in this pull request

  • Add the new divider transition to the HeaderFirstLevel using the useScrollViewOffset hook from reanimated
  • Add the new optional endBlock prop to HeaderFirstLevel to render custom block (see the Services screen for a demonstration update: removed from the branch)
  • Migrate the header configuration from the HeaderFirstLevelHandler to relative first-level sections
  • Replace GradientScrollView with IOScrollView in the new Wallet home screen, adding dark mode support in the process (cc @mastro993)
  • Add quick scroll to top to the new Wallet home screen when the user taps on the active tab item, like other sections (cc @mastro993)
  • Add the new useHeaderFirstLevelActionPropHelp hook
  • For testing purposes, update HeaderFirstLevel with the latest changes from io-app-design-system. Before merging this PR we'll also update the component in the io-app-design-system

Preview

Important

The divider is set with hairlineWidth, so it's very thin. If you want to see the change, download the following videos and play them at full size

Wallet Services Profile
wallet-divider.mp4
services-divider.mp4
profile-divider.mp4

How to test

Go to the above sections and check that everything is correct. Also check the relative flow of the Assistance in each first level section.

@dmnplb dmnplb added the Design System New visual language and reduction of previous UI clutter label Jul 26, 2024
@dmnplb dmnplb requested a review from a team as a code owner July 26, 2024 15:54
@pagopa-github-bot pagopa-github-bot changed the title [IOAPPX-356] Add divider to first level sections when the user scrolls chore(Cross): [IOAPPX-356] Add divider to first level sections when the user scrolls Jul 26, 2024
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Jul 26, 2024

Affected stories

  • ⚙️ IOAPPX-356: Aggiunta del divisore quando l'utente scorre nelle sezioni di primo livello
    subtask of

Generated by 🚫 dangerJS against 3960f88

dmnplb added a commit to pagopa/io-app-design-system that referenced this pull request Aug 27, 2024
… allow transition even if `triggerOffset` is not set (#323)

## Short description
This PR adds the new `enableDiscreteTransition` option to
`HeaderSecondLevel` to allow an animated transition when `triggerOffset`
is not set, or in some specific cases where there is a custom background
and the default transition looks bad. The new transition differs from
the previous one in that it's always triggered when the user scrolls
down, even by one pixel. In the default transition you need to set a
custom height along with a proper `snapToOffsets` array.

## List of changes proposed in this pull request
- Add the new `enableDiscreteTransition` boolean prop along with the
`animatedRef` mandatory prop
- Add two new screens to the `example` app for demo purposes

### Preview
| Default | Discrete |
|--------|--------|
| <video
src="https://github.com/user-attachments/assets/64066269-74db-462d-8a40-284410e0328a"
/> | <video
src="https://github.com/user-attachments/assets/cd565eee-f97c-4cee-bb2f-921822c2e016"
/> |





#### Related PR
* pagopa/io-app#6054

## How to test
1. Launch the example app
2. Go to the **Header Second Level (discrete transition, …)** screens
Comment on lines 54 to 96
/* CODE RELATED TO THE HEADER */

const navigation = useIONavigation();
const scrollViewContentRef = useAnimatedRef<Animated.ScrollView>();

/* Scroll to top when the active tab is tapped */
useTabItemPressWhenScreenActive(
() => scrollViewContentRef.current?.scrollTo({ y: 0, animated: true }),
false
);

const isSettingsVisibleAndHideProfile = useIOSelector(
isSettingsVisibleAndHideProfileSelector
);

const helpAction = useHeaderFirstLevelActionPropHelp(ROUTES.WALLET_HOME);
const settingsAction = useHeaderFirstLevelActionPropSettings();

useLayoutEffect(() => {
const headerFirstLevelProps: HeaderFirstLevel = {
title: I18n.t("wallet.wallet"),
firstAction: helpAction,
testID: "wallet-home-header-title",
animatedRef: scrollViewContentRef,
...(isSettingsVisibleAndHideProfile
? {
type: "twoActions",
secondAction: settingsAction
}
: { type: "singleAction" })
};

navigation.setOptions({
header: () => <HeaderFirstLevel {...headerFirstLevelProps} />
});
}, [
helpAction,
isSettingsVisibleAndHideProfile,
navigation,
scrollViewContentRef,
settingsAction
]);

Copy link
Contributor

Choose a reason for hiding this comment

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

We could move everything inside the WalletScrollView component. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in the following commit → 4005f91

@mastro993
Copy link
Contributor

In the services screen, I cannot reproduce the behavior that I see in the preview videos. The search bar is not sticky.

Senza.nome.mov

@dmnplb
Copy link
Contributor Author

dmnplb commented Sep 30, 2024

In the services screen, I cannot reproduce the behavior that I see in the preview videos. The search bar is not sticky.

@mastro993 That's because we got rid of the sticky behavior (removed in the following commit → eff2bd1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cross Design System New visual language and reduction of previous UI clutter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants