package com.hx.utils.application.view

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.blankj.utilcode.util.LanguageUtils
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.hx.utils.application.databinding.FragmentBottomSheetBinding
import java.util.Locale

class ModalBottomSheet : BottomSheetDialogFragment() {
    private var _binding: FragmentBottomSheetBinding? = null
    private val binding get() = _binding!!
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentBottomSheetBinding.inflate(inflater, container, false)
        val root: View = binding.root
        return root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        dialog?.window?.setLayout(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT
        )

        dialog?.setCanceledOnTouchOutside(false)

        binding.buttonCn.setOnClickListener {
            LanguageUtils.applyLanguage(Locale.CHINA, true)
            dialog?.dismiss()
        }

        binding.buttonEn.setOnClickListener {
            LanguageUtils.applyLanguage(Locale.ENGLISH, true)
            dialog?.dismiss()

        }
    }
}