-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #30267 from software-mansion-labs/ts/ConfirmationPage
[TS migration] Migrate 'ConfirmationPage.js' component to TypeScript
- Loading branch information
Showing
2 changed files
with
17 additions
and
29 deletions.
There are no files selected for viewing
44 changes: 16 additions & 28 deletions
44
src/components/ConfirmationPage.js → src/components/ConfirmationPage.tsx
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 |
---|---|---|
@@ -1,75 +1,63 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import useThemeStyles from '@styles/useThemeStyles'; | ||
import Button from './Button'; | ||
import FixedFooter from './FixedFooter'; | ||
import Lottie from './Lottie'; | ||
import LottieAnimations from './LottieAnimations'; | ||
import DotLottieAnimation from './LottieAnimations/types'; | ||
import Text from './Text'; | ||
|
||
const propTypes = { | ||
type ConfirmationPageProps = { | ||
/** The asset to render */ | ||
// eslint-disable-next-line react/forbid-prop-types | ||
animation: PropTypes.object, | ||
animation?: DotLottieAnimation; | ||
|
||
/** Heading of the confirmation page */ | ||
heading: PropTypes.string, | ||
heading: string; | ||
|
||
/** Description of the confirmation page */ | ||
description: PropTypes.string, | ||
description: string; | ||
|
||
/** The text for the button label */ | ||
buttonText: PropTypes.string, | ||
buttonText?: string; | ||
|
||
/** A function that is called when the button is clicked on */ | ||
onButtonPress: PropTypes.func, | ||
onButtonPress?: () => void; | ||
|
||
/** Whether we should show a confirmation button */ | ||
shouldShowButton: PropTypes.bool, | ||
shouldShowButton?: boolean; | ||
}; | ||
|
||
const defaultProps = { | ||
animation: LottieAnimations.Fireworks, | ||
heading: '', | ||
description: '', | ||
buttonText: '', | ||
onButtonPress: () => {}, | ||
shouldShowButton: false, | ||
}; | ||
|
||
function ConfirmationPage(props) { | ||
function ConfirmationPage({animation = LottieAnimations.Fireworks, heading, description, buttonText = '', onButtonPress = () => {}, shouldShowButton = false}: ConfirmationPageProps) { | ||
const styles = useThemeStyles(); | ||
|
||
return ( | ||
<> | ||
<View style={[styles.screenCenteredContainer, styles.alignItemsCenter]}> | ||
<Lottie | ||
source={props.animation} | ||
source={animation} | ||
autoPlay | ||
loop | ||
style={styles.confirmationAnimation} | ||
webStyle={styles.confirmationAnimationWeb} | ||
/> | ||
<Text style={[styles.textHeadline, styles.textAlignCenter, styles.mv2]}>{props.heading}</Text> | ||
<Text style={styles.textAlignCenter}>{props.description}</Text> | ||
<Text style={[styles.textHeadline, styles.textAlignCenter, styles.mv2]}>{heading}</Text> | ||
<Text style={styles.textAlignCenter}>{description}</Text> | ||
</View> | ||
{props.shouldShowButton && ( | ||
{shouldShowButton && ( | ||
<FixedFooter> | ||
<Button | ||
success | ||
text={props.buttonText} | ||
text={buttonText} | ||
style={styles.mt6} | ||
pressOnEnter | ||
onPress={props.onButtonPress} | ||
onPress={onButtonPress} | ||
/> | ||
</FixedFooter> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
ConfirmationPage.propTypes = propTypes; | ||
ConfirmationPage.defaultProps = defaultProps; | ||
ConfirmationPage.displayName = 'ConfirmationPage'; | ||
|
||
export default ConfirmationPage; |
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