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
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { useEffect, useRef } from "react";
|
|
import { ActionSheetIOS } from "react-native";
|
|
import { LANDING_PAGE_OPTIONS, type LandingPage } from "@/hooks/useUserPreferences";
|
|
|
|
interface LandingPagePickerProps {
|
|
visible: boolean;
|
|
currentValue: LandingPage;
|
|
onSelect: (value: LandingPage) => void;
|
|
onClose: () => void;
|
|
}
|
|
|
|
export function LandingPagePicker({
|
|
visible,
|
|
currentValue: _currentValue,
|
|
onSelect,
|
|
onClose,
|
|
}: LandingPagePickerProps) {
|
|
const sheetShownRef = useRef(false);
|
|
|
|
useEffect(() => {
|
|
if (visible && !sheetShownRef.current) {
|
|
sheetShownRef.current = true;
|
|
|
|
const options = [...LANDING_PAGE_OPTIONS.map((opt) => opt.label), "Cancel"];
|
|
const cancelButtonIndex = options.length - 1;
|
|
|
|
ActionSheetIOS.showActionSheetWithOptions(
|
|
{
|
|
title: "First Page",
|
|
message: "Choose which page opens when you launch the app",
|
|
options,
|
|
cancelButtonIndex,
|
|
destructiveButtonIndex: undefined,
|
|
},
|
|
(buttonIndex) => {
|
|
if (buttonIndex !== cancelButtonIndex && buttonIndex < LANDING_PAGE_OPTIONS.length) {
|
|
const selectedOption = LANDING_PAGE_OPTIONS[buttonIndex];
|
|
if (selectedOption) {
|
|
onSelect(selectedOption.value);
|
|
}
|
|
}
|
|
onClose();
|
|
}
|
|
);
|
|
}
|
|
|
|
if (!visible) {
|
|
sheetShownRef.current = false;
|
|
}
|
|
}, [visible, onSelect, onClose]);
|
|
|
|
return null;
|
|
}
|