Skip to content

Commit 3e1ec9a

Browse files
authored
Merge pull request #46 from ansari-project/mobile-usability-improvements
Mobile usability improvements
2 parents 6e6caee + aa9a47d commit 3e1ec9a

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

src/components/chat/MessageBubble.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const MessageBubble: React.FC<MessageBubbleProps> = ({
115115
</Markdown>
116116
</View>
117117
{!isOutgoing && !isSending && reactionsEnabled && (
118-
<View className='flex flex-row' key={message.id}>
118+
<View className='flex flex-row pb-4' key={message.id}>
119119
<ReactionButtons
120120
threadId={threadId}
121121
messageId={message.id}

src/components/chat/MessageList.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, { forwardRef, useRef, useState } from 'react'
66
import { ActivityIndicator, Platform, Pressable, ScrollView, View } from 'react-native'
77
import { useSelector } from 'react-redux'
88
import MessageBubble, { MessageBubbleProps } from './MessageBubble'
9+
import { useLocalSearchParams } from 'expo-router'
910

1011
// Memoize MessageBubble to avoid unnecessary re-renders
1112
const areEqual = (prevProps: MessageBubbleProps, nextProps: MessageBubbleProps) =>
@@ -47,8 +48,10 @@ const MessageList = forwardRef<MessageListRef, MessageListProps>(
4748
const sideMenuWidth = useSelector((state: RootState) => state.sideMenu.width)
4849
const { isSmallScreen, height } = useScreenInfo(sideMenuWidth)
4950
const theme = useSelector((state: RootState) => state.theme.theme)
51+
const { threadId } = useLocalSearchParams<{ threadId: string }>()
5052

51-
if (isLoading && !isSending && !activeThread) {
53+
const validThread = activeThread && activeThread.id === threadId
54+
if (isLoading && !isSending && !validThread) {
5255
return (
5356
<View className='flex-1 items-center justify-center'>
5457
<ActivityIndicator size='large' color={theme.hoverColor} />
@@ -87,7 +90,14 @@ const MessageList = forwardRef<MessageListRef, MessageListProps>(
8790
<ScrollView
8891
ref={scrollViewRef}
8992
className={`mb-${isSmallScreen ? '1' : '2'}`}
90-
scrollEventThrottle={250}
93+
scrollEventThrottle={50}
94+
onScroll={(event) => {
95+
const { contentOffset, layoutMeasurement } = event.nativeEvent
96+
// 250 accounts for the height of the fixed header + chat input + footer note
97+
const isAtBottom = contentOffset.y >= event.nativeEvent.contentSize.height - layoutMeasurement.height - 250
98+
99+
setDisplayScrollButton(!isAtBottom)
100+
}}
91101
onContentSizeChange={(contentWidth: number, contentHeight: number) => {
92102
if (isSending) return
93103

src/components/chat/ReactionButtons.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ const ReactionButtons: React.FC<ReactionButtonsProps> = ({ threadId, messageId,
116116

117117
return (
118118
<View className='w-full'>
119-
<View className='flex flex-row w-full'>
120-
<Pressable onPress={copyMessage} className={`w-5 h-5 ${isRTL ? 'mr-2' : 'ml-2'}`}>
119+
<View className='flex flex-row w-full gap-x-4'>
120+
<Pressable onPress={copyMessage} className={`w-5 h-5 ${isRTL ? 'mr-2' : 'ml-2'}`} hitSlop={8}>
121121
{copySuccess ? (
122-
<CheckIcon fill={theme.hoverColor} />
122+
<CheckIcon fill={theme.hoverColor} width={24} height={24} />
123123
) : (
124-
<CopyIcon fill={theme.iconFill} hoverFill={theme.hoverColor} />
124+
<CopyIcon fill={theme.iconFill} hoverFill={theme.hoverColor} width={24} height={24} />
125125
)}
126126
</Pressable>
127127
<Pressable
@@ -130,10 +130,13 @@ const ReactionButtons: React.FC<ReactionButtonsProps> = ({ threadId, messageId,
130130
setEditing(true)
131131
}}
132132
className={`w-5 h-5 ${isRTL ? 'mr-2' : 'ml-2'}`}
133+
hitSlop={8}
133134
>
134135
<LikeIcon
135136
fill={selectedIcon === FeedbackClass.ThumbsUp ? theme.hoverColor : theme.iconFill}
136137
hoverFill={theme.hoverColor}
138+
width={24}
139+
height={24}
137140
/>
138141
</Pressable>
139142
<Pressable
@@ -142,21 +145,24 @@ const ReactionButtons: React.FC<ReactionButtonsProps> = ({ threadId, messageId,
142145
setEditing(true)
143146
}}
144147
className={`w-5 h-5 ${isRTL ? 'mr-2' : 'ml-2'}`}
148+
hitSlop={8}
145149
>
146150
<DislikeIcon
147151
fill={selectedIcon === FeedbackClass.ThumbsDown ? theme.hoverColor : theme.iconFill}
148152
hoverFill={theme.hoverColor}
153+
width={24}
154+
height={24}
149155
/>
150156
</Pressable>
151157
</View>
152158
{modalVisible && (
153-
<View className={`w-full h-0 mt-6 ${modalVisible ? 'h-auto' : ''}`}>
159+
<View className={`w-full mt-6 ${modalVisible ? 'h-auto' : ''}`}>
154160
<View
155161
className='w-full px-2 sm:px-5 py-4 items-start rounded'
156162
style={{ backgroundColor: theme.inputBackgroundColor }}
157163
>
158164
<View className='flex-row w-full items-center'>
159-
<View className='flex-2 flex-row gap-2.5'>
165+
<View className='flex-2 flex-row gap-2'>
160166
<Text style={[{ color: theme.primaryColor, fontFamily: 'Inter', fontWeight: '500' }]}>
161167
{t('whyDidYouChooseThisRating')}
162168
</Text>

src/components/menu/SideMenuBody.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { AddIcon, LogoRoundIcon, MenuIcon } from '@/components/svg'
22
import { useAuth, useDirection, useScreenInfo } from '@/hooks'
33
import { AppDispatch, RootState, fetchThreads, toggleSideMenu } from '@/store'
44
import React, { useEffect, useState } from 'react'
5-
import { Pressable, View, SafeAreaView } from 'react-native'
5+
import { Pressable, View } from 'react-native'
6+
import { SafeAreaView } from 'react-native-safe-area-context'
67
import { useDispatch, useSelector } from 'react-redux'
78
import { useRouter } from 'expo-router'
89
import ActionButtons from '../ActionButtons'

0 commit comments

Comments
 (0)