import { View, Image, StyleSheet, Button } from "react-native";
import { LoginForm } from "../../components/login_form/login_form";
import { useLoggin } from "../../hooks/useLoggin";
import { LIGTHT_THEME } from "../../constants/theme";
import { router } from "expo-router";
import { LANG } from "../../lang/translations";
import { LanguageIcon } from "../../components/language_icon/language_icon";
const loginImage = require("../../../assets/login-image.jpg");

export const LoginPage = () => {
  const { control, onSubmit } = useLoggin();
  return (
    <View style={styles.mainContainer}>
      <View style={styles.imageContainer}>
        <Image
          source={loginImage}
          style={{ width: "100%", height: "100%" }}
          resizeMode="cover"
        />
      </View>
      <View style={styles.loginContainer}>
        <LoginForm control={control} onSubmit={onSubmit} />
        <Button title={LANG.t('loginScreen.registerButton')}  onPress={() => router.replace('/sign_up')}/>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  mainContainer: {
    flex: 1,
    backgroundColor: LIGTHT_THEME.color.background,
  },
  imageContainer: {
    height: "40%",
    overflow: "hidden",
    borderBottomLeftRadius: 70,
    elevation: 5,
  },
  loginContainer: {
    marginHorizontal: 20,
    marginTop: "-30%",
    marginBottom: 20,
    elevation: 5,
    borderRadius: 10,
    backgroundColor: LIGTHT_THEME.color.white,
    height: "70%",
  },
  loginScroll: {
    padding: 20,
    gap: 10,
    justifyContent: "center",
  },
  title: { fontSize: 30, fontWeight: "bold", alignSelf: "center" },
  submitBtn: {
    backgroundColor: "black",
    borderRadius: 5,
    width: "100%",
    padding: 10,
    justifyContent: "center",
    alignItems: "center",
  },
  submitBtnText: {
    color: "white",
    fontSize: 20,
  },
});
