* refactor(companion): extract AvailabilityDetailScreen with AppPressable migration Apply Phases 2, 3, 4 to availability-detail.tsx: - Phase 2: Extract screen logic (~995 lines) to components/screens/AvailabilityDetailScreen.tsx - Route file is now a minimal ~35 line wrapper with Stack.Screen config - Phase 3: ScrollView+map pattern kept (7 days is a fixed small list, FlatList not needed) - Phase 4: Migrate all TouchableOpacity to AppPressable (63 instances) Follows the same pattern as EventTypeDetailScreen extraction. * fix(companion): add GlassView header with Save button to AvailabilityDetailScreen (#26107) * refactor(companion): extract BookingDetailScreen with AppPressable migration (#26108) * refactor(companion): extract AvailabilityListScreen with AppPressable migration (#26109) * fix(companion): add GlassView header with Save button to AvailabilityDetailScreen * refactor(companion): extract BookingDetailScreen with AppPressable migration * refactor(companion): extract AvailabilityListScreen with AppPressable migration * refactor(companion): Standardized error handling with dev-only debug logs (#26110) * address cubics comments * address cubics comments * addressed typecheck erros * removed localhost from wxt.config for chrome extension * declare FullScreenModal FullScreenModalProps --------- Co-authored-by: Peer Richelsen <[email protected]> * add loggers for dev env --------- Co-authored-by: Peer Richelsen <[email protected]> --------- Co-authored-by: Peer Richelsen <[email protected]>
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
/**
|
|
* Browser Utilities
|
|
*
|
|
* Centralized utility for opening links in the in-app browser.
|
|
* Configured for session sharing with Safari/Chrome to maintain login state.
|
|
*/
|
|
|
|
import * as WebBrowser from "expo-web-browser";
|
|
import { showErrorAlert } from "./alerts";
|
|
|
|
/**
|
|
* Configuration options for in-app browser
|
|
*/
|
|
export interface BrowserOptions {
|
|
/** iOS: Toolbar color (hex string) */
|
|
toolbarColor?: string;
|
|
/** iOS: Controls color (hex string) */
|
|
controlsColor?: string;
|
|
}
|
|
|
|
/**
|
|
* Open a URL in the in-app browser with session sharing enabled.
|
|
*
|
|
* Session sharing allows cookies to be shared between the in-app browser
|
|
* and Safari (iOS) or Chrome (Android). This means users who authenticate
|
|
* via OAuth will remain logged in when opening Cal.com links.
|
|
*
|
|
* @param url - The URL to open
|
|
* @param fallbackMessage - Optional message to show in error alert (defaults to "link")
|
|
* @param options - Optional browser customization options
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* // Open a link with session sharing
|
|
* await openInAppBrowser("https://app.cal.com");
|
|
*
|
|
* // With custom error message
|
|
* await openInAppBrowser("https://app.cal.com/settings", "Settings page");
|
|
*
|
|
* // With custom toolbar color
|
|
* await openInAppBrowser("https://app.cal.com", "Cal.com", { toolbarColor: "#111827" });
|
|
* ```
|
|
*/
|
|
export const openInAppBrowser = async (
|
|
url: string,
|
|
fallbackMessage?: string,
|
|
options?: BrowserOptions
|
|
): Promise<void> => {
|
|
try {
|
|
// Configure browser options
|
|
// Session sharing happens automatically when using Safari View Controller (iOS)
|
|
// or Chrome Custom Tabs (Android) - no special configuration needed
|
|
const browserOptions: WebBrowser.WebBrowserOpenOptions = {
|
|
...(options?.toolbarColor && { toolbarColor: options.toolbarColor }),
|
|
...(options?.controlsColor && { controlsColor: options.controlsColor }),
|
|
};
|
|
|
|
await WebBrowser.openBrowserAsync(url, browserOptions);
|
|
} catch (error) {
|
|
console.error("Failed to open link");
|
|
if (__DEV__) {
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
const stack = error instanceof Error ? error.stack : undefined;
|
|
console.debug("[openInAppBrowser] failed", { message, stack, fallbackMessage });
|
|
}
|
|
showErrorAlert("Error", `Failed to open ${fallbackMessage || "link"}. Please try again.`);
|
|
}
|
|
};
|