Skip to content

Commit

Permalink
fix: review correction
Browse files Browse the repository at this point in the history
  • Loading branch information
RamyEB committed Aug 20, 2024
1 parent f130274 commit 0e2da57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useCallback, useMemo } from "react";
import { TouchableOpacity } from "react-native";
import { Flex, Text } from "@ledgerhq/native-ui";
import AppIcon from "LLM/features/Web3Hub/components/AppIcon";
Expand All @@ -7,14 +7,19 @@ import { AppManifest } from "@ledgerhq/live-common/wallet-api/types";
export default function MinimalAppCard({
item,
onPress,
disabled,
}: {
item: AppManifest;
onPress: () => void;
disabled?: boolean;
onPress: (manifest: AppManifest) => void;
}) {
const disabled = useMemo(() => item.branch === "soon", [item]);
const handlePress = useCallback(() => {
if (!disabled) {
onPress(item);
}
}, [disabled, item, onPress]);

return (
<TouchableOpacity disabled={disabled} onPress={onPress}>
<TouchableOpacity disabled={disabled} onPress={handlePress}>
<Flex rowGap={6} marginRight={3} width={70} alignItems={"center"}>
<AppIcon isDisabled={disabled} size={48} name={item.name} icon={item.icon} />
<Text numberOfLines={1}>{item.name}</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from "react";
import React from "react";
import { StyleSheet } from "react-native";
import { FlashList } from "@shopify/flash-list";
import { Box, Flex, InfiniteLoader, Text } from "@ledgerhq/native-ui";
Expand All @@ -10,36 +10,29 @@ type Props = {
isLoading: boolean;
data: AppManifest[];
onEndReached?: () => void;
extraData: (manifest: AppManifest) => void;
onPressItem: (manifest: AppManifest) => void;
testID?: string;
};

type PropRenderItem = {
item: AppManifest;
extraData?: (manifest: AppManifest) => void;
onPressItem?: (manifest: AppManifest) => void;
};

const identityFn = (item: AppManifest) => item.id;

const renderItem = ({ item, onPressItem = () => {} }: PropRenderItem) => {
return <MinimalAppCard item={item} onPress={onPressItem} />;
};

export default function HorizontalList({
title,
isLoading,
data,
onEndReached,
extraData,
onPressItem,
testID,
}: Props) {
const renderItem = useCallback(({ item, extraData = () => {} }: PropRenderItem) => {
const disabled = item.branch === "soon";
const handlePress = () => {
if (!disabled) {
extraData(item);
}
};

return <MinimalAppCard key={item.id} disabled={disabled} item={item} onPress={handlePress} />;
}, []);

return (
<>
<Text mt={2} mb={5} numberOfLines={1} variant="h5" mx={5} accessibilityRole="header">
Expand All @@ -62,7 +55,7 @@ export default function HorizontalList({
estimatedItemSize={70}
data={data}
showsHorizontalScrollIndicator={false}
extraData={extraData}
extraData={onPressItem}
onEndReached={onEndReached}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ManifestsCategoryList = ({ title, categoryId, navigation }: Props) => {
<HorizontalList
title={title}
data={data}
extraData={disclaimer.onPressItem}
onPressItem={disclaimer.onPressItem}
isLoading={isLoading}
onEndReached={onEndReached}
testID="web3hub-clear-signing-scroll"
Expand Down

0 comments on commit 0e2da57

Please sign in to comment.