import { Text, View } from "react-native";
import BaseBackground from "../../components/BaseBackground";
import BaseButton, { BaseButtonProps } from "../../components/BaseButton";
import { useThemeStore } from "../../stores/ThemeStore";
import { AuthService } from "../../services/AuthService";
import { router } from "expo-router";
import { Ionicons } from "@expo/vector-icons";
import { SimpleHeader } from "../../components/Header";
import { THEMES } from "../../Themes";
import CustomTextInput from "../../components/CustomTextInput";
import { useState } from "react";
import { CaldavConfigService } from "../../services/CaldavConfigService";
import { useCaldavConfigStore } from "../../stores";
const handleLogout = async () => {
await AuthService.logout();
router.replace("/login");
};
const SettingsButton = (props: BaseButtonProps) => {
return (
{props.children}
);
};
type CaldavTextInputProps = {
title: string;
value: string;
onValueChange: (text: string) => void;
};
const CaldavTextInput = ({
title,
value,
onValueChange,
}: CaldavTextInputProps) => {
return (
{title}:
);
};
const CaldavSettings = () => {
const { theme } = useThemeStore();
const { config, setConfig } = useCaldavConfigStore();
const [serverUrl, setServerUrl] = useState(config?.serverUrl ?? "");
const [username, setUsername] = useState(config?.username ?? "");
const [password, setPassword] = useState(config?.password ?? "");
const saveConfig = async () => {
const saved = await CaldavConfigService.saveConfig(
serverUrl,
username,
password,
);
setConfig(saved);
};
const sync = async () => {
await CaldavConfigService.sync();
};
return (
<>
Caldav Config
Save
Sync
>
);
};
const Settings = () => {
const { theme, setTheme } = useThemeStore();
return (
{" "}
Logout
Select Theme
{
setTheme("defaultLight");
}}
>
Default Light
{
setTheme("defaultDark");
}}
>
Default Dark
);
};
export default Settings;