This document describes the implementation of a Facebook-style global floating chat widget for the METU Help App. The chat overlay allows users to multitask by keeping chats accessible from anywhere in the app without navigating away from the current screen.
Purpose: Global state management for the chat overlay
Key Features:
- Manages overlay visibility (open/closed, minimized/expanded)
- Tracks active view (thread list or conversation)
- Subscribes to user's chats in real-time using
subscribeToUserChats - Calculates unread message count across all chats
- Provides actions:
openChat,openChatByRequestId,closeChat,toggleMinimize,goBackToThreads
State Structure:
{
isOpen: boolean;
isMinimized: boolean;
activeView: "threads" | "conversation";
activeChatId: string | null;
chats: Chat[];
unreadCount: number;
}Purpose: UI implementation of the floating chat widget
Components:
- Floating action button (FAB) in bottom-right corner
- Shows unread message count badge
- Animated press feedback
- Positioned:
bottom: 32px (web) / 96px (mobile), right: 32px
- Lists all active chat conversations
- Shows request title, other participant name, last message, and time
- Empty state with icon when no chats exist
- Click on thread to open conversation
- Displays messages for selected chat
- Shows chat header with request title and participant name
- Back button to return to thread list
- Message bubbles (own messages on right, others on left)
- Real-time message updates via
subscribeToMessages - Text input with send button
- Auto-scrolls to latest message
- Container for ThreadListView and ConversationView
- Platform-specific rendering:
- Web: Bottom-right positioned box (300x400px)
- Mobile: Full-screen modal from bottom (90% width, 70% height)
- Header with title, minimize, and close buttons
- KeyboardAvoidingView for proper input handling
Styling:
- Uses theme system for colors and spacing
- Follows METU design guidelines (Maroon primary color)
- Consistent with existing component styles
- Animations using react-native-reanimated
- Added
ChatOverlayProviderto provider hierarchy (after AuthProvider) - Mounted
ChatOverlaycomponent at root level - Overlay renders above navigation using absolute positioning with z-index: 1000
- Integrated
useChatOverlayhook - "Open Chat" button now calls
openChat(chatId)instead of navigating - Maintains existing functionality for viewing request details
- Integrated
useChatOverlayhook - Added
handleOpenChatfunction to open chat via overlay - When user offers help, chat opens in overlay instead of navigating
- Fixed missing language and state variables
- User clicks "Open Chat" on a help request (NeedHelpScreen)
- Context updates:
activeView = "conversation",isMinimized = false,isOpen = true - ChatOverlay renders ExpandedWindow with ConversationView
- User can send/receive messages in real-time
- User can click back to see all threads
- User can minimize to floating bubble
- Thread List → Conversation: Click on any thread item
- Conversation → Thread List: Click back button in header
- Expanded → Minimized: Click minimize button in header
- Minimized → Expanded: Click floating bubble
- Close: Click X button in header (resets to minimized state)
- User opens chat from NeedHelpScreen
- User minimizes chat (bubble appears in bottom-right)
- User navigates to ProfileScreen
- Chat bubble remains visible
- User can click bubble to continue conversation
- Chat overlay persists across all screens
- Chats:
subscribeToUserChats(from chatService) listens to Firestore - Messages:
subscribeToMessages(from chatService) listens to subcollection - Updates trigger React state changes, causing re-renders
| Feature | Web | Mobile |
|---|---|---|
| Container | Absolute positioned box | Full-screen Modal |
| Size | 300x400px | 90% width, 70% height |
| Position | Bottom-right corner | Bottom slide-up |
| Background | Floating with shadow | Semi-transparent overlay |
- Unsubscribe functions called in cleanup
- Chat subscriptions reset when user logs out
- Component unmount handlers prevent memory leaks
- User authentication required (overlay hidden if not authenticated)
- Chat access validated by Firebase security rules
- Only participants can see their messages
/src/contexts/ChatOverlayContext.tsx- Context for global state (162 lines)/src/components/ChatOverlay.tsx- Main overlay component (547 lines)
App.tsx- Added provider and overlay mount (7 lines changed)screens/NeedHelpScreen.tsx- Integrated overlay (10 lines changed)screens/RequestDetailScreen.tsx- Integrated overlay, fixed issues (43 lines changed)
- Added: 709 lines
- Modified: 60 lines
- Files changed: 5
-
Authentication Flow
- Login with test account
- Verify bubble appears after login
- Verify bubble disappears after logout
-
Chat Creation
- Create a help request
- Have another user offer help
- Verify chat appears in thread list
-
Messaging
- Send message from requester
- Verify helper receives message
- Send message from helper
- Verify requester receives message
- Check real-time updates
-
UI States
- Click bubble to expand
- Verify thread list shows
- Click thread to open conversation
- Click back to return to thread list
- Click minimize to collapse
- Click close to hide overlay
-
Navigation Persistence
- Open chat from NeedHelpScreen
- Minimize chat
- Navigate to ProfileScreen
- Verify bubble still visible
- Expand chat
- Verify conversation maintained
-
Platform-Specific
- Test on web browser
- Test on iOS simulator
- Test on Android emulator
- Verify keyboard handling on all platforms
- Unit tests for ChatOverlayContext actions
- Component tests for ChatOverlay UI states
- Integration tests for chat flow
- E2E tests for complete user journey
-
Unread Count: Currently shows total number of chats, not actual unread messages. Future enhancement needed to track read/unread status.
-
Push Notifications: Not implemented. Users must open the app to see new messages.
-
Message History: Limited to in-memory messages during session. Full history loading not implemented.
-
Typing Indicators: Not implemented. Users cannot see when others are typing.
-
File Attachments: Not supported. Only text messages.
-
Message Reactions: Not implemented.
-
Unread Message Tracking
- Add
read: booleanfield to messages - Track last read timestamp per user
- Update badge with actual unread count
- Add
-
Rich Messages
- File attachments (images, documents)
- Voice messages
- Link previews
-
Enhanced UX
- Typing indicators
- Message reactions (emoji)
- Message editing/deletion
- Search within conversations
-
Notifications
- Push notifications for new messages
- In-app notification sounds
- Desktop notifications (web)
-
Performance
- Message pagination
- Virtual scrolling for long conversations
- Image lazy loading
-
Accessibility
- Screen reader support
- Keyboard navigation
- High contrast mode
The global floating chat widget has been successfully implemented according to the requirements. It provides a seamless, Facebook-style chat experience that allows users to multitask while maintaining conversations. The implementation follows React Native and Expo best practices, integrates cleanly with existing code, and maintains the METU Help App design system.
The feature is ready for testing and can be further enhanced based on user feedback and requirements.