-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement - Add more click options #73
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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