Conversation
app/src/main/java/su/levenetc/android/textsurface/sample/animations/complex.kt
Outdated
Show resolved
Hide resolved
| typeface = Typeface.createFromAsset(assetManager, "fonts/Roboto-Black.ttf") | ||
| } | ||
|
|
||
| val textDaai = Text.Builder("Daai") |
There was a problem hiding this comment.
Seems like using Java API from Kotlin, feels a bit verbose. I would expect something more idiomatic to Kotlin (Data classes, type-safe builders, or just apply with mutable fields as you do earlier?) Maybe any reason for set..?
There was a problem hiding this comment.
Yeah, I agree. I actually tried to get rid of TextBuilder, but there two problems:
- Making of
Positioninstance has it's own requirements and there're 3 most frequent cases and they are hidden in setters:
val position1 = Position(align, alignText = alignText)
val position2 = Position(align)
val position3 = Position(point = PointF(px, py))- For most cases
scaleandscale pivotneeds to be set correctly and it's done in finalbuildcall:
val text = Text(text, position, padding, paint)
text.scaleX = scale
text.scaleY = scale
text.setScalePivot(scalePivot, scalePivot)So for most cases Builder hides these requirements inside setters and final build function. For custom (and probably very rare cases with weird position and maybe inverted or negative scale) cases developer can use Position and Text constructors without Builder.
But it might be that these requirements can be hidden inside type-safe builder. Need to think about better api.
ScaleValueandPositionconverted into data classesinvalidatecalls (text reveal animations)DebugtoTextSurfaceDebugto avoid spoiling namespaceTextBuilder>Text.Builder@CallSupertoTextEffect.onStart@CallSupertoSurfaceAnimation.cancelScrollViewFixes It doesn't work if it's in ScrollView #13