package com.adealink.weparty.profile.edit.dialog

import com.adealink.frame.mvvm.view.viewBinding
import com.adealink.frame.util.onClick
import com.adealink.weparty.commonui.widget.BottomDialogFragment
import com.adealink.weparty.profile.R
import com.adealink.weparty.profile.databinding.DialogEditIntroBinding

class EditIntroDialog : BottomDialogFragment(R.layout.dialog_edit_intro) {

    private val binding by viewBinding(DialogEditIntroBinding::bind)
    private var callback: IEditIntroCallback? = null

    fun setCallback(callback: IEditIntroCallback?) {
        this.callback = callback
    }

    override fun initViews() {
        super.initViews()
        binding.btnSave.onClick {
            save()
        }
    }

    private fun save() {
        val intro = binding.etInput.text?.toString()?.trim()
        callback?.onEditIntro(intro)
        dismiss()
    }


    interface IEditIntroCallback {
        fun onEditIntro(intro: String?)
    }


}