package com.dahe.mylibrary.utils

import android.content.Context
import android.widget.ImageView
import com.dahe.mylibrary.adapter.GridImageAdapter
import com.dahe.mylibrary.base.SingletonNoPHolder
import com.dahe.mylibrary.callback.OnPicResultListener
import com.dahe.mylibrary.pop.PopBottomPic
import com.dahe.mylibrary.pop.PopNorBottomPic
import com.lxj.xpopup.XPopup

/**
 * @ClassName PopsUtils
 * @Author john
 * @Date 2024/2/6 10:11
 * @Description TODO
 */
class PopsUtils private constructor(){



    companion object : SingletonNoPHolder<PopsUtils>(::PopsUtils)

    /**
     * 选择装卸货照片
     *
     * @param myAdapter
     * @param listenter 结果回调
     */
    fun showSelPic(ctx: Context,myAdapter: GridImageAdapter, listenter: OnPicResultListener){
        XPopup.Builder(ctx)
            .dismissOnTouchOutside(true)
            .asCustom(PopBottomPic(ctx,1, myAdapter, listenter))
            .show()
    }


    /**
     * 选择照片，并设置最大选中数量
     *
     * @param myAdapter
     * @param listenter 结果回调
     */
    fun showNorSelPicAndNum(ctx: Context,num: Int = 1,myAdapter: GridImageAdapter, listenter: OnPicResultListener){
//        XPopup.Builder(ctx)
//            .dismissOnTouchOutside(true)
//            .asCustom(PopNorBottomPic(ctx,1, myAdapter, listenter))
//            .show()
    }


    /**
     * 选择照片 拍照或者相机
     *
     * @param ctx
     * @param listenter
     */
    fun showSimSelPic(ctx: Context, listenter: OnPicResultListener){

        XPopup.Builder(ctx)
            .dismissOnTouchOutside(true)
            .asCustom(PopNorBottomPic(ctx, listenter))
            .show()
    }



    fun showBigPic(ctx: Context,srcImageView: ImageView){
//        XPopup.Builder(ctx)
//            .isDestroyOnDismiss(true)
//            .asImageViewer(srcImageView,0,,)
    }
}