#3673 Removed redundant snack function

This commit is contained in:
Sagar 2024-01-19 09:08:16 +00:00
parent 59dd343a24
commit c85bac1bd4

View File

@ -25,33 +25,19 @@ import androidx.annotation.ColorInt
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
@SuppressLint("ShowToast")
fun View.snack(
stringId: Int,
actionStringId: Int? = null,
actionClick: (() -> Unit)? = null,
) {
Snackbar.make(
this, stringId, Snackbar.LENGTH_LONG
).apply {
actionStringId?.let { setAction(it) { actionClick?.invoke() } }
show()
}
}
@SuppressLint("ShowToast")
fun View.snack(
stringId: Int,
anchor: View? = null,
actionStringId: Int? = null,
actionClick: (() -> Unit)? = null,
@ColorInt actionTextColor: Int = Color.WHITE
@ColorInt actionTextColor: Int? = null
) {
Snackbar.make(
this, stringId, Snackbar.LENGTH_LONG
).apply {
actionStringId?.let { setAction(it) { actionClick?.invoke() } }
setActionTextColor(actionTextColor)
actionTextColor?.let(::setActionTextColor)
anchor?.let {
anchorView = anchor
addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
@ -69,13 +55,13 @@ fun View.snack(
anchor: View,
actionStringId: Int? = null,
actionClick: (() -> Unit)? = null,
@ColorInt actionTextColor: Int = Color.WHITE
@ColorInt actionTextColor: Int? = null
) {
Snackbar.make(
this, message, Snackbar.LENGTH_LONG
).apply {
actionStringId?.let { setAction(it) { actionClick?.invoke() } }
setActionTextColor(actionTextColor)
actionTextColor?.let(::setActionTextColor)
anchorView = anchor
addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {