feat: add EditEventScreen with calendar and chat mode support
Add a unified event editor that works in two modes: - Calendar mode: Create/edit events directly via EventService API - Chat mode: Edit AI-proposed events before confirming them The chat mode allows users to modify proposed events (title, time, recurrence) and persists changes both locally and to the server. New components: DateTimePicker, ScrollableDropdown, useDropdownPosition New API: PUT /api/chat/messages/:messageId/proposal
This commit is contained in:
37
apps/client/src/hooks/useDropdownPosition.ts
Normal file
37
apps/client/src/hooks/useDropdownPosition.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
|
||||
type DropdownPosition = {
|
||||
top: number;
|
||||
left: number;
|
||||
width: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook for managing dropdown position measurement and visibility.
|
||||
* @param widthMultiplier - Multiply the measured width (default: 1)
|
||||
*/
|
||||
export const useDropdownPosition = (widthMultiplier = 1) => {
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [position, setPosition] = useState<DropdownPosition>({
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 0,
|
||||
});
|
||||
const ref = useRef<View>(null);
|
||||
|
||||
const open = useCallback(() => {
|
||||
ref.current?.measureInWindow((x, y, width, height) => {
|
||||
setPosition({
|
||||
top: y + height,
|
||||
left: x,
|
||||
width: width * widthMultiplier,
|
||||
});
|
||||
setVisible(true);
|
||||
});
|
||||
}, [widthMultiplier]);
|
||||
|
||||
const close = useCallback(() => setVisible(false), []);
|
||||
|
||||
return { ref, visible, position, open, close };
|
||||
};
|
||||
Reference in New Issue
Block a user