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: [IOBP-583] Added payment logo uri to ListItemNav and ListItemRadio #220

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/src/pages/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const renderListItemNav = () => (
<ListItemNav
value={"Value"}
description="This is a list item nav with a payment logo"
paymentLogo="bancomatPay"
paymentLogoUri="https://github.com/pagopa/io-services-metadata/blob/master/logos/apps/paypal.png?raw=true"
onPress={() => {
alert("Action triggered");
}}
Expand All @@ -179,7 +179,7 @@ const renderListItemNav = () => (
<ListItemNav
value={"Value"}
description="This is a list item nav with a loading indicator"
paymentLogo="bancomatPay"
paymentLogoUri="https://github.com/pagopa/io-services-metadata/blob/master/logos/apps/paypal.png?raw=true"
onPress={() => {
alert("Action triggered");
}}
Expand Down
7 changes: 7 additions & 0 deletions example/src/pages/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ const mockRadioItems = (): ReadonlyArray<RadioItem<string>> => [
),
id: "example-jsx-element"
},
{
startImage: {
uri: "https://github.com/pagopa/io-services-metadata/blob/master/logos/apps/paypal.png?raw=true"
},
value: "PayPal",
id: "example-paypal"
},
{
value: "Let's try with a basic title",
description:
Expand Down
37 changes: 27 additions & 10 deletions src/components/listitems/ListItemNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { useCallback } from "react";
import { GestureResponderEvent, Pressable, View } from "react-native";
import {
GestureResponderEvent,
Image,
Pressable,
StyleSheet,
View
} from "react-native";
import Animated, {
Extrapolate,
interpolate,
Expand All @@ -14,6 +20,7 @@ import {
IOListItemStyles,
IOListItemVisualParams,
IOScaleValues,
IOSelectionListItemVisualParams,
IOSpringValues,
IOStyles,
hexToRgba,
Expand All @@ -23,7 +30,6 @@ import {
import { WithTestID } from "../../utils/types";
import { Badge } from "../badge";
import { IOIcons, Icon } from "../icons";
import { IOLogoPaymentType, LogoPayment } from "../logos";
import { HSpacer, VSpacer } from "../spacer";
import { Caption, H6, LabelSmall } from "../typography";
import { LoadingSpinner } from "../loadingSpinner";
Expand All @@ -50,19 +56,26 @@ type ListItemNavPartialProps = WithTestID<{
}>;

export type ListItemNavGraphicProps =
| { icon?: never; iconColor?: never; paymentLogo: IOLogoPaymentType }
| { icon: IOIcons; iconColor?: IOColors; paymentLogo?: never }
| { icon?: never; iconColor?: never; paymentLogo?: never };
| { icon?: never; iconColor?: never; paymentLogoUri: string }
| { icon: IOIcons; iconColor?: IOColors; paymentLogoUri?: never }
| { icon?: never; iconColor?: never; paymentLogoUri?: never };

export type ListItemNav = ListItemNavPartialProps & ListItemNavGraphicProps;

const styles = StyleSheet.create({
paymentLogoSize: {
width: IOSelectionListItemVisualParams.iconSize,
height: IOSelectionListItemVisualParams.iconSize
}
});

export const ListItemNav = ({
value,
description,
onPress,
icon,
iconColor = "grey-450",
paymentLogo,
paymentLogoUri,
accessibilityLabel,
testID,
hideChevron = false,
Expand Down Expand Up @@ -203,12 +216,16 @@ export const ListItemNav = ({
/>
</View>
)}
{paymentLogo && (
{paymentLogoUri && (
<View style={{ marginRight: IOListItemVisualParams.iconMargin }}>
<LogoPayment
name={paymentLogo}
size={IOListItemVisualParams.iconSize}
<Image
source={{ uri: paymentLogoUri }}
style={styles.paymentLogoSize}
/>
{/* <LogoPayment
name={paymentLogoUri}
size={IOListItemVisualParams.iconSize}
/> */}
</View>
)}
<View style={IOStyles.flex}>{listItemNavContent}</View>
Expand Down
17 changes: 14 additions & 3 deletions src/components/listitems/ListItemRadio.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { useCallback, useState } from "react";
import { Pressable, View } from "react-native";
import { Image, Pressable, StyleSheet, View } from "react-native";
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
import Animated, {
Extrapolate,
Expand Down Expand Up @@ -30,8 +30,9 @@ import { HSpacer, VSpacer } from "../spacer";
import { H6, LabelSmall } from "../typography";

type ListItemRadioGraphicProps =
| { icon?: never; paymentLogo: IOLogoPaymentType }
| { icon: IOIcons; paymentLogo?: never };
| { icon?: never; paymentLogo: IOLogoPaymentType; uri?: never }
| { icon?: never; paymentLogo?: never; uri: string }
| { icon: IOIcons; paymentLogo?: never; uri?: never };

type ListItemRadioLoadingProps =
| {
Expand Down Expand Up @@ -64,6 +65,13 @@ type OwnProps = Props &
"onPress" | "accessibilityLabel" | "disabled"
>;

const styles = StyleSheet.create({
imageSize: {
width: IOSelectionListItemVisualParams.iconSize,
height: IOSelectionListItemVisualParams.iconSize
}
});

/**
* `ListItemRadio` component with the automatic state management that uses a {@link AnimatedCheckBox}
* The toggleValue change when a `onPress` event is received and dispatch the `onValueChange`.
Expand Down Expand Up @@ -237,6 +245,9 @@ export const ListItemRadio = ({
size={IOSelectionListItemVisualParams.iconSize}
/>
)}
{startImage.uri && (
<Image source={startImage} style={styles.imageSize} />
)}
{startImage.paymentLogo && (
<LogoPayment
name={startImage.paymentLogo}
Expand Down
Loading