-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Expensify/Expensify.cash into edited
- Loading branch information
Showing
20 changed files
with
205 additions
and
118 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,81 @@ | ||
import React from 'react'; | ||
import {TextInput} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'underscore'; | ||
import themeColors from '../../styles/themes/default'; | ||
|
||
/** | ||
* On native layers we like to have the Text Input not focused so the user can read new chats without they keyboard in | ||
* the way of the view | ||
* On Android, the selection prop is required on the TextInput but this prop has issues on IOS | ||
* https://github.com/facebook/react-native/issues/29063 | ||
*/ | ||
|
||
const propTypes = { | ||
/** If the input should clear, it actually gets intercepted instead of .clear() */ | ||
shouldClear: PropTypes.bool, | ||
|
||
/** A ref to forward to the text input */ | ||
forwardedRef: PropTypes.func, | ||
|
||
/** When the input has cleared whoever owns this input should know about it */ | ||
onClear: PropTypes.func, | ||
|
||
/** Set focus to this component the first time it renders. | ||
* Override this in case you need to set focus on one field out of many, or when you want to disable autoFocus */ | ||
autoFocus: PropTypes.bool, | ||
|
||
/** Prevent edits and interactions like focus for this input. */ | ||
isDisabled: PropTypes.bool, | ||
|
||
}; | ||
|
||
const defaultProps = { | ||
shouldClear: false, | ||
onClear: () => {}, | ||
autoFocus: false, | ||
isDisabled: false, | ||
forwardedRef: null, | ||
}; | ||
|
||
class TextInputFocusable extends React.Component { | ||
componentDidMount() { | ||
// This callback prop is used by the parent component using the constructor to | ||
// get a ref to the inner textInput element e.g. if we do | ||
// <constructor ref={el => this.textInput = el} /> this will not | ||
// return a ref to the component, but rather the HTML element by default | ||
if (this.props.forwardedRef && _.isFunction(this.props.forwardedRef)) { | ||
this.props.forwardedRef(this.textInput); | ||
} | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
if (!prevProps.shouldClear && this.props.shouldClear) { | ||
this.textInput.clear(); | ||
this.props.onClear(); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<TextInput | ||
placeholderTextColor={themeColors.placeholderText} | ||
ref={el => this.textInput = el} | ||
maxHeight={116} | ||
rejectResponderTermination={false} | ||
editable={!this.props.isDisabled} | ||
/* eslint-disable-next-line react/jsx-props-no-spreading */ | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
TextInputFocusable.displayName = 'TextInputFocusable'; | ||
TextInputFocusable.propTypes = propTypes; | ||
TextInputFocusable.defaultProps = defaultProps; | ||
|
||
export default React.forwardRef((props, ref) => ( | ||
/* eslint-disable-next-line react/jsx-props-no-spreading */ | ||
<TextInputFocusable {...props} forwardedRef={ref} /> | ||
)); |
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
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
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.