Skip to content

A React Native chat application built with Expo and React Navigation. This app allows users to enter their name, choose a background color, and navigate to a chat screen.

Notifications You must be signed in to change notification settings

apirollijr/chat-demo

Repository files navigation

Chat App

A React Native chat application built with Expo, Firebase (Firestore + Storage), and Gifted Chat. Users can enter their name, choose a background color, chat in real time, send images, and share their location.

Features

  • Start Screen:

    • Text input for user name with validation
    • Color picker with 4 background color options
    • Elegant UI with styled components and shadows
    • Form validation (name required before proceeding)
    • Keyboard handling to prevent UI coverage
  • Chat Screen:

    • Full chat UI with Gifted Chat
    • Real-time messaging backed by Firestore
    • Image sharing to Firebase Storage (download URLs saved in Firestore)
    • Share current location; renders a map bubble with a marker
    • Custom action button that opens an Action Sheet with four actions
    • Accessibility labels and roles on interactive elements
    • Keyboard handling and user avatars
  • Navigation:

    • Stack navigation between Start and Chat screens
    • Passes user data (name and color) between screens
    • Custom navigation header styling

Technologies Used

  • React Native: Mobile app framework
  • Expo: Development platform and toolchain
  • React Navigation: Navigation library for screen transitions
  • Gifted Chat: Complete chat UI and functionality library
  • React Hooks: useState, useEffect, and useCallback for state management
  • KeyboardAvoidingView: Cross-platform keyboard handling
  • Firebase: Firestore for chat messages; Cloud Storage for media uploads
  • Expo Image Picker for gallery/camera; Expo Location for GPS; react-native-maps for map bubbles

Installation

Prerequisites

  • Node.js LTS (18.x or 20.x) and npm
  • Git
  • Expo tooling (used via npx)
  • For Android build/emulator:
    • Android Studio with a "Google APIs" emulator image (API 33+ recommended)
    • Android SDK Platform Tools (added to PATH by Android Studio)
  • For iOS (macOS only): Xcode with iOS Simulator

On Windows, install Android Studio and create a Pixel emulator. No separate Java install is needed—Android Studio bundles it.

  1. Clone this repository:

    git clone [repository-url]
    cd chat-demo
  2. Install dependencies:

    npm install
  3. Install required packages:

    npx expo install react-native-screens react-native-safe-area-context
    npm install react-native-gifted-chat --save
  4. Install media, location, and maps packages (Expo managed):

    # Match versions to your Expo SDK automatically
    npx expo install expo-image-picker expo-location react-native-maps

Firebase setup (Firestore + Storage)

  1. In Firebase Console, create a project (or use your existing one) and add a Web app to get the config.
  2. Copy your Web config into firebase.js (replace the placeholder values if needed).
  3. Enable Cloud Firestore and Cloud Storage in the Console.
  4. Verify your Storage bucket. In most projects the default is <projectId>.appspot.com. If uploads fail and your bucket differs from firebaseConfig.storageBucket, update it accordingly.

