package com.hd.live.wall.wallpapers.act;

import android.content.Intent;
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.wall.wallpapers.R;
import com.hd.live.wall.wallpapers.adapter.AdaViewP;
import com.hd.live.wall.wallpapers.base.BasisActivity;
import com.hd.live.wall.wallpapers.databinding.ActivityMainBinding;
import com.hd.live.wall.wallpapers.databinding.MainTabBinding;

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

public class ActivityMain extends BasisActivity<ActivityMainBinding> {


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

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

        AdaViewP adapter = new AdaViewP(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) {
                MainTabBinding inflate = MainTabBinding.inflate(getLayoutInflater());
                tab.setCustomView(inflate.getRoot());
                switch (position) {
                    case 0:
                        inflate.tabTitle.setText(ContextCompat.getString(ActivityMain.this, R.string.tab_Trending));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActivityMain.this, R.drawable.status_fire));
                        break;
                    case 1:
                        inflate.tabTitle.setText(ContextCompat.getString(ActivityMain.this, R.string.tab_Explore));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActivityMain.this, R.drawable.status_xplore));
                        break;
                    case 2:
                        inflate.tabTitle.setText(ContextCompat.getString(ActivityMain.this, R.string.tab_Shift));
                        inflate.tabIm.setImageDrawable(ContextCompat.getDrawable(ActivityMain.this, R.drawable.status_shift));
                        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() {
     vb.ivFavorite.setOnClickListener(this);
    }

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

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

    @Override
    public void onClick(View v) {
        if(v.equals(vb.ivFavorite)){
            Intent intent = new Intent(this, ActivityCollection.class);
            startActivity(intent);
        }

    }
}