package com.ccwangluo.accelerator.ui.view

import android.content.Context
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.ccwangluo.cc_quickly.R
import com.xuexiang.xui.widget.dialog.materialdialog.CustomMaterialDialog
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog

class CommonDialog(
    var fragment: Fragment,
    var privacy_url: String,
    var callback: (Boolean) -> Unit
) : CustomMaterialDialog(fragment.context) {


    override fun getDialogBuilder(context: Context?): MaterialDialog.Builder {
        return MaterialDialog.Builder(context!!)
            .customView(R.layout.dialog_common, true);
    }


    override fun initViews(context: Context?) {

    }

    fun setContent(content: String): CommonDialog {
        val dia_text = findViewById<TextView>(R.id.dia_text)
        dia_text.text = content
        return this
    }

    fun setBtnLeft(btnText:String,callback:()->Unit): CommonDialog{
        val btn_left = findViewById<TextView>(R.id.btn_left)
        btn_left.text = btnText
        btn_left.setOnClickListener {
            callback()
        }
        return this
    }

    fun setBtnRight(btnText:String,callback:()->Unit): CommonDialog{
        val btn_right = findViewById<TextView>(R.id.btn_right)
        btn_right.text = btnText
        btn_right.setOnClickListener {
            callback()
        }
        return this
    }

}