import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import AppText from 'components/AppText';
import { useTranslation } from 'react-i18next';
import {
  Image,
  ScrollView,
  StyleSheet,
  TouchableOpacity,
  View,
  useWindowDimensions,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import Logo from 'screens/../../assets/bootsplash/logo_512.png';
import InfoIcon from 'svg/Info';
import { RootStackParamList } from 'types/types';

type LoginScreenNavigationProp = NativeStackNavigationProp<
  RootStackParamList,
  'Login'
>;

const SelectAuth = () => {
  const { t } = useTranslation();
  const navigation = useNavigation<LoginScreenNavigationProp>();
  const { width } = useWindowDimensions();

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <View style={styles.container}>
        <ScrollView
          style={{ flex: 1 }}
          contentContainerStyle={styles.scrollContent}
          showsVerticalScrollIndicator={false}
        >
          <View style={[styles.innerContainer, { maxWidth: 500 }]}>
            <View style={styles.logoWrapper}>
              <Image
                source={Logo}
                style={[
                  styles.logoImage,
                  {
                    width: 180,
                    height: 180,
                  },
                ]}
              />
              {/* <AppText style={[styles.logoText, { fontSize: 32 }]}>CPOST</AppText> */}
            </View>

            <AppText style={[styles.title, { fontSize: 24 }]}>
              {t('Ro’yxatdan o’tganmisz')}
            </AppText>

            <View style={styles.btnContainer}>
              <View style={{ gap: 6 }}>
                <TouchableOpacity
                  onPress={() => navigation.navigate('Login')}
                  style={[
                    styles.button,
                    {
                      backgroundColor: 'none',
                      borderWidth: 1,
                      borderColor: '#28A7E8',
                    },
                  ]}
                >
                  <AppText style={[styles.btnText, { color: '#28A7E8' }]}>
                    {t('Tizimga kirish')}
                  </AppText>
                </TouchableOpacity>
                <View
                  style={{
                    gap: 4,
                    flexDirection: 'row',
                    justifyContent: 'center',
                    alignItems: 'center',
                  }}
                >
                  <InfoIcon color="#000" height={18} width={18} />
                  <AppText style={styles.helperText}>
                    {t("Botdan ro'yxatdan o’tganmisiz")}?
                  </AppText>
                </View>
              </View>
              <View style={{ gap: 6 }}>
                <TouchableOpacity
                  onPress={() => navigation.navigate('Register')}
                  style={styles.button}
                >
                  <AppText style={styles.btnText}>
                    {t('Ro’yxatdan o’tish')}
                  </AppText>
                </TouchableOpacity>
                <View
                  style={{
                    gap: 4,
                    flexDirection: 'row',
                    justifyContent: 'center',
                    alignItems: 'center',
                  }}
                >
                  <InfoIcon color="#000" height={18} width={18} />
                  <AppText style={styles.helperText}>
                    {t("Yangi ro’yxatdan o'tmoqchimisiz")}?
                  </AppText>
                </View>
              </View>
            </View>
          </View>
        </ScrollView>
      </View>
    </SafeAreaView>
  );
};

export default SelectAuth;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingHorizontal: 20,
    margin: 5,
    borderRadius: 12,
  },
  scrollContent: {
    flexGrow: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  innerContainer: {
    width: '100%',
    paddingHorizontal: 10,
  },
  logoWrapper: {
    alignItems: 'center',
    marginBottom: 20,
  },
  logoImage: {
    resizeMode: 'stretch',
  },
  logoText: {
    fontWeight: '500',
    color: '#28A7E8',
  },
  title: {
    fontFamily: 'GolosText-Bold',
    textAlign: 'center',
    color: '#000',
    marginBottom: 20,
  },
  helperText: {
    color: '#252525ff',
    fontSize: 12,
  },
  button: {
    backgroundColor: '#28A7E8',
    height: 56,
    borderRadius: 6,
    justifyContent: 'center',
  },
  btnText: {
    color: '#fff',
    fontSize: 18,
    textAlign: 'center',
  },
  btnContainer: {
    gap: 16,
  },
});
