package kr.co.zumo.app.lifeplus.view.dialog;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import kr.co.zumo.app.R;
import kr.co.zumo.app.lifeplus.view.Event;

/**
 * AddRegistrationDialog
 * <pre>
 *   회원 가입 직후 메인 진입시 추가 등록 토스트 팝업 구현
 * </pre>
 *
 * @author 하세미
 * @version 1.0
 * @history 하세미   [2018-09-20]   [최초 작성]
 * @since 2018-09-20
 */
public class AddRegistrationDialog extends DialogBase implements View.OnClickListener {

  private TextView buttonAddEmail;
  private TextView buttonAddSpecialCode;

  public AddRegistrationDialog() {
  }

  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.add_registration_dialog, container, false);
    return view;
  }

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    getDialog().getWindow().setGravity(Gravity.BOTTOM);

    View view = getView();
    buttonAddEmail = (TextView) view.findViewById(R.id.button_add_email);
    buttonAddSpecialCode = (TextView) view.findViewById(R.id.button_add_special_code);

    buttonAddEmail.setOnClickListener(this::onClick);
    buttonAddSpecialCode.setOnClickListener(this::onClick);
  }

  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.button_add_email:
        getResultListener().onDialogResult(this, new Event.Builder(Event.EMAIL_CLICK).build());
        break;
      case R.id.button_add_special_code:
        getResultListener().onDialogResult(this, new Event.Builder(Event.SPECIAL_CODE_CLICK).build());
        break;
      default:
        break;

    }
  }
}




