-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
327 additions
and
425 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.
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,120 @@ | ||
import React, { memo, ReactElement, useState } from 'react'; | ||
import { | ||
Image, | ||
ImageSourcePropType, | ||
LayoutChangeEvent, | ||
StyleSheet, | ||
View, | ||
} from 'react-native'; | ||
|
||
import { BodyM, Display } from '../styles/text'; | ||
import BottomSheetNavigationHeader from '../components/BottomSheetNavigationHeader'; | ||
import SafeAreaInset from '../components/SafeAreaInset'; | ||
import Button from '../components/Button'; | ||
|
||
const BottomSheetScreen = ({ | ||
navTitle, | ||
title, | ||
description, | ||
image, | ||
continueText, | ||
cancelText, | ||
displayBackButton = true, | ||
isLoading, | ||
testID, | ||
onCancel, | ||
onContinue, | ||
}: { | ||
navTitle: string; | ||
title: string | ReactElement; | ||
description: string | ReactElement; | ||
image: ImageSourcePropType; | ||
continueText: string; | ||
cancelText?: string; | ||
displayBackButton?: boolean; | ||
isLoading?: boolean; | ||
testID?: string; | ||
onCancel?: () => void; | ||
onContinue: () => void; | ||
}): ReactElement => { | ||
const [isLarge, setIsLarge] = useState(false); | ||
|
||
const onLayout = (event: LayoutChangeEvent): void => { | ||
// add margin to the image container if the sheet is large | ||
if (event.nativeEvent.layout.height > 700) { | ||
setIsLarge(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<View style={styles.root} testID={testID} onLayout={onLayout}> | ||
<BottomSheetNavigationHeader | ||
title={navTitle} | ||
displayBackButton={displayBackButton} | ||
/> | ||
<View style={styles.content}> | ||
<View | ||
// eslint-disable-next-line react-native/no-inline-styles | ||
style={[styles.imageContainer, { marginBottom: isLarge ? 32 : 0 }]}> | ||
<Image style={styles.image} source={image} /> | ||
</View> | ||
<Display>{title}</Display> | ||
<BodyM color="secondary">{description}</BodyM> | ||
<View style={styles.buttonContainer}> | ||
{cancelText && ( | ||
<Button | ||
style={styles.button} | ||
variant="secondary" | ||
size="large" | ||
text={cancelText} | ||
testID={`${testID}-button-cancel`} | ||
onPress={onCancel} | ||
/> | ||
)} | ||
<Button | ||
style={styles.button} | ||
size="large" | ||
text={continueText} | ||
loading={isLoading} | ||
testID={`${testID}-button-continue`} | ||
onPress={onContinue} | ||
/> | ||
</View> | ||
</View> | ||
<SafeAreaInset type="bottom" minPadding={16} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
root: { | ||
flex: 1, | ||
}, | ||
content: { | ||
flex: 1, | ||
paddingHorizontal: 32, | ||
}, | ||
imageContainer: { | ||
flexShrink: 1, | ||
alignItems: 'center', | ||
alignSelf: 'center', | ||
width: '80%', | ||
aspectRatio: 1, | ||
marginTop: 'auto', | ||
}, | ||
image: { | ||
flex: 1, | ||
resizeMode: 'contain', | ||
}, | ||
buttonContainer: { | ||
flexDirection: 'row', | ||
justifyContent: 'center', | ||
marginTop: 32, | ||
gap: 16, | ||
}, | ||
button: { | ||
flex: 1, | ||
}, | ||
}); | ||
|
||
export default memo(BottomSheetScreen); |
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
Oops, something went wrong.