This app initializes Firestore and connects Cloud Storage using getStorage(app, \gs://${firebaseConfig.storageBucket}`). Instances are exported from firebase.js` and passed to screens via props.

Storage security rules (development)

For quick local testing you can temporarily allow authenticated users to read/write:

rules_version = '2';
service firebase.storage {
   match /b/{bucket}/o {
      match /{allPaths=**} {
         allow read, write: if request.auth != null;
      }
   }
}

Remember to tighten these rules for production.

Where to put credentials

  • Open firebase.js and replace the firebaseConfig object with your project’s Web app config from Firebase Console (Project settings → General → Your apps → Web app).
  • Ensure the storageBucket matches your project’s bucket. The app binds Storage to that exact bucket via getStorage(app, \gs://${firebaseConfig.storageBucket}`)`.

Running the App

  1. Start the Expo development server:

    npx expo start
  2. Choose how to run the app:

    • Expo Go (fastest):
      • Android: Press a to open in Expo Go on the emulator
      • iOS: Press i to open in iOS Simulator with Expo Go
    • Native build (standalone dev client):
      • Android: npm run android (runs expo run:android, uses Android Studio)
      • iOS (macOS): npm run ios
  3. Smoke test features:

    • Select or take a photo → image bubble appears
    • Share location → map bubble appears with a marker

Project Structure

chat-demo/
├── App.js                 # Main app component with navigation setup
├── components/
│   ├── Start.js          # Start screen component
│   ├── Chat.js           # Chat screen: Firestore sync, map bubble, actions
│   └── CustomActions.js  # Action sheet: pick image, take photo, share location, cancel
├── assets/               # App assets (icons, images)
├── package.json          # Dependencies and scripts
└── README.md            # Project documentation

App Flow

  1. Start Screen: User enters their name and selects a background color
  2. Navigation: User taps "Start Chatting" to navigate to chat screen
  3. Chat Screen: Displays personalized welcome with chosen background color

Available Background Colors

  • Black (#090C08) - Default
  • Dark Purple (#474056)
  • Blue Gray (#8A95A5)
  • Light Green (#B9C6AE)

Feature checklist (submission requirements)

The app implements the following:

  • Action sheet with four actions: select an image, take a photo, send location, cancel (components/CustomActions.js).
  • Storage implementation for media in Google Firebase Storage (firebase.js init + uploadBytes/uploadString + REST fallback).
  • Image URLs saved in Google Firestore (messages written by components/Chat.js -> onSend, with image field from Storage download URL).
  • Location information collected from device, stored in Firestore, and rendered on a map bubble (location field + renderCustomView with react-native-maps).
  • Accessibility props applied on the CustomActions TouchableOpacity (accessibilityRole, accessibilityLabel, accessibilityHint).
  • Properly formatted, commented code (see file headers and inline comments in Chat.js and CustomActions.js).
  • Project setup manual (this README).
  • Screen recording showcasing app features (see instructions below to record and add the link/file).

If anything is missing for your review flow, file an issue or ping us—happy to adjust.

Recording a demo (Android Emulator or device)

You can attach a short screen recording and link it here:

  1. Android Emulator: three-dots (Extended controls) > Record and Playback > Start recording. Reproduce features, then Stop recording. This produces a .webm file.
  2. Physical Android device: enable screen recording from Quick Settings; or use adb shell screenrecord.
  3. iOS Simulator: File > New Screen Recording; or QuickTime Player with your device attached.

Place the recording under assets/demo/ and link it here:

[Demo video](./assets/demo/chat-demo.webm)

Alternatively, upload to a share (Drive/Dropbox/YouTube Unlisted) and paste the URL.

Emulator tips for location sharing

If “Current location is unavailable” appears on the emulator:

  • Ensure Location services are ON in the emulator (Settings > Location > Use location ON).

  • Inject a mock location:

    • Android: Extended controls (⋮) > Location > choose a preset (e.g., San Francisco) or enter coordinates > Set Location.
    • iOS: Simulator menu Features > Location > select a preset.
  • Grant app permissions for “Location” (While in use + Precise).

  • Use a “Google APIs” AVD image for Android.

  • Cold boot the emulator after changing settings.

  • Chat messaging functionality (Implemented with Gifted Chat)

  • User authentication and login system

  • Message persistence with database storage

  • Group chat and multiple chat rooms

  • Image and file sharing capabilities

  • Push notifications for new messages

  • Online status indicators

  • Message read receipts

  • Custom emoji reactions

Development Notes

  • Uses functional components with React Hooks
  • Implements proper accessibility labels
  • Includes form validation and user feedback
  • Responsive design with Flexbox layout
  • Clean, modular code structure with comments
    • Custom action sheet with accessibility labels
    • Robust uploads to Firebase Storage with fallbacks and clear error messages
    • Location services checks, accuracy fallbacks, and last-known-position support

Testing

The app has been tested with:

  • Form validation (empty name handling)
  • Navigation between screens with parameter passing
  • Chat message sending and receiving
  • System message display on chat entry
  • Keyboard behavior on both screens
  • UI responsiveness across different screen sizes
  • Cross-platform compatibility (iOS/Android behavior)
  • Accessibility features and labels

For reviewers: the “Feature checklist” above maps directly to the submission rubric. The only manual artifact to add is the screen recording—see “Recording a demo”.


Note: This implementation includes both Exercise 5.3 (navigation setup) and Exercise 5.4 (chat functionality with Gifted Chat).

About

A React Native chat application built with Expo and React Navigation. This app allows users to enter their name, choose a background color, and navigate to a chat screen.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published