package com.apps.quicksketchtrace.activity

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import com.apps.quicksketchtrace.R
import com.apps.quicksketchtrace.adapter.DoubleLineAdapter
import com.apps.quicksketchtrace.databinding.FragmentCategoryBinding
import com.apps.quicksketchtrace.listener.MainClickListener


class CategoryFragment : Fragment(),MainClickListener {
    private lateinit var binding: FragmentCategoryBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentCategoryBinding.inflate(inflater,container,false)
        init()
        return binding.root
    }
    private fun init(){
        val adapter=DoubleLineAdapter()
        adapter.setListener(this)
        binding.recyclerView.adapter=adapter
        binding.recyclerView.layoutManager=GridLayoutManager(requireActivity(),2)
    }

    override fun onClick(name: String) {
        val intent = Intent(requireActivity(), EachCategoryActivity::class.java)
        intent.putExtra(EachCategoryActivity.TITLE_KEY,name)
        startActivity(intent)
    }
}