package com.app.simplitend.welcome.welcomepatient.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;

import com.app.simplitend.R;
import com.app.simplitend.databinding.SignInUpFragmentBinding;

public class SignInSignUpFragment extends Fragment {

    // view binding
    protected SignInUpFragmentBinding binding;

    protected OnBoardPagerAdapter onBoardPagerAdapter;

    public SignInSignUpFragment(){
        // required empty constructor
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = SignInUpFragmentBinding.inflate(inflater, container, false);

        initViews();

        clickEvents();

        return binding.getRoot();
    }

    private void clickEvents() {

        // log in
        binding.login.setOnClickListener(v ->
                Navigation.findNavController(v).navigate(R.id.action_signInSignUpFragment_to_signInFragment)
        );

        // register
        binding.register.setOnClickListener(v ->
                Navigation.findNavController(v).navigate(R.id.action_signInSignUpFragment_to_howToSetUpFragment)
        );

    }

    private void initViews() {
        onBoardPagerAdapter = new OnBoardPagerAdapter(getChildFragmentManager(), getLifecycle());
        binding.viewPager.setAdapter(onBoardPagerAdapter);
        binding.circleIndicator.setViewPager(binding.viewPager);
    }
}
