Skip to content

Commit

Permalink
MOB-73
Browse files Browse the repository at this point in the history
  • Loading branch information
chathurapathiranage committed Sep 23, 2024
1 parent 2896b17 commit fe7d485
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/components/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ import {
import { useTranslation } from "react-i18next";

import { Actions, DispatchContext, StateContext } from "../context/state";
import { useTheme } from "../context/ThemeContext";

import {
paymentFailedCtaText,
paymentSuccessCtaText,
ThemeModes,
} from "../util/constants";
import { ResponseScreenStatuses, ThemeSchemeType } from "../util/types";

import closeIcon from "../assets/images/close.png";
import closeDMIcon from "../assets/images/close_dm.png";

import { resizeFonts, responsiveScale, WINDOW_HEIGHT } from "../theme/scalling";
import { useCurrentTheme } from "../theme/useCurrentTheme";
Expand Down Expand Up @@ -71,7 +68,6 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
const dispatch = useContext(DispatchContext);
const theme = useCurrentTheme();
const styles = getStyles(theme);
const { mode } = useTheme();

useEffect(() => {
const yListener = translateY.addListener(({ value }) => {
Expand Down Expand Up @@ -108,7 +104,6 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
Keyboard.dismiss();

if (showAlert) {
// showing an alert when user try to close the SDK modal
Alert.alert(`${t("CANCEL_PAYMENT")}?`, "", [
{
text: t("NO"),
Expand All @@ -118,14 +113,12 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
{
text: t("YES"),
onPress: () => {
// invoking client provided onDismiss() callback when closing the SDK modal
onDismiss && onDismiss();
scrollTo(0);
},
},
]);
} else {
// invoking client provided callback when closing the SDK modal
onDismiss && onDismiss();
scrollTo(0);
}
Expand Down Expand Up @@ -170,6 +163,7 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
case ResponseScreenStatuses.SUCCESS:
case ResponseScreenStatuses.COMPLETE:
case ResponseScreenStatuses.CANCELLED:
case ResponseScreenStatuses.EXPIRED:
return paymentSuccessCtaText;
case ResponseScreenStatuses.FAILED:
return paymentFailedCtaText;
Expand All @@ -183,6 +177,7 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
case ResponseScreenStatuses.SUCCESS:
case ResponseScreenStatuses.COMPLETE:
case ResponseScreenStatuses.CANCELLED:
case ResponseScreenStatuses.EXPIRED:
return closeSheet(false);
case ResponseScreenStatuses.FAILED:
return dispatch({
Expand Down Expand Up @@ -210,22 +205,23 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
]}
>
<RNAnimated.View style={styles.line} {...panResponder.panHandlers}>
<KomojuText style={styles.headerLabel}>PAYMENT_OPTIONS</KomojuText>
<KomojuText style={styles.headerLabel}>
{!paymentState ? t("PAYMENT_OPTIONS") : ""}
</KomojuText>
<TouchableOpacity
style={styles.crossBtn}
onPress={() =>
closeSheet(
!(
paymentState === ResponseScreenStatuses.SUCCESS ||
paymentState === ResponseScreenStatuses.CANCELLED ||
paymentState === ResponseScreenStatuses.COMPLETE
paymentState === ResponseScreenStatuses.COMPLETE ||
paymentState === ResponseScreenStatuses.EXPIRED
)
)
}
>
<Image
source={mode === ThemeModes.light ? closeIcon : closeDMIcon}
/>
<Image source={closeIcon} />
</TouchableOpacity>
</RNAnimated.View>
{paymentState ? (
Expand Down

0 comments on commit fe7d485

Please sign in to comment.