package com.youra.qlicker.Fragments;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.youra.qlicker.R;


public class ForgotPswrdFragment extends Fragment {

    private ImageView img_back;
    private TextView btn_recupere;

    public ForgotPswrdFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_forgot_pswrd, container, false);

        btn_recupere = (TextView) view.findViewById(R.id.btn_recupere);
        img_back = (ImageView) view.findViewById(R.id.img_back);

        img_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                getActivity().onBackPressed();


            }
        });

        btn_recupere.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                ///back to first fragment
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.frame, new ForgetPswrdMsgFragment());
                Fragment savedFragment = getActivity()
                        .getSupportFragmentManager().findFragmentByTag("forgotMsg");

                if (savedFragment == null) {
                    transaction.replace(R.id.frame, new ForgetPswrdMsgFragment() , "forgotMsg" );
                }else {
                    transaction.replace(R.id.frame, savedFragment);
                }


                transaction.addToBackStack(null);
                transaction.commit();
            }
        });

        return view;
    }
}