import { Link, Stack } from 'expo-router';
import { StyleSheet, useWindowDimensions } from 'react-native';

import { Text, View } from '@/components/Themed';
import { clampContentWidth, isIPadLike } from '@/src/utils/device';

export default function NotFoundScreen() {
  const { width, height } = useWindowDimensions();
  const isTablet = isIPadLike(width, height);
  const contentWidth = isTablet ? clampContentWidth(width, 680, 24) : undefined;

  return (
    <>
      <Stack.Screen options={{ title: 'Oops!' }} />
      <View style={styles.container}>
        <View style={[styles.contentWrap, contentWidth ? { width: contentWidth } : null]}>
          <Text style={styles.title}>This screen doesn't exist.</Text>

          <Link href="/" style={styles.link}>
            <Text style={styles.linkText}>Go to home screen!</Text>
          </Link>
        </View>
      </View>
    </>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    padding: 20,
    width: '100%',
    alignSelf: 'stretch',
  },
  contentWrap: {
    width: '100%',
    alignItems: 'center',
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold',
  },
  link: {
    marginTop: 15,
    paddingVertical: 15,
  },
  linkText: {
    fontSize: 14,
    color: '#2e78b7',
  },
});
