Food Delivery Order Map

Screen is created using these React Native Core Components: <View />, <SafeAreaView />, <TouchableOpacity />, <Text />

import React from 'react';
import {
  StyleSheet,
  View,
  SafeAreaView,
  TouchableOpacity,
  Text,
} from 'react-native';
import MapView, { Marker, Polyline } from 'react-native-maps';
import FontAwesome from 'react-native-vector-icons/FontAwesome5''@expo/vector-icons/FontAwesome5';
import FeatherIcon from 'react-native-vector-icons/Feather''@expo/vector-icons/Feather';

const coordinates = [
  { latitude: 37.76546039999999, longitude: -122.4131604 },
  { latitude: 37.7694694, longitude: -122.4134004 },
  { latitude: 37.7701606, longitude: -122.4204751 },
  { latitude: 37.7698755, longitude: -122.422396 },
  { latitude: 37.772472, longitude: -122.4226411 },
  { latitude: 37.77332180000001, longitude: -122.4215392 },
  { latitude: 37.77396960000001, longitude: -122.4207761 },
  { latitude: 37.7854876, longitude: -122.4230498 },
  { latitude: 37.7828469, longitude: -122.4438805 },
  { latitude: 37.7821943, longitude: -122.4501325 },
  { latitude: 37.7844931, longitude: -122.4501513 },
  { latitude: 37.7846951, longitude: -122.449325 },
  { latitude: 37.7861347, longitude: -122.4500033 },
  { latitude: 37.7877763, longitude: -122.4503291 },
  { latitude: 37.7876254, longitude: -122.4515168 },
];

export default function Example() {
  const center = {
    latitude:
      coordinates.reduce((acc, c) => (acc += c.latitude), 0) /
      coordinates.length,
    longitude:
      coordinates.reduce((acc, c) => (acc += c.longitude), 0) /
      coordinates.length,
  };

  return (
    <View style={{ flex: 1 }}>
      <SafeAreaView>
        <View style={styles.header}>
          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}
            style={[styles.btn, styles.btnClose]}>
            <FeatherIcon color="#000" name="x" size={19} />
          </TouchableOpacity>

          <View style={styles.headerActions}>
            <TouchableOpacity
              onPress={() => {
                // handle onPress
              }}>
              <View style={styles.btn}>
                <Text style={styles.btnText}>Help</Text>
              </View>
            </TouchableOpacity>

            <TouchableOpacity
              onPress={() => {
                // handle onPress
              }}
              style={[styles.btn, styles.btnClose]}>
              <FeatherIcon
                color="#000"
                name="navigation"
                size={19} />
            </TouchableOpacity>
          </View>
        </View>
      </SafeAreaView>

      <MapView
        style={styles.map}
        initialRegion={{
          latitude: center.latitude - 0.015, // 0.015 accounts for the bottom sheet height (372px)
          longitude: center.longitude,
          latitudeDelta: 0.0922,
          longitudeDelta: 0.0421,
        }}>
        {/* Origin */}
        <Marker coordinate={coordinates[0]}>
          <View style={styles.marker}>
            <FontAwesome name="shopping-basket" color="#fff" size={15} />
          </View>
        </Marker>

        {/* Destination */}
        <Marker coordinate={coordinates[coordinates.length - 1]}>
          <View style={styles.marker}>
            <FontAwesome name="home" color="#fff" size={15} />
          </View>
        </Marker>

        {/* Driver */}
        <Marker coordinate={coordinates[8]}>
          <View style={styles.marker}>
            <FontAwesome name="car" color="#fff" size={15} />
          </View>
        </Marker>

        <Polyline
          coordinates={coordinates}
          strokeColor="#000"
          strokeWidth={3}
        />
      </MapView>

      <SafeAreaView style={styles.sheet}>
        <View style={styles.sheetHeader}>
          <Text style={styles.sheetTitle}>Order is coming soon</Text>

          <Text style={styles.sheetSubtitle}>
            Arrives in
            <Text style={{ fontWeight: '600', color: '#000' }}>
              {' 3 minutes'}
            </Text>
          </Text>
        </View>

        <View style={styles.sheetSection}>
          <View style={{ marginRight: 'auto' }}>
            <Text style={styles.sectionTitle}>Driver</Text>

            <Text style={styles.sectionSubtitle}>John D.</Text>
          </View>

          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}>
            <View style={styles.btnSm}>
              <Text style={styles.btnSmText}>Add tip</Text>
            </View>
          </TouchableOpacity>

          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}
            style={styles.btnSm}>
            <FeatherIcon color="#000" name="phone" size={19} />
          </TouchableOpacity>

          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}
            style={styles.btnSm}>
            <FeatherIcon color="#000" name="send" size={19} />
          </TouchableOpacity>
        </View>

        <View style={styles.sheetSection}>
          <View style={{ marginRight: 'auto' }}>
            <Text style={styles.sectionTitle}>Restaurant</Text>

            <Text style={styles.sectionSubtitle}>
              Old Fashion Burger Restaurant
            </Text>
          </View>

          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}>
            <View style={styles.btnSm}>
              <Text style={styles.btnSmText}>Add tip</Text>
            </View>
          </TouchableOpacity>

          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}
            style={styles.btnSm}>
            <FeatherIcon color="#000" name="phone" size={19} />
          </TouchableOpacity>
        </View>

        <View style={styles.sectionFooter}>
          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}>
            <View style={styles.btnPrimary}>
              <Text style={styles.btnPrimaryText}>View Order Details</Text>
            </View>
          </TouchableOpacity>

          <TouchableOpacity
            onPress={() => {
              // handle onPress
            }}>
            <View style={styles.btnEmpty}>
              <Text style={styles.btnEmptyText}>Cancel</Text>
            </View>
          </TouchableOpacity>
        </View>
      </SafeAreaView>
    </View>
  );
}

