Skip to content

Commit

Permalink
Merge pull request #32 from simonyiszk/crash-handling
Browse files Browse the repository at this point in the history
Crash handling
  • Loading branch information
berenteb authored Feb 11, 2024
2 parents 0a8d816 + 68bfe40 commit 4426396
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/[...unmatched].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useRouter } from 'expo-router';
import { SafeAreaView } from 'react-native';

import { StyledButton } from '../components/common/styled-button';
import { Subtitle } from '../components/common/subtitle';
import { Title } from '../components/common/title';

export default function Unmatched() {
const { canGoBack, back } = useRouter();
return (
<SafeAreaView className='items-center justify-center flex-grow space-y-5'>
<Title className='text-center'>Ismeretlen képernyőre jutottál</Title>
<Subtitle className='text-center'>Ilyet mi itt nem tartunk</Subtitle>
{canGoBack() && (
<StyledButton leftIcon='arrow-left' onPress={back}>
Vissza
</StyledButton>
)}
</SafeAreaView>
);
}
3 changes: 3 additions & 0 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { QueryClientProvider } from '@tanstack/react-query';
import { Slot } from 'expo-router';
import { View } from 'react-native';

import { ErrorBoundary } from '../components/common/error-boundary';
import { Splash } from '../components/common/splash';
import { queryClient } from '../config/query-client.config';
import { FavoritePresentationsProvider } from '../contexts/favorite-presentations.context';

export { ErrorBoundary };

export default function MainLayout() {
return (
<QueryClientProvider client={queryClient}>
Expand Down
31 changes: 31 additions & 0 deletions components/common/error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ErrorBoundaryProps } from 'expo-router';
import { ScrollView, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

import { StyledButton } from './styled-button';
import { Subtitle } from './subtitle';
import { Title } from './title';

export function ErrorBoundary(props: ErrorBoundaryProps) {
const { top, bottom, left, right } = useSafeAreaInsets();
return (
<View
className='bg-blue-500 items-center justify-center flex-1 space-y-5'
style={{
paddingTop: top,
paddingBottom: bottom,
paddingLeft: left + 20,
paddingRight: right + 20,
}}
>
<Title className='text-white'>Hopp, ez elszállt :(</Title>
<ScrollView>
<Subtitle className='text-white/50 flex-shrink'>{props.error.message}</Subtitle>
</ScrollView>
<Subtitle className='text-white/50'>Kérlek ezt jelezd a fejlesztőknek!</Subtitle>
<StyledButton onPress={props.retry} className='bg-blue-900'>
Újrapróbálkozás
</StyledButton>
</View>
);
}

0 comments on commit 4426396

Please sign in to comment.