-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [IOCOM-450,IOCOM-449,IOCOM-508] Bottom sheet for multiple payme…
…nts on SEND message details screen (#5153)⚠️ This PR depends on #5152⚠️ ## Short description This PR adds handling of SEND message multiple payments using a bottom sheet. ![Screenshot 2023-10-23 at 10 18 41](https://github.com/pagopa/io-app/assets/5150343/a671c4ac-81f1-4eca-84a0-68d7714d87f7) ## List of changes proposed in this pull request - Bottom sheet with Flat List for multiple payments on SEND message (more than five payments) - Handling of single payment (no bottom sheet but direct navigation to the payment) - Cancellation of PN payment's updates - Cancellation of PN payments' statuses on global message reload ## How to test Using the same configurations of the io-dev-api-server in #5152, try the bottom sheet. --------- Co-authored-by: Alessandro Dell'Oste <[email protected]>
- Loading branch information
Showing
12 changed files
with
186 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { MutableRefObject } from "react"; | ||
import { Dimensions, View } from "react-native"; | ||
import I18n from "i18n-js"; | ||
import { useDispatch } from "react-redux"; | ||
import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; | ||
import { UIMessageId } from "../../../store/reducers/entities/messages/types"; | ||
import { useIOBottomSheetModal } from "../../../utils/hooks/bottomSheet"; | ||
import { cancelQueuedPaymentUpdates } from "../store/actions"; | ||
import { MessagePaymentItem } from "./MessagePaymentItem"; | ||
|
||
export type MessagePaymentBottomSheetProps = { | ||
messageId: UIMessageId; | ||
payments: ReadonlyArray<NotificationPaymentInfo>; | ||
presentPaymentsBottomSheetRef: MutableRefObject<(() => void) | undefined>; | ||
dismissPaymentsBottomSheetRef: MutableRefObject<(() => void) | undefined>; | ||
}; | ||
|
||
export const MessagePaymentBottomSheet = ({ | ||
messageId, | ||
payments, | ||
presentPaymentsBottomSheetRef, | ||
dismissPaymentsBottomSheetRef | ||
}: MessagePaymentBottomSheetProps) => { | ||
// console.log(`=== Bottom Sheet: re-rendering`); | ||
const dispatch = useDispatch(); | ||
const windowHeight = Dimensions.get("window").height; | ||
const snapPoint = (payments.length > 5 ? 0.75 : 0.5) * windowHeight; | ||
// TODO replace with FlatList, check IOCOM-636 for further details | ||
const { present, dismiss, bottomSheet } = useIOBottomSheetModal({ | ||
component: ( | ||
<> | ||
{payments.map((payment, index) => ( | ||
<MessagePaymentItem | ||
index={index} | ||
key={`LI_${index}`} | ||
messageId={messageId} | ||
payment={payment} | ||
noSpaceOnTop={index === 0} | ||
willNavigateToPayment={() => dismiss()} | ||
/> | ||
))} | ||
</> | ||
), | ||
title: I18n.t("features.pn.details.paymentSection.bottomSheetTitle"), | ||
snapPoint: [snapPoint], | ||
footer: <View></View>, | ||
onDismiss: () => dispatch(cancelQueuedPaymentUpdates()) | ||
}); | ||
// eslint-disable-next-line functional/immutable-data | ||
presentPaymentsBottomSheetRef.current = present; | ||
// eslint-disable-next-line functional/immutable-data | ||
dismissPaymentsBottomSheetRef.current = dismiss; | ||
// console.log(`=== Bottom Sheet: re-rendering`); | ||
return bottomSheet; | ||
}; |
Oops, something went wrong.