Skip to content

Commit

Permalink
Merge branch 'master' into IOCOM-1994-1995
Browse files Browse the repository at this point in the history
  • Loading branch information
forrest57 authored Dec 4, 2024
2 parents 0942e45 + 2fbaa6c commit d8da83a
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions ts/features/wallet/screens/WalletHomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import { IOStyles, IOToast } from "@pagopa/io-app-design-system";
import { useFocusEffect } from "@react-navigation/native";
import React from "react";
import { ScrollView } from "react-native";
import Animated, { useAnimatedRef } from "react-native-reanimated";
import { IOScrollView } from "../../../components/ui/IOScrollView";
import { useTabItemPressWhenScreenActive } from "../../../hooks/useTabItemPressWhenScreenActive";
import I18n from "../../../i18n";
import {
IOStackNavigationRouteProps,
useIONavigation
} from "../../../navigation/params/AppParamsList";
import { MainTabParamsList } from "../../../navigation/params/MainTabParamsList";
import { useIODispatch, useIOSelector } from "../../../store/hooks";
import { useOnFirstRender } from "../../../utils/hooks/useOnFirstRender";
import { cgnDetails } from "../../bonus/cgn/store/actions/details";
import { idPayWalletGet } from "../../idpay/wallet/store/actions";
import {
trackOpenWalletScreen,
trackWalletAdd
} from "../../itwallet/analytics";
import { ITW_ROUTES } from "../../itwallet/navigation/routes";
import { getPaymentsWalletUserMethods } from "../../payments/wallet/store/actions";
import { WalletCardsContainer } from "../components/WalletCardsContainer";
import { WalletCategoryFilterTabs } from "../components/WalletCategoryFilterTabs";
import { walletToggleLoadingState } from "../store/actions/placeholders";
import { selectWalletCards } from "../store/selectors";
import {
trackOpenWalletScreen,
trackWalletAdd
} from "../../itwallet/analytics";
import { useOnFirstRender } from "../../../utils/hooks/useOnFirstRender";

export type WalletHomeNavigationParams = Readonly<{
newMethodAdded: boolean;
Expand Down Expand Up @@ -70,6 +71,7 @@ const WalletHomeScreen = ({ route }: Props) => {
};

const WalletScrollView = ({ children }: React.PropsWithChildren<any>) => {
const animatedScrollViewRef = useAnimatedRef<Animated.ScrollView>();
const navigation = useIONavigation();
const cards = useIOSelector(selectWalletCards);

Expand All @@ -80,21 +82,30 @@ const WalletScrollView = ({ children }: React.PropsWithChildren<any>) => {
});
};

useTabItemPressWhenScreenActive(
React.useCallback(() => {
animatedScrollViewRef.current?.scrollTo({ y: 0, animated: true });
}, [animatedScrollViewRef]),
false
);

if (cards.length === 0) {
return (
<ScrollView
<Animated.ScrollView
ref={animatedScrollViewRef}
contentContainerStyle={[
IOStyles.flex,
IOStyles.horizontalContentPadding
]}
>
{children}
</ScrollView>
</Animated.ScrollView>
);
}

return (
<IOScrollView
animatedRef={animatedScrollViewRef}
actions={{
type: "SingleButton",
primary: {
Expand Down

0 comments on commit d8da83a

Please sign in to comment.