-
Notifications
You must be signed in to change notification settings - Fork 14
Added common components #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ba463b0
c5e5517
f9d37fd
e1cca42
bf7f554
abab86c
96822f0
127e046
2c2c5ee
aa84d95
a6c91cd
60bf1fd
ef0317b
2a72bc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,44 @@ module.exports.CUSTOM_TEXT_PATH = `${module.exports.COMPONENTS_PATH}/CustomText` | |
module.exports.CUSTOM_TEXT = `${module.exports.CUSTOM_TEXT_PATH}/index.js`; | ||
module.exports.CUSTOM_TEXT_STYLES = `${module.exports.CUSTOM_TEXT_PATH}/styles.js`; | ||
|
||
// COMPONENTS - CUSTOM TEXT INPUT | ||
module.exports.CUSTOM_TEXT_INPUT_PATH = `${module.exports.COMPONENTS_PATH}/CustomTextInput`; | ||
module.exports.CUSTOM_TEXT_INPUT = `${module.exports.CUSTOM_TEXT_INPUT_PATH}/index.js`; | ||
module.exports.CUSTOM_TEXT_INPUT_STYLES = `${module.exports.CUSTOM_TEXT_INPUT_PATH}/styles.js`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH = `${module.exports.CUSTOM_TEXT_INPUT_PATH}/assets`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_VISIBILITY = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH | ||
}/ic_visibility.png`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_VISIBILITY_2X = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH | ||
}/[email protected]`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_VISIBILITY_3X = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH | ||
}/[email protected]`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_VISIBILITY_OFF = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH | ||
}/ic_visibility_off.png`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_VISIBILITY_OFF_2X = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH | ||
}/[email protected]`; | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_VISIBILITY_OFF_3X = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_ASSETS_PATH | ||
}/[email protected]`; | ||
module.exports.CUSTOM_TEXT_INPUT_SHOW_PASSWORD_PATH = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_PATH | ||
}/components/ShowPassword`; | ||
module.exports.CUSTOM_TEXT_INPUT_SHOW_PASSWORD = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_SHOW_PASSWORD_PATH | ||
}/index.js`; | ||
module.exports.CUSTOM_TEXT_INPUT_SHOW_PASSWORD_STYLES = `${ | ||
module.exports.CUSTOM_TEXT_INPUT_SHOW_PASSWORD_PATH | ||
}/styles.js`; | ||
|
||
// COMPONENTS - CUSTOM TEXT | ||
module.exports.CUSTOM_BUTTON_PATH = `${module.exports.COMPONENTS_PATH}/CustomButton`; | ||
module.exports.CUSTOM_BUTTON = `${module.exports.CUSTOM_BUTTON_PATH}/index.js`; | ||
module.exports.CUSTOM_BUTTON_STYLES = `${module.exports.CUSTOM_BUTTON_PATH}/styles.js`; | ||
|
||
// COMPONENTS - DRAWER | ||
module.exports.DRAWER_PATH = `${module.exports.COMPONENTS_PATH}/Drawer`; | ||
module.exports.DRAWER_INDEX = `${module.exports.DRAWER_PATH}/index.js`; | ||
|
@@ -54,6 +92,11 @@ module.exports.DRAWER_OVERLAY_PATH = `${module.exports.DRAWER_PATH}/components/D | |
module.exports.DRAWER_OVERLAY_INDEX = `${module.exports.DRAWER_OVERLAY_PATH}/index.js`; | ||
module.exports.DRAWER_OVERLAY_STYLES = `${module.exports.DRAWER_OVERLAY_PATH}/styles.js`; | ||
|
||
// COMPONENTS - LOADABLE | ||
module.exports.LOADABLE_PATH = `${module.exports.COMPONENTS_PATH}/Loadable`; | ||
module.exports.LOADABLE = `${module.exports.LOADABLE_PATH}/index.js`; | ||
module.exports.LOADABLE_STYLES = `${module.exports.LOADABLE_PATH}/styles.js`; | ||
|
||
// REDUX | ||
module.exports.REDUX_STORE = `${module.exports.REDUX_PATH}/store.js`; | ||
|
||
|
@@ -93,6 +136,7 @@ module.exports.ROUTES_CONSTANTS = `${module.exports.CONSTANTS_PATH}/routes.js`; | |
module.exports.ARRAY_UTILS = `${module.exports.UTILS_PATH}/arrayUtils.js`; | ||
module.exports.I18N_UTILS = `${module.exports.UTILS_PATH}/i18nUtils.js`; | ||
module.exports.NAV_UTILS = `${module.exports.UTILS_PATH}/navUtils.js`; | ||
module.exports.STYLE_UTILS = `${module.exports.UTILS_PATH}/styleUtils.js`; | ||
|
||
// TEST | ||
module.exports.ARRAY_UTILS_TESTS = `${module.exports.TEST_PATH}/utils/arrayUtils.spec.js`; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { TouchableOpacity, Image, ViewPropTypes } from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import CustomText from '../CustomText'; | ||
import { getCustomStyles } from '../../../utils/styleUtils'; | ||
|
||
import styles from './styles'; | ||
|
||
class CustomButton extends PureComponent { | ||
static VARIANTS = ['borderless', 'radial', 'black', 'green', 'white', 'gray']; | ||
|
||
customStyles = () => getCustomStyles(CustomButton.VARIANTS, this.props, styles); | ||
|
||
customTextStyles = () => getCustomStyles(CustomButton.VARIANTS, this.props, styles, 'Content'); | ||
|
||
render() { | ||
const { | ||
onPress, | ||
style, | ||
activeOpacity, | ||
icon, | ||
title, | ||
iconStyle, | ||
disabled, | ||
textStyle, | ||
...textProps | ||
} = this.props; | ||
// TODO: Set android ripple while pressing a button | ||
return ( | ||
<TouchableOpacity | ||
onPress={onPress} | ||
style={[styles.container, this.customStyles(), style]} | ||
activeOpacity={activeOpacity} | ||
disabled={disabled} | ||
> | ||
{icon && <Image source={icon} resizeMode="contain" style={[styles.icon, iconStyle]} />} | ||
{title && ( | ||
<CustomText {...textProps} style={[styles.text, this.customTextStyles(), textStyle]}> | ||
{title} | ||
</CustomText> | ||
)} | ||
</TouchableOpacity> | ||
); | ||
} | ||
} | ||
|
||
CustomButton.defaultProps = { | ||
activeOpacity: 1 | ||
}; | ||
|
||
CustomButton.propTypes = { | ||
activeOpacity: PropTypes.number, | ||
disabled: PropTypes.bool, | ||
icon: PropTypes.number, | ||
iconStyle: ViewPropTypes.style, | ||
onPress: PropTypes.func.isRequired, | ||
style: ViewPropTypes.style, | ||
textStyle: PropTypes.number, | ||
title: PropTypes.string | ||
}; | ||
|
||
export default CustomButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
import { transparent, black, green, gray, white } from '../../../constants/colors'; | ||
|
||
const iconSize = 20; | ||
|
||
const borderlessStyle = { | ||
borderWidth: 0, | ||
backgroundColor: transparent | ||
}; | ||
|
||
export default StyleSheet.create({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think that we have all export default of styles file like @ignaciosantise wrote. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mvbattan if we are changing the export position of Stylesheets, we should change all of them in another PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, let's do it in another PR |
||
container: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: 8 | ||
}, | ||
icon: { | ||
height: iconSize, | ||
width: iconSize | ||
}, | ||
borderless: borderlessStyle, | ||
radial: { | ||
borderRadius: 100 | ||
}, | ||
black: { | ||
backgroundColor: black | ||
}, | ||
blackContent: { | ||
color: white | ||
}, | ||
white: { | ||
backgroundColor: white | ||
}, | ||
whiteContent: { | ||
color: black | ||
}, | ||
gray: { | ||
backgroundColor: gray | ||
}, | ||
grayContent: { | ||
color: black | ||
}, | ||
borderlessContent: { | ||
color: gray | ||
}, | ||
green: { | ||
backgroundColor: green | ||
}, | ||
text: { | ||
color: black | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { TouchableOpacity, Image } from 'react-native'; | ||
|
||
import icVisible from '../../assets/ic_visibility.png'; | ||
import icVisibleOff from '../../assets/ic_visibility_off.png'; | ||
|
||
import styles from './styles'; | ||
|
||
const ShowPassword = ({ onShowPassword, passwordVisible }) => ( | ||
<TouchableOpacity onPress={onShowPassword} style={styles.container}> | ||
<Image source={passwordVisible ? icVisible : icVisibleOff} resizeMode="contain" style={styles.icon} /> | ||
</TouchableOpacity> | ||
); | ||
|
||
ShowPassword.propTypes = { | ||
onShowPassword: PropTypes.func.isRequired, | ||
passwordVisible: PropTypes.bool.isRequired | ||
}; | ||
|
||
export default ShowPassword; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
export default StyleSheet.create({ | ||
container: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center' | ||
}, | ||
icon: { | ||
width: 20, | ||
marginLeft: 8 | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno. It's likely this
ic_visibility
is being repeated over and over