All files / src/components EventDetailsPopup.tsx

100% Statements 7/7
100% Branches 5/5
100% Functions 3/3
100% Lines 6/6

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                                                              4x 4x 3x             3x     3x                                                                                               1x                                                                                                
import React from "react";
import { Pressable, StyleSheet, Text, View } from "react-native";
import FontAwesome5 from "@expo/vector-icons/FontAwesome5";
import PopupTemplate from "./PopupTemplate";
import { useTheme } from "../hooks/useTheme";
 
export default function EventDetailsPopup({
  visible,
  title,
  detailsText,
  showDirections = true,
  accessibility,
  onClose,
  onDirections,
  onChangeCalendar,
  onLogout,
}: Readonly<{
  visible: boolean;
  title: string;
  detailsText: string;
  showDirections?: boolean;
  accessibility?: {
    hasElevator: boolean;
    hasParking: boolean;
    isAccessible: boolean;
  };
  onClose: () => void;
  onDirections: () => void;
  onChangeCalendar: () => void;
  onLogout: () => void;
}>) {
  const { colors } = useTheme();
  if (!visible) return null;
  return (
    <PopupTemplate
      title={title}
      accessibility={accessibility}
      onClose={onClose}
      dismissOnBackdropPress
      renderBody={() => (
        <Text style={[styles.body, { color: colors.text }]}>{detailsText}</Text>
      )}
      renderButtons={() => (
        <>
          <View style={styles.buttonRow}>
            <Pressable
              style={[
                styles.actionBtn,
                styles.changeCalendarBtn,
                {
                  backgroundColor: `${colors.primary}14`,
                  borderColor: colors.primary,
                },
              ]}
              onPress={onChangeCalendar}
            >
              <Text
                style={[
                  styles.changeCalendarBtnText,
                  { color: colors.primary },
                ]}
              >
                Change calendar
              </Text>
            </Pressable>
            {showDirections ? (
              <Pressable
                onPress={onDirections}
                style={[
                  styles.directionsBtn,
                  { backgroundColor: colors.primary },
                ]}
              >
                <FontAwesome5 name="directions" size={18} color="white" />
                <Text style={styles.directionsText}>Directions</Text>
              </Pressable>
            ) : null}
          </View>
          <View style={{ height: 8 }} />
          <Pressable
            style={[styles.logoutBtn, { backgroundColor: colors.primary }]}
            onPress={onLogout}
          >
            <Text style={styles.logoutBtnText}>Log out of Google</Text>
          </Pressable>
        </>
      )}
    />
  );
}
 
const styles = StyleSheet.create({
  body: {
    fontSize: 14,
    lineHeight: 20,
    marginTop: 4,
  },
  buttonRow: {
    marginTop: 12,
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between",
    gap: 12,
  },
  actionBtn: {
    flex: 1,
    borderRadius: 999,
    paddingVertical: 10,
    alignItems: "center",
    justifyContent: "center",
  },
  directionsBtn: {
    flexDirection: "row",
    alignItems: "center",
    gap: 8,
    borderRadius: 999,
    paddingHorizontal: 14,
    paddingVertical: 10,
  },
  directionsText: {
    color: "#fff",
    fontWeight: "800",
  },
  changeCalendarBtn: {
    borderWidth: 1,
  },
  changeCalendarBtnText: {
    fontWeight: "700",
  },
  logoutBtn: {
    borderRadius: 999,
    paddingVertical: 10,
    alignItems: "center",
  },
  logoutBtnText: {
    color: "white",
    fontWeight: "700",
  },
});