chore: Migrate JoinCode room to ts
This commit is contained in:
parent
1849c295a2
commit
7408cf88fe
|
@ -69,11 +69,6 @@ interface IRCTextInputProps extends TextInputProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class RCTextInput extends React.PureComponent<IRCTextInputProps, any> {
|
export default class RCTextInput extends React.PureComponent<IRCTextInputProps, any> {
|
||||||
static defaultProps = {
|
|
||||||
error: {},
|
|
||||||
theme: 'light'
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
showPassword: false
|
showPassword: false
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React, { forwardRef, useImperativeHandle, useState } from 'react';
|
import React, { forwardRef, useImperativeHandle, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { InteractionManager, StyleSheet, Text, View } from 'react-native';
|
import { InteractionManager, StyleSheet, Text, View } from 'react-native';
|
||||||
import Modal from 'react-native-modal';
|
import Modal from 'react-native-modal';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@ -41,10 +40,18 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface IRoomJoinCodeProps {
|
||||||
|
rid: string;
|
||||||
|
t: string;
|
||||||
|
onJoin: Function;
|
||||||
|
isMasterDetail: boolean;
|
||||||
|
theme: string;
|
||||||
|
}
|
||||||
|
|
||||||
const JoinCode = React.memo(
|
const JoinCode = React.memo(
|
||||||
forwardRef(({ rid, t, onJoin, isMasterDetail, theme }, ref) => {
|
forwardRef(({ rid, t, onJoin, isMasterDetail, theme }: IRoomJoinCodeProps, ref) => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState<any>(false);
|
||||||
const [code, setCode] = useState('');
|
const [code, setCode] = useState('');
|
||||||
|
|
||||||
const show = () => setVisible(true);
|
const show = () => setVisible(true);
|
||||||
|
@ -64,7 +71,7 @@ const JoinCode = React.memo(
|
||||||
useImperativeHandle(ref, () => ({ show }));
|
useImperativeHandle(ref, () => ({ show }));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal transparent avoidKeyboard useNativeDriver isVisible={visible} hideModalContentWhileAnimating>
|
<Modal avoidKeyboard useNativeDriver isVisible={visible} hideModalContentWhileAnimating>
|
||||||
<View style={styles.container} testID='join-code'>
|
<View style={styles.container} testID='join-code'>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
@ -76,7 +83,7 @@ const JoinCode = React.memo(
|
||||||
<TextInput
|
<TextInput
|
||||||
value={code}
|
value={code}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
inputRef={e => InteractionManager.runAfterInteractions(() => e?.getNativeRef()?.focus())}
|
inputRef={(e: any) => InteractionManager.runAfterInteractions(() => e?.getNativeRef()?.focus())}
|
||||||
returnKeyType='send'
|
returnKeyType='send'
|
||||||
autoCapitalize='none'
|
autoCapitalize='none'
|
||||||
onChangeText={setCode}
|
onChangeText={setCode}
|
||||||
|
@ -111,15 +118,8 @@ const JoinCode = React.memo(
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
JoinCode.propTypes = {
|
|
||||||
rid: PropTypes.string,
|
|
||||||
t: PropTypes.string,
|
|
||||||
onJoin: PropTypes.func,
|
|
||||||
isMasterDetail: PropTypes.bool,
|
|
||||||
theme: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = (state: any) => ({
|
||||||
isMasterDetail: state.app.isMasterDetail
|
isMasterDetail: state.app.isMasterDetail
|
||||||
});
|
});
|
||||||
export default connect(mapStateToProps, null, null, { forwardRef: true })(JoinCode);
|
export default connect(mapStateToProps, null, null, { forwardRef: true })(JoinCode);
|
Loading…
Reference in New Issue