package com.rugvedsarika.easymath.ui.learn

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.rugvedsarika.easymath.databinding.FragmentLearnBinding

class LearnFragment : Fragment() {

    private var _binding: FragmentLearnBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentLearnBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.cardTables.setOnClickListener {
             val bundle = Bundle().apply {
                 putString("category", "Multiplication")
                 putString("level", "Easy")
             }
             findNavController().navigate(com.rugvedsarika.easymath.R.id.action_learn_to_practice, bundle)
        }
        
        binding.cardSquares.setOnClickListener {
             val bundle = Bundle().apply {
                 putString("category", "Geometry")
                 putString("level", "Medium")
             }
             findNavController().navigate(com.rugvedsarika.easymath.R.id.action_learn_to_practice, bundle)
        }
        
        binding.cardFractions.setOnClickListener {
             val bundle = Bundle().apply {
                 putString("category", "Fractions")
                 putString("level", "Medium")
             }
             findNavController().navigate(com.rugvedsarika.easymath.R.id.action_learn_to_practice, bundle)
        }
        
        binding.cardBODMAS.setOnClickListener {
             val bundle = Bundle().apply {
                 putString("category", "Mixed")
                 putString("level", "Hard")
             }
             findNavController().navigate(com.rugvedsarika.easymath.R.id.action_learn_to_practice, bundle)
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}
