Custom Dialog Composable

PHOTO EMBED

Sat Nov 13 2021 17:00:42 GMT+0000 (UTC)

Saved by @Kapleshwar_U #kotlin

@Composable
fun CustomDialog(
    onNegativeClick: () -> Unit,
    onPositiveClick: () -> Unit,
) {
    Dialog(
        onDismissRequest = {
            //Executes when dialog is dismissed
        },
    ) {
        Column(
            modifier = Modifier
                .background(Color(0xff2c3e50))
                .fillMaxWidth()
        ) {
            Box(
                modifier = Modifier
                    .fillMaxWidth()

            ) {
                val view: View =
                    LayoutInflater.from(LocalContext.current).inflate(R.layout.info_fragment, null)
                AndroidView(
                    factory = { view },
                    modifier = Modifier.fillMaxWidth()
                )
               val imageView = view.findViewById<ImageView>(R.id.pic)
                imageView.setOnClickListener {
                    //Perform action for Imageview click event
                }
            }
            Row(
                horizontalArrangement = Arrangement.End,
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier
                    .fillMaxWidth()
                    .background(
                        Color(0xff2c3e50)
                    )
            ) {

                TextButton(onClick = onNegativeClick) {
                    Text(
                        text = "Cancel",
                        style = TextStyle(
                            fontSize = 16.sp,
                            color = Color.White)
                    )
                }
                Spacer(modifier = Modifier.width(4.dp))
                TextButton(onClick = {
                    onPositiveClick()
                }) {
                    Text(text = "Ok",
                        style = TextStyle(
                            fontSize = 16.sp,
                            color = Color.White
                        )
                    )
                }
            }
        }


    }
}
content_copyCOPY