package rowedto.jockeyedto.sheetedto.balsamedto.formaledto.orientationedto

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import com.base.datarecovery.databinding.RideedtoBinding
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Overalledto
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Studiededto.requestStorePermission
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Dishedto

object Marketedto {
    private val TAG = "PermissionDialog"
    fun Context.showPermissionBottomSheet(launcher: Overalledto, dismissAction: () -> Unit): BottomSheetDialog {
        val dialog = BottomSheetDialog(this)
        val binding = RideedtoBinding.inflate(LayoutInflater.from(this))
        dialog.setContentView(binding.root)
//        dialog.setCanceledOnTouchOutside(false)
//        dialog.setCancelable(false)
        dialog.show()

        val parentView = binding.root.parent as View
        BottomSheetBehavior.from(parentView).state = BottomSheetBehavior.STATE_EXPANDED

        binding.medicineedto.setOnClickListener {
            requestStorePermission(launcher, result = {
                if (it) {
                    dialog.dismiss()
                    Dishedto.logDebug(TAG, "dismissAction 1")
                }
            })
        }
        dialog.setOnDismissListener {
            Dishedto.logDebug(TAG, "dismissAction 2")
            dismissAction.invoke()
        }
        return dialog

    }

}