Skip to content

Instantly share code, notes, and snippets.

@Sardorbekcyber
Created October 25, 2021 13:22
Show Gist options
  • Save Sardorbekcyber/052023e8f3d6af666230026e90c556c9 to your computer and use it in GitHub Desktop.
Save Sardorbekcyber/052023e8f3d6af666230026e90c556c9 to your computer and use it in GitHub Desktop.
inline fun View.snack(
@StringRes messageRes: Int,
length: Int = Snackbar.LENGTH_LONG,
f: Snackbar.() -> Unit
) {
snack(resources.getString(messageRes), length, f)
}
inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit) {
val snack = Snackbar.make(this, message, length)
snack.f()
snack.show()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment