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>
344 lines
12 KiB
TypeScript
344 lines
12 KiB
TypeScript
/**
|
|
* LocationsList Component
|
|
* Reusable component for displaying and managing multiple event type locations
|
|
*/
|
|
|
|
import { Ionicons } from "@expo/vector-icons";
|
|
import type React from "react";
|
|
import { useState } from "react";
|
|
import {
|
|
Modal,
|
|
Platform,
|
|
ScrollView,
|
|
Text,
|
|
TextInput,
|
|
TouchableOpacity,
|
|
useColorScheme,
|
|
View,
|
|
} from "react-native";
|
|
import type { LocationItem, LocationOptionGroup } from "@/types/locations";
|
|
import {
|
|
createLocationItemFromOption,
|
|
getLocationInputLabel,
|
|
getLocationInputPlaceholder,
|
|
locationRequiresInput,
|
|
} from "@/utils/locationHelpers";
|
|
import { LocationsListIOSPicker } from "./LocationsListIOSPicker";
|
|
import { SvgImage } from "./SvgImage";
|
|
|
|
interface LocationsListProps {
|
|
/** Array of current locations */
|
|
locations: LocationItem[];
|
|
/** Callback when a location is added */
|
|
onAdd: (location: LocationItem) => void;
|
|
/** Callback when a location is removed */
|
|
onRemove: (locationId: string) => void;
|
|
/** Callback when a location is updated (for input fields) */
|
|
onUpdate: (locationId: string, updates: Partial<LocationItem>) => void;
|
|
/** Available location options grouped by category */
|
|
locationOptions: LocationOptionGroup[];
|
|
/** Whether the component is disabled */
|
|
disabled?: boolean;
|
|
/** Whether locations are loading */
|
|
loading?: boolean;
|
|
/** Whether to hide the internal add button */
|
|
hideAddButton?: boolean;
|
|
/** External control for the add modal */
|
|
showAddModal?: boolean;
|
|
/** Callback to change modal visibility */
|
|
onShowAddModalChange?: (visible: boolean) => void;
|
|
}
|
|
|
|
function isLocationAlreadyAdded(locations: LocationItem[], optionValue: string): boolean {
|
|
return locations.some((loc) => {
|
|
if (loc.type === "integration" && optionValue.startsWith("integrations:")) {
|
|
return loc.integration === optionValue.replace("integrations:", "");
|
|
}
|
|
if (["address", "link", "phone"].includes(loc.type)) {
|
|
return false;
|
|
}
|
|
return loc.type === optionValue;
|
|
});
|
|
}
|
|
|
|
export const AddLocationTrigger = ({
|
|
isHeader = false,
|
|
locationOptions,
|
|
locations,
|
|
onSelectOption,
|
|
disabled = false,
|
|
loading = false,
|
|
onPressFallback,
|
|
}: {
|
|
isHeader?: boolean;
|
|
locationOptions: LocationOptionGroup[];
|
|
locations: LocationItem[];
|
|
onSelectOption: (value: string, label: string) => void;
|
|
disabled?: boolean;
|
|
loading?: boolean;
|
|
onPressFallback?: () => void;
|
|
}) => {
|
|
const colorScheme = useColorScheme();
|
|
const isDark = colorScheme === "dark";
|
|
|
|
const trigger = isHeader ? (
|
|
<TouchableOpacity
|
|
disabled={disabled || loading}
|
|
onPress={Platform.OS !== "ios" ? onPressFallback : undefined}
|
|
hitSlop={{ top: 15, bottom: 15, left: 15, right: 15 }}
|
|
className="flex-row items-center rounded-full border border-[#E5E5E5] bg-[#F2F2F7] p-1 dark:border-[#4D4D4D] dark:bg-[#262626]"
|
|
>
|
|
<Ionicons name="add" size={18} color={isDark ? "#FFFFFF" : "#000000"} />
|
|
</TouchableOpacity>
|
|
) : (
|
|
<TouchableOpacity
|
|
disabled={disabled || loading}
|
|
onPress={Platform.OS !== "ios" ? onPressFallback : undefined}
|
|
className={`flex-row items-center justify-center rounded-lg border border-dashed border-gray-300 bg-gray-50 px-4 py-3 dark:border-[#4D4D4D] dark:bg-[#262626] ${
|
|
disabled ? "opacity-50" : "active:bg-gray-100 dark:active:bg-[#171717]"
|
|
}`}
|
|
>
|
|
{loading ? (
|
|
<Text className="text-sm text-gray-500 dark:text-[#A3A3A3]">Loading options...</Text>
|
|
) : (
|
|
<>
|
|
<Ionicons name="add-circle-outline" size={20} color="#6B7280" />
|
|
<Text className="ml-2 text-sm font-medium text-gray-600 dark:text-[#A3A3A3]">
|
|
Add Location
|
|
</Text>
|
|
</>
|
|
)}
|
|
</TouchableOpacity>
|
|
);
|
|
|
|
if (Platform.OS !== "ios") {
|
|
return trigger;
|
|
}
|
|
|
|
const iosPicker = (
|
|
<LocationsListIOSPicker
|
|
isHeader={isHeader}
|
|
locationOptions={locationOptions}
|
|
locations={locations}
|
|
onSelectOption={onSelectOption}
|
|
trigger={trigger}
|
|
/>
|
|
);
|
|
|
|
return iosPicker ?? trigger;
|
|
};
|
|
|
|
export const LocationsList: React.FC<LocationsListProps> = ({
|
|
locations,
|
|
onAdd,
|
|
onRemove,
|
|
onUpdate,
|
|
locationOptions,
|
|
disabled = false,
|
|
loading = false,
|
|
hideAddButton = false,
|
|
showAddModal: controlledShowAddModal,
|
|
onShowAddModalChange,
|
|
}) => {
|
|
const [internalShowAddModal, setInternalShowAddModal] = useState(false);
|
|
const showAddModal = controlledShowAddModal ?? internalShowAddModal;
|
|
const setShowAddModal = onShowAddModalChange ?? setInternalShowAddModal;
|
|
|
|
const handleAddLocation = () => {
|
|
setShowAddModal(true);
|
|
};
|
|
|
|
const handleSelectOption = (optionValue: string, optionLabel: string) => {
|
|
const newLocation = createLocationItemFromOption(optionValue, optionLabel);
|
|
onAdd(newLocation);
|
|
setShowAddModal(false);
|
|
};
|
|
|
|
const renderLocationIcon = (location: LocationItem) => {
|
|
if (location.iconUrl) {
|
|
return (
|
|
<View className="mr-3 h-8 w-8 items-center justify-center rounded-lg bg-[#F2F2F7] dark:bg-[#262626]">
|
|
<SvgImage uri={location.iconUrl} width={20} height={20} />
|
|
</View>
|
|
);
|
|
}
|
|
return (
|
|
<View className="mr-3 h-8 w-8 items-center justify-center rounded-lg bg-[#F2F2F7] dark:bg-[#262626]">
|
|
<Ionicons name="location" size={18} color="#000000" />
|
|
</View>
|
|
);
|
|
};
|
|
|
|
const renderLocationInput = (location: LocationItem) => {
|
|
if (!locationRequiresInput(location.type)) {
|
|
return null;
|
|
}
|
|
|
|
const placeholder = getLocationInputPlaceholder(location.type);
|
|
const label = getLocationInputLabel(location.type);
|
|
|
|
let value = "";
|
|
let fieldKey: "address" | "link" | "phone" = "address";
|
|
|
|
switch (location.type) {
|
|
case "address":
|
|
value = location.address || "";
|
|
fieldKey = "address";
|
|
break;
|
|
case "link":
|
|
value = location.link || "";
|
|
fieldKey = "link";
|
|
break;
|
|
case "phone":
|
|
value = location.phone || "";
|
|
fieldKey = "phone";
|
|
break;
|
|
}
|
|
|
|
return (
|
|
<View className="mt-2">
|
|
<Text className="mb-1 text-[13px] text-[#6D6D72] dark:text-[#A3A3A3]">{label}</Text>
|
|
<TextInput
|
|
className="rounded-lg bg-[#F2F2F7] px-3 py-2 text-[17px] text-black dark:bg-[#262626] dark:text-white"
|
|
placeholder={placeholder}
|
|
value={value}
|
|
onChangeText={(text) => onUpdate(location.id, { [fieldKey]: text })}
|
|
editable={!disabled}
|
|
keyboardType={location.type === "phone" ? "phone-pad" : "default"}
|
|
autoCapitalize={location.type === "link" ? "none" : "sentences"}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<View className="bg-white dark:bg-[#171717]">
|
|
{/* Locations List */}
|
|
{locations.length > 0 ? (
|
|
<View className="mb-2">
|
|
{locations.map((location, index) => (
|
|
<View
|
|
key={location.id}
|
|
className={`pl-4 ${
|
|
index !== locations.length - 1
|
|
? "border-b border-[#E5E5E5] dark:border-[#4D4D4D]"
|
|
: ""
|
|
}`}
|
|
>
|
|
<View
|
|
className={`pr-4 ${
|
|
index === 0 ? "pt-4 pb-3" : index === locations.length - 1 ? "pt-3 pb-4" : "py-3"
|
|
}`}
|
|
>
|
|
<View className="flex-row items-center justify-between">
|
|
<View className="flex-1 flex-row items-center">
|
|
{renderLocationIcon(location)}
|
|
<Text
|
|
className="flex-1 text-[17px] text-black font-normal dark:text-white"
|
|
numberOfLines={1}
|
|
>
|
|
{location.displayName}
|
|
</Text>
|
|
</View>
|
|
{!disabled ? (
|
|
<TouchableOpacity
|
|
onPress={() => onRemove(location.id)}
|
|
className="ml-2"
|
|
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
>
|
|
<Ionicons name="close-circle" size={20} color="#C7C7CC" />
|
|
</TouchableOpacity>
|
|
) : null}
|
|
</View>
|
|
{renderLocationInput(location)}
|
|
</View>
|
|
</View>
|
|
))}
|
|
</View>
|
|
) : null}
|
|
|
|
{/* Add Location Button */}
|
|
{!hideAddButton && (
|
|
<View className="pb-2 pt-1 items-center justify-center">
|
|
<AddLocationTrigger
|
|
locationOptions={locationOptions}
|
|
locations={locations}
|
|
onSelectOption={handleSelectOption}
|
|
onPressFallback={handleAddLocation}
|
|
disabled={disabled}
|
|
loading={loading}
|
|
/>
|
|
</View>
|
|
)}
|
|
|
|
{/* Add Location Modal (for non-iOS) */}
|
|
<Modal
|
|
visible={showAddModal}
|
|
transparent
|
|
animationType="slide"
|
|
onRequestClose={() => setShowAddModal(false)}
|
|
>
|
|
<View className="flex-1 justify-end bg-black/50">
|
|
<View className="max-h-[70%] rounded-t-3xl bg-white dark:bg-[#171717]">
|
|
{/* Header */}
|
|
<View className="flex-row items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-[#4D4D4D]">
|
|
<Text className="text-lg font-semibold text-gray-900 dark:text-white">
|
|
Add Location
|
|
</Text>
|
|
<TouchableOpacity onPress={() => setShowAddModal(false)} className="p-1">
|
|
<Ionicons name="close" size={24} color="#6B7280" />
|
|
</TouchableOpacity>
|
|
</View>
|
|
|
|
{/* Options List */}
|
|
<ScrollView className="px-4 py-2">
|
|
{locationOptions.map((group, groupIndex) => (
|
|
<View key={group.category} className={groupIndex > 0 ? "mt-4" : ""}>
|
|
<Text className="mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-[#A3A3A3]">
|
|
{group.category}
|
|
</Text>
|
|
{group.options.map((option) => {
|
|
const alreadyAdded = isLocationAlreadyAdded(locations, option.value);
|
|
|
|
return (
|
|
<TouchableOpacity
|
|
key={option.value}
|
|
onPress={() => handleSelectOption(option.value, option.label)}
|
|
disabled={alreadyAdded}
|
|
className={`flex-row items-center rounded-lg px-2 py-3 ${
|
|
alreadyAdded
|
|
? "opacity-40"
|
|
: "active:bg-gray-100 dark:active:bg-[#262626]"
|
|
}`}
|
|
>
|
|
{option.iconUrl ? (
|
|
<SvgImage
|
|
uri={option.iconUrl}
|
|
width={24}
|
|
height={24}
|
|
style={{ marginRight: 12 }}
|
|
/>
|
|
) : (
|
|
<View style={{ marginRight: 12 }}>
|
|
<Ionicons name="location-outline" size={24} color="#6B7280" />
|
|
</View>
|
|
)}
|
|
<Text className="flex-1 text-base text-gray-900 dark:text-white">
|
|
{option.label}
|
|
</Text>
|
|
{alreadyAdded && <Ionicons name="checkmark" size={20} color="#10B981" />}
|
|
</TouchableOpacity>
|
|
);
|
|
})}
|
|
</View>
|
|
))}
|
|
{/* Bottom padding for safe area */}
|
|
<View className="h-8" />
|
|
</ScrollView>
|
|
</View>
|
|
</View>
|
|
</Modal>
|
|
</View>
|
|
);
|
|
};
|