package com.pan_american.android.ui.resource_management.service_resource

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import com.pan_american.android.R
import com.pan_american.android.base.BaseFragment
import com.pan_american.android.databinding.FragmentServiceResourceSearchBinding

class ServiceResourceSearchFragment : BaseFragment<FragmentServiceResourceSearchBinding>() {

    override fun getViewBinding(
        inflater: LayoutInflater, container: ViewGroup?, bundle: Bundle?
    ) = FragmentServiceResourceSearchBinding.inflate(layoutInflater, container, false)

    override fun onStart() {
        super.onStart()

        initViews()
        initEvents()
    }

    override fun initEvents() {
        binding.commit.setOnClickListener {
            //点击查询隐藏软键盘
            val inputMethodManager =
                requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
            if (inputMethodManager.isActive) {
                inputMethodManager.hideSoftInputFromWindow(
                    requireActivity().window.decorView.windowToken, 0
                )
            }
            parentFragmentManager.beginTransaction().setCustomAnimations(
                R.anim.slide_right_in,
                R.anim.slide_left_out,
                R.anim.slide_left_in,
                R.anim.slide_right_out
            ).addToBackStack(null)
                .replace(R.id.service_resource_container, ServiceResourceListFragment()).commit()
        }
    }
}