1
0
Fork 0
fenix/app/src/main/java/org/mozilla/fenix/utils/ItsNotBrokenSnack.kt

42 lines
1.5 KiB
Kotlin

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.utils
import android.content.Context
import android.view.View
import androidx.core.content.ContextCompat
import com.google.android.material.snackbar.Snackbar
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.asActivity
import org.mozilla.fenix.ext.components
class ItsNotBrokenSnack(val context: Context) {
fun showSnackbar(issueNumber: String) {
val rootView =
context.asActivity()?.window?.decorView?.findViewById<View>(android.R.id.content)
rootView?.let {
Snackbar.make(rootView, message.replace("%", issueNumber), Snackbar.LENGTH_SHORT)
.apply {
setAction("Add Tab to Issue") {
context.components.useCases.tabsUseCases.addTab
.invoke(issues + issueNumber)
}.setActionTextColor(
ContextCompat.getColor(
context,
R.color.accent_bright_dark_theme
)
)
show()
}
}
}
companion object {
const val issues = "https://github.com/mozilla-mobile/fenix/issues/"
const val message = "Feature is not implemented, Issue #%"
}
}