Skip to content

Instantly share code, notes, and snippets.

@GeorgCantor
Created March 13, 2021 11:24
Show Gist options
  • Save GeorgCantor/ae339a3b6b084c9ac7ca3816c43458d9 to your computer and use it in GitHub Desktop.
Save GeorgCantor/ae339a3b6b084c9ac7ca3816c43458d9 to your computer and use it in GitHub Desktop.
fun Context.showOneButtonDialog(
title: String,
message: String,
isRegistrationDialog: Boolean,
transitionFunction: (View, ConstraintLayout) -> (Unit)
): View {
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_one_button, null)
val builder = AlertDialog.Builder(this).setView(dialogView)
val alertDialog = builder.show()
with(alertDialog) {
window?.setBackgroundDrawable(ColorDrawable(TRANSPARENT))
this.title.text = title
this.message.text = message
ok_button.setOnClickListener {
transitionFunction(dialogView, dialog_root_layout)
550L.runDelayed { dismiss() }
}
if (isRegistrationDialog) {
this.message.setMultiColoredText(R.string.terms_description)
this.message.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
this.line.visible()
this.extra_message.visible()
}
}
return dialogView
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment