package com.application.tak.takapplication;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.content.IntentCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.application.tak.takapplication.data_access.Config;
import com.application.tak.takapplication.data_model.Adress;
import com.application.tak.takapplication.data_model.User;
import com.application.tak.takapplication.services.LoginStatus;

import java.nio.channels.FileLock;

/**
 * Created by Aleksandra on 04.05.2017.
 */
public class actClientLoginTutorialFragment extends Fragment {

    private FloatingActionButton fab;
    Context ctx;
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.act_client_login_tutorial, container, false);

        ctx = getContext();
        fab = (FloatingActionButton) rootView.findViewById(R.id.floatingActionButton2);



    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if(actClientLoginRegulationFragment.regulationAccepted == false)
            {
                Toast.makeText(ctx,"Regulamin nie został zaakceptowany.",Toast.LENGTH_LONG).show();
                ((actClientLogin)getActivity()).SetCurrentItem(1);
            }
            else if(Config.LoggedInClient != null && Config.LoggedInClient.get_Id() != null) {
                Intent i = new Intent(view.getContext(), actClientTask.class);
                i.addFlags((Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
                startActivity(i);

                getActivity().finish();

            }
            else{
                Toast.makeText(ctx,"Użytkownik nie został zarejestrowany!",Toast.LENGTH_LONG).show();
                ((actClientLogin)getActivity()).SetCurrentItem(0);
            }

        }
    });



        return rootView;
    }

}