import { AntDesign, Ionicons } from "@expo/vector-icons";
import React, { useState } from "react";
import { Button, View, Text, Checkbox } from "react-native-ui-lib";
import { StyleSheet } from "react-native";
import { colorMap } from "@/contexts/SettingsContext";
import { TouchableOpacity } from "react-native-gesture-handler";

const CalendarSettingsPage = (props: {
  setSelectedPage: (page: number) => void;
}) => {
  const [selectedColor, setSelectedColor] = useState<string>(colorMap.pink);
  const [startDate, setStartDate] = useState<boolean>(true);
  return (
    <View marginH-30>
      <TouchableOpacity onPress={() => props.setSelectedPage(0)}>
        <View row marginT-20 marginB-35 centerV>
          <Ionicons name="chevron-back" size={22} color="#979797" />
          <Text text70 color="#979797">Return to main settings</Text>
        </View>
      </TouchableOpacity>
      <Text text60R>Calendar settings</Text>
      <View style={styles.card}>
        <Text text70 marginB-14>
          Event Color Preference
        </Text>
        <View row spread>
          <TouchableOpacity onPress={() => setSelectedColor(colorMap.pink)}>
            <View style={styles.colorBox} backgroundColor={colorMap.pink}>
              {selectedColor == colorMap.pink && (
                <AntDesign name="check" size={30} color="white" />
              )}
            </View>
          </TouchableOpacity>
          <TouchableOpacity onPress={() => setSelectedColor(colorMap.orange)}>
            <View style={styles.colorBox} backgroundColor={colorMap.orange}>
              {selectedColor == colorMap.orange && (
                <AntDesign name="check" size={30} color="white" />
              )}
            </View>
          </TouchableOpacity>
          <TouchableOpacity onPress={() => setSelectedColor(colorMap.green)}>
            <View style={styles.colorBox} backgroundColor={colorMap.green}>
              {selectedColor == colorMap.green && (
                <AntDesign name="check" size={30} color="white" />
              )}
            </View>
          </TouchableOpacity>
          <TouchableOpacity onPress={() => setSelectedColor(colorMap.teal)}>
            <View style={styles.colorBox} backgroundColor={colorMap.teal}>
              {selectedColor == colorMap.teal && (
                <AntDesign name="check" size={30} color="white" />
              )}
            </View>
          </TouchableOpacity>
          <TouchableOpacity onPress={() => setSelectedColor(colorMap.purple)}>
            <View style={styles.colorBox} backgroundColor={colorMap.purple}>
              {selectedColor == colorMap.purple && (
                <AntDesign name="check" size={30} color="white" />
              )}
            </View>
          </TouchableOpacity>
        </View>
      </View>
      <View style={styles.card}>
        <Text text70>Weekly Start Date</Text>
        <View row marginV-5 marginT-20>
          <Checkbox
            value={startDate}
            style={styles.checkbox}
            color="#ea156d"
            onValueChange={() => setStartDate(true)}
          />
          <View row marginL-8>
            <Text text70>Sundays</Text>
            <Text text70 color="gray">
              {" "}
              (default)
            </Text>
          </View>
        </View>
        <View row marginV-5>
          <Checkbox
            value={!startDate}
            style={styles.checkbox}
            color="#ea156d"
            onValueChange={() => setStartDate(false)}
          />
          <Text text70 marginL-8>
            Mondays
          </Text>
        </View>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  backBtn: {
    backgroundColor: "red",
    marginLeft: -2,
    justifyContent: "flex-start",
  },
  card: {
    backgroundColor: "white",
    width: "100%",
    padding: 20,
    paddingBottom: 30,
    marginTop: 20,
    borderRadius: 20,
  },
  colorBox: {
    aspectRatio: 1,
    justifyContent: "center",
    alignItems: "center",
    width: 50,
    borderRadius: 12,
  },
  checkbox: {
    borderRadius: 50,
  },
});

export default CalendarSettingsPage;
