import React from "react"; import { Pressable, ScrollView } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { StatusBar } from "expo-status-bar"; import { useColorScheme } from "nativewind"; import { MutedText, Text } from "../../components/text"; import { Button } from "../../components/button"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "../../components/card"; import { withClickTracking } from "../../services/telemetry"; /** A signed-in account the picker can choose. */ export interface PickableAccount { userId: string; username: string; email: string; displayName?: string; } export interface AccountPickerScreenProps { accounts: PickableAccount[]; /** Continue as the chosen account. */ onSelect: (account: PickableAccount) => void; /** Sign in with a different account. */ onUseAnother: () => void; isLoading?: boolean; } /** * "Choose an account" screen for multi-session SSO (OIDC `prompt=select_account` * style). Presentational: the host app supplies the accounts and handles the * selection (resume the authorize request) / "use another" (login) navigation. */ export function AccountPickerScreen({ accounts, onSelect, onUseAnother, isLoading, }: AccountPickerScreenProps) { const { colorScheme } = useColorScheme(); const isDark = colorScheme === "dark"; return ( Choose an account Select an account to continue, or use a different one. {accounts.length === 0 ? ( No signed-in accounts. ) : ( accounts.map((a) => ( onSelect(a))} disabled={isLoading} accessibilityRole="button" accessibilityLabel={`Continue as ${a.username}`} className="rounded-md border border-border px-3 py-3" > {a.displayName || a.username} {a.email} )) )} ); } export default AccountPickerScreen;