Changeset View
Changeset View
Standalone View
Standalone View
native/navigation/community-drawer-item.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { View, FlatList, TouchableOpacity } from 'react-native'; | import { View, FlatList, TouchableOpacity } from 'react-native'; | ||||
import type { ThreadInfo } from 'lib/types/thread-types.js'; | import type { CommunityDrawerItemData } from 'lib/utils/drawer-utils.react.js'; | ||||
import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; | import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; | ||||
import { ExpandButton, ExpandButtonDisabled } from './expand-buttons.react.js'; | import { ExpandButton, ExpandButtonDisabled } from './expand-buttons.react.js'; | ||||
import SubchannelsButton from './subchannels-button.react.js'; | import SubchannelsButton from './subchannels-button.react.js'; | ||||
import type { MessageListParams } from '../chat/message-list-types.js'; | import type { MessageListParams } from '../chat/message-list-types.js'; | ||||
import { SingleLine } from '../components/single-line.react.js'; | import { SingleLine } from '../components/single-line.react.js'; | ||||
import { useStyles } from '../themes/colors.js'; | import { useStyles } from '../themes/colors.js'; | ||||
import type { TextStyle } from '../types/styles.js'; | import type { TextStyle } from '../types/styles.js'; | ||||
export type CommunityDrawerItemData = { | |||||
+threadInfo: ThreadInfo, | |||||
+itemChildren?: $ReadOnlyArray<CommunityDrawerItemData>, | |||||
+labelStyle: TextStyle, | |||||
+hasSubchannelsButton: boolean, | |||||
}; | |||||
export type DrawerItemProps = { | export type DrawerItemProps = { | ||||
+itemData: CommunityDrawerItemData, | +itemData: CommunityDrawerItemData<TextStyle>, | ||||
+toggleExpanded: (threadID: string) => void, | +toggleExpanded: (threadID: string) => void, | ||||
+expanded: boolean, | +expanded: boolean, | ||||
+navigateToThread: (params: MessageListParams) => void, | +navigateToThread: (params: MessageListParams) => void, | ||||
}; | }; | ||||
function CommunityDrawerItem(props: DrawerItemProps): React.Node { | function CommunityDrawerItem(props: DrawerItemProps): React.Node { | ||||
const { | const { | ||||
itemData: { threadInfo, itemChildren, labelStyle, hasSubchannelsButton }, | itemData: { threadInfo, itemChildren, labelStyle, hasSubchannelsButton }, | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | const unboundStyles = { | ||||
}, | }, | ||||
subchannelsButton: { | subchannelsButton: { | ||||
marginLeft: 24, | marginLeft: 24, | ||||
marginBottom: 6, | marginBottom: 6, | ||||
}, | }, | ||||
}; | }; | ||||
export type CommunityDrawerItemChatProps = { | export type CommunityDrawerItemChatProps = { | ||||
+itemData: CommunityDrawerItemData, | +itemData: CommunityDrawerItemData<TextStyle>, | ||||
+navigateToThread: (params: MessageListParams) => void, | +navigateToThread: (params: MessageListParams) => void, | ||||
}; | }; | ||||
function CommunityDrawerItemChat( | function CommunityDrawerItemChat( | ||||
props: CommunityDrawerItemChatProps, | props: CommunityDrawerItemChatProps, | ||||
): React.Node { | ): React.Node { | ||||
const [expanded, setExpanded] = React.useState(false); | const [expanded, setExpanded] = React.useState(false); | ||||
const styles = useStyles(unboundStyles); | const styles = useStyles(unboundStyles); | ||||
Show All 24 Lines |