All files / src/components LocationPromptModal.tsx

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148          1x                                 2x                                                                                               1x                                                                                                                                                          
import React from "react";
import { Modal, StyleSheet, Text, View, Pressable } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { Building } from "../data/buildings";
 
const BURGUNDY = "#800020";
 
interface LocationPromptModalProps {
  visible: boolean;
  building: Building;
  onSelectInside: () => void;
  onSelectOutside: () => void;
  onClose: () => void;
}
 
export default function LocationPromptModal({
  visible,
  building,
  onSelectInside,
  onSelectOutside,
  onClose,
}: Readonly<LocationPromptModalProps>) {
  return (
    <Modal
      visible={visible}
      transparent
      animationType="fade"
      onRequestClose={onClose}
    >
      <View style={styles.overlay}>
        <View style={styles.container}>
          <Pressable style={styles.closeButton} onPress={onClose}>
            <Ionicons name="close" size={24} color="#666" />
          </Pressable>
 
          <View style={styles.iconContainer}>
            <Ionicons name="location" size={32} color={BURGUNDY} />
          </View>
 
          <Text style={styles.title}>Where are you?</Text>
          <Text style={styles.subtitle}>
            You're near <Text style={styles.buildingName}>{building.name}</Text>
            . Are you inside or outside the building?
          </Text>
 
          <View style={styles.buttonContainer}>
            <Pressable
              style={[styles.button, styles.insideButton]}
              onPress={onSelectInside}
            >
              <Ionicons name="business" size={20} color="#fff" />
              <Text style={styles.buttonText}>Inside Building</Text>
            </Pressable>
 
            <Pressable
              style={[styles.button, styles.outsideButton]}
              onPress={onSelectOutside}
            >
              <Ionicons name="walk" size={20} color={BURGUNDY} />
              <Text style={[styles.buttonText, styles.outsideButtonText]}>
                Outside
              </Text>
            </Pressable>
          </View>
        </View>
      </View>
    </Modal>
  );
}
 
const styles = StyleSheet.create({
  overlay: {
    flex: 1,
    backgroundColor: "rgba(0, 0, 0, 0.5)",
    justifyContent: "center",
    alignItems: "center",
    padding: 24,
  },
  container: {
    backgroundColor: "#fff",
    borderRadius: 16,
    padding: 24,
    width: "100%",
    maxWidth: 340,
    alignItems: "center",
  },
  closeButton: {
    position: "absolute",
    top: 12,
    right: 12,
    padding: 4,
  },
  iconContainer: {
    width: 64,
    height: 64,
    borderRadius: 32,
    backgroundColor: "rgba(128, 0, 32, 0.1)",
    alignItems: "center",
    justifyContent: "center",
    marginBottom: 16,
  },
  title: {
    fontSize: 20,
    fontWeight: "700",
    color: "#333",
    marginBottom: 8,
  },
  subtitle: {
    fontSize: 14,
    color: "#666",
    textAlign: "center",
    lineHeight: 20,
    marginBottom: 24,
  },
  buildingName: {
    fontWeight: "600",
    color: "#333",
  },
  buttonContainer: {
    width: "100%",
    gap: 12,
  },
  button: {
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "center",
    paddingVertical: 14,
    borderRadius: 12,
    gap: 8,
  },
  insideButton: {
    backgroundColor: BURGUNDY,
  },
  outsideButton: {
    backgroundColor: "#fff",
    borderWidth: 2,
    borderColor: BURGUNDY,
  },
  buttonText: {
    fontSize: 16,
    fontWeight: "600",
    color: "#fff",
  },
  outsideButtonText: {
    color: BURGUNDY,
  },
});