package com.wall.engine.wallpaper;

import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.viewpager2.widget.ViewPager2;

import com.wall.engine.wallpaper.R;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);


        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(android.R.color.transparent));

        setContentView(R.layout.activity_main2);

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), (v, insets) -> {
            int systemBarsTop = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top;
            int systemBarsBottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
            v.setPadding(0, systemBarsTop, 0, systemBarsBottom);
            return insets;
        });

        TabLayout innerTabLayout = findViewById(R.id.innerTabLayout);
        TabLayout outerTabLayout = findViewById(R.id.outerTabLayout);
        ViewPager2 outerViewPager = findViewById(R.id.outerViewPager);

        OuterTabAdapter outerTabAdapter = new OuterTabAdapter(this);
        outerViewPager.setAdapter(outerTabAdapter);

        new TabLayoutMediator(outerTabLayout, outerViewPager, (tab, position) -> {
            if (position == 0) {
                tab.setText("Home");
                tab.setIcon(R.drawable.home);
            } else {
                tab.setText("Setting");
                tab.setIcon(R.drawable.setting);
            }
        }).attach();
    }
}
