diff --git a/app/containers/RoomItem/Actions.tsx b/app/containers/RoomItem/Actions.tsx index 770fa5655ba..3396f46136d 100644 --- a/app/containers/RoomItem/Actions.tsx +++ b/app/containers/RoomItem/Actions.tsx @@ -35,7 +35,11 @@ export const LeftActions = React.memo(({ transX, isRead, width, onToggleReadPres const viewHeight = { height: isCondensed ? rowHeightCondensed : rowHeight }; return ( - + @@ -120,7 +124,11 @@ export const RightActions = React.memo(({ transX, favorite, width, toggleFav, on const viewHeight = { height: isCondensed ? rowHeightCondensed : rowHeight }; return ( - + @@ -156,7 +164,7 @@ export const RightActions = React.memo(({ transX, favorite, width, toggleFav, on animatedHideStyles ]}> diff --git a/app/containers/RoomItem/RoomItem.tsx b/app/containers/RoomItem/RoomItem.tsx index 5939b0d583e..297ce431ec7 100644 --- a/app/containers/RoomItem/RoomItem.tsx +++ b/app/containers/RoomItem/RoomItem.tsx @@ -93,6 +93,7 @@ const RoomItem = ({ displayMode={displayMode}> { +const Wrapper = ({ + accessibilityLabel, + accessibilityHint, + children, + displayMode, + ...props +}: IWrapperProps): React.ReactElement => { const { colors } = useTheme(); const { rowHeight, rowHeightCondensed } = useResponsiveLayout(); return ( diff --git a/app/containers/RoomItem/__snapshots__/RoomItem.test.tsx.snap b/app/containers/RoomItem/__snapshots__/RoomItem.test.tsx.snap index 971e7b8dc59..88bba9ded18 100644 --- a/app/containers/RoomItem/__snapshots__/RoomItem.test.tsx.snap +++ b/app/containers/RoomItem/__snapshots__/RoomItem.test.tsx.snap @@ -6,6 +6,8 @@ exports[`Story Snapshots: Alerts should match snapshot 1`] = ` collapsable={false} > [ + { + title: I18n.t(isRead ? 'Mark_unread' : 'Mark_read'), + icon: isRead ? 'flag' : 'check', + onPress: () => toggleRead(rid, isRead, serverVersion), + testID: `action-sheet-${isRead ? 'mark-unread' : 'mark-read'}` + }, + { + title: I18n.t(favorite ? 'Unfavorite' : 'Favorite'), + icon: favorite ? 'star-filled' : 'star', + onPress: () => toggleFav(rid, favorite), + testID: `action-sheet-${favorite ? 'unfavorite' : 'favorite'}` + }, + { + title: I18n.t('Hide'), + icon: 'unread-on-top-disabled', + onPress: () => hideRoom(rid, type), + testID: 'action-sheet-hide' + } +]; diff --git a/app/containers/RoomItem/index.tsx b/app/containers/RoomItem/index.tsx index 44b112921e2..b22c0a14c9b 100644 --- a/app/containers/RoomItem/index.tsx +++ b/app/containers/RoomItem/index.tsx @@ -1,10 +1,14 @@ import React, { useEffect, useReducer, useRef } from 'react'; import { type Subscription } from 'rxjs'; +import { AccessibilityInfo } from 'react-native'; +import { useActionSheet } from '../ActionSheet'; +import { useAppSelector } from '../../lib/hooks/useAppSelector'; import { isGroupChat } from '../../lib/methods/helpers'; import { formatDate, formatDateAccessibility } from '../../lib/methods/helpers/room'; import { type IRoomItemContainerProps } from './interfaces'; import RoomItem from './RoomItem'; +import { getRoomActionsOptions } from './getRoomActionsOptions'; import { isInviteSubscription } from '../../lib/methods/isInviteSubscription'; const attrs = ['width', 'isFocused', 'showLastMessage', 'autoJoin', 'showAvatar', 'displayMode']; @@ -28,6 +32,8 @@ const RoomItemContainer = React.memo( getIsRead = () => false, swipeEnabled = true }: IRoomItemContainerProps) => { + const { showActionSheet } = useActionSheet(); + const serverVersion = useAppSelector(state => state.server.version); const name = getRoomTitle(item); const testID = `rooms-list-view-item-${name}`; const avatar = getRoomAvatar(item); @@ -55,7 +61,25 @@ const RoomItemContainer = React.memo( const handleOnPress = () => onPress(item); - const handleOnLongPress = () => onLongPress && onLongPress(item); + const handleOnLongPress = async () => { + if (onLongPress) { + onLongPress(item); + return; + } + const isScreenReaderEnabled = await AccessibilityInfo.isScreenReaderEnabled(); + if (item.separator || !isScreenReaderEnabled) { + return; + } + showActionSheet({ + options: getRoomActionsOptions({ + rid: item.rid, + type: item.t, + isRead, + favorite: !!item.f, + serverVersion + }) + }); + }; return (