react-native-nitro-input 0.3.8 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/README.md +6 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/DigitSlots.kt +143 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputMeasure.kt +52 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +80 -80
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +18 -18
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +14 -14
- package/android/src/main/java/com/margelo/nitro/nitroinput/InputFonts.kt +244 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/InputSizing.kt +404 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +168 -338
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +178 -30
- package/ios/HybridNitroInputView.swift +73 -75
- package/ios/HybridNitroNumberView.swift +18 -18
- package/ios/HybridNitroTextView.swift +14 -14
- package/ios/InputSizing.swift +628 -0
- package/ios/NitroInputView.swift +180 -209
- package/ios/NitroNumberView.swift +98 -23
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +14 -8
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
- package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
- package/lib/commonjs/src/NitroInput.js +166 -23
- package/lib/commonjs/src/NitroNumber.js +1 -1
- package/lib/commonjs/src/NitroText.js +6 -6
- package/lib/commonjs/src/specs/NitroInputMeasure.nitro.js +2 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +14 -8
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
- package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
- package/lib/module/src/NitroInput.js +167 -24
- package/lib/module/src/NitroNumber.js +1 -1
- package/lib/module/src/NitroText.js +6 -6
- package/lib/module/src/specs/NitroInputMeasure.nitro.js +1 -0
- package/lib/typescript/src/NitroInput.d.ts +20 -16
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +21 -8
- package/lib/typescript/src/specs/NitroInputMeasure.nitro.d.ts +69 -0
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +6 -6
- package/lib/typescript/src/specs/NitroText.nitro.d.ts +6 -6
- package/nitro.json +10 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +2 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +16 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.cpp +93 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +94 -40
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +28 -16
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +30 -30
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +12 -12
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +30 -30
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +12 -12
- package/nitrogen/generated/android/c++/JNitroInputSize.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputSizing.hpp +292 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +54 -24
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +18 -18
- package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +18 -18
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputMeasureSpec.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +44 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSize.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSizing.kt +256 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +29 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +11 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.hpp +112 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +68 -32
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +24 -24
- package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +24 -24
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +68 -32
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +24 -24
- package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +24 -24
- package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec_cxx.swift +138 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +14 -8
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +90 -24
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +18 -18
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +18 -18
- package/nitrogen/generated/ios/swift/NitroInputSize.swift +34 -0
- package/nitrogen/generated/ios/swift/NitroInputSizing.swift +252 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +28 -16
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +28 -16
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +12 -12
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +12 -12
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +12 -12
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +12 -12
- package/nitrogen/generated/shared/c++/NitroInputSize.hpp +87 -0
- package/nitrogen/generated/shared/c++/NitroInputSizing.hpp +271 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +28 -16
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +42 -24
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +12 -12
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +18 -18
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +12 -12
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +18 -18
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +14 -8
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
- package/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
- package/package.json +4 -2
- package/src/NitroInput.tsx +215 -64
- package/src/NitroNumber.tsx +6 -6
- package/src/NitroText.tsx +6 -6
- package/src/specs/NitroInput.nitro.ts +21 -8
- package/src/specs/NitroInputMeasure.nitro.ts +78 -0
- package/src/specs/NitroNumber.nitro.ts +6 -6
- package/src/specs/NitroText.nitro.ts +6 -6
|
@@ -54,6 +54,8 @@ private const val NUMERIC_BLUR = 0.08f
|
|
|
54
54
|
/** Blurred copies per digit, from a touch of blur to the full one. */
|
|
55
55
|
private const val NUMERIC_BLUR_LEVELS = 6
|
|
56
56
|
|
|
57
|
+
private fun isMainThread(): Boolean = Looper.myLooper() === Looper.getMainLooper()
|
|
58
|
+
|
|
57
59
|
/** `RollingEngine::TextSlot`. */
|
|
58
60
|
private const val TEXT_PREFIX = 0
|
|
59
61
|
private const val TEXT_SUFFIX = 1
|
|
@@ -449,7 +451,20 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
449
451
|
digitIndex * (NUMERIC_BLUR_LEVELS + 1) + level.coerceIn(0, NUMERIC_BLUR_LEVELS)
|
|
450
452
|
digitMasks.get(slot)?.let { return it }
|
|
451
453
|
val radius = if (level <= 0 || numericBlur <= 0f) 0 else Math.round(lineHeight * numericBlur * level / NUMERIC_BLUR_LEVELS).coerceAtLeast(1)
|
|
452
|
-
val
|
|
454
|
+
val cacheKey = "${key(role)}|$digitIndex|$radius|$blurPad"
|
|
455
|
+
if (radius > 0 && isMainThread()) {
|
|
456
|
+
// Not warmed yet (a font or size that just changed): blur it on the
|
|
457
|
+
// warm thread and draw the sharp mask this frame. A blur in onDraw was
|
|
458
|
+
// ANRing low-end phones, see [BlurredGlyphCache].
|
|
459
|
+
val ready = BlurredGlyphCache.peek(cacheKey)
|
|
460
|
+
if (ready == null) {
|
|
461
|
+
WarmExecutor.request(cacheKey) { blurred(role, digitIndex, level) }
|
|
462
|
+
return blurred(role, digitIndex, 0)
|
|
463
|
+
}
|
|
464
|
+
digitMasks.set(slot, ready)
|
|
465
|
+
return ready
|
|
466
|
+
}
|
|
467
|
+
val mask = BlurredGlyphCache.get(cacheKey) {
|
|
453
468
|
val text = glyphs[digitIndex]
|
|
454
469
|
val pad = blurPad
|
|
455
470
|
val w = ceil(cell).toInt() + 2 * pad
|
|
@@ -463,7 +478,7 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
463
478
|
val canvas = Canvas(mask)
|
|
464
479
|
// A paint of its own: the masks are warmed off the main thread, where
|
|
465
480
|
// the digit paint's alpha is being changed by the draws.
|
|
466
|
-
val paint = TextPaint(
|
|
481
|
+
val paint = TextPaint(threadPaint(role)).apply { alpha = 255 }
|
|
467
482
|
canvas.drawText(text, pad + (cell - width(text, role)) / 2f, pad + digitBaseline(role), paint)
|
|
468
483
|
if (radius > 0) boxBlurMask(mask, radius)
|
|
469
484
|
// Immutable and uploaded ahead of its first draw: HWUI re-pins a mutable
|
|
@@ -471,7 +486,6 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
471
486
|
// for its texture upload.
|
|
472
487
|
val done = mask.copy(Bitmap.Config.ALPHA_8, false) ?: mask
|
|
473
488
|
if (done !== mask) mask.recycle()
|
|
474
|
-
done.prepareToDraw()
|
|
475
489
|
done
|
|
476
490
|
}
|
|
477
491
|
digitMasks.set(slot, mask)
|
|
@@ -487,18 +501,25 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
487
501
|
fun blurredText(text: String, role: GlyphRole, level: Int): Bitmap? {
|
|
488
502
|
if (text.isEmpty() || lineHeight <= 0f) return null
|
|
489
503
|
val radius = if (level <= 0 || numericBlur <= 0f) 0 else Math.round(lineHeight * numericBlur * level / NUMERIC_BLUR_LEVELS).coerceAtLeast(1)
|
|
490
|
-
|
|
504
|
+
val cacheKey = "${key(role)}|t|$text|$radius|$blurPad"
|
|
505
|
+
if (radius > 0 && isMainThread()) {
|
|
506
|
+
// Never warmed ahead (any text can change into any other): blurred on
|
|
507
|
+
// the warm thread, sharp until it lands, as [blurred] does.
|
|
508
|
+
BlurredGlyphCache.peek(cacheKey)?.let { return it }
|
|
509
|
+
WarmExecutor.request(cacheKey) { blurredText(text, role, level) }
|
|
510
|
+
return blurredText(text, role, 0)
|
|
511
|
+
}
|
|
512
|
+
return BlurredGlyphCache.get(cacheKey) {
|
|
491
513
|
val pad = blurPad
|
|
492
514
|
val w = ceil(width(text, role)).toInt() + 2 * pad
|
|
493
515
|
val h = ceil(lineHeight).toInt() + 2 * pad
|
|
494
516
|
val mask = Bitmap.createBitmap(w.coerceAtLeast(1), h, Bitmap.Config.ALPHA_8)
|
|
495
517
|
val canvas = Canvas(mask)
|
|
496
|
-
val paint = TextPaint(
|
|
518
|
+
val paint = TextPaint(threadPaint(role)).apply { alpha = 255 }
|
|
497
519
|
canvas.drawText(text, pad.toFloat(), pad + baseline(role, text, 0f), paint)
|
|
498
520
|
if (radius > 0) boxBlurMask(mask, radius)
|
|
499
521
|
val done = mask.copy(Bitmap.Config.ALPHA_8, false) ?: mask
|
|
500
522
|
if (done !== mask) mask.recycle()
|
|
501
|
-
done.prepareToDraw()
|
|
502
523
|
done
|
|
503
524
|
}
|
|
504
525
|
}
|
|
@@ -547,8 +568,10 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
547
568
|
if (strip !== drawn) drawn.recycle()
|
|
548
569
|
return strip
|
|
549
570
|
}
|
|
550
|
-
|
|
551
|
-
|
|
571
|
+
// Concurrent: a prefix or suffix blurred on the warm thread ([blurredText])
|
|
572
|
+
// aligns itself through these while the UI thread draws through them.
|
|
573
|
+
private val capHeightCache = java.util.concurrent.ConcurrentHashMap<GlyphRole, Float>()
|
|
574
|
+
private val inkDescentCache = java.util.concurrent.ConcurrentHashMap<String, Float>()
|
|
552
575
|
|
|
553
576
|
/** A fraction digit's baseline in the line box, at its alignment. */
|
|
554
577
|
private val fractionBaseline: Float
|
|
@@ -560,6 +583,15 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
560
583
|
* strips and masks are keyed by it.
|
|
561
584
|
*/
|
|
562
585
|
private val roleKeys: Array<String>
|
|
586
|
+
/**
|
|
587
|
+
* Each role's paint as the font set was made, never changed after: what
|
|
588
|
+
* the warm thread measures and draws masks with. The UI thread changes the
|
|
589
|
+
* role paints' alpha as it draws, and a Paint promises no thread safety.
|
|
590
|
+
*/
|
|
591
|
+
private val maskPaints: Array<TextPaint>
|
|
592
|
+
|
|
593
|
+
/** The paint to measure or draw [role] with on this thread: the UI thread's own, the warm thread's unchanging copy. */
|
|
594
|
+
private fun threadPaint(role: GlyphRole): TextPaint = if (isMainThread()) paint(role) else maskPaints[role.ordinal]
|
|
563
595
|
|
|
564
596
|
init {
|
|
565
597
|
for (d in 0..9) digitWidths[d] = width(glyphs[d], GlyphRole.DIGIT)
|
|
@@ -575,6 +607,7 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
575
607
|
"${t.fontFamily}|${t.fontWeight}|${digit.textSize}|${p.textSize}|${p.color}|${p.typeface?.hashCode()}|${p.fontFeatureSettings}|" +
|
|
576
608
|
"${role.name}|${alignment(role)}|${if (role == GlyphRole.PREFIX) prefixOffset else if (role == GlyphRole.SUFFIX) suffixOffset else 0f}|$glyphsKey"
|
|
577
609
|
}
|
|
610
|
+
maskPaints = Array(GlyphRole.entries.size) { TextPaint(paint(GlyphRole.entries[it])).apply { alpha = 255 } }
|
|
578
611
|
}
|
|
579
612
|
|
|
580
613
|
private fun key(role: GlyphRole): String = roleKeys[role.ordinal]
|
|
@@ -600,7 +633,7 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
600
633
|
// One map per role: a joined "role|text" key allocated a string on every
|
|
601
634
|
// lookup, and the layout looks widths up for every glyph on every frame.
|
|
602
635
|
fun width(text: String, role: GlyphRole): Float =
|
|
603
|
-
widthCache[role.ordinal].getOrPut(text) {
|
|
636
|
+
widthCache[role.ordinal].getOrPut(text) { threadPaint(role).measureText(text) }
|
|
604
637
|
|
|
605
638
|
private val shapedCache = Array(GlyphRole.entries.size) { java.util.concurrent.ConcurrentHashMap<String, ShapedText>() }
|
|
606
639
|
|
|
@@ -656,13 +689,13 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
656
689
|
/** How far `text`'s ink hangs below the baseline (0 for digits and capitals). */
|
|
657
690
|
private fun inkDescent(text: String, role: GlyphRole): Float = inkDescentCache.getOrPut(role.name + "|" + text) {
|
|
658
691
|
val bounds = Rect()
|
|
659
|
-
|
|
692
|
+
threadPaint(role).getTextBounds(text, 0, text.length, bounds)
|
|
660
693
|
max(0, bounds.bottom).toFloat()
|
|
661
694
|
}
|
|
662
695
|
|
|
663
696
|
private fun capHeight(role: GlyphRole): Float = capHeightCache.getOrPut(role) {
|
|
664
697
|
val bounds = Rect()
|
|
665
|
-
|
|
698
|
+
threadPaint(role).getTextBounds("0", 0, 1, bounds)
|
|
666
699
|
-bounds.top.toFloat()
|
|
667
700
|
}
|
|
668
701
|
}
|
|
@@ -680,10 +713,16 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
680
713
|
val w = mask.width
|
|
681
714
|
val h = mask.height
|
|
682
715
|
val stride = mask.rowBytes
|
|
683
|
-
|
|
716
|
+
// Reused, not allocated per mask: two float copies of a large glyph went
|
|
717
|
+
// to the large-object heap, and a screenful of masks collected mid-frame.
|
|
718
|
+
val buffers = BlurBuffers.get(stride * h, w * h)
|
|
719
|
+
val bytes = buffers.bytes
|
|
720
|
+
bytes.clear()
|
|
721
|
+
bytes.limit(stride * h)
|
|
684
722
|
mask.copyPixelsToBuffer(bytes)
|
|
685
|
-
val alpha =
|
|
686
|
-
val scratch =
|
|
723
|
+
val alpha = buffers.alpha
|
|
724
|
+
val scratch = buffers.scratch
|
|
725
|
+
for (i in 0 until w * h) alpha[i] = (bytes.get((i / w) * stride + i % w).toInt() and 0xff).toFloat()
|
|
687
726
|
val window = (2 * radius + 1).toFloat()
|
|
688
727
|
repeat(3) {
|
|
689
728
|
// horizontal
|
|
@@ -706,7 +745,7 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
706
745
|
}
|
|
707
746
|
}
|
|
708
747
|
}
|
|
709
|
-
for (i in
|
|
748
|
+
for (i in 0 until w * h) bytes.put((i / w) * stride + i % w, Math.round(alpha[i]).coerceIn(0, 255).toByte())
|
|
710
749
|
bytes.rewind()
|
|
711
750
|
mask.copyPixelsFromBuffer(bytes)
|
|
712
751
|
}
|
|
@@ -1142,16 +1181,105 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
1142
1181
|
if (timing.transition != Transition.NUMERIC) return
|
|
1143
1182
|
val set = fonts
|
|
1144
1183
|
val fraction = format.fractionDigits > 0
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1184
|
+
// One task a mask, so a mask the UI thread asks for meanwhile is made
|
|
1185
|
+
// next rather than after the whole set (70 to 140 blurs).
|
|
1186
|
+
val roles = if (fraction) listOf(GlyphRole.DIGIT, GlyphRole.FRACTION) else listOf(GlyphRole.DIGIT)
|
|
1187
|
+
for (role in roles) for (digit in 0..9) for (level in 0..NUMERIC_BLUR_LEVELS) {
|
|
1188
|
+
WarmExecutor.execute { set.blurred(role, digit, level) }
|
|
1148
1189
|
}
|
|
1149
1190
|
}
|
|
1150
1191
|
|
|
1151
|
-
/**
|
|
1192
|
+
/**
|
|
1193
|
+
* One background thread for glyph masks, shared by every view. A mask the UI
|
|
1194
|
+
* thread is waiting on ([request]) goes to the front of the queue, ahead of
|
|
1195
|
+
* the ten-digits-at-every-level warm-ups ([execute]): behind a font change's
|
|
1196
|
+
* warm-up, the glyph on screen stayed sharp for its whole swap.
|
|
1197
|
+
*
|
|
1198
|
+
* At background priority plus one step (Glide's choice): below the UI
|
|
1199
|
+
* thread, not starved under load (Thread.MIN_PRIORITY is the lowest nice
|
|
1200
|
+
* level there is). A mask that cannot be made (out of memory, say) is
|
|
1201
|
+
* skipped, the glyph stays sharp, and it is not asked for again for a
|
|
1202
|
+
* while: an exception escaping a thread of its own takes the whole app down
|
|
1203
|
+
* on Android, and a failure retried every frame logged every frame. Any
|
|
1204
|
+
* other Error is a bug and is not swallowed.
|
|
1205
|
+
*/
|
|
1152
1206
|
private object WarmExecutor : java.util.concurrent.Executor {
|
|
1153
|
-
private val
|
|
1154
|
-
|
|
1207
|
+
private val queue = java.util.concurrent.LinkedBlockingDeque<Runnable>()
|
|
1208
|
+
/** Masks the UI thread has asked for and the warm thread has not made yet. */
|
|
1209
|
+
private val pending = java.util.concurrent.ConcurrentHashMap.newKeySet<String>()
|
|
1210
|
+
/** When a mask last failed, by key: not asked for again until [RETRY_MS] later. */
|
|
1211
|
+
private val failed = java.util.concurrent.ConcurrentHashMap<String, Long>()
|
|
1212
|
+
private const val RETRY_MS = 2000L
|
|
1213
|
+
|
|
1214
|
+
init {
|
|
1215
|
+
Thread({
|
|
1216
|
+
android.os.Process.setThreadPriority(
|
|
1217
|
+
android.os.Process.THREAD_PRIORITY_BACKGROUND + android.os.Process.THREAD_PRIORITY_MORE_FAVORABLE
|
|
1218
|
+
)
|
|
1219
|
+
while (true) {
|
|
1220
|
+
val task = try {
|
|
1221
|
+
queue.take()
|
|
1222
|
+
} catch (_: InterruptedException) {
|
|
1223
|
+
continue
|
|
1224
|
+
}
|
|
1225
|
+
try {
|
|
1226
|
+
task.run()
|
|
1227
|
+
} catch (e: Exception) {
|
|
1228
|
+
android.util.Log.w("NitroNumber", "A glyph mask could not be made; the glyph is drawn sharp", e)
|
|
1229
|
+
} catch (e: OutOfMemoryError) {
|
|
1230
|
+
android.util.Log.w("NitroNumber", "Out of memory making a glyph mask; the glyph is drawn sharp", e)
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}, "NitroNumberWarm").apply {
|
|
1234
|
+
isDaemon = true
|
|
1235
|
+
start()
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
override fun execute(command: Runnable) {
|
|
1240
|
+
queue.offerLast(command)
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/** Makes [key]'s mask on the warm thread next, once however many frames ask for it while it is queued. */
|
|
1244
|
+
fun request(key: String, make: () -> Unit) {
|
|
1245
|
+
failed[key]?.let { if (SystemClock.uptimeMillis() - it < RETRY_MS) return }
|
|
1246
|
+
if (!pending.add(key)) return
|
|
1247
|
+
queue.offerFirst(
|
|
1248
|
+
Runnable {
|
|
1249
|
+
try {
|
|
1250
|
+
make()
|
|
1251
|
+
failed.remove(key)
|
|
1252
|
+
} catch (e: Exception) {
|
|
1253
|
+
failed[key] = SystemClock.uptimeMillis()
|
|
1254
|
+
throw e
|
|
1255
|
+
} catch (e: OutOfMemoryError) {
|
|
1256
|
+
failed[key] = SystemClock.uptimeMillis()
|
|
1257
|
+
throw e
|
|
1258
|
+
} finally {
|
|
1259
|
+
pending.remove(key)
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
)
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/** Per-thread buffers for [boxBlurMask], grown to the largest mask that thread has blurred. */
|
|
1267
|
+
private object BlurBuffers {
|
|
1268
|
+
class Buffers {
|
|
1269
|
+
var bytes: java.nio.ByteBuffer = java.nio.ByteBuffer.allocate(0)
|
|
1270
|
+
var alpha = FloatArray(0)
|
|
1271
|
+
var scratch = FloatArray(0)
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
private val local = ThreadLocal.withInitial { Buffers() }
|
|
1275
|
+
|
|
1276
|
+
fun get(byteCount: Int, pixelCount: Int): Buffers = local.get()!!.apply {
|
|
1277
|
+
if (bytes.capacity() < byteCount) bytes = java.nio.ByteBuffer.allocate(byteCount)
|
|
1278
|
+
if (alpha.size < pixelCount) {
|
|
1279
|
+
alpha = FloatArray(pixelCount)
|
|
1280
|
+
scratch = FloatArray(pixelCount)
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1155
1283
|
}
|
|
1156
1284
|
|
|
1157
1285
|
/**
|
|
@@ -2028,18 +2156,38 @@ class NitroNumberView(context: Context) : View(context) {
|
|
|
2028
2156
|
private var bytes = 0L
|
|
2029
2157
|
|
|
2030
2158
|
@Synchronized
|
|
2159
|
+
fun peek(key: String): Bitmap? = entries[key]
|
|
2160
|
+
|
|
2161
|
+
/**
|
|
2162
|
+
* [make] runs OUTSIDE the lock. Run inside it, the warm thread (then at
|
|
2163
|
+
* Thread.MIN_PRIORITY) held the lock through each blur, and the UI thread's
|
|
2164
|
+
* lookup in onDraw waited on it: ANRs with the main thread `Blocked` in
|
|
2165
|
+
* `get`. Two threads making the same key both make it; the second keeps
|
|
2166
|
+
* the first's bitmap and recycles its own, which nobody has seen.
|
|
2167
|
+
*/
|
|
2031
2168
|
fun get(key: String, make: () -> Bitmap): Bitmap {
|
|
2032
|
-
|
|
2169
|
+
peek(key)?.let { return it }
|
|
2033
2170
|
val bitmap = make()
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
bytes
|
|
2041
|
-
eldest.
|
|
2171
|
+
synchronized(this) {
|
|
2172
|
+
entries[key]?.let { existing ->
|
|
2173
|
+
bitmap.recycle()
|
|
2174
|
+
return existing
|
|
2175
|
+
}
|
|
2176
|
+
entries[key] = bitmap
|
|
2177
|
+
bytes += bitmap.allocationByteCount
|
|
2178
|
+
val eldest = entries.entries.iterator()
|
|
2179
|
+
while (bytes > BUDGET && eldest.hasNext()) {
|
|
2180
|
+
val entry = eldest.next()
|
|
2181
|
+
if (entry.value === bitmap) break
|
|
2182
|
+
bytes -= entry.value.allocationByteCount
|
|
2183
|
+
eldest.remove()
|
|
2184
|
+
}
|
|
2042
2185
|
}
|
|
2186
|
+
// Immutable and uploaded ahead of its first draw: HWUI re-pins a mutable
|
|
2187
|
+
// bitmap at every sync, and the first frame that drew a fresh mask paid
|
|
2188
|
+
// for its texture upload. Only the one that is kept: a race's loser is
|
|
2189
|
+
// recycled above, unseen.
|
|
2190
|
+
bitmap.prepareToDraw()
|
|
2043
2191
|
return bitmap
|
|
2044
2192
|
}
|
|
2045
2193
|
}
|
|
@@ -70,7 +70,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
70
70
|
self?.onKeyPress?(key)
|
|
71
71
|
}
|
|
72
72
|
inputView.onIntrinsicSizeChange = { [weak self] size in
|
|
73
|
-
self
|
|
73
|
+
guard let self else { return }
|
|
74
|
+
if !self.configured || self.committing {
|
|
75
|
+
self.sizeHeld = true
|
|
76
|
+
} else {
|
|
77
|
+
self.onSizeChange?(Double(size.width), Double(size.height))
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
|
|
@@ -112,7 +117,9 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
112
117
|
var signPlacement: NitroInputSignPlacement = .beforeaffix { didSet { markConfigDirty() } }
|
|
113
118
|
var prefixAlign: NitroInputAffixAlign = .baseline { didSet { markConfigDirty() } }
|
|
114
119
|
var suffixAlign: NitroInputAffixAlign = .baseline { didSet { markConfigDirty() } }
|
|
115
|
-
var
|
|
120
|
+
var textLetterSpacing: Double = 0 { didSet { markConfigDirty() } }
|
|
121
|
+
var tabularNums: Bool = true { didSet { markConfigDirty() } }
|
|
122
|
+
var slotDigits: Bool = false { didSet { markConfigDirty() } }
|
|
116
123
|
var prefixSpacing: Double = .infinity { didSet { markConfigDirty() } }
|
|
117
124
|
var suffixSpacing: Double = .infinity { didSet { markConfigDirty() } }
|
|
118
125
|
var prefixOffset: Double = 0 { didSet { markConfigDirty() } }
|
|
@@ -123,12 +130,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
123
130
|
var easing: NitroInputEasing = .expo { didSet { markConfigDirty() } }
|
|
124
131
|
var bounce: Double = 0.15 { didSet { markConfigDirty() } }
|
|
125
132
|
var effect: NitroInputEffect = .auto { didSet { markConfigDirty() } }
|
|
126
|
-
var
|
|
127
|
-
var
|
|
128
|
-
var
|
|
129
|
-
var
|
|
130
|
-
var
|
|
131
|
-
var
|
|
133
|
+
var textSize: Double = 32 { didSet { markConfigDirty() } }
|
|
134
|
+
var textLineHeight: Double = 0 { didSet { markConfigDirty() } }
|
|
135
|
+
var textWeight: Double = 400 { didSet { markConfigDirty() } }
|
|
136
|
+
var textFamily: String = "" { didSet { markConfigDirty() } }
|
|
137
|
+
var textColor: Double = .nan { didSet { markConfigDirty() } }
|
|
138
|
+
var textAlignment: NitroInputTextAlign = .auto { didSet { markConfigDirty() } }
|
|
132
139
|
var rightToLeft: Bool = false { didSet { markConfigDirty() } }
|
|
133
140
|
var caretColor: Double = .nan { didSet { markConfigDirty() } }
|
|
134
141
|
var selectionColor: Double = .nan { didSet { markConfigDirty() } }
|
|
@@ -144,7 +151,13 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
144
151
|
var editable: Bool = true { didSet { markConfigDirty() } }
|
|
145
152
|
var multiline: Bool = false { didSet { markConfigDirty() } }
|
|
146
153
|
var numberOfLines: Double = 0 { didSet { markConfigDirty() } }
|
|
147
|
-
var
|
|
154
|
+
var textVerticalAlignment: NitroInputTextAlignVertical = .auto { didSet { markConfigDirty() } }
|
|
155
|
+
/// The style's padding and border. Android insets its content by them; on
|
|
156
|
+
/// iOS React Native already lays the view's content out inside them.
|
|
157
|
+
var textInsetLeft: Double = 0
|
|
158
|
+
var textInsetTop: Double = 0
|
|
159
|
+
var textInsetRight: Double = 0
|
|
160
|
+
var textInsetBottom: Double = 0
|
|
148
161
|
var scrollEnabled: Bool = true { didSet { markConfigDirty() } }
|
|
149
162
|
var autoFocus: Bool = false { didSet { markConfigDirty() } }
|
|
150
163
|
var fieldTestID: String = "" { didSet { markConfigDirty() } }
|
|
@@ -181,7 +194,7 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
181
194
|
var onSelectionChange: ((Double, Double) -> Void)?
|
|
182
195
|
var onKeyPress: ((String) -> Void)?
|
|
183
196
|
var onSizeChange: ((Double, Double) -> Void)? {
|
|
184
|
-
didSet { onMain { self.inputView.resendIntrinsicSize() } }
|
|
197
|
+
didSet { onMain { if self.configured { self.inputView.resendIntrinsicSize() } } }
|
|
185
198
|
}
|
|
186
199
|
|
|
187
200
|
// MARK: - Methods
|
|
@@ -325,7 +338,9 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
325
338
|
signPlacement = .beforeaffix
|
|
326
339
|
prefixAlign = .baseline
|
|
327
340
|
suffixAlign = .baseline
|
|
328
|
-
|
|
341
|
+
textLetterSpacing = 0
|
|
342
|
+
tabularNums = true
|
|
343
|
+
slotDigits = false
|
|
329
344
|
prefixSpacing = .infinity
|
|
330
345
|
suffixSpacing = .infinity
|
|
331
346
|
prefixOffset = 0
|
|
@@ -336,12 +351,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
336
351
|
easing = .expo
|
|
337
352
|
bounce = 0.15
|
|
338
353
|
effect = .auto
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
354
|
+
textSize = 32
|
|
355
|
+
textLineHeight = 0
|
|
356
|
+
textWeight = 400
|
|
357
|
+
textFamily = ""
|
|
358
|
+
textColor = .nan
|
|
359
|
+
textAlignment = .auto
|
|
345
360
|
rightToLeft = false
|
|
346
361
|
caretColor = .nan
|
|
347
362
|
selectionColor = .nan
|
|
@@ -357,7 +372,11 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
357
372
|
editable = true
|
|
358
373
|
multiline = false
|
|
359
374
|
numberOfLines = 0
|
|
360
|
-
|
|
375
|
+
textVerticalAlignment = .auto
|
|
376
|
+
textInsetLeft = 0
|
|
377
|
+
textInsetTop = 0
|
|
378
|
+
textInsetRight = 0
|
|
379
|
+
textInsetBottom = 0
|
|
361
380
|
scrollEnabled = true
|
|
362
381
|
autoFocus = false
|
|
363
382
|
fieldTestID = ""
|
|
@@ -401,7 +420,10 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
401
420
|
snapshotLock.lock()
|
|
402
421
|
snapshot = Snapshot()
|
|
403
422
|
snapshotLock.unlock()
|
|
404
|
-
onMain {
|
|
423
|
+
onMain {
|
|
424
|
+
self.configured = false
|
|
425
|
+
self.inputView.resetForRecycle()
|
|
426
|
+
}
|
|
405
427
|
}
|
|
406
428
|
|
|
407
429
|
// MARK: - Batching
|
|
@@ -425,11 +447,32 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
425
447
|
if !isBatching { commit() }
|
|
426
448
|
}
|
|
427
449
|
|
|
450
|
+
/// Whether the props have been applied since the view was made or recycled.
|
|
451
|
+
/// Until then its size is the defaults' (or the last element's), and JS,
|
|
452
|
+
/// which lays the field out at its measured size from the first commit, must
|
|
453
|
+
/// not see it: a stray report made the field jump to it and back.
|
|
454
|
+
private var configured = false
|
|
455
|
+
/// Inside `commit`, where a size is of half-applied props (the config
|
|
456
|
+
/// applied, the text not yet).
|
|
457
|
+
private var committing = false
|
|
458
|
+
/// A size was held back by the two above, so the settled one is sent after.
|
|
459
|
+
private var sizeHeld = false
|
|
460
|
+
|
|
428
461
|
private func commit() {
|
|
429
462
|
onMain {
|
|
430
|
-
self.
|
|
431
|
-
self.
|
|
432
|
-
|
|
463
|
+
self.committing = true
|
|
464
|
+
self.inputView.batch {
|
|
465
|
+
self.flushConfigIfNeeded()
|
|
466
|
+
self.applyTextIfNeeded()
|
|
467
|
+
self.applySelectionIfNeeded()
|
|
468
|
+
}
|
|
469
|
+
self.committing = false
|
|
470
|
+
// Once after the first commit, so JS always hears the view's size.
|
|
471
|
+
if !self.configured || self.sizeHeld {
|
|
472
|
+
self.configured = true
|
|
473
|
+
self.sizeHeld = false
|
|
474
|
+
self.inputView.resendIntrinsicSize()
|
|
475
|
+
}
|
|
433
476
|
}
|
|
434
477
|
}
|
|
435
478
|
|
|
@@ -519,54 +562,18 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
519
562
|
guard configDirty else { return }
|
|
520
563
|
configDirty = false
|
|
521
564
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
format.mask = mask
|
|
529
|
-
format.maskNotations = maskNotations.map {
|
|
530
|
-
NitroInputView.MaskNotation(character: $0.character, characterSet: $0.characterSet, isOptional: $0.isOptional)
|
|
531
|
-
}
|
|
532
|
-
format.maskAutocomplete = maskAutocomplete
|
|
533
|
-
format.maskAutoSkip = maskAutoSkip
|
|
534
|
-
format.maskAffinityFormats = maskAffinityFormats
|
|
535
|
-
format.maskAffinityStrategy = Int(maskAffinityStrategy.rawValue)
|
|
536
|
-
format.maskTextCase = Int(maskTextCase.rawValue)
|
|
537
|
-
format.maskCharacterMap = maskCharacterMap.map { NitroInputView.MaskMapping(from: $0.from, to: $0.to) }
|
|
538
|
-
format.maskSlotPlaceholder = maskSlotPlaceholder
|
|
539
|
-
format.keepPlaceholder = keepPlaceholder
|
|
540
|
-
format.fractionDigits = Self.clampInt(fractionDigits, 0, 9, fallback: 2)
|
|
541
|
-
format.maxIntegerDigits = Self.clampInt(maxIntegerDigits, 1, 30, fallback: 15)
|
|
542
|
-
format.groupingSeparator = groupingSeparator
|
|
543
|
-
format.decimalSeparator = decimalSeparator.isEmpty ? "." : decimalSeparator
|
|
544
|
-
format.prefix = prefix
|
|
545
|
-
format.suffix = suffix
|
|
546
|
-
format.signPlacement = signPlacement == .afteraffix ? .afterAffix : .beforeAffix
|
|
547
|
-
format.placeholder = placeholder
|
|
548
|
-
format.maxLength = Self.clampInt(maxLength, 0, 1_000_000, fallback: 0)
|
|
549
|
-
|
|
550
|
-
var typography = NitroInputView.Typography()
|
|
551
|
-
typography.fontSize = CGFloat(fontSize.isFinite && fontSize > 0 ? fontSize : 32)
|
|
552
|
-
typography.lineHeight = CGFloat(lineHeight.isFinite && lineHeight > 0 ? lineHeight : 0)
|
|
553
|
-
typography.prefixFontSize = prefixFontSize.isFinite && prefixFontSize > 0 ? CGFloat(prefixFontSize) : nil
|
|
554
|
-
typography.suffixFontSize = suffixFontSize.isFinite && suffixFontSize > 0 ? CGFloat(suffixFontSize) : nil
|
|
555
|
-
typography.fontWeight = CGFloat(fontWeight.isFinite ? fontWeight : 400)
|
|
556
|
-
typography.fontFamily = fontFamily.isEmpty ? nil : fontFamily
|
|
557
|
-
typography.color = Self.color(fromARGB: color) ?? .label
|
|
565
|
+
// The sizing half of the mapping is shared with HybridNitroInputMeasure,
|
|
566
|
+
// which sizes the field before this view exists (InputSizing.swift).
|
|
567
|
+
let format = InputMapping.format(self)
|
|
568
|
+
var typography = InputMapping.sizingTypography(self)
|
|
569
|
+
typography.color = Self.color(fromARGB: textColor) ?? .label
|
|
558
570
|
typography.placeholderColor = Self.color(fromARGB: placeholderColor) ?? .placeholderText
|
|
559
571
|
typography.prefixAlign = Self.mapAffixAlign(prefixAlign)
|
|
560
572
|
typography.suffixAlign = Self.mapAffixAlign(suffixAlign)
|
|
561
|
-
typography.letterSpacing = CGFloat(letterSpacing.isFinite ? letterSpacing : 0)
|
|
562
|
-
typography.prefixSpacing = prefixSpacing.isFinite ? CGFloat(prefixSpacing) : nil
|
|
563
|
-
typography.suffixSpacing = suffixSpacing.isFinite ? CGFloat(suffixSpacing) : nil
|
|
564
573
|
typography.prefixOffset = CGFloat(prefixOffset.isFinite ? prefixOffset : 0)
|
|
565
574
|
typography.suffixOffset = CGFloat(suffixOffset.isFinite ? suffixOffset : 0)
|
|
566
575
|
typography.adjustsFontSizeToFit = adjustsFontSizeToFit
|
|
567
576
|
typography.minimumFontScale = CGFloat(min(1, max(0.05, minimumFontScale.isFinite ? minimumFontScale : 0.5)))
|
|
568
|
-
typography.allowFontScaling = allowFontScaling
|
|
569
|
-
typography.maxFontSizeMultiplier = CGFloat(max(0, maxFontSizeMultiplier.isFinite ? maxFontSizeMultiplier : 0))
|
|
570
577
|
|
|
571
578
|
var timing = NitroInputView.Timing()
|
|
572
579
|
timing.duration = max(0, (duration.isFinite ? duration : 400) / 1000)
|
|
@@ -582,7 +589,7 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
582
589
|
traits.editable = editable
|
|
583
590
|
traits.multiline = multiline
|
|
584
591
|
traits.numberOfLines = numberOfLines.isFinite ? max(0, Int(numberOfLines)) : 0
|
|
585
|
-
traits.textAlignVertical = switch
|
|
592
|
+
traits.textAlignVertical = switch textVerticalAlignment {
|
|
586
593
|
case .top: .top
|
|
587
594
|
case .center: .center
|
|
588
595
|
case .bottom: .bottom
|
|
@@ -620,28 +627,19 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
620
627
|
worklets.onKeyPress = Self.clampInt(onKeyPressWorklet, 0, Int(Int32.max), fallback: 0)
|
|
621
628
|
|
|
622
629
|
inputView.typography = typography
|
|
623
|
-
var inputFrame =
|
|
624
|
-
switch variant {
|
|
625
|
-
case .outlined: inputFrame.variant = .outlined
|
|
626
|
-
case .filled: inputFrame.variant = .filled
|
|
627
|
-
case .none: inputFrame.variant = .none
|
|
628
|
-
}
|
|
629
|
-
inputFrame.label = label
|
|
630
|
-
inputFrame.labelBehavior = labelBehavior == .always ? .always : .float
|
|
630
|
+
var inputFrame = InputMapping.sizingFrame(self)
|
|
631
631
|
inputFrame.labelColor = Self.color(fromARGB: labelColor)
|
|
632
632
|
inputFrame.labelFocusedColor = Self.color(fromARGB: labelFocusedColor)
|
|
633
|
-
inputFrame.labelFontSize = labelFontSize.isFinite ? max(0, CGFloat(labelFontSize)) : 0
|
|
634
633
|
inputFrame.strokeColor = Self.color(fromARGB: strokeColor)
|
|
635
634
|
inputFrame.focusedStrokeColor = Self.color(fromARGB: focusedStrokeColor)
|
|
636
635
|
inputFrame.strokeWidth = strokeWidth.isFinite ? max(0, CGFloat(strokeWidth)) : 1
|
|
637
|
-
inputFrame.cornerRadius = cornerRadius.isFinite ? max(0, CGFloat(cornerRadius)) : 8
|
|
638
636
|
inputFrame.fillColor = Self.color(fromARGB: fillColor)
|
|
639
637
|
inputView.inputFrame = inputFrame
|
|
640
638
|
inputView.format = format
|
|
641
639
|
inputView.timing = timing
|
|
642
640
|
inputView.traits = traits
|
|
643
641
|
inputView.worklets = worklets
|
|
644
|
-
inputView.alignment = Self.mapAlignment(
|
|
642
|
+
inputView.alignment = Self.mapAlignment(textAlignment)
|
|
645
643
|
// Fabric does not hand a Hybrid View its layout direction, so JS resolves
|
|
646
644
|
// it and the view is told outright; `effectiveUserInterfaceLayoutDirection`
|
|
647
645
|
// then reads it back for everything that has an edge.
|