Skip to content

Commit

Permalink
fix: [PE-587,PE-589,PE-591] CGN revamp fixes (#5754)
Browse files Browse the repository at this point in the history
## Short description
This PR fixes:
- Dividers between merchant categories;
- Wrong scrollbar into merchant details screen;
- Wrong badge spacing into list item nav;

## List of changes proposed in this pull request
- Added `<Divider />` component between categories list items;
- Removed the default chevron from the `ListItemNav` adding a custom one
with custom spacing

## How to test
Inside the CGN flows, open the categories list and merchant details
  • Loading branch information
Hantex9 committed May 15, 2024
1 parent ac022ab commit e0dcee1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
52 changes: 26 additions & 26 deletions ts/features/bonus/cgn/components/merchants/CgnMerchantsListView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { View } from "react-native";
import { FlatList, View } from "react-native";
import { Badge, Divider, H6, ListItemNav } from "@pagopa/io-app-design-system";
import { IOStyles } from "../../../../../components/core/variables/IOStyles";
import { OfflineMerchant } from "../../../../../../definitions/cgn/merchants/OfflineMerchant";
Expand All @@ -14,32 +14,32 @@ type Props = {

// Component that renders the list of merchants as a FlatList
const CgnMerchantsListView: React.FunctionComponent<Props> = (props: Props) => (
<View style={[IOStyles.flex, IOStyles.horizontalContentPadding]}>
{props.merchantList.map((merchant, index) => (
<React.Fragment key={index}>
<ListItemNav
onPress={() => props.onItemPress(merchant.id)}
value={
merchant.newDiscounts ? (
<View style={IOStyles.rowSpaceBetween}>
<H6 style={{ flexGrow: 1, flexShrink: 1 }}>{merchant.name}</H6>
<View style={{ alignSelf: "center" }}>
<Badge
variant="purple"
text={I18n.t("bonus.cgn.merchantsList.news")}
/>
</View>
<FlatList
style={IOStyles.horizontalContentPadding}
ItemSeparatorComponent={() => <Divider />}
scrollEnabled={false}
data={props.merchantList}
keyExtractor={item => item.id}
renderItem={({ item }) => (
<ListItemNav
onPress={() => props.onItemPress(item.id)}
value={
<View style={IOStyles.rowSpaceBetween}>
<H6 style={{ flexGrow: 1, flexShrink: 1 }}>{item.name}</H6>
{item.newDiscounts && (
<View style={[IOStyles.rowSpaceBetween, IOStyles.alignCenter]}>
<Badge
variant="purple"
text={I18n.t("bonus.cgn.merchantsList.news")}
/>
</View>
) : (
merchant.name
)
}
accessibilityLabel={merchant.name}
/>
{props.merchantList.length - 1 !== index && <Divider />}
</React.Fragment>
))}
</View>
)}
</View>
}
accessibilityLabel={item.name}
/>
)}
/>
);

export default CgnMerchantsListView;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as pot from "@pagopa/ts-commons/lib/pot";
import {
Badge,
Body,
Divider,
H6,
IOStyles,
IOToast,
Expand All @@ -24,12 +25,16 @@ import { cgnCategoriesListSelector } from "../../store/reducers/categories";
import { cgnCategories } from "../../store/actions/categories";
import CGN_ROUTES from "../../navigation/routes";
import { useIOBottomSheetAutoresizableModal } from "../../../../../utils/hooks/bottomSheet";
import { isDesignSystemEnabledSelector } from "../../../../../store/reducers/persistedPreferences";

export const CgnMerchantCategoriesListScreen = () => {
const insets = useSafeAreaInsets();
const isFirstRender = React.useRef<boolean>(true);
const dispatch = useIODispatch();
const potCategories = useIOSelector(cgnCategoriesListSelector);

const isDesignSystemEnabled = useIOSelector(isDesignSystemEnabledSelector);

const navigation =
useNavigation<
IOStackNavigationProp<CgnDetailsParamsList, "CGN_MERCHANTS_CATEGORIES">
Expand Down Expand Up @@ -97,6 +102,7 @@ export const CgnMerchantCategoriesListScreen = () => {
}
);
}}
iconColor="grey-300"
icon={s.icon}
/>
)
Expand Down Expand Up @@ -128,17 +134,20 @@ export const CgnMerchantCategoriesListScreen = () => {
onRefresh={loadCategories}
/>
}
ItemSeparatorComponent={() => <Divider />}
ListFooterComponent={
<ListItemAction
onPress={present}
accessibilityLabel={I18n.t(
"bonus.cgn.merchantsList.categoriesList.bottomSheet.cta"
)}
label={I18n.t(
"bonus.cgn.merchantsList.categoriesList.bottomSheet.cta"
)}
variant="primary"
/>
isDesignSystemEnabled ? (
<ListItemAction
onPress={present}
accessibilityLabel={I18n.t(
"bonus.cgn.merchantsList.categoriesList.bottomSheet.cta"
)}
label={I18n.t(
"bonus.cgn.merchantsList.categoriesList.bottomSheet.cta"
)}
variant="primary"
/>
) : null
}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ const CgnMerchantDetailScreen = () => {
style={{ flexGrow: 1 }}
onScroll={scrollHandler}
scrollEventThrottle={8}
scrollIndicatorInsets={{ right: 1 }}
snapToOffsets={[0]}
snapToEnd={false}
scrollIndicatorInsets={{ right: 1 }}
contentContainerStyle={{
flexGrow: 1,
paddingBottom: safeBottomAreaHeight
Expand Down

0 comments on commit e0dcee1

Please sign in to comment.