-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from degica/task/ui-finetune-p2
success|failed screen
- Loading branch information
Showing
8 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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, | ||
}, | ||
}); |
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