Chore: Evaluate TextInput - TypeScript (#3908)
* update `TextInput` component update: ActivityIndicator * remove: `any` * update: `TextInput` on `UIKit` * Fix returnKeyType Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
f90f1a326f
commit
e8d23791d3
|
@ -9,7 +9,7 @@ import { Q } from '@nozbe/watermelondb';
|
||||||
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
|
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
|
||||||
|
|
||||||
import { generateTriggerId } from '../../lib/methods/actions';
|
import { generateTriggerId } from '../../lib/methods/actions';
|
||||||
import TextInput from '../../presentation/TextInput';
|
import TextInput, { IThemedTextInput } from '../../presentation/TextInput';
|
||||||
import { userTyping as userTypingAction } from '../../actions/room';
|
import { userTyping as userTypingAction } from '../../actions/room';
|
||||||
import RocketChat from '../../lib/rocketchat';
|
import RocketChat from '../../lib/rocketchat';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
@ -1038,7 +1038,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
tmid
|
tmid
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const isAndroidTablet =
|
const isAndroidTablet: Partial<IThemedTextInput> =
|
||||||
isTablet && isAndroid
|
isTablet && isAndroid
|
||||||
? {
|
? {
|
||||||
multiline: false,
|
multiline: false,
|
||||||
|
@ -1090,7 +1090,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
<TextInput
|
<TextInput
|
||||||
ref={component => (this.component = component)}
|
ref={component => (this.component = component)}
|
||||||
style={[styles.textBoxInput, { color: themes[theme].bodyText }]}
|
style={[styles.textBoxInput, { color: themes[theme].bodyText }]}
|
||||||
// @ts-ignore
|
|
||||||
returnKeyType='default'
|
returnKeyType='default'
|
||||||
keyboardType='twitter'
|
keyboardType='twitter'
|
||||||
blurOnSubmit={false}
|
blurOnSubmit={false}
|
||||||
|
|
|
@ -52,10 +52,7 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
export interface IRCTextInputProps extends TextInputProps {
|
export interface IRCTextInputProps extends TextInputProps {
|
||||||
label?: string;
|
label?: string;
|
||||||
error?: {
|
error?: any;
|
||||||
error: any;
|
|
||||||
reason: any;
|
|
||||||
};
|
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
containerStyle?: StyleProp<ViewStyle>;
|
containerStyle?: StyleProp<ViewStyle>;
|
||||||
inputStyle?: StyleProp<TextStyle>;
|
inputStyle?: StyleProp<TextStyle>;
|
||||||
|
@ -68,7 +65,11 @@ export interface IRCTextInputProps extends TextInputProps {
|
||||||
theme: string;
|
theme: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class RCTextInput extends React.PureComponent<IRCTextInputProps, any> {
|
interface IRCTextInputState {
|
||||||
|
showPassword: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class RCTextInput extends React.PureComponent<IRCTextInputProps, IRCTextInputState> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
error: {},
|
error: {},
|
||||||
theme: 'light'
|
theme: 'light'
|
||||||
|
@ -120,7 +121,7 @@ export default class RCTextInput extends React.PureComponent<IRCTextInputProps,
|
||||||
}
|
}
|
||||||
|
|
||||||
tooglePassword = () => {
|
tooglePassword = () => {
|
||||||
this.setState((prevState: any) => ({ showPassword: !prevState.showPassword }));
|
this.setState(prevState => ({ showPassword: !prevState.showPassword }));
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -126,7 +126,6 @@ export const MultiSelect = React.memo(
|
||||||
<View style={[styles.content, { backgroundColor: themes[theme].backgroundColor }]}>
|
<View style={[styles.content, { backgroundColor: themes[theme].backgroundColor }]}>
|
||||||
<TextInput
|
<TextInput
|
||||||
testID='multi-select-search'
|
testID='multi-select-search'
|
||||||
/* @ts-ignore*/
|
|
||||||
onChangeText={onSearch || onSearchChange}
|
onChangeText={onSearch || onSearchChange}
|
||||||
placeholder={I18n.t('Search')}
|
placeholder={I18n.t('Search')}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
|
|
@ -187,16 +187,14 @@ class ModalParser extends UiKitParserModal {
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<TextInput
|
<TextInput
|
||||||
id={actionId}
|
key={actionId}
|
||||||
placeholder={plainText(placeholder)}
|
placeholder={plainText(placeholder)}
|
||||||
onInput={action}
|
|
||||||
multiline={multiline}
|
multiline={multiline}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onChangeText={(text: any) => action({ value: text })}
|
onChangeText={text => action({ value: text })}
|
||||||
inputStyle={multiline && styles.multiline}
|
inputStyle={multiline && styles.multiline}
|
||||||
containerStyle={styles.input}
|
containerStyle={styles.input}
|
||||||
value={value}
|
value={value}
|
||||||
// @ts-ignore
|
|
||||||
error={{ error }}
|
error={{ error }}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -10,7 +10,7 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IThemedTextInput extends IRCTextInputProps {
|
export interface IThemedTextInput extends IRCTextInputProps {
|
||||||
style: StyleProp<TextStyle>;
|
style: StyleProp<TextStyle>;
|
||||||
theme: string;
|
theme: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,6 @@ class CreateChannelView extends React.Component<ICreateChannelViewProps, any> {
|
||||||
testID='multi-select-discussion-name'
|
testID='multi-select-discussion-name'
|
||||||
placeholder={I18n.t('A_meaningful_name_for_the_discussion_room')}
|
placeholder={I18n.t('A_meaningful_name_for_the_discussion_room')}
|
||||||
containerStyle={styles.inputStyle}
|
containerStyle={styles.inputStyle}
|
||||||
/* @ts-ignore*/
|
|
||||||
defaultValue={name}
|
defaultValue={name}
|
||||||
onChangeText={(text: string) => this.setState({ name: text })}
|
onChangeText={(text: string) => this.setState({ name: text })}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
|
|
@ -186,7 +186,7 @@ class RegisterView extends React.Component<IProps, any> {
|
||||||
}}
|
}}
|
||||||
value={customFields[key]}>
|
value={customFields[key]}>
|
||||||
<TextInput
|
<TextInput
|
||||||
inputRef={(e: any) => {
|
inputRef={e => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this[key] = e;
|
this[key] = e;
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in New Issue