Skip to content

Commit

Permalink
Merge pull request #11 from degica/task/ui-finetune-p2
Browse files Browse the repository at this point in the history
success|failed screen
  • Loading branch information
kasunprabath98 authored Jun 7, 2024
2 parents 60e18a6 + 8f589c7 commit 9f9927f
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 0 deletions.
Binary file added payment_sdk/src/assets/images/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions payment_sdk/src/components/ResponseScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import {Image, StyleSheet, Text, View} from 'react-native';
import React, {useCallback, useMemo} from 'react';
import SubmitButton from './SubmitButton';

type Props = {
status: 'success' | 'failed';
message?: string;
onPressLabel: string;
onPress: () => void;
};

const ResponseScreen = ({status, message, onPress, onPressLabel}: Props) => {
const renderMessageContent = useMemo(() => {
const title = status === 'success' ? 'Payment Success' : 'Payment Failed';
const defaultMessage =
status === 'success'
? 'Thank you for your order'
: 'Hey there, We tried to charge your card but, something went wrong. Please update your payment method below to continue';
const msg = message || defaultMessage;

return (
<View style={styles.container}>
<Text style={styles.title}>{title}</Text>
<Text style={styles.message}>{msg}</Text>
</View>
);
}, [status, message]);

const renderIcon = useMemo(() => {
const source =
status === 'success'
? require('../assets/images/success.png')
: require('../assets/images/error.png');
return <Image source={source} style={styles.icon} />;
}, [status]);

const memoizedOnPress = useCallback(onPress, [onPress]);

return (
<View style={styles.parentContainer}>
<View style={styles.imageContainer}>{renderIcon}</View>
{renderMessageContent}
<View style={styles.bottomButton}>
<SubmitButton onPress={memoizedOnPress} label={onPressLabel} />
</View>
</View>
);
};

export default ResponseScreen;

const styles = StyleSheet.create({
parentContainer: {
flex: 1,
},
container: {
padding: 16,
alignItems: 'center',
},
imageContainer: {
alignItems: 'center',
marginBottom: 18,
},
icon: {
width: 48,
height: 48,
},
title: {
fontSize: 28,
fontWeight: 'bold',
marginBottom: 16,
color: '#172E44',
},
message: {
fontSize: 16,
marginBottom: 16,
textAlign: 'center',
paddingHorizontal: 32,
},
bottomButton: {
position: 'absolute',
bottom: 32,
left: 0,
right: 0,
},
});
1 change: 1 addition & 0 deletions payment_sdk/src/components/SubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const styles = StyleSheet.create({
buttonWrapper: {
backgroundColor: "#0B82EE",
borderRadius: 8,
height: 50,
minHeight: 50,
marginHorizontal: 16,
flex: 1,
Expand Down

0 comments on commit 9f9927f

Please sign in to comment.