-
Notifications
You must be signed in to change notification settings - Fork 25
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
1 parent
06e563d
commit 553f87b
Showing
7 changed files
with
278 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from 'react'; | ||
import { | ||
StyleSheet, | ||
View, | ||
TouchableOpacity | ||
} from 'react-native'; | ||
import { COLORS } from '../styles/themes'; | ||
|
||
import { PenIcon } from './Icon/Pen.icon'; | ||
|
||
export const EditInfoContainer = ({ center, onPress, children }) => ( | ||
<TouchableOpacity | ||
style={[ | ||
center && styles.editInfoWrapperCentered | ||
]} | ||
onPress={onPress} | ||
> | ||
<View style={[ | ||
styles.editInfoContainer, | ||
center && styles.editInfoContainerCentered, | ||
]} | ||
> | ||
<View style={[ | ||
center && styles.alignCenter, | ||
]} | ||
> | ||
{children} | ||
</View> | ||
<View style={styles.editIcon}> | ||
<PenIcon /> | ||
</View> | ||
</View> | ||
</TouchableOpacity> | ||
); | ||
|
||
const styles = StyleSheet.create({ | ||
editInfoWrapperCentered: { | ||
alignSelf: 'center', | ||
}, | ||
editInfoContainer: { | ||
paddingVertical: 8, | ||
paddingLeft: 8, | ||
paddingRight: 40, | ||
borderRadius: 8, | ||
backgroundColor: COLORS.white, | ||
}, | ||
editInfoContainerCentered: { | ||
paddingLeft: 40, | ||
}, | ||
alignCenter: { | ||
alignItems: 'center', | ||
}, | ||
editIcon: { | ||
position: 'absolute', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
width: 24, | ||
height: '100%', | ||
marginVertical: 8, | ||
marginRight: 8, | ||
}, | ||
}); |
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,121 @@ | ||
/** | ||
* Copyright (c) Hathor Labs and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React, { ReactNode } from 'react'; | ||
import { | ||
StyleSheet, | ||
View, | ||
Text, | ||
StyleProp, | ||
ViewStyle | ||
} from 'react-native'; | ||
import Modal from 'react-native-modal'; | ||
|
||
import { COLORS } from '../styles/themes'; | ||
import NewHathorButton from './NewHathorButton'; | ||
|
||
const ModalBase = ({ styleModal, styleWrapper, show, onDismiss, children }) => { | ||
const hasChildren = children != null; | ||
|
||
const title = hasChildren && React.Children.toArray(children).find( | ||
(child) => child.type.displayName === Title.displayName | ||
); | ||
const body = hasChildren && React.Children.toArray(children).find( | ||
(child) => child.type.displayName === Body.displayName | ||
); | ||
const button = hasChildren && React.Children.toArray(children).find( | ||
(child) => child.type.displayName === Button.displayName | ||
); | ||
|
||
const discreteButton = hasChildren && React.Children.toArray(children).find( | ||
(child) => child.type.displayName === DiscreteButton.displayName | ||
); | ||
|
||
return ( | ||
<Modal | ||
isVisible={show} | ||
animationIn='slideInUp' | ||
swipeDirection={['down']} | ||
onSwipeComplete={onDismiss} | ||
onBackButtonPress={onDismiss} | ||
onBackdropPress={onDismiss} | ||
style={styleModal} | ||
propagateSwipe | ||
> | ||
<View style={[ | ||
styles.wrapper, | ||
styleWrapper, | ||
]} | ||
> | ||
{title && title} | ||
{body && body} | ||
{button && button} | ||
{discreteButton && discreteButton} | ||
</View> | ||
</Modal> | ||
); | ||
}; | ||
|
||
const Title = ({ children }) => ( | ||
<View style={styles.titleWrapper}> | ||
<Text style={styles.title}> | ||
{children} | ||
</Text> | ||
</View> | ||
); | ||
Title.displayName = 'ModalBaseTitle'; | ||
|
||
/** | ||
* @typedef {Object} Properties p | ||
* @property {ReactNode} p.children | ||
* @property {StyleProp<ViewStyle>} p.style | ||
* | ||
* @param {Properties} | ||
*/ | ||
const Body = ({ style, children }) => ( | ||
<View style={style}> | ||
{children} | ||
</View> | ||
); | ||
Body.displayName = 'ModalBaseBody'; | ||
|
||
const Button = ({ title, disabled, secondary, danger, onPress }) => ( | ||
<NewHathorButton title={title} {...{ disabled, secondary, danger, onPress }} /> | ||
); | ||
Button.displayName = 'ModalBaseButton'; | ||
|
||
const DiscreteButton = ({ title, onPress }) => ( | ||
<NewHathorButton title={title} discrete {...{ onPress }} wrapperStyle={styles.discreteButton} /> | ||
); | ||
DiscreteButton.displayName = 'ModalBaseDiscreteButton'; | ||
|
||
ModalBase.Title = Title; | ||
ModalBase.Body = Body; | ||
ModalBase.Button = Button; | ||
ModalBase.DiscreteButton = DiscreteButton; | ||
|
||
const styles = StyleSheet.create({ | ||
wrapper: { | ||
borderRadius: 8, | ||
paddingVertical: 24, | ||
paddingHorizontal: 16, | ||
backgroundColor: COLORS.white, | ||
}, | ||
titleWrapper: { | ||
paddingBottom: 20, | ||
}, | ||
title: { | ||
color: 'black', | ||
fontSize: 18, | ||
lineHeight: 20, | ||
}, | ||
discreteButton: { | ||
marginTop: 8, | ||
}, | ||
}); | ||
|
||
export { ModalBase } |
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,28 @@ | ||
import React from 'react'; | ||
import { | ||
StyleSheet, | ||
Text, | ||
} from 'react-native'; | ||
|
||
export const TextLabel = ({ pb8, bold, children }) => ( | ||
<Text style={[ | ||
styles.textLabel, | ||
pb8 && styles.pb8, | ||
bold && styles.bold, | ||
]} | ||
>{children}</Text> | ||
); | ||
|
||
const styles = StyleSheet.create({ | ||
textLabel: { | ||
fontSize: 12, | ||
lineHeight: 20, | ||
color: 'hsla(0, 0%, 38%, 1)', | ||
}, | ||
pb8: { | ||
paddingBottom: 8, | ||
}, | ||
bold: { | ||
fontWeight: 'bold', | ||
}, | ||
}); |
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,28 @@ | ||
import React from 'react'; | ||
import { | ||
StyleSheet, | ||
Text, | ||
} from 'react-native'; | ||
|
||
export const TextValue = ({ bold, pb4, children }) => ( | ||
<Text style={[ | ||
styles.textValue, | ||
bold && styles.bold, | ||
pb4 && styles.pb4, | ||
]} | ||
>{children}</Text> | ||
); | ||
|
||
const styles = StyleSheet.create({ | ||
textValue: { | ||
fontSize: 14, | ||
lineHeight: 20, | ||
color: 'black', | ||
}, | ||
pb4: { | ||
paddingBottom: 4, | ||
}, | ||
bold: { | ||
fontWeight: 'bold', | ||
}, | ||
}); |
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