const styles = StyleSheet.create({
  map: {
    flex: 1,
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    zIndex: -1,
  },
  marker: {
    width: 30,
    height: 30,
    backgroundColor: '#000',
    borderRadius: 9999,
    alignItems: 'center',
    justifyContent: 'center',
  },
  /** Header */
  header: {
    flexDirection: 'row',
    alignItems: 'flex-start',
    justifyContent: 'space-between',
    paddingHorizontal: 12,
    paddingTop: 12,
  },
  headerActions: {
    alignItems: 'flex-end',
  },
  /** Button */
  btn: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    borderRadius: 9999,
    paddingVertical: 8,
    paddingHorizontal: 16,
    borderWidth: 1,
    backgroundColor: '#efefef',
    borderColor: '#efefef',
    marginBottom: 8,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.23,
    shadowRadius: 2.62,
    elevation: 4,
  },
  btnClose: {
    width: 40,
    height: 40,
    paddingHorizontal: 0,
  },
  btnText: {
    fontSize: 16,
    lineHeight: 24,
    fontWeight: 'bold',
    color: '#000',
    letterSpacing: 0.45,
  },
  btnSm: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    borderRadius: 9999,
    paddingVertical: 8,
    paddingHorizontal: 16,
    borderWidth: 1,
    backgroundColor: '#efefef',
    borderColor: '#efefef',
    marginLeft: 4,
  },
  btnSmText: {
    fontSize: 14,
    lineHeight: 20,
    fontWeight: '600',
    color: '#000',
  },
  btnPrimary: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    borderRadius: 8,
    paddingVertical: 8,
    paddingHorizontal: 16,
    borderWidth: 1,
    backgroundColor: '#F82E08',
    borderColor: '#F82E08',
  },
  btnPrimaryText: {
    fontSize: 17,
    lineHeight: 24,
    fontWeight: '700',
    color: '#fff',
  },
  btnEmpty: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    borderRadius: 8,
    paddingVertical: 8,
    paddingHorizontal: 16,
    backgroundColor: 'transparent',
    marginTop: 4,
  },
  btnEmptyText: {
    fontSize: 17,
    lineHeight: 24,
    fontWeight: '700',
    color: '#1D1D1D',
  },
  /** Sheet */
  sheet: {
    flex: 1,
    maxHeight: 372,
    marginTop: 'auto',
    backgroundColor: '#fff',
    borderTopLeftRadius: 16,
    borderTopRightRadius: 16,
  },
  sheetHeader: {
    padding: 16,
    borderBottomWidth: 1,
    borderColor: '#e8e8e8',
  },
  sheetTitle: {
    fontSize: 23,
    fontWeight: '700',
    color: '#1d1d1d',
    marginBottom: 4,
  },
  sheetSubtitle: {
    fontSize: 15,
    fontWeight: '500',
    color: '#6d6d6d',
  },
  sheetSection: {
    flexDirection: 'row',
    alignItems: 'center',
    justifySelf: 'center',
    padding: 16,
    borderBottomWidth: 1,
    borderColor: '#e8e8e8',
  },
  sectionTitle: {
    fontSize: 17,
    fontWeight: '600',
    color: '#1d1d1d',
    marginBottom: 4,
  },
  sectionSubtitle: {
    fontSize: 13,
    color: '#6a6a6a',
  },
  sectionFooter: {
    paddingHorizontal: 16,
    marginTop: 16,
  },
});

Dependencies

Before getting started, make sure you have all the necessary dependencies for this component. Follow the steps below to install any missing dependencies.

Explore more components

Over 100 Ready to Use React Native Components for all your needs.

Never miss a beat

Stay in the loop with our latest updates and offers - no spam, just the good stuff!