jvmMain.tech.skot.core.components.SKComponentViewMock.kt Maven / Gradle / Ivy
The newest version!
package tech.skot.core.components
import tech.skot.core.view.SKPermission
import tech.skot.core.view.Style
abstract class SKComponentViewMock : SKComponentVC {
override var style: Style? = null
var closeKeyBoardCounter = 0
override fun closeKeyboard() {
closeKeyBoardCounter++
}
val displayMessageMessages: MutableList = mutableListOf()
override fun displayMessage(message: SKComponentVC.Message) {
displayMessageMessages.add(message)
}
@Deprecated("Use displayMessageMessages and filter on type SKComponentVC.Message.Error")
val displayErrorMessages: List
get() = displayMessageMessages.filterIsInstance()
.map { it.content }
override fun displayErrorMessage(message: String) {
displayMessageMessages.add(SKComponentVC.Message.Error(message))
}
var permissionsOk = emptyList()
override fun requestPermissions(
permissions: List,
onResult: (permissionsOk: List) -> Unit,
) {
onResult(permissions.filter { permissionsOk.contains(it) })
}
override fun hasPermission(vararg permission: SKPermission): Boolean {
return permission.all {
permissionsOk.contains(it)
}
}
var notificationsPermissionManaged: Boolean = false
override fun notificationsPermissionManaged(): Boolean {
return notificationsPermissionManaged
}
var hasNotificationsPermission: Boolean = false
override fun hasNotificationsPermission(): Boolean {
return hasNotificationsPermission
}
override fun requestNotificationsPermissions(onOk: () -> Unit, onKo: (() -> Unit)?) {
if (hasNotificationsPermission) {
onOk()
} else {
onKo?.invoke()
}
}
var removed = false
override fun onRemove() {
removed = true
}
}