package com.example.logistics.ui;

import androidx.fragment.app.Fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.example.logistics.R;

public class MeUI extends Fragment implements View.OnClickListener{
    private LinearLayout ll_waiting;
    private LinearLayout ll_history;
    private LinearLayout ll_exit;
    private Context mContext;
    private String user;

    public MeUI(){

    }
    @Nullable

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.my_fragment3,container,false);

        ll_waiting = (LinearLayout) view.findViewById(R.id.waiting);
        ll_history = (LinearLayout) view.findViewById(R.id.history);
        ll_exit = (LinearLayout) view.findViewById(R.id.exit);

        ll_waiting.setOnClickListener(this);
        ll_history.setOnClickListener(this);
        ll_exit.setOnClickListener(this);

        mContext = getActivity();

        Bundle bundle = getArguments();
        user = bundle.getString("user");

        return view;
    }

    @Override
    public void onClick(View view) {
        Intent intent;
        switch(view.getId()){
            case R.id.waiting:
                intent = new Intent(mContext, NoPickActivity.class);
                intent.putExtra("user", user);
                startActivity(intent);
                break;
            case R.id.history:

                intent = new Intent(mContext, HistoryActivity.class);
                intent.putExtra("user", user);
                startActivity(intent);
                break;
            case R.id.exit:
                Toast.makeText(mContext, "exit", Toast.LENGTH_SHORT).show();
                intent = new Intent(mContext, LoginActivity.class);
                startActivity(intent);
                getActivity().finish();
                break;
        }
    }
}

