package com.b2lmobitech.fieldcloudhrms

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.b2lmobitech.fieldcloudhrms.databinding.FragmentLeaveTrackerBinding
import com.google.android.material.tabs.TabLayoutMediator

class LeaveTrackerFragment : Fragment() {

    private lateinit var binding: FragmentLeaveTrackerBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View {
        binding = FragmentLeaveTrackerBinding.inflate(inflater, container, false)

        val adapter = LeavePagerAdapter(requireActivity())
        binding.viewPager.adapter = adapter

        TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
            tab.text = if (position == 0) "Leave Summary" else "Leave Balance"
        }.attach()

        binding.fabAddLeave.setOnClickListener {
            val intent = Intent(requireContext(), AddLeaveActivity::class.java)
            startActivity(intent)
        }

        return binding.root
    }
}
