From c85bac1bd4079c77a3e7a87dd6e1c8d46bdbf36f Mon Sep 17 00:00:00 2001 From: Sagar <85388413+Sagar0-0@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:08:16 +0000 Subject: [PATCH] #3673 Removed redundant snack function --- .../core/extensions/ViewExtensions.kt | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt index e1320f2e8..63e034b7f 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/ViewExtensions.kt @@ -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() { @@ -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() { override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {