Zoltan Demant
10/02/2021, 4:33 PMVisualTransformation
& formatting duration input! 🧵Zoltan Demant
10/02/2021, 4:33 PMdewildte
10/03/2021, 4:38 AMdewildte
10/03/2021, 4:41 AMdewildte
10/03/2021, 4:41 AMdewildte
10/03/2021, 4:42 AMdewildte
10/03/2021, 4:44 AMdewildte
10/03/2021, 4:45 AMdigit digit : digit digit
dewildte
10/03/2021, 4:47 AMZoltan Demant
10/03/2021, 9:53 AM:
separator .. 1,3,5 becomes "1:35" and 1,3,5,6 becomes "13:56" etc.
It feels odd typing that way though, and I think its due to the cursor position moving left through the input as youre typing instead of always being at the end; theoretically that should be an easy fix?
I can share some code around it tomorrow. As for including a colon right from the get go, wouldnt that be hard to accomplish as well? Id be down to experiment with it, but I dont really know how to implement it right now! Perhaps Im just all too new to the offset mapping..Zoltan Demant
10/04/2021, 5:02 AMVisualTransformation { annotatedString ->
val trimmed = if (annotatedString.text.length > 5) annotatedString.text.take(5) else annotatedString.text
var out = ""
var separators = 0
trimmed.forEachIndexed { index, c ->
out += c
if (index % 2 == 0 && index + 1 < trimmed.length) {
out += ':'
separators++
}
}
}
Zoltan Demant
10/07/2021, 5:44 AMdewildte
10/13/2021, 4:24 PMZoltan Demant
10/14/2021, 6:42 AM