diff --git a/native/chat/chat-thread-list-item.react.js b/native/chat/chat-thread-list-item.react.js --- a/native/chat/chat-thread-list-item.react.js +++ b/native/chat/chat-thread-list-item.react.js @@ -56,6 +56,10 @@ ); }, [data.mostRecentMessageInfo, data.threadInfo, styles]); + const numOfSidebarsWithExtendedArrow = + data.sidebars.filter(sidebarItem => sidebarItem.type === 'sidebar').length - + 1; + const sidebars = data.sidebars.map((sidebarItem, index) => { if (sidebarItem.type === 'sidebar') { const { type, ...sidebarInfo } = sidebarItem; @@ -66,7 +70,7 @@ onSwipeableWillOpen={onSwipeableWillOpen} currentlyOpenedSwipeableId={currentlyOpenedSwipeableId} key={sidebarItem.threadInfo.id} - extendArrow={index > 0} + extendArrow={index < numOfSidebarsWithExtendedArrow} /> ); } else if (sidebarItem.type === 'seeMore') { diff --git a/native/chat/chat-thread-list-sidebar.react.js b/native/chat/chat-thread-list-sidebar.react.js --- a/native/chat/chat-thread-list-sidebar.react.js +++ b/native/chat/chat-thread-list-sidebar.react.js @@ -1,14 +1,16 @@ // @flow import * as React from 'react'; -import { View, StyleSheet } from 'react-native'; +import { View } from 'react-native'; import type { ThreadInfo, SidebarInfo } from 'lib/types/thread-types'; -import ArrowLong from '../components/arrow-long.react'; +import ExtendedArrow from '../components/arrow-extended.react'; import Arrow from '../components/arrow.react'; +import Button from '../components/button.react'; import UnreadDot from '../components/unread-dot.react'; -import { SidebarItem } from './sidebar-item.react'; +import { useColors, useStyles } from '../themes/colors'; +import { SidebarItem, sidebarHeight } from './sidebar-item.react'; import SwipeableThread from './swipeable-thread.react'; type Props = { @@ -19,6 +21,9 @@ +extendArrow: boolean, }; function ChatThreadListSidebar(props: Props): React.Node { + const colors = useColors(); + const styles = useStyles(unboundStyles); + const { sidebarInfo, onSwipeableWillOpen, @@ -30,8 +35,8 @@ let arrow; if (extendArrow) { arrow = ( - - + + ); } else { @@ -42,8 +47,21 @@ ); } + const { threadInfo } = sidebarInfo; + + const onPress = React.useCallback(() => onPressItem(threadInfo), [ + threadInfo, + onPressItem, + ]); + return ( - + ); } -const styles = StyleSheet.create({ +const unboundStyles = { arrow: { - left: 27.5, + left: 28, position: 'absolute', top: -12, }, - chatThreadListContainer: { - display: 'flex', - flexDirection: 'row', - }, - longArrow: { + extendedArrow: { left: 28, position: 'absolute', - top: -19, + top: -6, + }, + sidebar: { + alignItems: 'center', + flexDirection: 'row', + width: '100%', + height: sidebarHeight, + paddingLeft: 6, + paddingRight: 18, + backgroundColor: 'listBackground', }, swipeableThreadContainer: { flex: 1, + height: '100%', }, unreadIndicatorContainer: { - display: 'flex', - justifyContent: 'center', + alignItems: 'center', + flexDirection: 'row', + justifyContent: 'flex-start', paddingLeft: 6, width: 56, }, -}); +}; export default ChatThreadListSidebar; diff --git a/native/chat/sidebar-item.react.js b/native/chat/sidebar-item.react.js --- a/native/chat/sidebar-item.react.js +++ b/native/chat/sidebar-item.react.js @@ -1,20 +1,16 @@ // @flow import * as React from 'react'; -import { Text } from 'react-native'; +import { Text, View } from 'react-native'; -import type { ThreadInfo, SidebarInfo } from 'lib/types/thread-types'; +import type { SidebarInfo } from 'lib/types/thread-types'; import { shortAbsoluteDate } from 'lib/utils/date-utils'; -import Button from '../components/button.react'; import { SingleLine } from '../components/single-line.react'; -import { useColors, useStyles } from '../themes/colors'; -import type { ViewStyle } from '../types/styles'; +import { useStyles } from '../themes/colors'; type Props = { +sidebarInfo: SidebarInfo, - +onPressItem: (threadInfo: ThreadInfo) => void, - +style?: ?ViewStyle, }; function SidebarItem(props: Props): React.Node { const { lastUpdatedTime } = props.sidebarInfo; @@ -24,49 +20,27 @@ const styles = useStyles(unboundStyles); const unreadStyle = threadInfo.currentUser.unread ? styles.unread : null; - const { onPressItem } = props; - const onPress = React.useCallback(() => onPressItem(threadInfo), [ - threadInfo, - onPressItem, - ]); - - const colors = useColors(); - - const sidebarStyle = React.useMemo(() => { - return [styles.sidebar, props.style]; - }, [props.style, styles.sidebar]); - return ( - + ); } const sidebarHeight = 30; const unboundStyles = { + itemContainer: { + flexDirection: 'row', + height: sidebarHeight, + alignItems: 'center', + }, unread: { color: 'listForegroundLabel', fontWeight: 'bold', }, - sidebar: { - height: sidebarHeight, - flexDirection: 'row', - display: 'flex', - paddingLeft: 6, - paddingRight: 18, - alignItems: 'center', - backgroundColor: 'listBackground', - }, name: { color: 'listForegroundSecondaryLabel', flex: 1, diff --git a/native/chat/sidebar-list-modal.react.js b/native/chat/sidebar-list-modal.react.js --- a/native/chat/sidebar-list-modal.react.js +++ b/native/chat/sidebar-list-modal.react.js @@ -1,17 +1,19 @@ // @flow import * as React from 'react'; -import { TextInput, FlatList, StyleSheet, View } from 'react-native'; +import { TextInput, FlatList, View } from 'react-native'; import { useSearchSidebars } from 'lib/hooks/search-sidebars'; import type { ThreadInfo, SidebarInfo } from 'lib/types/thread-types'; -import ArrowLong from '../components/arrow-long.react'; +import ExtendedArrow from '../components/arrow-extended.react'; +import Arrow from '../components/arrow.react'; +import Button from '../components/button.react'; import Modal from '../components/modal.react'; import Search from '../components/search.react'; import type { RootNavigationProp } from '../navigation/root-navigator.react'; import type { NavigationRoute } from '../navigation/route-names'; -import { useIndicatorStyle } from '../themes/colors'; +import { useColors, useIndicatorStyle, useStyles } from '../themes/colors'; import { waitForModalInputFocus } from '../utils/timers'; import { useNavigateToThread } from './message-list-types'; import { SidebarItem } from './sidebar-item.react'; @@ -69,25 +71,24 @@ [navigateToThread, setSearchState], ); + const styles = useStyles(unboundStyles); + + const numOfSidebarsWithExtendedArrow = React.useMemo( + () => listData.length - 1, + [listData], + ); + const renderItem = React.useCallback( - (row: { item: SidebarInfo, ... }) => { + (row: { item: SidebarInfo, index: number, ... }) => { + let extendArrow: boolean = false; + if (row.index < numOfSidebarsWithExtendedArrow) { + extendArrow = true; + } return ( - - - - - - - - - + ); }, - [onPressItem], + [onPressItem, numOfSidebarsWithExtendedArrow], ); const indicatorStyle = useIndicatorStyle(); @@ -113,16 +114,70 @@ ); } -const styles = StyleSheet.create({ +function Item(props: { + row: { item: SidebarInfo, index: number, ... }, + onPressItem: (threadInfo: ThreadInfo) => void, + extendArrow: boolean, +}): React.Node { + const { row, onPressItem, extendArrow } = props; + const { threadInfo } = row.item; + + const onPressButton = React.useCallback(() => onPressItem(threadInfo), [ + onPressItem, + threadInfo, + ]); + + const colors = useColors(); + const styles = useStyles(unboundStyles); + + let arrow; + if (extendArrow) { + arrow = ( + + + + ); + } else { + arrow = ( + + + + ); + } + + return ( + + ); +} + +const unboundStyles = { arrow: { position: 'absolute', - top: -19, + top: -12, + }, + extendedArrow: { + position: 'absolute', + top: -6, }, search: { marginBottom: 8, }, sidebar: { - backgroundColor: 'transparent', + backgroundColor: 'listBackground', paddingLeft: 0, paddingRight: 5, }, @@ -136,6 +191,6 @@ spacer: { width: 30, }, -}); +}; export default SidebarListModal; diff --git a/native/components/arrow-extended.react.js b/native/components/arrow-extended.react.js new file mode 100644 --- /dev/null +++ b/native/components/arrow-extended.react.js @@ -0,0 +1,23 @@ +// @flow + +import * as React from 'react'; +import Svg, { Path } from 'react-native-svg'; + +function ExtendedArrow(): React.Node { + return ( + + + + ); +} + +export default ExtendedArrow; diff --git a/native/components/arrow-long.react.js b/native/components/arrow-long.react.js deleted file mode 100644 --- a/native/components/arrow-long.react.js +++ /dev/null @@ -1,23 +0,0 @@ -// @flow - -import * as React from 'react'; -import Svg, { Path } from 'react-native-svg'; - -function ArrowLong(): React.Node { - return ( - - - - ); -} - -export default ArrowLong;