mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* feat(companion): add configurable landing page feature - Add useUserPreferences hook for persistent storage of landing page preference - Add LandingPagePicker component for both iOS and Android/web platforms - Update tabs index to redirect based on user preference - Update bookings index to accept initial filter from URL params - Add App Settings section in More screen with landing page selector - Clear user preferences on logout for fresh state * fix(companion): remove try-finally for React Compiler compatibility * fix(companion): use router.replace for dynamic landing page redirect Replace Redirect component with router.replace() to fix TypeScript strict typing issue with expo-router's Href type for dynamic routes. * fix(companion): use literal route strings for TypeScript strict typing Use switch statement with literal route strings instead of dynamic string variable to satisfy expo-router's strict Href type checking. * working fix * better css
76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
import { Ionicons } from "@expo/vector-icons";
|
|
import { Platform, Text, TouchableOpacity, View } from "react-native";
|
|
import { FullScreenModal } from "./FullScreenModal";
|
|
import {
|
|
LANDING_PAGE_OPTIONS,
|
|
type LandingPage,
|
|
type LandingPageOption,
|
|
} from "@/hooks/useUserPreferences";
|
|
|
|
interface LandingPagePickerProps {
|
|
visible: boolean;
|
|
currentValue: LandingPage;
|
|
onSelect: (value: LandingPage) => void;
|
|
onClose: () => void;
|
|
}
|
|
|
|
export function LandingPagePicker({
|
|
visible,
|
|
currentValue,
|
|
onSelect,
|
|
onClose,
|
|
}: LandingPagePickerProps) {
|
|
const handleSelect = (option: LandingPageOption) => {
|
|
onSelect(option.value);
|
|
onClose();
|
|
};
|
|
|
|
return (
|
|
<FullScreenModal visible={visible} onRequestClose={onClose}>
|
|
<View className="flex-1 items-center justify-center bg-black/50">
|
|
<View className="mx-4 min-w-[320px] max-w-[400px] rounded-lg bg-white shadow-lg">
|
|
<View className="border-b border-gray-200 px-4 py-3">
|
|
<Text className="text-lg font-semibold text-gray-900">First Page</Text>
|
|
<Text className="mt-1 text-sm text-gray-500">
|
|
Choose which page opens when you launch the app
|
|
</Text>
|
|
</View>
|
|
|
|
<View className="py-2">
|
|
{LANDING_PAGE_OPTIONS.map((option) => {
|
|
const isSelected = currentValue === option.value;
|
|
return (
|
|
<TouchableOpacity
|
|
key={option.value}
|
|
onPress={() => handleSelect(option)}
|
|
className="flex-row items-center justify-between px-4 py-3 active:bg-gray-100"
|
|
style={Platform.OS === "web" ? { cursor: "pointer" } : undefined}
|
|
activeOpacity={0.7}
|
|
>
|
|
<Text
|
|
className={`text-base ${isSelected ? "font-semibold text-gray-900" : "text-gray-700"}`}
|
|
>
|
|
{option.label}
|
|
</Text>
|
|
{isSelected && <Ionicons name="checkmark" size={20} color="#111827" />}
|
|
</TouchableOpacity>
|
|
);
|
|
})}
|
|
</View>
|
|
|
|
<View className="border-t border-gray-200 px-4 py-3">
|
|
<TouchableOpacity
|
|
onPress={onClose}
|
|
className="items-center rounded-md border border-gray-300 bg-white px-4 py-2"
|
|
style={Platform.OS === "web" ? { cursor: "pointer" } : undefined}
|
|
activeOpacity={0.7}
|
|
>
|
|
<Text className="font-medium text-gray-700">Cancel</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</FullScreenModal>
|
|
);
|
|
}
|