package com.develop.common.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.blankj.utilcode.util.KeyboardUtils
import com.develop.base.mvvm.FullScreenTransparentDialog
import com.develop.base.util.MMkvUtils
import com.develop.common.databinding.ItemNoteDialogBinding


class NoteEditDialog: FullScreenTransparentDialog() {

    private lateinit var binding: ItemNoteDialogBinding

    var listener:OnDialogClickListener?=null;

    var text:String?="";

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        isCancelable = true
        binding = ItemNoteDialogBinding.inflate(
            inflater, container, false
        )
        binding.root.setOnClickListener {
            KeyboardUtils.hideSoftInput(binding.etNote)
        }
        binding.viewComplete.setOnClickListener {
            listener?.onComplete(binding.etNote.text.toString());
            removeSelf()
            removeSelf()
        }
        binding.viewEdit.setOnClickListener {
            binding.etNote.text.clear();
            listener?.onClear();
        }
        if(text != null){
            binding.etNote.text.insert(0,text)

        }
        return binding.root
    }

    fun configListener(listener:OnDialogClickListener){
        this.listener = listener;
    }

    interface OnDialogClickListener {
        fun onComplete(remark:String)
        fun onClear()
    }


}