import { spacing } from '@expo/styleguide-native'; import { StackScreenProps } from '@react-navigation/stack'; import dedent from 'dedent'; import { Divider, Spacer, Text, useExpoTheme, View } from 'expo-dev-client-components'; import * as React from 'react'; import { ActivityIndicator } from 'react-native'; import { ConstantItem } from '../../components/ConstantItem'; import ScrollView from '../../components/NavigationScrollView'; import ShareProjectButton from '../../components/ShareProjectButton'; import { WebContainerProjectPage_Query } from '../../graphql/types'; import { HomeStackRoutes } from '../../navigation/Navigation.types'; import { EASUpdateLaunchSection } from './EASUpdateLaunchSection'; import { EmptySection } from './EmptySection'; import { LegacyLaunchSection } from './LegacyLaunchSection'; import { ProjectHeader } from './ProjectHeader'; const ERROR_TEXT = dedent` An unexpected error has occurred. Sorry about this. We will resolve the issue as soon as possible. `; type Props = { loading: boolean; error?: Error; data?: WebContainerProjectPage_Query; } & StackScreenProps; type ProjectPageApp = WebContainerProjectPage_Query['app']['byId']; export function ProjectView({ loading, error, data, navigation }: Props) { const theme = useExpoTheme(); let contents; if (error && !data?.app?.byId) { console.log(error); contents = ( {ERROR_TEXT} ); } else if (loading || !data?.app?.byId) { contents = ( ); } else { const app = data.app.byId; contents = ( {appHasEASUpdates(app) && ( <> )} {appHasLegacyUpdate(app) && ( <> )} {!appHasLegacyUpdate(app) && !appHasEASUpdates(app) && ( <> )} {app.sdkVersion !== '0.0.0' && ( <> )} {app.latestReleaseForReleaseChannel?.runtimeVersion && ( <> )} ); } React.useEffect(() => { if (data?.app?.byId) { const fullName = data?.app.byId.fullName; const title = data?.app.byId.name ?? fullName; navigation.setOptions({ title, headerRight: () => , }); } }, [navigation, data?.app?.byId]); return {contents}; } function appHasLegacyUpdate(app: ProjectPageApp): boolean { return app.published; } function appHasEASUpdates(app: ProjectPageApp): boolean { return app.updateBranches.some((branch) => branch.updates.length > 0); }