package com.hd.live.wallpapers.actfrag;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.hd.live.wallpapers.R;
import com.hd.live.wallpapers.alladapter.AdaVp;
import com.hd.live.wallpapers.base.BaseActivity;
import com.hd.live.wallpapers.databinding.ActMainBinding;
import com.hd.live.wallpapers.databinding.ItemTabViewBinding;

import java.util.ArrayList;
import java.util.List;

public class ActMain extends BaseActivity<ActMainBinding> {


    @Override
    protected ActMainBinding getViewBinding() {
        return ActMainBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void onCreateInit() {
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(FragHome.newInstance(0));
        fragmentList.add(FragHome.newInstance(3));
        fragmentList.add(FragHome.newInstance(2));
        fragmentList.add(FragLike.newInstance());

        AdaVp adapter = new AdaVp(this, fragmentList);
        vb.vp.setAdapter(adapter);
        new TabLayoutMediator(vb.tab, vb.vp, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                ItemTabViewBinding inflate = ItemTabViewBinding.inflate(getLayoutInflater());
                tab.setCustomView(inflate.getRoot());
                switch (position) {
                    case 0:
                        inflate.tabTitle.setText(ContextCompat.getString(ActMain.this, R.string.tab_Trending));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActMain.this, R.drawable.selector_tab1));
                        break;
                    case 1:
                        inflate.tabTitle.setText(ContextCompat.getString(ActMain.this, R.string.tab_Explore));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActMain.this, R.drawable.selector_tab2));
                        break;
                    case 2:
                        inflate.tabTitle.setText(ContextCompat.getString(ActMain.this, R.string.tab_Shift));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActMain.this, R.drawable.selector_tab3));
                        break;
                    case 3:
                        inflate.tabTitle.setText(ContextCompat.getString(ActMain.this, R.string.tab_Favorites));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActMain.this, R.drawable.selector_tab_like));
                        break;
                }
            }
        }).attach();
    }

    @Override
    protected void onInitClick() {

    }

    @Override
    public boolean isFullScreen() {
        return true;
    }

    @Override
    public boolean statusBarLight() {
        return false;
    }

    @Override
    public void onClick(View v) {

    }
}