mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* feat(companion): add dark mode support using NativeWind system preference - Set userInterfaceStyle to 'automatic' in app.json to follow system preference - Add useColorScheme hook from NativeWind to detect color scheme - Update root layout with dynamic colors for StatusBar, containers, and modals - Update tabs layout with dynamic colors for tab bar and icons - Update all Stack.Screen options to use dynamic background colors and blur effects - Support both iOS and Android with appropriate dark mode colors Co-Authored-By: [email protected] <[email protected]> * fix(companion): use NativeWind dark: variant classes for automatic dark mode Use dark: Tailwind variant classes instead of conditional logic based on useColorScheme for the container background. This ensures NativeWind automatically applies dark mode styles based on system preference. Co-Authored-By: [email protected] <[email protected]> * fix(companion): use darkMode 'media' for automatic dark mode detection - Changed darkMode from 'class' to 'media' in tailwind.config.js - Updated global.css to use @media (prefers-color-scheme: dark) instead of .dark selector - This ensures NativeWind properly detects system color scheme on iOS/Android Co-Authored-By: [email protected] <[email protected]> * dark mode starting * feat(companion): add dark mode support to core infrastructure (Phase 1) * feat(companion): add dark mode support to tab pages (Phase 2) * fix(companion): add dark mode support to booking list components for font visibility * fix(companion): add dark mode support to EventTypeListItem components * event types and bookings page * Availability list page * more page, and some ui fixes * feat(companion): add dark mode support to detail screens and modals - BookingDetailScreen (iOS & Android): dynamic colors for all UI elements - AvailabilityDetailScreen (iOS & Android): dark mode backgrounds and text - profile-sheet (iOS & Android): dark mode support for profile modal - RescheduleScreen (all platforms): dark mode for date/time pickers - EditLocationScreen (iOS & Android): dark mode for location editor - AddGuestsScreen: partial dark mode implementation (in progress) Uses iOS system colors: #000000 (black), #1C1C1E (secondary), #FFFFFF (white), #38383A (border), #8E8E93 (text secondary) * fix typecheck and lint * feat(companion): add dark mode support to remaining screens - ScreenWrapper: Fix hardcoded #800020 color with dynamic destructive color - EditAvailabilityDayScreen: Add dark mode for Android/Web and iOS - EditAvailabilityHoursScreen: Add dark mode for Android/Web and iOS - EditAvailabilityNameScreen: Add dark mode for Android/Web and iOS - EditAvailabilityOverrideScreen: Add dark mode for Web, iOS, and Android - MarkNoShowScreen: Add dark mode with dynamic colors for no-show states - MeetingSessionDetailsScreen: Add dark mode for session details - ViewRecordingsScreen: Add dark mode for recordings list Uses iOS system colors (#000000, #1C1C1E, #38383A, #8E8E93) and useColorScheme hook for automatic theme detection. * fix(companion): fix iOS modal dark mode backgrounds for transparent glass UI * fix(companion): fix dark mode for booking action screens in transparent background mode * fix(companion): fix Android dark mode for transparent background in EditAvailabilityOverrideScreen * refactor(companion): centralize dark mode colors and align with main website - Update tailwind.config.js with centralized color definitions - Create constants/colors.ts for inline style color references - Replace iOS system colors with main website neutral grays: - #1C1C1E -> #171717 (secondary dark background) - #38383A -> #4D4D4D (dark border) - #8E8E93 -> #A3A3A3 (secondary text dark) - Keep pure black (#000000) for main backgrounds (OLED friendly) - Add semantic color mappings for consistent UI styling * feat(companion): complete dark mode implementation across all priority files - Priority 1: Updated SettingsUI.tsx, BasicsTab.tsx, LimitsTab.tsx, AdvancedTab.tsx, RecurringTab.tsx, AvailabilityTab.tsx, event-type-detail.tsx - Priority 2: Updated edit-availability-hours/name/override/day.tsx, oauth/callback.tsx - Priority 3: Updated AvailabilityListScreen.tsx with dark mode for modals and list items - Priority 4: Updated BookingActionsModal.tsx, BookingActionsModal.ios.tsx, GlassModalHeader.tsx, LoginScreen.tsx, LocationsList.tsx, SearchHeader.tsx, toast.tsx Dark mode colors used: - Main bg: #000000 (cal.bg.dark) - Secondary bg: #171717 (cal.bg.secondaryDark) - Muted bg: #262626 (cal.bg.mutedDark) - Borders: #4D4D4D (cal.border.dark) - Secondary text: #A3A3A3 (cal.text.secondaryDark) * fix(companion): add dark mode support to iOS header, GlassView modals, and main content background * fix(companion): add dark mode support to toggle/switch components * fix(companion): use iOS green (#34C759) for toggle ON state in dark mode * fix(companion): use white track + black thumb for dark mode toggles * fix(companion): add dark mode support to login page logo and button * dark mode to many pages, centralize the colors * dark mode skelaton * Availability pages android * toggles * headers * red color for dark mode * copy button * white flash on bottom ui native ios sheet * bottom sheet buttons * bottom sheet in gray color * bottom sheet again.. yeahh * toggle green * toggle green * fix lint and typechecks * fix exntension error * Update companion/components/event-type-detail/tabs/LimitsTabDatePicker.android.tsx Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * address cubic comments --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
248 lines
8.2 KiB
TypeScript
248 lines
8.2 KiB
TypeScript
import { Ionicons } from "@expo/vector-icons";
|
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from "react";
|
|
import {
|
|
Alert,
|
|
KeyboardAvoidingView,
|
|
Platform,
|
|
ScrollView,
|
|
Text,
|
|
TextInput,
|
|
TouchableOpacity,
|
|
useColorScheme,
|
|
View,
|
|
} from "react-native";
|
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
import { AppPressable } from "@/components/AppPressable";
|
|
import { FullScreenModal } from "@/components/FullScreenModal";
|
|
import { TIMEZONES as ALL_TIMEZONES } from "@/constants/timezones";
|
|
import { type Schedule, useUpdateSchedule } from "@/hooks/useSchedules";
|
|
import { showErrorAlert, showSuccessAlert } from "@/utils/alerts";
|
|
import { shadows } from "@/utils/shadows";
|
|
|
|
// Format timezones for display
|
|
const TIMEZONES = ALL_TIMEZONES.map((tz) => ({
|
|
id: tz,
|
|
label: tz.replace(/_/g, " "),
|
|
}));
|
|
|
|
export interface EditAvailabilityNameScreenProps {
|
|
schedule: Schedule | null;
|
|
onSuccess: () => void;
|
|
onSavingChange?: (isSaving: boolean) => void;
|
|
transparentBackground?: boolean;
|
|
}
|
|
|
|
export interface EditAvailabilityNameScreenHandle {
|
|
submit: () => void;
|
|
}
|
|
|
|
export const EditAvailabilityNameScreen = forwardRef<
|
|
EditAvailabilityNameScreenHandle,
|
|
EditAvailabilityNameScreenProps
|
|
>(function EditAvailabilityNameScreen({ schedule, onSuccess, onSavingChange }, ref) {
|
|
const insets = useSafeAreaInsets();
|
|
const colorScheme = useColorScheme();
|
|
const isDark = colorScheme === "dark";
|
|
|
|
const [name, setName] = useState("");
|
|
const [timezone, setTimezone] = useState("UTC");
|
|
const [showTimezoneModal, setShowTimezoneModal] = useState(false);
|
|
|
|
// Use the mutation hook for updating schedules with optimistic updates
|
|
const { mutate: updateSchedule, isPending: isSaving } = useUpdateSchedule();
|
|
|
|
// Initialize from schedule
|
|
useEffect(() => {
|
|
if (schedule) {
|
|
setName(schedule.name ?? "");
|
|
setTimezone(schedule.timeZone ?? "UTC");
|
|
}
|
|
}, [schedule]);
|
|
|
|
// Notify parent of saving state
|
|
useEffect(() => {
|
|
onSavingChange?.(isSaving);
|
|
}, [isSaving, onSavingChange]);
|
|
|
|
const handleSubmit = useCallback(() => {
|
|
if (!schedule || isSaving) return;
|
|
|
|
const trimmedName = name.trim();
|
|
if (!trimmedName) {
|
|
Alert.alert("Error", "Please enter a schedule name");
|
|
return;
|
|
}
|
|
|
|
updateSchedule(
|
|
{
|
|
id: schedule.id,
|
|
updates: {
|
|
name: trimmedName,
|
|
timeZone: timezone,
|
|
},
|
|
},
|
|
{
|
|
onSuccess: () => {
|
|
showSuccessAlert("Success", "Schedule updated successfully");
|
|
onSuccess();
|
|
},
|
|
onError: () => {
|
|
showErrorAlert("Error", "Failed to update schedule. Please try again.");
|
|
},
|
|
}
|
|
);
|
|
}, [schedule, name, timezone, onSuccess, isSaving, updateSchedule]);
|
|
|
|
// Expose submit to parent via ref
|
|
useImperativeHandle(
|
|
ref,
|
|
() => ({
|
|
submit: handleSubmit,
|
|
}),
|
|
[handleSubmit]
|
|
);
|
|
|
|
const selectedTimezoneLabel = TIMEZONES.find((tz) => tz.id === timezone)?.label || timezone;
|
|
|
|
// Render timezone list content
|
|
const renderTimezoneContent = () => (
|
|
<>
|
|
<View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-4 dark:border-[#4D4D4D]">
|
|
<Text className="text-[17px] font-semibold text-black dark:text-white">
|
|
Select Timezone
|
|
</Text>
|
|
<AppPressable onPress={() => setShowTimezoneModal(false)}>
|
|
<Ionicons name="close" size={24} color={isDark ? "#FFFFFF" : "#A3A3A3"} />
|
|
</AppPressable>
|
|
</View>
|
|
<ScrollView className="px-4 py-3">
|
|
{TIMEZONES.map((tz) => (
|
|
<AppPressable
|
|
key={tz.id}
|
|
onPress={() => {
|
|
setTimezone(tz.id);
|
|
setShowTimezoneModal(false);
|
|
}}
|
|
>
|
|
<View
|
|
className={`mb-2.5 rounded-xl border-2 px-4 py-4 ${
|
|
tz.id === timezone
|
|
? "border-[#007AFF] bg-blue-50 shadow-md dark:bg-[#0A84FF]/20"
|
|
: "border-gray-200 bg-gray-50 dark:border-[#4D4D4D] dark:bg-[#171717]"
|
|
}`}
|
|
>
|
|
<View className="flex-row items-center justify-between">
|
|
<View className="flex-1">
|
|
<Text
|
|
className={`text-[17px] ${
|
|
tz.id === timezone
|
|
? "font-semibold text-[#007AFF]"
|
|
: "font-medium text-gray-900 dark:text-white"
|
|
}`}
|
|
>
|
|
{tz.label}
|
|
</Text>
|
|
<Text className="mt-0.5 text-[13px] text-gray-500 dark:text-[#A3A3A3]">
|
|
{tz.id}
|
|
</Text>
|
|
</View>
|
|
{tz.id === timezone && (
|
|
<View className="rounded-full bg-[#007AFF] p-1.5">
|
|
<Ionicons name="checkmark" size={14} color="#FFFFFF" />
|
|
</View>
|
|
)}
|
|
</View>
|
|
</View>
|
|
</AppPressable>
|
|
))}
|
|
</ScrollView>
|
|
</>
|
|
);
|
|
|
|
if (!schedule) {
|
|
return (
|
|
<View className="flex-1 items-center justify-center bg-white dark:bg-black">
|
|
<Text className="text-gray-500 dark:text-[#A3A3A3]">No schedule data</Text>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<KeyboardAvoidingView behavior="padding" className="flex-1 bg-white dark:bg-black">
|
|
<ScrollView
|
|
className="flex-1"
|
|
contentContainerStyle={{
|
|
padding: 16,
|
|
paddingBottom: insets.bottom + 16,
|
|
}}
|
|
keyboardShouldPersistTaps="handled"
|
|
>
|
|
<Text className="mb-2 text-[13px] font-medium uppercase tracking-wide text-gray-500 dark:text-[#A3A3A3]">
|
|
Schedule Name
|
|
</Text>
|
|
<TextInput
|
|
className="mb-4 rounded-lg border border-gray-300 bg-gray-50 px-4 py-3 text-[17px] text-black dark:border-[#4D4D4D] dark:bg-[#171717] dark:text-white"
|
|
placeholder="Enter schedule name"
|
|
placeholderTextColor={isDark ? "#A3A3A3" : "#9CA3AF"}
|
|
value={name}
|
|
onChangeText={setName}
|
|
autoCapitalize="words"
|
|
editable={!isSaving}
|
|
/>
|
|
|
|
<Text className="mb-2 text-[13px] font-medium uppercase tracking-wide text-gray-500 dark:text-[#A3A3A3]">
|
|
Timezone
|
|
</Text>
|
|
<AppPressable onPress={() => setShowTimezoneModal(true)}>
|
|
<View className="flex-row items-center justify-between rounded-xl border-2 border-gray-200 bg-gray-50 px-4 py-4 dark:border-[#4D4D4D] dark:bg-[#171717]">
|
|
<View className="flex-row items-center">
|
|
<Ionicons
|
|
name="globe-outline"
|
|
size={20}
|
|
color="#007AFF"
|
|
style={{ marginRight: 12 }}
|
|
/>
|
|
<View>
|
|
<Text className="text-[17px] text-black dark:text-white">
|
|
{selectedTimezoneLabel}
|
|
</Text>
|
|
<Text className="mt-0.5 text-[13px] text-gray-500 dark:text-[#A3A3A3]">
|
|
{timezone}
|
|
</Text>
|
|
</View>
|
|
</View>
|
|
<Ionicons name="chevron-down" size={20} color={isDark ? "#A3A3A3" : "#C7C7CC"} />
|
|
</View>
|
|
</AppPressable>
|
|
</ScrollView>
|
|
|
|
<FullScreenModal
|
|
visible={showTimezoneModal}
|
|
animationType={Platform.OS === "web" ? "fade" : "slide"}
|
|
onRequestClose={() => setShowTimezoneModal(false)}
|
|
>
|
|
{Platform.OS === "web" ? (
|
|
<TouchableOpacity
|
|
className="flex-1 items-center justify-center bg-black/50 p-4"
|
|
activeOpacity={1}
|
|
onPress={() => setShowTimezoneModal(false)}
|
|
>
|
|
<TouchableOpacity
|
|
className="max-h-[80%] w-full max-w-[500px] overflow-hidden rounded-2xl bg-white p-2 dark:bg-[#171717]"
|
|
activeOpacity={1}
|
|
onPress={(e) => e.stopPropagation()}
|
|
style={shadows.xl()}
|
|
>
|
|
{renderTimezoneContent()}
|
|
</TouchableOpacity>
|
|
</TouchableOpacity>
|
|
) : (
|
|
<View className="flex-1 bg-white p-2 dark:bg-[#171717]">{renderTimezoneContent()}</View>
|
|
)}
|
|
</FullScreenModal>
|
|
</KeyboardAvoidingView>
|
|
);
|
|
});
|
|
|
|
export default EditAvailabilityNameScreen;
|