package kr.co.zumo.app.lifeplus.view.fragment.signup;

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 java.util.ArrayList;

import kr.co.zumo.app.R;
import kr.co.zumo.app.lifeplus.bean.api.BannerBean;
import kr.co.zumo.app.lifeplus.model.SignUpModel;
import kr.co.zumo.app.lifeplus.view.Event;
import kr.co.zumo.app.lifeplus.view.custom.BannerView;
import kr.co.zumo.app.lifeplus.view.fragment.FragmentBase;
import kr.co.zumo.app.lifeplus.view.presenter.signup.ISignUpStartView;
import kr.co.zumo.app.lifeplus.view.presenter.signup.SignUpStartPresenter;

/**
 * SignUpStartFragment
 * <pre>
 * </pre>
 *
 * @author 하세미
 * @version 1.0
 * @history 하세미   [2018-09-21]   [최초 작성]
 * @since 2018-09-21
 */
public class SignUpStartFragment extends FragmentBase<SignUpStartPresenter> implements ISignUpStartView {

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

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

  @Override
  protected void onAfterActivityCreated(Bundle savedInstanceState) {

    Button button = getView().findViewById(R.id.button_confirm);
    button.setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.SUCCESS).build()));

    presenter.onEvent(new Event.Builder(Event.INIT).build());
  }

  public void drawBanners(ArrayList<BannerBean> beans) {
    ViewGroup container = getView().findViewById(R.id.container_banner);

    for (BannerBean data : beans) {
      BannerView banner = new BannerView(getContext(), data.getTitle(), data.getDescription());
      container.addView(banner);
    }
  }

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

}
