Conversation
Vacxe
left a comment
There was a problem hiding this comment.
Thanks for your contribution. Could you please fix lint issues (empty lines in the end of files). As well provide new test cases implementation for the new functionality.
| data class LongClickConfig( | ||
| val xOffset: Float = 0F, | ||
| val yOffset: Float = 0F, | ||
| val durationMs: Long? = null |
There was a problem hiding this comment.
durationMs can be a first argument in performLongClick with default value. In most cases devs will prefer to override this parameter.
| data class DoubleClickConfig( | ||
| val xOffset: Float = 0F, | ||
| val yOffset: Float = 0F, | ||
| val delayMs: Long? = null |
There was a problem hiding this comment.
delayMs can be a first argument in performDoubleClick with default value.
| enum class Offsets { | ||
| CENTER, CENTER_LEFT, CENTER_RIGHT, | ||
| TOP_CENTER, TOP_LEFT, TOP_RIGHT, | ||
| BOTTOM_CENTER, BOTTOM_LEFT, BOTTOM_RIGHT | ||
| } No newline at end of file |
There was a problem hiding this comment.
I think will be better to use sealed class with objects for default offsets + data class for custom offsets to avoid duplication in LongClickConfig DoubleClickConfig and ClickConfig. As well it will be more straight forward.
| internal fun TouchInjectionScope.createOffset( | ||
| offset: Offsets, | ||
| offsetX: Float? = null, | ||
| offsetY: Float? = null | ||
| ): Offset { | ||
| return when (offset) { | ||
| Offsets.CENTER -> center | ||
| Offsets.CENTER_LEFT -> centerLeft.copy(x = 1f) | ||
| Offsets.CENTER_RIGHT -> centerRight | ||
| Offsets.TOP_CENTER -> topCenter.copy(y = 1f) | ||
| Offsets.TOP_LEFT -> topLeft.copy(x = 1f, y = 1f) | ||
| Offsets.TOP_RIGHT -> topRight.copy(y = 1f) | ||
| Offsets.BOTTOM_CENTER -> bottomCenter | ||
| Offsets.BOTTOM_LEFT -> bottomLeft.copy(x = 1f) | ||
| Offsets.BOTTOM_RIGHT -> bottomRight | ||
| }.run { | ||
| copy(x = x + (offsetX ?: 0F), y = y + (offsetY ?: 0F)) | ||
| } |
There was a problem hiding this comment.
Applying offsetX offsetY to existing offset looks misleading to me. sealed class with default objects + data class will be more clear IMO
Extend base actions