import SingleFileDrop from 'components/FileDrop';
import NavbarBack from 'components/NavbarBack';
import Navigation from 'components/Navigation';
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import {
  RefreshControl,
  ScrollView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import TabsAutoWarehouses from './TabsAutoWarehouses';
import TabsAviaWarehouses from './TabsAviaWarehouses';

interface WarehousesProps {}

const Warehouses = (props: WarehousesProps) => {
  const [refreshing, setRefreshing] = React.useState(false);
  const { t } = useTranslation();

  const onRefresh = React.useCallback(() => {
    setRefreshing(true);
    setTimeout(() => {
      setRefreshing(false);
    }, 1500);
  }, []);

  const refreshControl = React.useMemo(
    () => <RefreshControl refreshing={refreshing} onRefresh={onRefresh} />,
    [refreshing, onRefresh],
  );

  const contentContainerStyle = React.useMemo(
    () => ({ paddingBottom: 10 }),
    [],
  );
  return (
    <SafeAreaView style={{ flex: 1 }}>
      <View style={styles.container}>
        <NavbarBack title={t('Xitoy omborlari manzili')} />
        <ScrollView
          keyboardShouldPersistTaps="handled"
          refreshControl={refreshControl}
          contentContainerStyle={contentContainerStyle}
        >
          <View style={styles.card}>
            <Text style={styles.title}>{t('Bizning Xitoy manzilimiz')}</Text>
            <Text style={styles.text}>
              {t(
                'Taobao, pinduoduo, 1688 ,alibaba va Xitoyning istalgan platformasiga kiritish uchun',
              )}
            </Text>
            <TabsAviaWarehouses />
            <TabsAutoWarehouses />
            <Text style={styles.title}>
              {t('Xitoy omborlarimiz manzilini programmaga kiriting')}
            </Text>
            <View style={{ gap: 20 }}>
              <Text style={styles.text}>
                {t(
                  "Diqqat! Iltimos, Xitoy omborimiz manzilini Xitoy programmalariga kiritganingizdan so'ng, kiritilgan holatdagi skrenshotni bizga yuborib, tekshirtiring",
                )}
              </Text>
              <Text style={styles.text}>
                {t(
                  "Xitoy ombori manzilini to'g'ri kiritish, mahsulotingiz yo'qolib qolish oldini oladi.",
                )}
              </Text>
              <Text style={styles.text}>
                {t(
                  "Agar sizda savol tug'ilsa yoki biron narsaga tushunmasangiz bizga murojaat qiling",
                )}
              </Text>
            </View>
            <Text style={styles.title}>{t('Skrenshot rasmini yuklang')}</Text>
            <SingleFileDrop title={t('Rasmni shu yerga yuklang')} />
            <TouchableOpacity style={styles.button}>
              <Text style={styles.btnText}>{t('Manzilni tekshirish')}</Text>
            </TouchableOpacity>
          </View>
        </ScrollView>
        <Navigation />
      </View>
    </SafeAreaView>
  );
};

export default Warehouses;

const styles = StyleSheet.create({
  container: { flex: 1 },
  card: {
    width: '95%',
    marginTop: 20,
    margin: 'auto',
    gap: 10,
  },
  title: {
    fontSize: 20,
    fontWeight: '500',
  },
  text: {
    fontSize: 18,
    color: '#000000B2',
    fontWeight: '400',
  },
  button: {
    backgroundColor: '#28A7E8',
    height: 56,
    borderRadius: 8,
    textAlign: 'center',
    display: 'flex',
    justifyContent: 'center',
  },
  btnText: {
    color: '#fff',
    fontSize: 20,
    textAlign: 'center',
  },
});
