From 349e10e328ab8aff06c87436972f2d6385aa210a Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 7 Apr 2022 16:25:25 -0400 Subject: [PATCH] Chore: TypeScript Migration - evaluate DirectoryItem (#4016) * chore: evaluate DirectoryItem * chore: move `DirectoryItem` to `containers` * update: `themes` import --- app/containers/DirectoryItem/index.tsx | 74 +++++++++++++++++++ .../DirectoryItem/styles.ts | 0 app/presentation/DirectoryItem/index.tsx | 72 ------------------ app/views/DirectoryView/index.tsx | 2 +- app/views/ShareListView/index.tsx | 4 +- 5 files changed, 76 insertions(+), 76 deletions(-) create mode 100644 app/containers/DirectoryItem/index.tsx rename app/{presentation => containers}/DirectoryItem/styles.ts (100%) delete mode 100644 app/presentation/DirectoryItem/index.tsx diff --git a/app/containers/DirectoryItem/index.tsx b/app/containers/DirectoryItem/index.tsx new file mode 100644 index 000000000..14d4c361d --- /dev/null +++ b/app/containers/DirectoryItem/index.tsx @@ -0,0 +1,74 @@ +import React from 'react'; +import { Text, View, ViewStyle } from 'react-native'; + +import Touch from '../../utils/touch'; +import Avatar from '../Avatar'; +import RoomTypeIcon from '../RoomTypeIcon'; +import styles, { ROW_HEIGHT } from './styles'; +import { themes } from '../../lib/constants'; +import { useTheme } from '../../theme'; + +export { ROW_HEIGHT }; + +interface IDirectoryItemLabel { + text?: string; + theme: string; +} + +interface IDirectoryItem { + title: string; + description: string; + avatar: string; + type: string; + onPress(): void; + testID: string; + style?: ViewStyle; + rightLabel?: string; + rid?: string; + teamMain?: boolean; +} + +const DirectoryItemLabel = React.memo(({ text, theme }: IDirectoryItemLabel) => { + if (!text) { + return null; + } + return {text}; +}); + +const DirectoryItem = ({ + title, + description, + avatar, + onPress, + testID, + style, + rightLabel, + type, + rid, + teamMain +}: IDirectoryItem): React.ReactElement => { + const { theme } = useTheme(); + return ( + + + + + + + + {title} + + + {description ? ( + + {description} + + ) : null} + + + + + ); +}; + +export default DirectoryItem; diff --git a/app/presentation/DirectoryItem/styles.ts b/app/containers/DirectoryItem/styles.ts similarity index 100% rename from app/presentation/DirectoryItem/styles.ts rename to app/containers/DirectoryItem/styles.ts diff --git a/app/presentation/DirectoryItem/index.tsx b/app/presentation/DirectoryItem/index.tsx deleted file mode 100644 index 1cdbe63e8..000000000 --- a/app/presentation/DirectoryItem/index.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import React from 'react'; -import { Text, View, ViewStyle } from 'react-native'; - -import Touch from '../../utils/touch'; -import Avatar from '../../containers/Avatar'; -import RoomTypeIcon from '../../containers/RoomTypeIcon'; -import styles, { ROW_HEIGHT } from './styles'; -import { themes } from '../../lib/constants'; - -export { ROW_HEIGHT }; - -interface IDirectoryItemLabel { - text?: string; - theme: string; -} - -interface IDirectoryItem { - title: string; - description: string; - avatar: string; - type: string; - onPress(): void; - testID: string; - style?: ViewStyle; - rightLabel?: string; - rid?: string; - theme: string; - teamMain?: boolean; -} - -const DirectoryItemLabel = React.memo(({ text, theme }: IDirectoryItemLabel) => { - if (!text) { - return null; - } - return {text}; -}); - -const DirectoryItem = ({ - title, - description, - avatar, - onPress, - testID, - style, - rightLabel, - type, - rid, - theme, - teamMain -}: IDirectoryItem): JSX.Element => ( - - - - - - - - {title} - - - {description ? ( - - {description} - - ) : null} - - - - -); - -export default DirectoryItem; diff --git a/app/views/DirectoryView/index.tsx b/app/views/DirectoryView/index.tsx index 9cc0c3749..8a53a04fd 100644 --- a/app/views/DirectoryView/index.tsx +++ b/app/views/DirectoryView/index.tsx @@ -7,7 +7,7 @@ import { ChatsStackParamList } from '../../stacks/types'; import * as List from '../../containers/List'; import Touch from '../../utils/touch'; import RocketChat from '../../lib/rocketchat'; -import DirectoryItem from '../../presentation/DirectoryItem'; +import DirectoryItem from '../../containers/DirectoryItem'; import sharedStyles from '../Styles'; import I18n from '../../i18n'; import SearchBox from '../../containers/SearchBox'; diff --git a/app/views/ShareListView/index.tsx b/app/views/ShareListView/index.tsx index 581345e79..9343d148d 100644 --- a/app/views/ShareListView/index.tsx +++ b/app/views/ShareListView/index.tsx @@ -11,7 +11,7 @@ import { Q } from '@nozbe/watermelondb'; import database from '../../lib/database'; import { isAndroid, isIOS } from '../../utils/deviceInfo'; import I18n from '../../i18n'; -import DirectoryItem, { ROW_HEIGHT } from '../../presentation/DirectoryItem'; +import DirectoryItem, { ROW_HEIGHT } from '../../containers/DirectoryItem'; import ServerItem from '../../containers/ServerItem'; import * as HeaderButton from '../../containers/HeaderButton'; import ActivityIndicator from '../../containers/ActivityIndicator'; @@ -371,7 +371,6 @@ class ShareListView extends React.Component { renderItem = ({ item }: { item: IChat }) => { const { serverInfo } = this.state; - const { theme } = this.props; let description; switch (item.t) { case 'c': @@ -395,7 +394,6 @@ class ShareListView extends React.Component { type={item.prid ? 'discussion' : item.t} onPress={() => this.shareMessage(item)} testID={`share-extension-item-${item.name}`} - theme={theme} /> ); };