package com.develop.auth.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.develop.auth.viewmodel.MemberViewModel
import com.develop.base.mvvm.FullScreenTransparentDialog
import com.develop.common.databinding.DialogUserIconSelectBinding

class UserIconSelectDialog(var viewModel: MemberViewModel) : FullScreenTransparentDialog() {

    private lateinit var binding: DialogUserIconSelectBinding
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View {
        binding = DialogUserIconSelectBinding.inflate(
            inflater, container, false
        )
        binding.ivCancel.setOnClickListener {
            removeSelf()
        }
        binding.root.setOnClickListener {
            removeSelf()
        }
        settingIconClick(binding.ivIcon1, 0)
        settingIconClick(binding.ivIcon2, 1)
        settingIconClick(binding.ivIcon3, 2)
        settingIconClick(binding.ivIcon4, 3)
        settingIconClick(binding.ivIcon5, 4)
        settingIconClick(binding.ivIcon6, 5)
        return binding.root
    }

    private fun settingIconClick(view: View, index: Int) {
        view.setOnClickListener {
            viewModel.chooseAvatar.value = index
            removeSelf()
        }
    }
}