Unverified Commit e8d23791 authored by Gerzon Z's avatar Gerzon Z Committed by GitHub
Browse files

Chore: Evaluate TextInput - TypeScript (#3908)



* update `TextInput` component

update: ActivityIndicator

* remove: `any`

* update: `TextInput` on `UIKit`

* Fix returnKeyType

Co-authored-by: default avatarDiego Mello <diegolmello@gmail.com>
parent f90f1a32
......@@ -9,7 +9,7 @@ import { Q } from '@nozbe/watermelondb';
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
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 RocketChat from '../../lib/rocketchat';
import styles from './styles';
......@@ -1038,7 +1038,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
tmid
} = this.props;
const isAndroidTablet =
const isAndroidTablet: Partial<IThemedTextInput> =
isTablet && isAndroid
? {
multiline: false,
......@@ -1090,7 +1090,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
<TextInput
ref={component => (this.component = component)}
style={[styles.textBoxInput, { color: themes[theme].bodyText }]}
// @ts-ignore
returnKeyType='default'
keyboardType='twitter'
blurOnSubmit={false}
......
......@@ -52,10 +52,7 @@ const styles = StyleSheet.create({
export interface IRCTextInputProps extends TextInputProps {
label?: string;
error?: {
error: any;
reason: any;
};
error?: any;
loading?: boolean;
containerStyle?: StyleProp<ViewStyle>;
inputStyle?: StyleProp<TextStyle>;
......@@ -68,7 +65,11 @@ export interface IRCTextInputProps extends TextInputProps {
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 = {
error: {},
theme: 'light'
......@@ -120,7 +121,7 @@ export default class RCTextInput extends React.PureComponent<IRCTextInputProps,
}
tooglePassword = () => {
this.setState((prevState: any) => ({ showPassword: !prevState.showPassword }));
this.setState(prevState => ({ showPassword: !prevState.showPassword }));
};
render() {
......
......@@ -126,7 +126,6 @@ export const MultiSelect = React.memo(
<View style={[styles.content, { backgroundColor: themes[theme].backgroundColor }]}>
<TextInput
testID='multi-select-search'
/* @ts-ignore*/
onChangeText={onSearch || onSearchChange}
placeholder={I18n.t('Search')}
theme={theme}
......
......@@ -187,16 +187,14 @@ class ModalParser extends UiKitParserModal {
return (
// @ts-ignore
<TextInput
id={actionId}
key={actionId}
placeholder={plainText(placeholder)}
onInput={action}
multiline={multiline}
loading={loading}
onChangeText={(text: any) => action({ value: text })}
onChangeText={text => action({ value: text })}
inputStyle={multiline && styles.multiline}
containerStyle={styles.input}
value={value}
// @ts-ignore
error={{ error }}
theme={theme}
/>
......
......@@ -10,7 +10,7 @@ const styles = StyleSheet.create({
}
});
interface IThemedTextInput extends IRCTextInputProps {
export interface IThemedTextInput extends IRCTextInputProps {
style: StyleProp<TextStyle>;
theme: string;
}
......
......@@ -175,7 +175,6 @@ class CreateChannelView extends React.Component<ICreateChannelViewProps, any> {
testID='multi-select-discussion-name'
placeholder={I18n.t('A_meaningful_name_for_the_discussion_room')}
containerStyle={styles.inputStyle}
/* @ts-ignore*/
defaultValue={name}
onChangeText={(text: string) => this.setState({ name: text })}
theme={theme}
......
......@@ -186,7 +186,7 @@ class RegisterView extends React.Component<IProps, any> {
}}
value={customFields[key]}>
<TextInput
inputRef={(e: any) => {
inputRef={e => {
// @ts-ignore
this[key] = e;
}}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment