package com.develop.common.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.develop.base.mvvm.FullScreenTransparentDialog
import com.develop.common.databinding.DialogGenderSelectBinding


class GenderSelectDialog(
    private val onSelect: (male: Boolean) -> Unit
) : FullScreenTransparentDialog() {

    private lateinit var binding: DialogGenderSelectBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = DialogGenderSelectBinding.inflate(
            inflater, container, false
        )
        binding.root.setOnClickListener {
            removeSelf()
        }
        binding.ivCancel.setOnClickListener {
            removeSelf()
        }
        binding.tvSelectMale.setOnClickListener {
            binding.tvSelectFemale.isSelected = false
            binding.tvSelectMale.isSelected = true
            onSelect(true)
            removeSelf()
        }
        binding.tvSelectFemale.setOnClickListener {
            binding.tvSelectFemale.isSelected = true
            binding.tvSelectMale.isSelected = false
            onSelect(false)
            removeSelf()
        }
        binding.tvSelectMale.isSelected = true
        return binding.root
    }
}