diff --git a/native/chat/settings/thread-settings-avatar.react.js b/native/chat/settings/thread-settings-avatar.react.js new file mode 100644 --- /dev/null +++ b/native/chat/settings/thread-settings-avatar.react.js @@ -0,0 +1,39 @@ +// @flow + +import * as React from 'react'; +import { View } from 'react-native'; + +import { useGetAvatarForThread } from 'lib/shared/avatar-utils.js'; +import { type ThreadInfo } from 'lib/types/thread-types.js'; +import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; + +import Avatar from '../../components/avatar.react.js'; +import { useStyles } from '../../themes/colors.js'; + +type Props = { + +threadInfo: ThreadInfo, +}; +function ThreadSettingsAvatar(props: Props): React.Node { + const resolvedThreadInfo = useResolvedThreadInfo(props.threadInfo); + + const styles = useStyles(unboundStyles); + const avatarInfo = useGetAvatarForThread(resolvedThreadInfo); + + const avatar = React.useMemo( + () => , + [avatarInfo], + ); + + return {avatar}; +} + +const unboundStyles = { + container: { + alignItems: 'center', + backgroundColor: 'panelForeground', + flex: 1, + paddingVertical: 16, + }, +}; + +export default ThreadSettingsAvatar; diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js --- a/native/chat/settings/thread-settings.react.js +++ b/native/chat/settings/thread-settings.react.js @@ -43,6 +43,7 @@ useResolvedOptionalThreadInfos, } from 'lib/utils/entity-helpers.js'; +import ThreadSettingsAvatar from './thread-settings-avatar.react.js'; import type { CategoryType } from './thread-settings-category.react.js'; import { ThreadSettingsCategoryHeader, @@ -94,6 +95,7 @@ } from '../../themes/colors.js'; import type { VerticalBounds } from '../../types/layout-types.js'; import type { ViewStyle } from '../../types/styles.js'; +import { useShouldRenderAvatars } from '../../utils/avatar-utils.js'; import type { ChatNavigationProp } from '../chat.react.js'; const itemPageLength = 5; @@ -126,6 +128,11 @@ +key: string, +categoryType: CategoryType, } + | { + +itemType: 'avatar', + +key: string, + +threadInfo: ResolvedThreadInfo, + } | { +itemType: 'name', +key: string, @@ -246,6 +253,7 @@ // withKeyboardState +keyboardState: ?KeyboardState, +canPromoteSidebar: boolean, + +shouldRenderAvatars: boolean, }; type State = { +numMembersShowing: number, @@ -341,6 +349,25 @@ const canChangeColor = canEditThreadColor && canStartEditing; const listData: ChatSettingsItem[] = []; + if (this.props.shouldRenderAvatars) { + listData.push({ + itemType: 'header', + key: 'avatarHeader', + title: 'Channel Avatar', + categoryType: 'unpadded', + }); + listData.push({ + itemType: 'avatar', + key: 'avatar', + threadInfo, + }); + listData.push({ + itemType: 'footer', + key: 'avatarFooter', + categoryType: 'outline', + }); + } + listData.push({ itemType: 'header', key: 'basicsHeader', @@ -878,6 +905,8 @@ ); } else if (item.itemType === 'footer') { return ; + } else if (item.itemType === 'avatar') { + return ; } else if (item.itemType === 'name') { return ( ); });