@onekeyfe/react-native-auto-size-input 1.1.35 → 1.1.36
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/android/src/main/java/com/margelo/nitro/autosizeinput/AutoSizeInput.kt +137 -25
- package/ios/AutoSizeInput.swift +30 -10
- package/lib/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.cpp +9 -0
- package/lib/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.hpp +2 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.cpp +4 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/HybridAutoSizeInputSpec.kt +6 -0
- package/lib/nitrogen/generated/ios/c++/HybridAutoSizeInputSpecSwift.hpp +7 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridAutoSizeInputComponent.mm +5 -0
- package/lib/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec.swift +1 -0
- package/lib/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec_cxx.swift +24 -0
- package/lib/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.hpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.cpp +12 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.hpp +1 -0
- package/lib/nitrogen/generated/shared/json/AutoSizeInputConfig.json +1 -0
- package/lib/typescript/src/AutoSizeInput.nitro.d.ts +1 -0
- package/lib/typescript/src/AutoSizeInput.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.cpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/HybridAutoSizeInputSpec.kt +6 -0
- package/nitrogen/generated/ios/c++/HybridAutoSizeInputSpecSwift.hpp +7 -0
- package/nitrogen/generated/ios/c++/views/HybridAutoSizeInputComponent.mm +5 -0
- package/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec_cxx.swift +24 -0
- package/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.cpp +12 -0
- package/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.hpp +1 -0
- package/nitrogen/generated/shared/json/AutoSizeInputConfig.json +1 -0
- package/package.json +1 -1
- package/src/AutoSizeInput.nitro.ts +7 -1
|
@@ -342,6 +342,14 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
342
342
|
view.requestLayout()
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
override var contentCentered: Boolean? = null
|
|
346
|
+
get() = field
|
|
347
|
+
set(value) {
|
|
348
|
+
if (isDisposed) return
|
|
349
|
+
field = value
|
|
350
|
+
view.requestLayout()
|
|
351
|
+
}
|
|
352
|
+
|
|
345
353
|
|
|
346
354
|
override var onChangeText: ((String) -> Unit)? = null
|
|
347
355
|
override var onFocus: (() -> Unit)? = null
|
|
@@ -436,25 +444,37 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
436
444
|
val prefixGap = if (prefixView.visibility == View.VISIBLE) ((prefixMarginRight ?: 0.0) * density).toInt() else 0
|
|
437
445
|
val suffixGap = if (suffixView.visibility == View.VISIBLE) ((suffixMarginLeft ?: 0.0) * density).toInt() else 0
|
|
438
446
|
|
|
439
|
-
val inputX = edgeInset + prefixW + prefixGap
|
|
440
447
|
val isContentAutoWidthEnabled = contentAutoWidth == true && multiline != true
|
|
448
|
+
val isContentCenteredEnabled = contentCentered == true && multiline != true
|
|
449
|
+
val prefixSegment = prefixW + prefixGap
|
|
450
|
+
val suffixSegment = if (suffixView.visibility == View.VISIBLE) suffixGap + suffixW else 0
|
|
451
|
+
val availableTrackWidth = maxOf(width - (edgeInset * 2), 0)
|
|
452
|
+
val maxInputWidth = maxOf(availableTrackWidth - prefixSegment - suffixSegment, 0)
|
|
453
|
+
val rawInputText = inputView.text?.toString() ?: ""
|
|
454
|
+
val displayInputText = if (rawInputText.isEmpty()) (placeholder ?: "") else rawInputText
|
|
441
455
|
val inputW: Int
|
|
442
|
-
val suffixX: Int
|
|
443
456
|
|
|
444
457
|
if (isContentAutoWidthEnabled) {
|
|
445
|
-
val typedText = inputView.text?.toString() ?: ""
|
|
446
458
|
val minInputWidth = (24f * density).toInt()
|
|
447
|
-
val
|
|
448
|
-
val
|
|
449
|
-
|
|
459
|
+
val singleLineWidthPadding = contentAutoWidthPaddingPx()
|
|
460
|
+
val desiredInputWidth = maxOf(
|
|
461
|
+
measureSingleLineTextWidthPx(displayInputText) + singleLineWidthPadding,
|
|
462
|
+
minInputWidth
|
|
463
|
+
)
|
|
450
464
|
inputW = minOf(desiredInputWidth, maxInputWidth)
|
|
451
|
-
val desiredSuffixX = if (suffixView.visibility == View.VISIBLE) inputX + inputW + suffixGap else width - edgeInset
|
|
452
|
-
suffixX = minOf(desiredSuffixX, width - edgeInset - suffixW)
|
|
453
465
|
} else {
|
|
454
|
-
inputW =
|
|
455
|
-
suffixX = width - edgeInset - suffixW
|
|
466
|
+
inputW = maxInputWidth
|
|
456
467
|
}
|
|
457
468
|
|
|
469
|
+
val groupWidth = prefixSegment + inputW + suffixSegment
|
|
470
|
+
val groupStartX = if (isContentCenteredEnabled) {
|
|
471
|
+
edgeInset + maxOf((availableTrackWidth - groupWidth) / 2, 0)
|
|
472
|
+
} else {
|
|
473
|
+
edgeInset
|
|
474
|
+
}
|
|
475
|
+
val inputX = groupStartX + prefixSegment
|
|
476
|
+
val suffixX = inputX + inputW + if (suffixView.visibility == View.VISIBLE) suffixGap else 0
|
|
477
|
+
|
|
458
478
|
// Re-measure with the exact final slot size before layout.
|
|
459
479
|
if (prefixView.visibility == View.VISIBLE) {
|
|
460
480
|
prefixView.measure(
|
|
@@ -469,7 +489,6 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
469
489
|
)
|
|
470
490
|
}
|
|
471
491
|
|
|
472
|
-
// Layout input
|
|
473
492
|
val inputHeightSpec = if (multiline == true) {
|
|
474
493
|
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY)
|
|
475
494
|
} else {
|
|
@@ -479,19 +498,50 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
479
498
|
View.MeasureSpec.makeMeasureSpec(inputW, View.MeasureSpec.EXACTLY),
|
|
480
499
|
inputHeightSpec
|
|
481
500
|
)
|
|
482
|
-
val inputH = if (multiline == true)
|
|
483
|
-
|
|
501
|
+
val inputH = if (multiline == true) {
|
|
502
|
+
height
|
|
503
|
+
} else {
|
|
504
|
+
inputView.measuredHeight.coerceAtMost(height)
|
|
505
|
+
}
|
|
506
|
+
val targetBaseline: Int = if (multiline == true) {
|
|
507
|
+
0
|
|
508
|
+
} else {
|
|
509
|
+
centeredBaselineY(height)
|
|
510
|
+
}
|
|
511
|
+
val inputTop = if (multiline == true) {
|
|
512
|
+
0
|
|
513
|
+
} else {
|
|
514
|
+
topForBaseline(inputView, targetBaseline, height)
|
|
515
|
+
}
|
|
484
516
|
inputView.layout(inputX, inputTop, inputX + inputW, inputTop + inputH)
|
|
485
517
|
resetSingleLineVerticalOffset()
|
|
486
518
|
|
|
487
|
-
val prefixTop = (
|
|
488
|
-
|
|
519
|
+
val prefixTop = if (multiline == true) {
|
|
520
|
+
((height - prefixView.measuredHeight) / 2).coerceAtLeast(0)
|
|
521
|
+
} else {
|
|
522
|
+
topForBaseline(prefixView, targetBaseline, height)
|
|
523
|
+
}
|
|
524
|
+
val suffixTop = if (multiline == true) {
|
|
525
|
+
((height - suffixView.measuredHeight) / 2).coerceAtLeast(0)
|
|
526
|
+
} else {
|
|
527
|
+
topForBaseline(suffixView, targetBaseline, height)
|
|
528
|
+
}
|
|
489
529
|
|
|
490
530
|
// Layout prefix
|
|
491
|
-
prefixView.layout(
|
|
531
|
+
prefixView.layout(
|
|
532
|
+
groupStartX,
|
|
533
|
+
prefixTop,
|
|
534
|
+
groupStartX + prefixW,
|
|
535
|
+
prefixTop + prefixView.measuredHeight
|
|
536
|
+
)
|
|
492
537
|
|
|
493
538
|
// Layout suffix
|
|
494
|
-
suffixView.layout(
|
|
539
|
+
suffixView.layout(
|
|
540
|
+
suffixX,
|
|
541
|
+
suffixTop,
|
|
542
|
+
suffixX + suffixW,
|
|
543
|
+
suffixTop + suffixView.measuredHeight
|
|
544
|
+
)
|
|
495
545
|
|
|
496
546
|
}
|
|
497
547
|
|
|
@@ -517,28 +567,41 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
517
567
|
if (isContentAutoWidthEnabled) {
|
|
518
568
|
val density = context.resources.displayMetrics.density
|
|
519
569
|
val edgeInset = (2f * density).toInt()
|
|
570
|
+
val singleLineWidthPadding = contentAutoWidthPaddingPx()
|
|
520
571
|
val prefixW = if (prefixView.visibility == View.VISIBLE) measureTextViewWidthPx(prefixView) else 0
|
|
521
572
|
val suffixW = if (suffixView.visibility == View.VISIBLE) measureTextViewWidthPx(suffixView) else 0
|
|
522
573
|
val prefixGap = if (prefixView.visibility == View.VISIBLE) ((prefixMarginRight ?: 0.0) * density).toInt() else 0
|
|
523
574
|
val suffixGap = if (suffixView.visibility == View.VISIBLE) ((suffixMarginLeft ?: 0.0) * density).toInt() else 0
|
|
524
|
-
val
|
|
575
|
+
val prefixSegment = prefixW + prefixGap
|
|
525
576
|
val suffixSegment = if (suffixView.visibility == View.VISIBLE) suffixGap + suffixW else 0
|
|
526
|
-
val
|
|
577
|
+
val availableTrackWidth = maxOf(width - (edgeInset * 2), 0)
|
|
578
|
+
val maxInputWidth = maxOf(availableTrackWidth - prefixSegment - suffixSegment, 0)
|
|
579
|
+
val maxTextWidth = maxOf(maxInputWidth - singleLineWidthPadding, 0)
|
|
580
|
+
val maxTextHeight = maxOf(height - inputView.paddingTop - inputView.paddingBottom, 0)
|
|
527
581
|
val textForSizing = if (inputText.isEmpty()) (placeholder ?: "") else inputText
|
|
582
|
+
val probeText = if (textForSizing.isEmpty()) "0" else textForSizing
|
|
528
583
|
|
|
529
|
-
//
|
|
530
|
-
val
|
|
584
|
+
// Keep both width and line-height within the input slot.
|
|
585
|
+
val widthFitSize = if (maxTextWidth <= 0) {
|
|
531
586
|
minSize
|
|
532
|
-
} else if (textForSizing.isEmpty()) {
|
|
533
|
-
maxSize
|
|
534
587
|
} else {
|
|
535
588
|
findOptimalFontSizeSingleLine(
|
|
536
|
-
fullText =
|
|
537
|
-
availableWidth =
|
|
589
|
+
fullText = probeText,
|
|
590
|
+
availableWidth = maxTextWidth.toFloat(),
|
|
591
|
+
minSize = minSize,
|
|
592
|
+
maxSize = maxSize
|
|
593
|
+
)
|
|
594
|
+
}
|
|
595
|
+
val heightFitSize = if (maxTextHeight <= 0) {
|
|
596
|
+
minSize
|
|
597
|
+
} else {
|
|
598
|
+
findOptimalFontSizeForSingleLineHeight(
|
|
599
|
+
availableHeight = maxTextHeight.toFloat(),
|
|
538
600
|
minSize = minSize,
|
|
539
601
|
maxSize = maxSize
|
|
540
602
|
)
|
|
541
603
|
}
|
|
604
|
+
val targetSize = minOf(widthFitSize, heightFitSize).coerceIn(minSize, maxSize)
|
|
542
605
|
applyFontSize(targetSize)
|
|
543
606
|
return
|
|
544
607
|
}
|
|
@@ -628,6 +691,32 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
628
691
|
return low
|
|
629
692
|
}
|
|
630
693
|
|
|
694
|
+
private fun findOptimalFontSizeForSingleLineHeight(
|
|
695
|
+
availableHeight: Float,
|
|
696
|
+
minSize: Float,
|
|
697
|
+
maxSize: Float
|
|
698
|
+
): Float {
|
|
699
|
+
if (availableHeight <= 0f) return minSize
|
|
700
|
+
var low = minSize
|
|
701
|
+
var high = maxSize
|
|
702
|
+
val paint = TextPaint(Paint.ANTI_ALIAS_FLAG)
|
|
703
|
+
paint.typeface = makeTypeface()
|
|
704
|
+
|
|
705
|
+
while (high - low > 0.5f) {
|
|
706
|
+
val mid = (low + high) / 2f
|
|
707
|
+
paint.textSize = mid * context.resources.displayMetrics.scaledDensity
|
|
708
|
+
val fm = paint.fontMetrics
|
|
709
|
+
val lineHeight = kotlin.math.ceil((fm.descent - fm.ascent).toDouble()).toFloat()
|
|
710
|
+
if (lineHeight <= availableHeight) {
|
|
711
|
+
low = mid
|
|
712
|
+
} else {
|
|
713
|
+
high = mid
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return low
|
|
718
|
+
}
|
|
719
|
+
|
|
631
720
|
private fun applyFontSize(size: Float) {
|
|
632
721
|
currentFontSize = size
|
|
633
722
|
val typeface = makeTypeface()
|
|
@@ -739,6 +828,29 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
|
|
|
739
828
|
}
|
|
740
829
|
}
|
|
741
830
|
|
|
831
|
+
private fun contentAutoWidthPaddingPx(): Int {
|
|
832
|
+
val density = context.resources.displayMetrics.density
|
|
833
|
+
return (8f * density).toInt()
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
private fun centeredBaselineY(containerHeight: Int): Int {
|
|
837
|
+
val paint = inputView.paint
|
|
838
|
+
return kotlin.math.round(
|
|
839
|
+
(containerHeight / 2f) - ((paint.descent() + paint.ascent()) / 2f)
|
|
840
|
+
).toInt()
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
private fun topForBaseline(textView: TextView, targetBaseline: Int, containerHeight: Int): Int {
|
|
844
|
+
val measuredHeight = textView.measuredHeight
|
|
845
|
+
if (measuredHeight <= 0) return 0
|
|
846
|
+
val baseline = textView.baseline
|
|
847
|
+
val fallback = ((containerHeight - measuredHeight) / 2).coerceAtLeast(0)
|
|
848
|
+
if (baseline < 0) return fallback
|
|
849
|
+
val rawTop = targetBaseline - baseline
|
|
850
|
+
val maxTop = maxOf(containerHeight - measuredHeight, 0)
|
|
851
|
+
return rawTop.coerceIn(0, maxTop)
|
|
852
|
+
}
|
|
853
|
+
|
|
742
854
|
override fun afterUpdate() {
|
|
743
855
|
super.afterUpdate()
|
|
744
856
|
if (!isDisposed) {
|
package/ios/AutoSizeInput.swift
CHANGED
|
@@ -210,6 +210,12 @@ class HybridAutoSizeInput: HybridAutoSizeInputSpec {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
var contentCentered: Bool? {
|
|
214
|
+
didSet {
|
|
215
|
+
view.setNeedsLayout()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
213
219
|
var onChangeText: ((String) -> Void)?
|
|
214
220
|
var onFocus: (() -> Void)?
|
|
215
221
|
var onBlur: (() -> Void)?
|
|
@@ -302,25 +308,35 @@ class HybridAutoSizeInput: HybridAutoSizeInputSpec {
|
|
|
302
308
|
let prefixGap = prefixLabel.isHidden ? 0 : CGFloat(prefixMarginRight ?? 0)
|
|
303
309
|
let suffixGap = suffixLabel.isHidden ? 0 : CGFloat(suffixMarginLeft ?? 0)
|
|
304
310
|
|
|
305
|
-
let inputX = prefixW + prefixGap
|
|
306
311
|
let isContentAutoWidthEnabled = contentAutoWidth == true && multiline != true
|
|
312
|
+
let isContentCenteredEnabled = contentCentered == true && multiline != true
|
|
313
|
+
let prefixSegment = prefixW + prefixGap
|
|
314
|
+
let suffixSegment = suffixLabel.isHidden ? 0 : (suffixGap + suffixW)
|
|
315
|
+
let maxInputWidth = max(bounds.width - prefixSegment - suffixSegment, 0)
|
|
307
316
|
let inputW: CGFloat
|
|
308
|
-
let suffixX: CGFloat
|
|
309
317
|
|
|
310
318
|
if isContentAutoWidthEnabled {
|
|
311
319
|
let typedText = singleLineInput.text ?? ""
|
|
312
|
-
let
|
|
313
|
-
let
|
|
314
|
-
let
|
|
320
|
+
let displayText = typedText.isEmpty ? (placeholder ?? "") : typedText
|
|
321
|
+
let minInputWidth: CGFloat = 24
|
|
322
|
+
let desiredInputWidth = max(
|
|
323
|
+
measuredSingleLineTextWidth(displayText, font: singleLineInput.font) + contentAutoWidthPadding(),
|
|
324
|
+
minInputWidth
|
|
325
|
+
)
|
|
315
326
|
inputW = min(desiredInputWidth, maxInputWidth)
|
|
316
|
-
let desiredSuffixX = suffixLabel.isHidden ? bounds.width : (inputX + inputW + suffixGap)
|
|
317
|
-
suffixX = min(desiredSuffixX, bounds.width - suffixW)
|
|
318
327
|
} else {
|
|
319
|
-
inputW =
|
|
320
|
-
suffixX = bounds.width - suffixW
|
|
328
|
+
inputW = maxInputWidth
|
|
321
329
|
}
|
|
322
330
|
|
|
323
|
-
|
|
331
|
+
let groupWidth = prefixSegment + inputW + suffixSegment
|
|
332
|
+
let groupStartX = isContentCenteredEnabled
|
|
333
|
+
? max((bounds.width - groupWidth) / 2, 0)
|
|
334
|
+
: 0
|
|
335
|
+
let prefixX = groupStartX
|
|
336
|
+
let inputX = prefixX + prefixSegment
|
|
337
|
+
let suffixX = inputX + inputW + (suffixLabel.isHidden ? 0 : suffixGap)
|
|
338
|
+
|
|
339
|
+
prefixLabel.frame = CGRect(x: prefixX, y: 0, width: prefixW, height: bounds.height)
|
|
324
340
|
suffixLabel.frame = CGRect(x: suffixX, y: 0, width: suffixW, height: bounds.height)
|
|
325
341
|
|
|
326
342
|
let activeInput: UIView = (multiline == true) ? multiLineInput : singleLineInput
|
|
@@ -589,6 +605,10 @@ class HybridAutoSizeInput: HybridAutoSizeInputSpec {
|
|
|
589
605
|
return (text as NSString).size(withAttributes: [.font: effectiveFont]).width
|
|
590
606
|
}
|
|
591
607
|
|
|
608
|
+
private func contentAutoWidthPadding() -> CGFloat {
|
|
609
|
+
return 8
|
|
610
|
+
}
|
|
611
|
+
|
|
592
612
|
private func textAlignmentFrom(_ align: String?) -> NSTextAlignment {
|
|
593
613
|
switch align {
|
|
594
614
|
case "center": return .center
|
|
@@ -279,6 +279,15 @@ namespace margelo::nitro::autosizeinput {
|
|
|
279
279
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* contentAutoWidth */)>("setContentAutoWidth");
|
|
280
280
|
method(_javaPart, contentAutoWidth.has_value() ? jni::JBoolean::valueOf(contentAutoWidth.value()) : nullptr);
|
|
281
281
|
}
|
|
282
|
+
std::optional<bool> JHybridAutoSizeInputSpec::getContentCentered() {
|
|
283
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getContentCentered");
|
|
284
|
+
auto __result = method(_javaPart);
|
|
285
|
+
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
|
|
286
|
+
}
|
|
287
|
+
void JHybridAutoSizeInputSpec::setContentCentered(std::optional<bool> contentCentered) {
|
|
288
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* contentCentered */)>("setContentCentered");
|
|
289
|
+
method(_javaPart, contentCentered.has_value() ? jni::JBoolean::valueOf(contentCentered.value()) : nullptr);
|
|
290
|
+
}
|
|
282
291
|
std::optional<std::function<void(const std::string& /* text */)>> JHybridAutoSizeInputSpec::getOnChangeText() {
|
|
283
292
|
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnChangeText_cxx");
|
|
284
293
|
auto __result = method(_javaPart);
|
|
@@ -102,6 +102,8 @@ namespace margelo::nitro::autosizeinput {
|
|
|
102
102
|
void setInputBackgroundColor(const std::optional<std::string>& inputBackgroundColor) override;
|
|
103
103
|
std::optional<bool> getContentAutoWidth() override;
|
|
104
104
|
void setContentAutoWidth(std::optional<bool> contentAutoWidth) override;
|
|
105
|
+
std::optional<bool> getContentCentered() override;
|
|
106
|
+
void setContentCentered(std::optional<bool> contentCentered) override;
|
|
105
107
|
std::optional<std::function<void(const std::string& /* text */)>> getOnChangeText() override;
|
|
106
108
|
void setOnChangeText(const std::optional<std::function<void(const std::string& /* text */)>>& onChangeText) override;
|
|
107
109
|
std::optional<std::function<void()>> getOnFocus() override;
|
|
@@ -140,6 +140,10 @@ void JHybridAutoSizeInputStateUpdater::updateViewProps(jni::alias_ref<jni::JClas
|
|
|
140
140
|
view->setContentAutoWidth(props.contentAutoWidth.value);
|
|
141
141
|
// TODO: Set isDirty = false
|
|
142
142
|
}
|
|
143
|
+
if (props.contentCentered.isDirty) {
|
|
144
|
+
view->setContentCentered(props.contentCentered.value);
|
|
145
|
+
// TODO: Set isDirty = false
|
|
146
|
+
}
|
|
143
147
|
if (props.onChangeText.isDirty) {
|
|
144
148
|
view->setOnChangeText(props.onChangeText.value);
|
|
145
149
|
// TODO: Set isDirty = false
|
|
@@ -198,6 +198,12 @@ abstract class HybridAutoSizeInputSpec: HybridView() {
|
|
|
198
198
|
@set:Keep
|
|
199
199
|
abstract var contentAutoWidth: Boolean?
|
|
200
200
|
|
|
201
|
+
@get:DoNotStrip
|
|
202
|
+
@get:Keep
|
|
203
|
+
@set:DoNotStrip
|
|
204
|
+
@set:Keep
|
|
205
|
+
abstract var contentCentered: Boolean?
|
|
206
|
+
|
|
201
207
|
abstract var onChangeText: ((text: String) -> Unit)?
|
|
202
208
|
|
|
203
209
|
private var onChangeText_cxx: Func_void_std__string?
|
|
@@ -240,6 +240,13 @@ namespace margelo::nitro::autosizeinput {
|
|
|
240
240
|
inline void setContentAutoWidth(std::optional<bool> contentAutoWidth) noexcept override {
|
|
241
241
|
_swiftPart.setContentAutoWidth(contentAutoWidth);
|
|
242
242
|
}
|
|
243
|
+
inline std::optional<bool> getContentCentered() noexcept override {
|
|
244
|
+
auto __result = _swiftPart.getContentCentered();
|
|
245
|
+
return __result;
|
|
246
|
+
}
|
|
247
|
+
inline void setContentCentered(std::optional<bool> contentCentered) noexcept override {
|
|
248
|
+
_swiftPart.setContentCentered(contentCentered);
|
|
249
|
+
}
|
|
243
250
|
inline std::optional<std::function<void(const std::string& /* text */)>> getOnChangeText() noexcept override {
|
|
244
251
|
auto __result = _swiftPart.getOnChangeText();
|
|
245
252
|
return __result;
|
|
@@ -201,6 +201,11 @@ using namespace margelo::nitro::autosizeinput::views;
|
|
|
201
201
|
swiftPart.setContentAutoWidth(newViewProps.contentAutoWidth.value);
|
|
202
202
|
newViewProps.contentAutoWidth.isDirty = false;
|
|
203
203
|
}
|
|
204
|
+
// contentCentered: optional
|
|
205
|
+
if (newViewProps.contentCentered.isDirty) {
|
|
206
|
+
swiftPart.setContentCentered(newViewProps.contentCentered.value);
|
|
207
|
+
newViewProps.contentCentered.isDirty = false;
|
|
208
|
+
}
|
|
204
209
|
// onChangeText: optional
|
|
205
210
|
if (newViewProps.onChangeText.isDirty) {
|
|
206
211
|
swiftPart.setOnChangeText(newViewProps.onChangeText.value);
|
|
@@ -37,6 +37,7 @@ public protocol HybridAutoSizeInputSpec_protocol: HybridObject, HybridView {
|
|
|
37
37
|
var showBorder: Bool? { get set }
|
|
38
38
|
var inputBackgroundColor: String? { get set }
|
|
39
39
|
var contentAutoWidth: Bool? { get set }
|
|
40
|
+
var contentCentered: Bool? { get set }
|
|
40
41
|
var onChangeText: ((_ text: String) -> Void)? { get set }
|
|
41
42
|
var onFocus: (() -> Void)? { get set }
|
|
42
43
|
var onBlur: (() -> Void)? { get set }
|
|
@@ -703,6 +703,30 @@ open class HybridAutoSizeInputSpec_cxx {
|
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
+
public final var contentCentered: bridge.std__optional_bool_ {
|
|
707
|
+
@inline(__always)
|
|
708
|
+
get {
|
|
709
|
+
return { () -> bridge.std__optional_bool_ in
|
|
710
|
+
if let __unwrappedValue = self.__implementation.contentCentered {
|
|
711
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
712
|
+
} else {
|
|
713
|
+
return .init()
|
|
714
|
+
}
|
|
715
|
+
}()
|
|
716
|
+
}
|
|
717
|
+
@inline(__always)
|
|
718
|
+
set {
|
|
719
|
+
self.__implementation.contentCentered = { () -> Bool? in
|
|
720
|
+
if bridge.has_value_std__optional_bool_(newValue) {
|
|
721
|
+
let __unwrapped = bridge.get_std__optional_bool_(newValue)
|
|
722
|
+
return __unwrapped
|
|
723
|
+
} else {
|
|
724
|
+
return nil
|
|
725
|
+
}
|
|
726
|
+
}()
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
706
730
|
public final var onChangeText: bridge.std__optional_std__function_void_const_std__string_____text______ {
|
|
707
731
|
@inline(__always)
|
|
708
732
|
get {
|
|
@@ -66,6 +66,8 @@ namespace margelo::nitro::autosizeinput {
|
|
|
66
66
|
prototype.registerHybridSetter("inputBackgroundColor", &HybridAutoSizeInputSpec::setInputBackgroundColor);
|
|
67
67
|
prototype.registerHybridGetter("contentAutoWidth", &HybridAutoSizeInputSpec::getContentAutoWidth);
|
|
68
68
|
prototype.registerHybridSetter("contentAutoWidth", &HybridAutoSizeInputSpec::setContentAutoWidth);
|
|
69
|
+
prototype.registerHybridGetter("contentCentered", &HybridAutoSizeInputSpec::getContentCentered);
|
|
70
|
+
prototype.registerHybridSetter("contentCentered", &HybridAutoSizeInputSpec::setContentCentered);
|
|
69
71
|
prototype.registerHybridGetter("onChangeText", &HybridAutoSizeInputSpec::getOnChangeText);
|
|
70
72
|
prototype.registerHybridSetter("onChangeText", &HybridAutoSizeInputSpec::setOnChangeText);
|
|
71
73
|
prototype.registerHybridGetter("onFocus", &HybridAutoSizeInputSpec::getOnFocus);
|
|
@@ -98,6 +98,8 @@ namespace margelo::nitro::autosizeinput {
|
|
|
98
98
|
virtual void setInputBackgroundColor(const std::optional<std::string>& inputBackgroundColor) = 0;
|
|
99
99
|
virtual std::optional<bool> getContentAutoWidth() = 0;
|
|
100
100
|
virtual void setContentAutoWidth(std::optional<bool> contentAutoWidth) = 0;
|
|
101
|
+
virtual std::optional<bool> getContentCentered() = 0;
|
|
102
|
+
virtual void setContentCentered(std::optional<bool> contentCentered) = 0;
|
|
101
103
|
virtual std::optional<std::function<void(const std::string& /* text */)>> getOnChangeText() = 0;
|
|
102
104
|
virtual void setOnChangeText(const std::optional<std::function<void(const std::string& /* text */)>>& onChangeText) = 0;
|
|
103
105
|
virtual std::optional<std::function<void()>> getOnFocus() = 0;
|
|
@@ -285,6 +285,16 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
285
285
|
throw std::runtime_error(std::string("AutoSizeInput.contentAutoWidth: ") + exc.what());
|
|
286
286
|
}
|
|
287
287
|
}()),
|
|
288
|
+
contentCentered([&]() -> CachedProp<std::optional<bool>> {
|
|
289
|
+
try {
|
|
290
|
+
const react::RawValue* rawValue = rawProps.at("contentCentered", nullptr, nullptr);
|
|
291
|
+
if (rawValue == nullptr) return sourceProps.contentCentered;
|
|
292
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
293
|
+
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.contentCentered);
|
|
294
|
+
} catch (const std::exception& exc) {
|
|
295
|
+
throw std::runtime_error(std::string("AutoSizeInput.contentCentered: ") + exc.what());
|
|
296
|
+
}
|
|
297
|
+
}()),
|
|
288
298
|
onChangeText([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* text */)>>> {
|
|
289
299
|
try {
|
|
290
300
|
const react::RawValue* rawValue = rawProps.at("onChangeText", nullptr, nullptr);
|
|
@@ -354,6 +364,7 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
354
364
|
showBorder(other.showBorder),
|
|
355
365
|
inputBackgroundColor(other.inputBackgroundColor),
|
|
356
366
|
contentAutoWidth(other.contentAutoWidth),
|
|
367
|
+
contentCentered(other.contentCentered),
|
|
357
368
|
onChangeText(other.onChangeText),
|
|
358
369
|
onFocus(other.onFocus),
|
|
359
370
|
onBlur(other.onBlur),
|
|
@@ -387,6 +398,7 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
387
398
|
case hashString("showBorder"): return true;
|
|
388
399
|
case hashString("inputBackgroundColor"): return true;
|
|
389
400
|
case hashString("contentAutoWidth"): return true;
|
|
401
|
+
case hashString("contentCentered"): return true;
|
|
390
402
|
case hashString("onChangeText"): return true;
|
|
391
403
|
case hashString("onFocus"): return true;
|
|
392
404
|
case hashString("onBlur"): return true;
|
|
@@ -69,6 +69,7 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
69
69
|
CachedProp<std::optional<bool>> showBorder;
|
|
70
70
|
CachedProp<std::optional<std::string>> inputBackgroundColor;
|
|
71
71
|
CachedProp<std::optional<bool>> contentAutoWidth;
|
|
72
|
+
CachedProp<std::optional<bool>> contentCentered;
|
|
72
73
|
CachedProp<std::optional<std::function<void(const std::string& /* text */)>>> onChangeText;
|
|
73
74
|
CachedProp<std::optional<std::function<void()>>> onFocus;
|
|
74
75
|
CachedProp<std::optional<std::function<void()>>> onBlur;
|
|
@@ -26,6 +26,7 @@ export interface AutoSizeInputProps extends HybridViewProps {
|
|
|
26
26
|
showBorder?: boolean;
|
|
27
27
|
inputBackgroundColor?: string;
|
|
28
28
|
contentAutoWidth?: boolean;
|
|
29
|
+
contentCentered?: boolean;
|
|
29
30
|
onChangeText?: (text: string) => void;
|
|
30
31
|
onFocus?: () => void;
|
|
31
32
|
onBlur?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoSizeInput.nitro.d.ts","sourceRoot":"","sources":["../../../src/AutoSizeInput.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAEzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAG9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAG3B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;CACd;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"AutoSizeInput.nitro.d.ts","sourceRoot":"","sources":["../../../src/AutoSizeInput.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAEzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAG9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAG3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAG1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;CACd;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CACpC,kBAAkB,EAClB,oBAAoB,CACrB,CAAC"}
|
|
@@ -279,6 +279,15 @@ namespace margelo::nitro::autosizeinput {
|
|
|
279
279
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* contentAutoWidth */)>("setContentAutoWidth");
|
|
280
280
|
method(_javaPart, contentAutoWidth.has_value() ? jni::JBoolean::valueOf(contentAutoWidth.value()) : nullptr);
|
|
281
281
|
}
|
|
282
|
+
std::optional<bool> JHybridAutoSizeInputSpec::getContentCentered() {
|
|
283
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getContentCentered");
|
|
284
|
+
auto __result = method(_javaPart);
|
|
285
|
+
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
|
|
286
|
+
}
|
|
287
|
+
void JHybridAutoSizeInputSpec::setContentCentered(std::optional<bool> contentCentered) {
|
|
288
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* contentCentered */)>("setContentCentered");
|
|
289
|
+
method(_javaPart, contentCentered.has_value() ? jni::JBoolean::valueOf(contentCentered.value()) : nullptr);
|
|
290
|
+
}
|
|
282
291
|
std::optional<std::function<void(const std::string& /* text */)>> JHybridAutoSizeInputSpec::getOnChangeText() {
|
|
283
292
|
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnChangeText_cxx");
|
|
284
293
|
auto __result = method(_javaPart);
|
|
@@ -102,6 +102,8 @@ namespace margelo::nitro::autosizeinput {
|
|
|
102
102
|
void setInputBackgroundColor(const std::optional<std::string>& inputBackgroundColor) override;
|
|
103
103
|
std::optional<bool> getContentAutoWidth() override;
|
|
104
104
|
void setContentAutoWidth(std::optional<bool> contentAutoWidth) override;
|
|
105
|
+
std::optional<bool> getContentCentered() override;
|
|
106
|
+
void setContentCentered(std::optional<bool> contentCentered) override;
|
|
105
107
|
std::optional<std::function<void(const std::string& /* text */)>> getOnChangeText() override;
|
|
106
108
|
void setOnChangeText(const std::optional<std::function<void(const std::string& /* text */)>>& onChangeText) override;
|
|
107
109
|
std::optional<std::function<void()>> getOnFocus() override;
|
|
@@ -140,6 +140,10 @@ void JHybridAutoSizeInputStateUpdater::updateViewProps(jni::alias_ref<jni::JClas
|
|
|
140
140
|
view->setContentAutoWidth(props.contentAutoWidth.value);
|
|
141
141
|
// TODO: Set isDirty = false
|
|
142
142
|
}
|
|
143
|
+
if (props.contentCentered.isDirty) {
|
|
144
|
+
view->setContentCentered(props.contentCentered.value);
|
|
145
|
+
// TODO: Set isDirty = false
|
|
146
|
+
}
|
|
143
147
|
if (props.onChangeText.isDirty) {
|
|
144
148
|
view->setOnChangeText(props.onChangeText.value);
|
|
145
149
|
// TODO: Set isDirty = false
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/HybridAutoSizeInputSpec.kt
CHANGED
|
@@ -198,6 +198,12 @@ abstract class HybridAutoSizeInputSpec: HybridView() {
|
|
|
198
198
|
@set:Keep
|
|
199
199
|
abstract var contentAutoWidth: Boolean?
|
|
200
200
|
|
|
201
|
+
@get:DoNotStrip
|
|
202
|
+
@get:Keep
|
|
203
|
+
@set:DoNotStrip
|
|
204
|
+
@set:Keep
|
|
205
|
+
abstract var contentCentered: Boolean?
|
|
206
|
+
|
|
201
207
|
abstract var onChangeText: ((text: String) -> Unit)?
|
|
202
208
|
|
|
203
209
|
private var onChangeText_cxx: Func_void_std__string?
|
|
@@ -240,6 +240,13 @@ namespace margelo::nitro::autosizeinput {
|
|
|
240
240
|
inline void setContentAutoWidth(std::optional<bool> contentAutoWidth) noexcept override {
|
|
241
241
|
_swiftPart.setContentAutoWidth(contentAutoWidth);
|
|
242
242
|
}
|
|
243
|
+
inline std::optional<bool> getContentCentered() noexcept override {
|
|
244
|
+
auto __result = _swiftPart.getContentCentered();
|
|
245
|
+
return __result;
|
|
246
|
+
}
|
|
247
|
+
inline void setContentCentered(std::optional<bool> contentCentered) noexcept override {
|
|
248
|
+
_swiftPart.setContentCentered(contentCentered);
|
|
249
|
+
}
|
|
243
250
|
inline std::optional<std::function<void(const std::string& /* text */)>> getOnChangeText() noexcept override {
|
|
244
251
|
auto __result = _swiftPart.getOnChangeText();
|
|
245
252
|
return __result;
|
|
@@ -201,6 +201,11 @@ using namespace margelo::nitro::autosizeinput::views;
|
|
|
201
201
|
swiftPart.setContentAutoWidth(newViewProps.contentAutoWidth.value);
|
|
202
202
|
newViewProps.contentAutoWidth.isDirty = false;
|
|
203
203
|
}
|
|
204
|
+
// contentCentered: optional
|
|
205
|
+
if (newViewProps.contentCentered.isDirty) {
|
|
206
|
+
swiftPart.setContentCentered(newViewProps.contentCentered.value);
|
|
207
|
+
newViewProps.contentCentered.isDirty = false;
|
|
208
|
+
}
|
|
204
209
|
// onChangeText: optional
|
|
205
210
|
if (newViewProps.onChangeText.isDirty) {
|
|
206
211
|
swiftPart.setOnChangeText(newViewProps.onChangeText.value);
|
|
@@ -37,6 +37,7 @@ public protocol HybridAutoSizeInputSpec_protocol: HybridObject, HybridView {
|
|
|
37
37
|
var showBorder: Bool? { get set }
|
|
38
38
|
var inputBackgroundColor: String? { get set }
|
|
39
39
|
var contentAutoWidth: Bool? { get set }
|
|
40
|
+
var contentCentered: Bool? { get set }
|
|
40
41
|
var onChangeText: ((_ text: String) -> Void)? { get set }
|
|
41
42
|
var onFocus: (() -> Void)? { get set }
|
|
42
43
|
var onBlur: (() -> Void)? { get set }
|
|
@@ -703,6 +703,30 @@ open class HybridAutoSizeInputSpec_cxx {
|
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
+
public final var contentCentered: bridge.std__optional_bool_ {
|
|
707
|
+
@inline(__always)
|
|
708
|
+
get {
|
|
709
|
+
return { () -> bridge.std__optional_bool_ in
|
|
710
|
+
if let __unwrappedValue = self.__implementation.contentCentered {
|
|
711
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
712
|
+
} else {
|
|
713
|
+
return .init()
|
|
714
|
+
}
|
|
715
|
+
}()
|
|
716
|
+
}
|
|
717
|
+
@inline(__always)
|
|
718
|
+
set {
|
|
719
|
+
self.__implementation.contentCentered = { () -> Bool? in
|
|
720
|
+
if bridge.has_value_std__optional_bool_(newValue) {
|
|
721
|
+
let __unwrapped = bridge.get_std__optional_bool_(newValue)
|
|
722
|
+
return __unwrapped
|
|
723
|
+
} else {
|
|
724
|
+
return nil
|
|
725
|
+
}
|
|
726
|
+
}()
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
706
730
|
public final var onChangeText: bridge.std__optional_std__function_void_const_std__string_____text______ {
|
|
707
731
|
@inline(__always)
|
|
708
732
|
get {
|
|
@@ -66,6 +66,8 @@ namespace margelo::nitro::autosizeinput {
|
|
|
66
66
|
prototype.registerHybridSetter("inputBackgroundColor", &HybridAutoSizeInputSpec::setInputBackgroundColor);
|
|
67
67
|
prototype.registerHybridGetter("contentAutoWidth", &HybridAutoSizeInputSpec::getContentAutoWidth);
|
|
68
68
|
prototype.registerHybridSetter("contentAutoWidth", &HybridAutoSizeInputSpec::setContentAutoWidth);
|
|
69
|
+
prototype.registerHybridGetter("contentCentered", &HybridAutoSizeInputSpec::getContentCentered);
|
|
70
|
+
prototype.registerHybridSetter("contentCentered", &HybridAutoSizeInputSpec::setContentCentered);
|
|
69
71
|
prototype.registerHybridGetter("onChangeText", &HybridAutoSizeInputSpec::getOnChangeText);
|
|
70
72
|
prototype.registerHybridSetter("onChangeText", &HybridAutoSizeInputSpec::setOnChangeText);
|
|
71
73
|
prototype.registerHybridGetter("onFocus", &HybridAutoSizeInputSpec::getOnFocus);
|
|
@@ -98,6 +98,8 @@ namespace margelo::nitro::autosizeinput {
|
|
|
98
98
|
virtual void setInputBackgroundColor(const std::optional<std::string>& inputBackgroundColor) = 0;
|
|
99
99
|
virtual std::optional<bool> getContentAutoWidth() = 0;
|
|
100
100
|
virtual void setContentAutoWidth(std::optional<bool> contentAutoWidth) = 0;
|
|
101
|
+
virtual std::optional<bool> getContentCentered() = 0;
|
|
102
|
+
virtual void setContentCentered(std::optional<bool> contentCentered) = 0;
|
|
101
103
|
virtual std::optional<std::function<void(const std::string& /* text */)>> getOnChangeText() = 0;
|
|
102
104
|
virtual void setOnChangeText(const std::optional<std::function<void(const std::string& /* text */)>>& onChangeText) = 0;
|
|
103
105
|
virtual std::optional<std::function<void()>> getOnFocus() = 0;
|
|
@@ -285,6 +285,16 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
285
285
|
throw std::runtime_error(std::string("AutoSizeInput.contentAutoWidth: ") + exc.what());
|
|
286
286
|
}
|
|
287
287
|
}()),
|
|
288
|
+
contentCentered([&]() -> CachedProp<std::optional<bool>> {
|
|
289
|
+
try {
|
|
290
|
+
const react::RawValue* rawValue = rawProps.at("contentCentered", nullptr, nullptr);
|
|
291
|
+
if (rawValue == nullptr) return sourceProps.contentCentered;
|
|
292
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
293
|
+
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.contentCentered);
|
|
294
|
+
} catch (const std::exception& exc) {
|
|
295
|
+
throw std::runtime_error(std::string("AutoSizeInput.contentCentered: ") + exc.what());
|
|
296
|
+
}
|
|
297
|
+
}()),
|
|
288
298
|
onChangeText([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* text */)>>> {
|
|
289
299
|
try {
|
|
290
300
|
const react::RawValue* rawValue = rawProps.at("onChangeText", nullptr, nullptr);
|
|
@@ -354,6 +364,7 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
354
364
|
showBorder(other.showBorder),
|
|
355
365
|
inputBackgroundColor(other.inputBackgroundColor),
|
|
356
366
|
contentAutoWidth(other.contentAutoWidth),
|
|
367
|
+
contentCentered(other.contentCentered),
|
|
357
368
|
onChangeText(other.onChangeText),
|
|
358
369
|
onFocus(other.onFocus),
|
|
359
370
|
onBlur(other.onBlur),
|
|
@@ -387,6 +398,7 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
387
398
|
case hashString("showBorder"): return true;
|
|
388
399
|
case hashString("inputBackgroundColor"): return true;
|
|
389
400
|
case hashString("contentAutoWidth"): return true;
|
|
401
|
+
case hashString("contentCentered"): return true;
|
|
390
402
|
case hashString("onChangeText"): return true;
|
|
391
403
|
case hashString("onFocus"): return true;
|
|
392
404
|
case hashString("onBlur"): return true;
|
|
@@ -69,6 +69,7 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
69
69
|
CachedProp<std::optional<bool>> showBorder;
|
|
70
70
|
CachedProp<std::optional<std::string>> inputBackgroundColor;
|
|
71
71
|
CachedProp<std::optional<bool>> contentAutoWidth;
|
|
72
|
+
CachedProp<std::optional<bool>> contentCentered;
|
|
72
73
|
CachedProp<std::optional<std::function<void(const std::string& /* text */)>>> onChangeText;
|
|
73
74
|
CachedProp<std::optional<std::function<void()>>> onFocus;
|
|
74
75
|
CachedProp<std::optional<std::function<void()>>> onBlur;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-auto-size-input",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.36",
|
|
4
4
|
"description": "Auto-sizing text input with font scaling, prefix and suffix support",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -49,6 +49,9 @@ export interface AutoSizeInputProps extends HybridViewProps {
|
|
|
49
49
|
// Let input width grow with content and push suffix to the right
|
|
50
50
|
contentAutoWidth?: boolean;
|
|
51
51
|
|
|
52
|
+
// Keep prefix + input + suffix centered as a whole inside the container
|
|
53
|
+
contentCentered?: boolean;
|
|
54
|
+
|
|
52
55
|
// Event callbacks
|
|
53
56
|
onChangeText?: (text: string) => void;
|
|
54
57
|
onFocus?: () => void;
|
|
@@ -60,4 +63,7 @@ export interface AutoSizeInputMethods extends HybridViewMethods {
|
|
|
60
63
|
blur(): void;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
export type AutoSizeInput = HybridView<
|
|
66
|
+
export type AutoSizeInput = HybridView<
|
|
67
|
+
AutoSizeInputProps,
|
|
68
|
+
AutoSizeInputMethods
|
|
69
|
+
>;
|