/*
 * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
 */
package kr.co.zumo.app.lifeplus.view.fragment.rest;

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

import kr.co.zumo.app.R;
import kr.co.zumo.app.lifeplus.model.RestMemberModel;
import kr.co.zumo.app.lifeplus.util.ResourceUtil;
import kr.co.zumo.app.lifeplus.view.Event;
import kr.co.zumo.app.lifeplus.view.IView;
import kr.co.zumo.app.lifeplus.view.fragment.FragmentBase;
import kr.co.zumo.app.lifeplus.view.presenter.rest.RestMemberActiveCompletedPresenter;

/**
 * RestMemberActiveCompletedFragment
 * <pre>
 * </pre>
 *
 * @author 민효동
 * @version 1.0
 * @history 민효동   [2018. 10. 8.]   [최초 작성]
 * @since 2018. 10. 8.
 */
public class RestMemberActiveCompletedFragment extends FragmentBase<RestMemberActiveCompletedPresenter> implements IView {
  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    return inflater.inflate(R.layout.activity_rest_member, container, false);
  }

  @Override
  protected void onAfterActivityCreated(Bundle savedInstanceState) {
    View parent = getView();

    ((TextView) parent.findViewById(R.id.text_message)).setText(ResourceUtil.getString(R.string.rest_member_active_message));
    ((TextView) parent.findViewById(R.id.text_message_description)).setText(ResourceUtil.getString(R.string.rest_member_active_message_description));
    parent.findViewById(R.id.layout_guide).setVisibility(View.GONE);
    ((Button) parent.findViewById(R.id.button_rest_cancel)).setText(R.string.confirm);
    ((ImageView) parent.findViewById(R.id.icon)).setImageResource(R.drawable.icon_cancel_resting);

    parent.findViewById(R.id.button_rest_member_close).setOnClickListener(v -> {
      // 닫기 버튼
      presenter.onEvent(new Event.Builder(Event.EXIT).build());
    });

    parent.findViewById(R.id.button_rest_cancel).setOnClickListener(v -> {
      // 확인
      presenter.onEvent(new Event.Builder(Event.CONFIRM).build());
    });

    parent.findViewById(R.id.text_view_rest_email_information).setOnClickListener(v -> {
      presenter.onEvent(new Event.Builder(Event.EMAIL_CLICK).build());
    });

  }

  @Override
  protected RestMemberActiveCompletedPresenter definePresenter() {
    return new RestMemberActiveCompletedPresenter(getModel(RestMemberModel.class), this);
  }
}
