package com.app.brush.guitar.ink.eraser;

import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.GridLayoutManager;

import com.app.brush.guitar.ink.App;
import com.app.brush.guitar.ink.R;
import com.app.brush.guitar.ink.drama.DichotomyDetails;
import com.app.brush.guitar.ink.drama.EphemeralWrapper;
import com.app.brush.guitar.ink.databinding.SmallActivityListCategoryBinding;
import com.app.brush.guitar.ink.gallery.HomeChildGalvanize;
import com.app.brush.guitar.ink.iguana.ListDecorationFossil;

import java.util.List;

public class CategoryListResonance extends AppCompatActivity {
    private SmallActivityListCategoryBinding vb;
    public static final String KEY_NAME ="class_name";
    private String name;
    private List<DichotomyDetails> data;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        vb = SmallActivityListCategoryBinding.inflate(getLayoutInflater());
        EdgeToEdge.enable(this);
        setContentView(vb.getRoot());
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        name = getIntent().getStringExtra(KEY_NAME);
        initData();
        initClick();
    }

    private void initData(){
        vb.className.setText(name);
        for (EphemeralWrapper beanWrapper : App.list) {
            if(beanWrapper.getParentName().equals(name)){
                data = beanWrapper.getKeyboardList();
            }
        }
        ListDecorationFossil listDecoration = new ListDecorationFossil(3, 3, 0);
        HomeChildGalvanize adapterMain = new HomeChildGalvanize(this,data);
        vb.recycler.setLayoutManager(new GridLayoutManager(CategoryListResonance.this,2));
        vb.recycler.setAdapter(adapterMain);
        vb.recycler.addItemDecoration(listDecoration);

    }
    private void initClick(){
        vb.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

}