Test adding events by clicking on calendar cells

This commit is contained in:
Milan Paunovic
2024-09-22 13:14:26 +02:00
parent 87b2f6965d
commit e5540c15e3
4 changed files with 12 additions and 5 deletions

View File

@ -16,7 +16,7 @@
"supportsTablet": true, "supportsTablet": true,
"bundleIdentifier": "com.cally.app", "bundleIdentifier": "com.cally.app",
"googleServicesFile": "./ios/GoogleService-Info.plist", "googleServicesFile": "./ios/GoogleService-Info.plist",
"buildNumber": "10" "buildNumber": "11"
}, },
"android": { "android": {
"adaptiveIcon": { "adaptiveIcon": {

View File

@ -5,6 +5,7 @@ import {Button, Picker, PickerModes, SegmentedControl, Text, View} from "react-n
import {MaterialIcons} from "@expo/vector-icons"; import {MaterialIcons} from "@expo/vector-icons";
import {AddEventDialog} from "@/components/pages/calendar/AddEventDialog"; import {AddEventDialog} from "@/components/pages/calendar/AddEventDialog";
import {useGetEvents} from "@/hooks/firebase/useGetEvents"; import {useGetEvents} from "@/hooks/firebase/useGetEvents";
import {ManuallyAddEventModal} from "@/components/pages/calendar/ManuallyAddEventModal";
const modeMap = new Map([ const modeMap = new Map([
[0, "day"], [0, "day"],
@ -21,6 +22,8 @@ export default function Screen() {
const [calendarHeight, setCalendarHeight] = useState(0); const [calendarHeight, setCalendarHeight] = useState(0);
const [mode, setMode] = useState<"week" | "month" | "day">("week"); const [mode, setMode] = useState<"week" | "month" | "day">("week");
const [selectedDate, setSelectedDate] = useState<Date>(new Date()); const [selectedDate, setSelectedDate] = useState<Date>(new Date());
const [selectedNewEventDate, setSelectedNewEndDate] = useState<Date | undefined>(undefined);
const calendarContainerRef = useRef(null); const calendarContainerRef = useRef(null);
const { data: events} = useGetEvents() const { data: events} = useGetEvents()
@ -109,6 +112,7 @@ export default function Screen() {
events={events ?? []} events={events ?? []}
height={calendarHeight} height={calendarHeight}
activeDate={selectedDate} activeDate={selectedDate}
onPressCell={setSelectedNewEndDate}
onSwipeEnd={(newDate) => { onSwipeEnd={(newDate) => {
console.log(newDate) console.log(newDate)
setSelectedDate(newDate); setSelectedDate(newDate);
@ -117,7 +121,9 @@ export default function Screen() {
)} )}
</View> </View>
<AddEventDialog/> <AddEventDialog />
<ManuallyAddEventModal show={!!selectedNewEventDate} close={() => setSelectedNewEndDate(undefined)}/>
</View> </View>
); );
} }

View File

@ -29,14 +29,14 @@ const daysOfWeek = [
{label: "Sunday", value: "sunday"}, {label: "Sunday", value: "sunday"},
]; ];
export const ManuallyAddEventModal = ({show, close}: { show: boolean, close: () => void }) => { export const ManuallyAddEventModal = ({show, close, initialDate}: { show: boolean, close: () => void, initialDate?: Date }) => {
const {user} = useAuthContext() const {user} = useAuthContext()
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const [title, setTitle] = useState<string>(""); const [title, setTitle] = useState<string>("");
const [isAllDay, setIsAllDay] = useState(false); const [isAllDay, setIsAllDay] = useState(false);
const [startTime, setStartTime] = useState(new Date()); const [startTime, setStartTime] = useState(initialDate ?? new Date());
const [endTime, setEndTime] = useState(new Date()) const [endTime, setEndTime] = useState(new Date())
const [startDate, setStartDate] = useState(new Date()); const [startDate, setStartDate] = useState(new Date());

View File

@ -45,7 +45,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>10</string> <string>11</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>
@ -61,6 +61,7 @@
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
</array> </array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>SplashScreen</string> <string>SplashScreen</string>