diff --git a/native/chat/settings/compose-subthread-modal.react.js b/native/chat/settings/compose-subthread-modal.react.js index d44c72b58..f85543495 100644 --- a/native/chat/settings/compose-subthread-modal.react.js +++ b/native/chat/settings/compose-subthread-modal.react.js @@ -1,163 +1,142 @@ // @flow -import PropTypes from 'prop-types'; import * as React from 'react'; import { Text } from 'react-native'; import IonIcon from 'react-native-vector-icons/Ionicons'; import Icon from 'react-native-vector-icons/MaterialIcons'; import { threadTypeDescriptions } from 'lib/shared/thread-utils'; -import { - type ThreadInfo, - threadInfoPropType, - threadTypes, -} from 'lib/types/thread-types'; -import { connect } from 'lib/utils/redux-utils'; +import { type ThreadInfo, threadTypes } from 'lib/types/thread-types'; import Button from '../../components/button.react'; import Modal from '../../components/modal.react'; import type { RootNavigationProp } from '../../navigation/root-navigator.react'; import type { NavigationRoute } from '../../navigation/route-names'; import { ComposeThreadRouteName } from '../../navigation/route-names'; -import type { AppState } from '../../redux/redux-setup'; -import { - type Colors, - colorsPropType, - colorsSelector, - styleSelector, -} from '../../themes/colors'; +import { type Colors, useStyles, useColors } from '../../themes/colors'; export type ComposeSubthreadModalParams = {| presentedFrom: string, threadInfo: ThreadInfo, |}; +type BaseProps = {| + +navigation: RootNavigationProp<'ComposeSubthreadModal'>, + +route: NavigationRoute<'ComposeSubthreadModal'>, +|}; type Props = {| - navigation: RootNavigationProp<'ComposeSubthreadModal'>, - route: NavigationRoute<'ComposeSubthreadModal'>, - // Redux state - colors: Colors, - styles: typeof styles, + ...BaseProps, + +colors: Colors, + +styles: typeof unboundStyles, |}; class ComposeSubthreadModal extends React.PureComponent { - static propTypes = { - navigation: PropTypes.shape({ - navigate: PropTypes.func.isRequired, - }).isRequired, - route: PropTypes.shape({ - params: PropTypes.shape({ - presentedFrom: PropTypes.string.isRequired, - threadInfo: threadInfoPropType.isRequired, - }).isRequired, - }).isRequired, - colors: colorsPropType.isRequired, - styles: PropTypes.objectOf(PropTypes.object).isRequired, - }; - render() { return ( Thread type ); } onPressOpen = () => { const threadInfo = this.props.route.params.threadInfo; this.props.navigation.navigate({ name: ComposeThreadRouteName, params: { threadType: threadTypes.CHAT_NESTED_OPEN, parentThreadInfo: threadInfo, }, key: `${ComposeThreadRouteName}|${threadInfo.id}|${threadTypes.CHAT_NESTED_OPEN}`, }); }; onPressSecret = () => { const threadInfo = this.props.route.params.threadInfo; this.props.navigation.navigate({ name: ComposeThreadRouteName, params: { threadType: threadTypes.CHAT_SECRET, parentThreadInfo: threadInfo, }, key: `${ComposeThreadRouteName}|${threadInfo.id}|${threadTypes.CHAT_SECRET}`, }); }; } -const styles = { +const unboundStyles = { forwardIcon: { color: 'link', paddingLeft: 10, }, modal: { flex: 0, }, option: { alignItems: 'center', flexDirection: 'row', paddingHorizontal: 10, paddingVertical: 20, }, optionExplanation: { color: 'modalBackgroundLabel', flex: 1, fontSize: 14, paddingLeft: 20, textAlign: 'center', }, optionText: { color: 'modalBackgroundLabel', fontSize: 20, paddingLeft: 5, }, visibility: { color: 'modalBackgroundLabel', fontSize: 24, textAlign: 'center', }, visibilityIcon: { color: 'modalBackgroundLabel', paddingRight: 3, }, }; -const stylesSelector = styleSelector(styles); -export default connect((state: AppState) => ({ - colors: colorsSelector(state), - styles: stylesSelector(state), -}))(ComposeSubthreadModal); +export default React.memo(function ConnectedComposeSubthreadModal( + props: BaseProps, +) { + const styles = useStyles(unboundStyles); + const colors = useColors(); + + return ; +});