-
Notifications
You must be signed in to change notification settings - Fork 51
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
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import {forwardRef} from 'react'; | ||
import {Platform, StyleProp, View, ViewStyle} from 'react-native'; | ||
import {Modalize as RNModalize, ModalizeProps as RNModalizeProps} from 'react-native-modalize'; | ||
import {SafeAreaView} from 'react-native-safe-area-context'; | ||
|
||
import {useStyles} from '../../hooks'; | ||
import {Divider} from '../Divider'; | ||
import {Text} from '../Text'; | ||
import stylesheet from './styles'; | ||
|
||
export type Modalize = RNModalize; | ||
|
||
export type ModalizeProps = RNModalizeProps & { | ||
title?: string; | ||
style?: StyleProp<ViewStyle>; | ||
children?: React.ReactNode; | ||
}; | ||
|
||
export const Modalize = forwardRef<RNModalize, ModalizeProps>((props, ref) => { | ||
const {title, style: styleProp, modalStyle: modalStyleProp, children, ...modalizeProps} = props; | ||
|
||
const styles = useStyles(stylesheet); | ||
|
||
return ( | ||
<RNModalize | ||
ref={ref} | ||
handlePosition={Platform.OS === 'ios' ? 'inside' : 'outside'} | ||
adjustToContentHeight | ||
modalStyle={[styles.modal, modalStyleProp]} | ||
{...modalizeProps} | ||
> | ||
<SafeAreaView edges={['bottom', 'left', 'right']} style={[styles.content, styleProp]}> | ||
{title && ( | ||
<View style={styles.header}> | ||
<Text | ||
weight="bold" | ||
color="textSecondary" | ||
align="center" | ||
fontSize={18} | ||
style={styles.title} | ||
> | ||
{title} | ||
</Text> | ||
|
||
<Divider /> | ||
</View> | ||
)} | ||
|
||
{children} | ||
</SafeAreaView> | ||
</RNModalize> | ||
); | ||
}); | ||
|
||
Modalize.displayName = 'Modalize'; |
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,22 @@ | ||
import {Platform} from 'react-native'; | ||
|
||
import {Spacing, ThemedStyleSheet} from '../../styles'; | ||
|
||
export default ThemedStyleSheet((theme) => ({ | ||
modal: { | ||
backgroundColor: theme.colors.surface, | ||
}, | ||
|
||
header: { | ||
width: '100%', | ||
marginBottom: Spacing.medium, | ||
}, | ||
title: { | ||
marginBottom: Spacing.xsmall, | ||
}, | ||
|
||
content: { | ||
padding: Spacing.xlarge, | ||
paddingTop: Platform.OS === 'ios' ? Spacing.xlarge : Spacing.xsmall, | ||
}, | ||
})); |
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