Skip to content

Commit

Permalink
replaced end: with to:
Browse files Browse the repository at this point in the history
  • Loading branch information
suspenseV committed Oct 29, 2024
1 parent 3aa99ce commit 0de3a62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ data class YamlFluentCommand(
return MaestroCommand(
swipeCommand = SwipeCommand(
elementSelector = toElementSelector(swipeElement.from),
endRelative = swipeElement.end,
endRelative = swipeElement.to,
duration = swipeElement.duration,
label = swipeElement.label,
optional = swipeElement.optional,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ data class YamlSwipeElement(

data class YamlRelativeCoordinateSwipeElement(
val from: YamlElementSelectorUnion,
val end: String,
val to: String,
override val duration: Long = DEFAULT_DURATION_IN_MILLIS,
override val label: String? = null,
override val optional: Boolean,
Expand Down Expand Up @@ -96,8 +96,7 @@ class YamlSwipeDeserializer : JsonDeserializer<YamlSwipe>() {
mapper.convertValue(root, YamlSwipeElement::class.java)
}
}
input.contains("from") && input.contains("end") -> {
// Handling YamlRelativeCoordinateSwipeElement
input.contains("from") && input.contains("to") -> {
return resolveRelativeCoordinateSwipeElement(root, duration, label, optional, mapper)
}
else -> {
Expand All @@ -122,26 +121,26 @@ class YamlSwipeDeserializer : JsonDeserializer<YamlSwipe>() {
mapper: ObjectMapper
): YamlRelativeCoordinateSwipeElement {
val from = mapper.convertValue(root.path("from"), YamlElementSelectorUnion::class.java)
val end = root.path("end").toString().replace("\"", "")
val to = root.path("to").toString().replace("\"", "")

val isRelative = end.contains("%")
val isRelative = to.contains("%")

if (isRelative) {
val endPoints = end
val endPoints = to
.replace("%", "")
.split(",")
.map { it.trim().toInt() }
check(endPoints[0] in 0..100 && endPoints[1] in 0..100) {
"Invalid end point: $end should be between 0 to 100 when using relative coordinates."
"Invalid end point: $to should be between 0 to 100 when using relative coordinates."
}
} else {
val endPoints = end
val endPoints = to
.split(",")
.map { it.trim().toInt() }
check(endPoints.size == 2) { "Invalid format for absolute coordinates: $end" }
check(endPoints.size == 2) { "Invalid format for absolute coordinates: $to" }
}

return YamlRelativeCoordinateSwipeElement(from, end, duration, label, optional)
return YamlRelativeCoordinateSwipeElement(from, to, duration, label, optional)
}

private fun resolveCoordinateSwipe(root: TreeNode, duration: Long, label: String?, optional: Boolean): YamlSwipe {
Expand Down

0 comments on commit 0de3a62

Please sign in to comment.