package com.example.prettywallpapers.activity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.example.prettywallpapers.prettyadapter.FragmentAdapter;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import com.example.prettywallpapers.R;

public class MainActivity extends AppCompatActivity {
    private ViewPager2 viewPager2;
    private ImageView image_set;
    private RelativeLayout relative_main;
    private TabLayout tabLayout;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        image_set = findViewById(R.id.image_set);
        image_set.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        relative_main = findViewById(R.id.relative_main);
        init();
        viewPager2 = findViewById(R.id.view_page_main);
        viewPager2.setAdapter(new FragmentAdapter(this));
        tabLayout = findViewById(R.id.app_table);
        viewPager2.setUserInputEnabled(false);
        TabLayoutMediator tabLayoutMediator = new TabLayoutMediator(tabLayout, viewPager2, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                switch (position) {
                    case 0:
                        tab.setIcon(R.drawable.table_home_src);
                        break;
                    case 1:
                        tab.setIcon(R.drawable.table_category_src);
                        break;
                    case 2:
                        tab.setIcon(R.drawable.table_like_src);
                        break;

                }
            }
        });
        tabLayoutMediator.attach();
    }

    private void init() {
        Window window = getWindow();
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        relative_main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }
}