-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add the NewRoomPage
#6314
Add the NewRoomPage
#6314
Changes from all commits
020c905
d3de848
cb21b63
ad233af
06480a3
5ff5cd7
6beddeb
e029ca2
ca2c8dc
f20186f
c8aedbf
57b0dc1
758f52d
0169faf
38a4334
57d78fe
791c561
e209667
309836a
fa2eca0
6554d32
b936cbf
9ef9565
0f52610
9c06ec5
068a8cd
d731cf4
bd5f153
60293f7
9c6dddc
e5981d3
f7d26eb
b31eb64
b0a57a7
18ac388
216edb3
d0ddaa6
e2dbd3e
5bb254f
8855bce
64024cf
63b68f5
6da57f5
5d89b6c
6e0ed17
684401e
e2d3944
b83df70
87a7f08
3c09488
9ea046a
8f01cb3
fb9b7fb
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import PropTypes from 'prop-types'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import {TextInput, View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import React from 'react'; | ||
import ExpensifyText from '../ExpensifyText'; | ||
import styles from '../../styles/styles'; | ||
|
||
const propTypes = { | ||
/** Prefix character */ | ||
prefixCharacter: PropTypes.string, | ||
|
||
/** Text to show if there is an error */ | ||
errorText: PropTypes.string, | ||
|
||
/** Whether to disable the field and style */ | ||
disabled: PropTypes.bool, | ||
|
||
/** Callback to execute the text input is modified */ | ||
onChangeText: PropTypes.func, | ||
}; | ||
|
||
const defaultProps = { | ||
errorText: '', | ||
prefixCharacter: '', | ||
disabled: false, | ||
onChangeText: () => {}, | ||
}; | ||
|
||
const TextInputWithPrefix = props => (_.isEmpty(props.prefixCharacter) | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
? <TextInput {..._.omit(props, ['prefixCharacter', 'errorText'])} /> | ||
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. Same comment about props spreading as the one above. 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. Here, there are other |
||
: ( | ||
<View | ||
style={[ | ||
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. Same here, linter was being weird. |
||
styles.textInputWithPrefix.container, | ||
{paddingTop: 0}, | ||
props.disabled && styles.inputDisabled, | ||
props.errorText && styles.errorOutline, | ||
]} | ||
> | ||
<ExpensifyText style={[styles.textInputWithPrefix.prefix, {paddingTop: 10}]}>{props.prefixCharacter}</ExpensifyText> | ||
<TextInput | ||
style={[ | ||
styles.textInputWithPrefix.textInput, | ||
styles.noOutline, | ||
{height: 40}, | ||
]} | ||
onChangeText={text => props.onChangeText(`${props.prefixCharacter}${text}`)} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{..._.omit(props, ['prefixCharacter', 'errorText', 'onChangeText'])} | ||
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. Same as above, let's just explicitly list out the props to pass if we can |
||
/> | ||
</View> | ||
)); | ||
|
||
TextInputWithPrefix.propTypes = propTypes; | ||
TextInputWithPrefix.defaultProps = defaultProps; | ||
export default TextInputWithPrefix; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import PropTypes from 'prop-types'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import {TextInput, View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import React from 'react'; | ||
import ExpensifyText from '../ExpensifyText'; | ||
import styles from '../../styles/styles'; | ||
|
||
const propTypes = { | ||
/** Prefix character */ | ||
prefixCharacter: PropTypes.string, | ||
|
||
/** Text to show if there is an error */ | ||
errorText: PropTypes.string, | ||
|
||
/** Whether to disable the field and style */ | ||
disabled: PropTypes.bool, | ||
|
||
/** Callback to execute the text input is modified */ | ||
onChangeText: PropTypes.func, | ||
}; | ||
|
||
const defaultProps = { | ||
errorText: '', | ||
prefixCharacter: '', | ||
disabled: false, | ||
onChangeText: () => {}, | ||
}; | ||
|
||
const TextInputWithPrefix = props => (_.isEmpty(props.prefixCharacter) | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
? <TextInput {..._.omit(props, ['prefixCharacter', 'errorText'])} /> | ||
: ( | ||
<View | ||
style={[ | ||
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. Linter was being weird here and required an extra 4 spaces for some reason, hence the extra indent 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. Is this a problem with our linter? |
||
styles.textInputWithPrefix.container, | ||
props.disabled ? styles.inputDisabled : undefined, | ||
props.errorText ? styles.errorOutline : undefined, | ||
]} | ||
> | ||
<ExpensifyText style={styles.textInputWithPrefix.prefix}>{props.prefixCharacter}</ExpensifyText> | ||
<TextInput | ||
style={[ | ||
styles.textInputWithPrefix.textInput, | ||
styles.noOutline, | ||
]} | ||
onChangeText={text => props.onChangeText(`${props.prefixCharacter}${text}`)} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{..._.omit(props, ['prefixCharacter', 'errorText', 'onChangeText'])} | ||
/> | ||
</View> | ||
)); | ||
|
||
TextInputWithPrefix.propTypes = propTypes; | ||
TextInputWithPrefix.defaultProps = defaultProps; | ||
export default TextInputWithPrefix; |
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.
@yuwenmemon See my comment here about implicitly passing
TextInput
props.