package ch.pizzalemon.android.fragment;

import android.os.Bundle;
import androidx.appcompat.widget.AppCompatImageView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzalemon.android.R;
import ch.pizzalemon.android.helper.ImageLoadHelper;
import ch.pizzalemon.android.model.CampaignBannerModel;

public class CampaignBannerFragment extends BaseFragment {

    @BindView(R.id.campaignBannerImageView) AppCompatImageView campaignBannerImageView;

    public static final String FRAGMENT_NAME = "campaignFragment";
    private CampaignBannerModel campaignBannerModel;

    public CampaignBannerFragment() {}

    public static CampaignBannerFragment newInstance(CampaignBannerModel campaignBannerModel)  {
        Bundle args = new Bundle();
        args.putSerializable("campaignBannerModel", campaignBannerModel);
        CampaignBannerFragment fragment = new CampaignBannerFragment();
        fragment.setArguments(args);
        return fragment;
    }

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_campaign_banner, container, false);
        ButterKnife.bind(this, view);
        getDataFromArguments();
        initViews();
        return view;
    }

    private void getDataFromArguments(){
        campaignBannerModel = (CampaignBannerModel) getArguments().getSerializable("campaignBannerModel");
    }

    private void initViews(){
        ImageLoadHelper.loadImage(campaignBannerImageView, campaignBannerModel.getImageUrl());
    }
}
