@onekeyfe/react-native-auto-size-input 3.0.131 → 3.0.133

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.
Files changed (33) hide show
  1. package/android/src/main/java/com/margelo/nitro/autosizeinput/AutoSizeInput.kt +71 -28
  2. package/android/src/main/java/com/margelo/nitro/autosizeinput/AutoWidthFontFit.kt +30 -0
  3. package/android/src/test/java/com/margelo/nitro/autosizeinput/AutoWidthFontFitTest.kt +45 -0
  4. package/ios/AutoSizeInput.swift +16 -0
  5. package/lib/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.cpp +9 -0
  6. package/lib/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.hpp +2 -0
  7. package/lib/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.cpp +5 -0
  8. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/HybridAutoSizeInputSpec.kt +6 -0
  9. package/lib/nitrogen/generated/ios/c++/HybridAutoSizeInputSpecSwift.hpp +7 -0
  10. package/lib/nitrogen/generated/ios/c++/views/HybridAutoSizeInputComponent.mm +6 -0
  11. package/lib/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec.swift +1 -0
  12. package/lib/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec_cxx.swift +24 -0
  13. package/lib/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.cpp +2 -0
  14. package/lib/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.hpp +2 -0
  15. package/lib/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.cpp +2 -0
  16. package/lib/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.hpp +3 -0
  17. package/lib/nitrogen/generated/shared/json/AutoSizeInputConfig.json +1 -0
  18. package/lib/typescript/src/AutoSizeInput.nitro.d.ts +1 -0
  19. package/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.cpp +9 -0
  20. package/nitrogen/generated/android/c++/JHybridAutoSizeInputSpec.hpp +2 -0
  21. package/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.cpp +5 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/HybridAutoSizeInputSpec.kt +6 -0
  23. package/nitrogen/generated/ios/c++/HybridAutoSizeInputSpecSwift.hpp +7 -0
  24. package/nitrogen/generated/ios/c++/views/HybridAutoSizeInputComponent.mm +6 -0
  25. package/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec.swift +1 -0
  26. package/nitrogen/generated/ios/swift/HybridAutoSizeInputSpec_cxx.swift +24 -0
  27. package/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.cpp +2 -0
  28. package/nitrogen/generated/shared/c++/HybridAutoSizeInputSpec.hpp +2 -0
  29. package/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.cpp +2 -0
  30. package/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.hpp +3 -0
  31. package/nitrogen/generated/shared/json/AutoSizeInputConfig.json +1 -0
  32. package/package.json +1 -1
  33. package/src/AutoSizeInput.nitro.ts +1 -0
@@ -255,6 +255,8 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
255
255
  })
256
256
  }
257
257
 
258
+ override var keyboardAppearance: String? = null
259
+
258
260
  override var returnKeyType: String? = null
259
261
  get() = field
260
262
  set(value) {
@@ -337,6 +339,10 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
337
339
  if (isDisposed) return
338
340
  field = value
339
341
  view.requestLayout()
342
+ // requestLayout() is a no-op under React Native (the parent
343
+ // ReactViewGroup swallows it), so a gap change that arrives after the
344
+ // prefix/suffix props has to re-run the fit, which lays the row out again.
345
+ recalculateFontSize()
340
346
  }
341
347
 
342
348
  override var suffixMarginLeft: Double? = null
@@ -345,6 +351,10 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
345
351
  if (isDisposed) return
346
352
  field = value
347
353
  view.requestLayout()
354
+ // requestLayout() is a no-op under React Native (the parent
355
+ // ReactViewGroup swallows it), so a gap change that arrives after the
356
+ // prefix/suffix props has to re-run the fit, which lays the row out again.
357
+ recalculateFontSize()
348
358
  }
349
359
 
350
360
  override var showBorder: Boolean? = null
@@ -595,31 +605,43 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
595
605
  // In contentAutoWidth mode, prioritize width expansion instead of shrinking text.
596
606
  if (isContentAutoWidthEnabled) {
597
607
  val density = context.resources.displayMetrics.density
608
+ val scaledDensity = context.resources.displayMetrics.scaledDensity
598
609
  val edgeInset = (2f * density).toInt()
599
610
  val singleLineWidthPadding = contentAutoWidthPaddingPx()
600
- val prefixW = if (prefixView.visibility == View.VISIBLE) measureTextViewWidthPx(prefixView) else 0
601
- val suffixW = if (suffixView.visibility == View.VISIBLE) measureTextViewWidthPx(suffixView) else 0
611
+ val minInputWidth = (24f * density).toInt()
612
+ // Measure prefix/suffix at every candidate size instead of
613
+ // once at the current size. applyFontSize scales them together with the
614
+ // input, so a fit that used their old (smaller) width left performLayout
615
+ // with a slot narrower than the text and the EditText scrolled the
616
+ // leading digits out of view (send-amount fiat toggle: "$" prefix appears
617
+ // while the token suffix disappears and the font grows).
618
+ val prefixText = if (prefixView.visibility == View.VISIBLE) prefixView.text?.toString().orEmpty() else ""
619
+ val suffixText = if (suffixView.visibility == View.VISIBLE) suffixView.text?.toString().orEmpty() else ""
602
620
  val prefixGap = if (prefixView.visibility == View.VISIBLE) ((prefixMarginRight ?: 0.0) * density).toInt() else 0
603
621
  val suffixGap = if (suffixView.visibility == View.VISIBLE) ((suffixMarginLeft ?: 0.0) * density).toInt() else 0
604
- val prefixSegment = prefixW + prefixGap
605
- val suffixSegment = if (suffixView.visibility == View.VISIBLE) suffixGap + suffixW else 0
606
622
  val availableTrackWidth = maxOf(width - (edgeInset * 2), 0)
607
- val maxInputWidth = maxOf(availableTrackWidth - prefixSegment - suffixSegment, 0)
608
- val maxTextWidth = maxOf(maxInputWidth - singleLineWidthPadding, 0)
623
+ val availableGroupWidth = maxOf(availableTrackWidth - prefixGap - suffixGap, 0)
609
624
  val maxTextHeight = maxOf(height - inputView.paddingTop - inputView.paddingBottom, 0)
610
625
  val textForSizing = if (inputText.isEmpty()) (placeholder ?: "") else inputText
611
626
  val probeText = if (textForSizing.isEmpty()) "0" else textForSizing
612
-
613
- // Keep both width and line-height within the input slot.
614
- val widthFitSize = if (maxTextWidth <= 0) {
615
- minSize
616
- } else {
617
- findOptimalFontSizeSingleLine(
618
- fullText = probeText,
619
- availableWidth = maxTextWidth.toFloat(),
620
- minSize = minSize,
621
- maxSize = maxSize
627
+ val typeface = makeTypeface()
628
+
629
+ // Keep both width and line-height within the input slot. The width probe
630
+ // mirrors performLayout: input slot (text + padding, at least the minimum
631
+ // width) plus both side labels, all at the candidate size.
632
+ val widthFitSize = AutoWidthFontFit.findLargestFittingSize(
633
+ minSize = minSize,
634
+ maxSize = maxSize,
635
+ availableWidth = availableGroupWidth.toFloat()
636
+ ) { candidateSize ->
637
+ val textSizePx = candidateSize * scaledDensity
638
+ val inputW = maxOf(
639
+ measureSingleLineTextWidthPx(probeText, textSizePx, typeface) + singleLineWidthPadding,
640
+ minInputWidth
622
641
  )
642
+ (inputW +
643
+ measureSideLabelWidthPx(prefixText, textSizePx, typeface) +
644
+ measureSideLabelWidthPx(suffixText, textSizePx, typeface)).toFloat()
623
645
  }
624
646
  val heightFitSize = if (maxTextHeight <= 0) {
625
647
  minSize
@@ -838,30 +860,51 @@ class HybridAutoSizeInput(val context: ThemedReactContext) : HybridAutoSizeInput
838
860
  }
839
861
 
840
862
  private fun measureSingleLineTextWidthPx(text: String): Int {
863
+ return measureSingleLineTextWidthPx(
864
+ text,
865
+ currentFontSize * context.resources.displayMetrics.scaledDensity,
866
+ makeTypeface()
867
+ )
868
+ }
869
+
870
+ // Size-parameterized so the auto-width fit can probe candidates.
871
+ private fun measureSingleLineTextWidthPx(text: String, textSizePx: Float, typeface: Typeface): Int {
841
872
  if (text.isEmpty()) return 0
842
873
  val paint = TextPaint(Paint.ANTI_ALIAS_FLAG)
843
- paint.textSize = currentFontSize * context.resources.displayMetrics.scaledDensity
844
- paint.typeface = makeTypeface()
874
+ paint.textSize = textSizePx
875
+ paint.typeface = typeface
845
876
  return kotlin.math.ceil(paint.measureText(text).toDouble()).toInt()
846
877
  }
847
878
 
879
+ // Width a prefix/suffix label occupies at [textSizePx]. Shared by
880
+ // the auto-width fit and measureTextViewWidthPx so both agree per size.
881
+ private fun measureSideLabelWidthPx(text: String, textSizePx: Float, typeface: Typeface): Int {
882
+ if (text.isEmpty()) return 0
883
+ val paint = TextPaint(Paint.ANTI_ALIAS_FLAG)
884
+ paint.textSize = textSizePx
885
+ paint.typeface = typeface
886
+ val bounds = Rect()
887
+ paint.getTextBounds(text, 0, text.length, bounds)
888
+ val advanceWidth = kotlin.math.ceil(paint.measureText(text).toDouble()).toInt()
889
+ return maxOf(advanceWidth, bounds.width()) + sideLabelSafetyPaddingPx(textSizePx)
890
+ }
891
+
892
+ // Keep extra room for side bearings/kerning to avoid clipping on some glyphs/fonts.
893
+ private fun sideLabelSafetyPaddingPx(textSizePx: Float): Int {
894
+ val density = context.resources.displayMetrics.density
895
+ return maxOf((4f * density).toInt(), kotlin.math.ceil(textSizePx * 0.5f).toInt())
896
+ }
897
+
848
898
  private fun measureTextViewWidthPx(textView: TextView): Int {
849
899
  val content = textView.text?.toString().orEmpty()
850
900
  if (content.isEmpty()) return 0
851
- val bounds = Rect()
852
- textView.paint.getTextBounds(content, 0, content.length, bounds)
853
- val advanceWidth = kotlin.math.ceil(textView.paint.measureText(content).toDouble()).toInt()
854
- val glyphWidth = bounds.width()
855
901
  textView.measure(
856
902
  View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
857
903
  View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
858
904
  )
859
- val desiredWidth = textView.measuredWidth
860
- val density = context.resources.displayMetrics.density
861
- // Keep extra room for side bearings/kerning to avoid clipping on some glyphs/fonts.
862
- val safetyPadding = maxOf((4f * density).toInt(), kotlin.math.ceil(textView.textSize * 0.5f).toInt())
863
- val measured = maxOf(maxOf(advanceWidth, glyphWidth), desiredWidth) + safetyPadding
864
- return measured
905
+ val desiredWidth = textView.measuredWidth + sideLabelSafetyPaddingPx(textView.textSize)
906
+ val paintWidth = measureSideLabelWidthPx(content, textView.textSize, textView.typeface)
907
+ return maxOf(paintWidth, desiredWidth)
865
908
  }
866
909
 
867
910
  private fun requestInputFocus() {
@@ -0,0 +1,30 @@
1
+ package com.margelo.nitro.autosizeinput
2
+
3
+ // Font fit for contentAutoWidth mode. The input text, prefix,
4
+ // suffix and their safety padding all scale with the font, so every candidate
5
+ // size must be measured as a whole. Measuring the side labels once at the
6
+ // previous font size under-reports their width whenever the font grows (e.g.
7
+ // the send-amount fiat toggle adds a "$" prefix and drops the token suffix) and
8
+ // the layout pass then hands the input a slot narrower than its text, which
9
+ // scrolls the leading digits out of view.
10
+ internal object AutoWidthFontFit {
11
+ fun findLargestFittingSize(
12
+ minSize: Float,
13
+ maxSize: Float,
14
+ availableWidth: Float,
15
+ measureAt: (Float) -> Float
16
+ ): Float {
17
+ if (availableWidth <= 0f || maxSize <= minSize) return minSize
18
+ var low = minSize
19
+ var high = maxSize
20
+ while (high - low > 0.5f) {
21
+ val mid = (low + high) / 2f
22
+ if (measureAt(mid) <= availableWidth) {
23
+ low = mid
24
+ } else {
25
+ high = mid
26
+ }
27
+ }
28
+ return low
29
+ }
30
+ }
@@ -0,0 +1,45 @@
1
+ package com.margelo.nitro.autosizeinput
2
+
3
+ import org.junit.Assert.assertEquals
4
+ import org.junit.Assert.assertTrue
5
+ import org.junit.Test
6
+
7
+ class AutoWidthFontFitTest {
8
+ // Synthetic metrics: ten digits plus a "$" prefix whose safety padding
9
+ // scales with the font, mirroring measureTextViewWidthPx.
10
+ private fun contentWidthAt(size: Float): Float {
11
+ val text = 10 * 0.58f * size
12
+ val prefix = 0.55f * size + 0.5f * size
13
+ return text + prefix
14
+ }
15
+
16
+ @Test
17
+ fun scalesSideLabelsWithTheCandidateSize() {
18
+ val available = 400f
19
+ val size = AutoWidthFontFit.findLargestFittingSize(16f, 67f, available, ::contentWidthAt)
20
+
21
+ assertTrue(contentWidthAt(size) <= available)
22
+ assertTrue(contentWidthAt(size + 0.5f) > available)
23
+ }
24
+
25
+ @Test
26
+ fun regressionPrefixMeasuredAtOldSizeOverflows() {
27
+ // Before the fix the prefix was measured once at the previous font size
28
+ // (20sp here) and only the text was fitted, so the chosen size overflowed
29
+ // once applyFontSize scaled the prefix up as well.
30
+ val available = 400f
31
+ val stalePrefix = 0.55f * 20f + 0.5f * 20f
32
+ val staleFit = AutoWidthFontFit.findLargestFittingSize(16f, 67f, available - stalePrefix) { 10 * 0.58f * it }
33
+ assertTrue(contentWidthAt(staleFit) > available)
34
+
35
+ val fit = AutoWidthFontFit.findLargestFittingSize(16f, 67f, available, ::contentWidthAt)
36
+ assertTrue(contentWidthAt(fit) <= available)
37
+ assertTrue(fit < staleFit)
38
+ }
39
+
40
+ @Test
41
+ fun returnsMinSizeWhenNothingFits() {
42
+ assertEquals(16f, AutoWidthFontFit.findLargestFittingSize(16f, 67f, 0f, ::contentWidthAt), 0f)
43
+ assertEquals(16f, AutoWidthFontFit.findLargestFittingSize(16f, 67f, 10f, ::contentWidthAt), 0f)
44
+ }
45
+ }
@@ -203,6 +203,14 @@ class HybridAutoSizeInput: HybridAutoSizeInputSpec {
203
203
  }
204
204
  }
205
205
 
206
+ var keyboardAppearance: String? {
207
+ didSet {
208
+ let appearance = keyboardAppearanceFrom(keyboardAppearance)
209
+ singleLineInput.keyboardAppearance = appearance
210
+ multiLineInput.keyboardAppearance = appearance
211
+ }
212
+ }
213
+
206
214
  var returnKeyType: String? {
207
215
  didSet {
208
216
  let rkt = returnKeyTypeFrom(returnKeyType)
@@ -703,6 +711,14 @@ class HybridAutoSizeInput: HybridAutoSizeInputSpec {
703
711
  }
704
712
  }
705
713
 
714
+ private func keyboardAppearanceFrom(_ appearance: String?) -> UIKeyboardAppearance {
715
+ switch appearance {
716
+ case "light": return .light
717
+ case "dark": return .dark
718
+ default: return .default
719
+ }
720
+ }
721
+
706
722
  private func autoCapitalizeTypeFrom(_ type: String?) -> UITextAutocapitalizationType {
707
723
  switch type {
708
724
  case "characters": return .allCharacters
@@ -208,6 +208,15 @@ namespace margelo::nitro::autosizeinput {
208
208
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* keyboardType */)>("setKeyboardType");
209
209
  method(_javaPart, keyboardType.has_value() ? jni::make_jstring(keyboardType.value()) : nullptr);
210
210
  }
211
+ std::optional<std::string> JHybridAutoSizeInputSpec::getKeyboardAppearance() {
212
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getKeyboardAppearance");
213
+ auto __result = method(_javaPart);
214
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
215
+ }
216
+ void JHybridAutoSizeInputSpec::setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) {
217
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* keyboardAppearance */)>("setKeyboardAppearance");
218
+ method(_javaPart, keyboardAppearance.has_value() ? jni::make_jstring(keyboardAppearance.value()) : nullptr);
219
+ }
211
220
  std::optional<std::string> JHybridAutoSizeInputSpec::getReturnKeyType() {
212
221
  static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getReturnKeyType");
213
222
  auto __result = method(_javaPart);
@@ -86,6 +86,8 @@ namespace margelo::nitro::autosizeinput {
86
86
  void setEditable(std::optional<bool> editable) override;
87
87
  std::optional<std::string> getKeyboardType() override;
88
88
  void setKeyboardType(const std::optional<std::string>& keyboardType) override;
89
+ std::optional<std::string> getKeyboardAppearance() override;
90
+ void setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) override;
89
91
  std::optional<std::string> getReturnKeyType() override;
90
92
  void setReturnKeyType(const std::optional<std::string>& returnKeyType) override;
91
93
  std::optional<bool> getAutoCorrect() override;
@@ -143,6 +143,11 @@ void JHybridAutoSizeInputStateUpdater::updateViewProps(jni::alias_ref<jni::JClas
143
143
  : !newProps->keyboardType.hasSameValue(oldProps->keyboardType)) {
144
144
  hybridView->setKeyboardType(newProps->keyboardType.get());
145
145
  }
146
+ if (oldProps == nullptr
147
+ ? newProps->keyboardAppearance.isProvided()
148
+ : !newProps->keyboardAppearance.hasSameValue(oldProps->keyboardAppearance)) {
149
+ hybridView->setKeyboardAppearance(newProps->keyboardAppearance.get());
150
+ }
146
151
  if (oldProps == nullptr
147
152
  ? newProps->returnKeyType.isProvided()
148
153
  : !newProps->returnKeyType.hasSameValue(oldProps->returnKeyType)) {
@@ -135,6 +135,12 @@ abstract class HybridAutoSizeInputSpec: HybridView() {
135
135
  @set:Keep
136
136
  abstract var keyboardType: String?
137
137
 
138
+ @get:DoNotStrip
139
+ @get:Keep
140
+ @set:DoNotStrip
141
+ @set:Keep
142
+ abstract var keyboardAppearance: String?
143
+
138
144
  @get:DoNotStrip
139
145
  @get:Keep
140
146
  @set:DoNotStrip
@@ -190,6 +190,13 @@ namespace margelo::nitro::autosizeinput {
190
190
  inline void setKeyboardType(const std::optional<std::string>& keyboardType) noexcept override {
191
191
  _swiftPart.setKeyboardType(keyboardType);
192
192
  }
193
+ inline std::optional<std::string> getKeyboardAppearance() noexcept override {
194
+ auto __result = _swiftPart.getKeyboardAppearance();
195
+ return __result;
196
+ }
197
+ inline void setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) noexcept override {
198
+ _swiftPart.setKeyboardAppearance(keyboardAppearance);
199
+ }
193
200
  inline std::optional<std::string> getReturnKeyType() noexcept override {
194
201
  auto __result = _swiftPart.getReturnKeyType();
195
202
  return __result;
@@ -206,6 +206,12 @@ using namespace margelo::nitro::autosizeinput::views;
206
206
  : !newViewProps.keyboardType.hasSameValue(oldViewProps->keyboardType)) {
207
207
  swiftPart.setKeyboardType(newViewProps.keyboardType.get());
208
208
  }
209
+ // keyboardAppearance: optional
210
+ if (oldViewProps == nullptr
211
+ ? newViewProps.keyboardAppearance.isProvided()
212
+ : !newViewProps.keyboardAppearance.hasSameValue(oldViewProps->keyboardAppearance)) {
213
+ swiftPart.setKeyboardAppearance(newViewProps.keyboardAppearance.get());
214
+ }
209
215
  // returnKeyType: optional
210
216
  if (oldViewProps == nullptr
211
217
  ? newViewProps.returnKeyType.isProvided()
@@ -28,6 +28,7 @@ public protocol HybridAutoSizeInputSpec_protocol: HybridObject, HybridView {
28
28
  var fontWeight: String? { get set }
29
29
  var editable: Bool? { get set }
30
30
  var keyboardType: String? { get set }
31
+ var keyboardAppearance: String? { get set }
31
32
  var returnKeyType: String? { get set }
32
33
  var autoCorrect: Bool? { get set }
33
34
  var autoCapitalize: String? { get set }
@@ -553,6 +553,30 @@ open class HybridAutoSizeInputSpec_cxx {
553
553
  }
554
554
  }
555
555
 
556
+ public final var keyboardAppearance: bridge.std__optional_std__string_ {
557
+ @inline(__always)
558
+ get {
559
+ return { () -> bridge.std__optional_std__string_ in
560
+ if let __unwrappedValue = self.__implementation.keyboardAppearance {
561
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
562
+ } else {
563
+ return .init()
564
+ }
565
+ }()
566
+ }
567
+ @inline(__always)
568
+ set {
569
+ self.__implementation.keyboardAppearance = { () -> String? in
570
+ if bridge.has_value_std__optional_std__string_(newValue) {
571
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
572
+ return String(__unwrapped)
573
+ } else {
574
+ return nil
575
+ }
576
+ }()
577
+ }
578
+ }
579
+
556
580
  public final var returnKeyType: bridge.std__optional_std__string_ {
557
581
  @inline(__always)
558
582
  get {
@@ -50,6 +50,8 @@ namespace margelo::nitro::autosizeinput {
50
50
  prototype.registerHybridSetter("editable", &HybridAutoSizeInputSpec::setEditable);
51
51
  prototype.registerHybridGetter("keyboardType", &HybridAutoSizeInputSpec::getKeyboardType);
52
52
  prototype.registerHybridSetter("keyboardType", &HybridAutoSizeInputSpec::setKeyboardType);
53
+ prototype.registerHybridGetter("keyboardAppearance", &HybridAutoSizeInputSpec::getKeyboardAppearance);
54
+ prototype.registerHybridSetter("keyboardAppearance", &HybridAutoSizeInputSpec::setKeyboardAppearance);
53
55
  prototype.registerHybridGetter("returnKeyType", &HybridAutoSizeInputSpec::getReturnKeyType);
54
56
  prototype.registerHybridSetter("returnKeyType", &HybridAutoSizeInputSpec::setReturnKeyType);
55
57
  prototype.registerHybridGetter("autoCorrect", &HybridAutoSizeInputSpec::getAutoCorrect);
@@ -82,6 +82,8 @@ namespace margelo::nitro::autosizeinput {
82
82
  virtual void setEditable(std::optional<bool> editable) = 0;
83
83
  virtual std::optional<std::string> getKeyboardType() = 0;
84
84
  virtual void setKeyboardType(const std::optional<std::string>& keyboardType) = 0;
85
+ virtual std::optional<std::string> getKeyboardAppearance() = 0;
86
+ virtual void setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) = 0;
85
87
  virtual std::optional<std::string> getReturnKeyType() = 0;
86
88
  virtual void setReturnKeyType(const std::optional<std::string>& returnKeyType) = 0;
87
89
  virtual std::optional<bool> getAutoCorrect() = 0;
@@ -38,6 +38,7 @@ namespace margelo::nitro::autosizeinput::views {
38
38
  fontWeight(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "fontWeight", rawProps, sourceProps.fontWeight)),
39
39
  editable(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "editable", rawProps, sourceProps.editable)),
40
40
  keyboardType(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "keyboardType", rawProps, sourceProps.keyboardType)),
41
+ keyboardAppearance(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "keyboardAppearance", rawProps, sourceProps.keyboardAppearance)),
41
42
  returnKeyType(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "returnKeyType", rawProps, sourceProps.returnKeyType)),
42
43
  autoCorrect(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "autoCorrect", rawProps, sourceProps.autoCorrect)),
43
44
  autoCapitalize(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "autoCapitalize", rawProps, sourceProps.autoCapitalize)),
@@ -73,6 +74,7 @@ namespace margelo::nitro::autosizeinput::views {
73
74
  case hashString("fontWeight"): return true;
74
75
  case hashString("editable"): return true;
75
76
  case hashString("keyboardType"): return true;
77
+ case hashString("keyboardAppearance"): return true;
76
78
  case hashString("returnKeyType"): return true;
77
79
  case hashString("autoCorrect"): return true;
78
80
  case hashString("autoCapitalize"): return true;
@@ -61,6 +61,7 @@ namespace margelo::nitro::autosizeinput::views {
61
61
  nitro::ReactProp<std::optional<std::string>> fontWeight;
62
62
  nitro::ReactProp<std::optional<bool>> editable;
63
63
  nitro::ReactProp<std::optional<std::string>> keyboardType;
64
+ nitro::ReactProp<std::optional<std::string>> keyboardAppearance;
64
65
  nitro::ReactProp<std::optional<std::string>> returnKeyType;
65
66
  nitro::ReactProp<std::optional<bool>> autoCorrect;
66
67
  nitro::ReactProp<std::optional<std::string>> autoCapitalize;
@@ -96,6 +97,7 @@ namespace margelo::nitro::autosizeinput::views {
96
97
  fontWeight.hasSameValue(other.fontWeight) &&
97
98
  editable.hasSameValue(other.editable) &&
98
99
  keyboardType.hasSameValue(other.keyboardType) &&
100
+ keyboardAppearance.hasSameValue(other.keyboardAppearance) &&
99
101
  returnKeyType.hasSameValue(other.returnKeyType) &&
100
102
  autoCorrect.hasSameValue(other.autoCorrect) &&
101
103
  autoCapitalize.hasSameValue(other.autoCapitalize) &&
@@ -132,6 +134,7 @@ namespace margelo::nitro::autosizeinput::views {
132
134
  fontWeight.isProvided() ||
133
135
  editable.isProvided() ||
134
136
  keyboardType.isProvided() ||
137
+ keyboardAppearance.isProvided() ||
135
138
  returnKeyType.isProvided() ||
136
139
  autoCorrect.isProvided() ||
137
140
  autoCapitalize.isProvided() ||
@@ -22,6 +22,7 @@
22
22
  "fontWeight": true,
23
23
  "editable": true,
24
24
  "keyboardType": true,
25
+ "keyboardAppearance": true,
25
26
  "returnKeyType": true,
26
27
  "autoCorrect": true,
27
28
  "autoCapitalize": true,
@@ -18,6 +18,7 @@ export interface AutoSizeInputProps extends HybridViewProps {
18
18
  fontWeight?: string;
19
19
  editable?: boolean;
20
20
  keyboardType?: string;
21
+ keyboardAppearance?: string;
21
22
  returnKeyType?: string;
22
23
  autoCorrect?: boolean;
23
24
  autoCapitalize?: string;
@@ -208,6 +208,15 @@ namespace margelo::nitro::autosizeinput {
208
208
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* keyboardType */)>("setKeyboardType");
209
209
  method(_javaPart, keyboardType.has_value() ? jni::make_jstring(keyboardType.value()) : nullptr);
210
210
  }
211
+ std::optional<std::string> JHybridAutoSizeInputSpec::getKeyboardAppearance() {
212
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getKeyboardAppearance");
213
+ auto __result = method(_javaPart);
214
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
215
+ }
216
+ void JHybridAutoSizeInputSpec::setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) {
217
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* keyboardAppearance */)>("setKeyboardAppearance");
218
+ method(_javaPart, keyboardAppearance.has_value() ? jni::make_jstring(keyboardAppearance.value()) : nullptr);
219
+ }
211
220
  std::optional<std::string> JHybridAutoSizeInputSpec::getReturnKeyType() {
212
221
  static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getReturnKeyType");
213
222
  auto __result = method(_javaPart);
@@ -86,6 +86,8 @@ namespace margelo::nitro::autosizeinput {
86
86
  void setEditable(std::optional<bool> editable) override;
87
87
  std::optional<std::string> getKeyboardType() override;
88
88
  void setKeyboardType(const std::optional<std::string>& keyboardType) override;
89
+ std::optional<std::string> getKeyboardAppearance() override;
90
+ void setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) override;
89
91
  std::optional<std::string> getReturnKeyType() override;
90
92
  void setReturnKeyType(const std::optional<std::string>& returnKeyType) override;
91
93
  std::optional<bool> getAutoCorrect() override;
@@ -143,6 +143,11 @@ void JHybridAutoSizeInputStateUpdater::updateViewProps(jni::alias_ref<jni::JClas
143
143
  : !newProps->keyboardType.hasSameValue(oldProps->keyboardType)) {
144
144
  hybridView->setKeyboardType(newProps->keyboardType.get());
145
145
  }
146
+ if (oldProps == nullptr
147
+ ? newProps->keyboardAppearance.isProvided()
148
+ : !newProps->keyboardAppearance.hasSameValue(oldProps->keyboardAppearance)) {
149
+ hybridView->setKeyboardAppearance(newProps->keyboardAppearance.get());
150
+ }
146
151
  if (oldProps == nullptr
147
152
  ? newProps->returnKeyType.isProvided()
148
153
  : !newProps->returnKeyType.hasSameValue(oldProps->returnKeyType)) {
@@ -135,6 +135,12 @@ abstract class HybridAutoSizeInputSpec: HybridView() {
135
135
  @set:Keep
136
136
  abstract var keyboardType: String?
137
137
 
138
+ @get:DoNotStrip
139
+ @get:Keep
140
+ @set:DoNotStrip
141
+ @set:Keep
142
+ abstract var keyboardAppearance: String?
143
+
138
144
  @get:DoNotStrip
139
145
  @get:Keep
140
146
  @set:DoNotStrip
@@ -190,6 +190,13 @@ namespace margelo::nitro::autosizeinput {
190
190
  inline void setKeyboardType(const std::optional<std::string>& keyboardType) noexcept override {
191
191
  _swiftPart.setKeyboardType(keyboardType);
192
192
  }
193
+ inline std::optional<std::string> getKeyboardAppearance() noexcept override {
194
+ auto __result = _swiftPart.getKeyboardAppearance();
195
+ return __result;
196
+ }
197
+ inline void setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) noexcept override {
198
+ _swiftPart.setKeyboardAppearance(keyboardAppearance);
199
+ }
193
200
  inline std::optional<std::string> getReturnKeyType() noexcept override {
194
201
  auto __result = _swiftPart.getReturnKeyType();
195
202
  return __result;
@@ -206,6 +206,12 @@ using namespace margelo::nitro::autosizeinput::views;
206
206
  : !newViewProps.keyboardType.hasSameValue(oldViewProps->keyboardType)) {
207
207
  swiftPart.setKeyboardType(newViewProps.keyboardType.get());
208
208
  }
209
+ // keyboardAppearance: optional
210
+ if (oldViewProps == nullptr
211
+ ? newViewProps.keyboardAppearance.isProvided()
212
+ : !newViewProps.keyboardAppearance.hasSameValue(oldViewProps->keyboardAppearance)) {
213
+ swiftPart.setKeyboardAppearance(newViewProps.keyboardAppearance.get());
214
+ }
209
215
  // returnKeyType: optional
210
216
  if (oldViewProps == nullptr
211
217
  ? newViewProps.returnKeyType.isProvided()
@@ -28,6 +28,7 @@ public protocol HybridAutoSizeInputSpec_protocol: HybridObject, HybridView {
28
28
  var fontWeight: String? { get set }
29
29
  var editable: Bool? { get set }
30
30
  var keyboardType: String? { get set }
31
+ var keyboardAppearance: String? { get set }
31
32
  var returnKeyType: String? { get set }
32
33
  var autoCorrect: Bool? { get set }
33
34
  var autoCapitalize: String? { get set }
@@ -553,6 +553,30 @@ open class HybridAutoSizeInputSpec_cxx {
553
553
  }
554
554
  }
555
555
 
556
+ public final var keyboardAppearance: bridge.std__optional_std__string_ {
557
+ @inline(__always)
558
+ get {
559
+ return { () -> bridge.std__optional_std__string_ in
560
+ if let __unwrappedValue = self.__implementation.keyboardAppearance {
561
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
562
+ } else {
563
+ return .init()
564
+ }
565
+ }()
566
+ }
567
+ @inline(__always)
568
+ set {
569
+ self.__implementation.keyboardAppearance = { () -> String? in
570
+ if bridge.has_value_std__optional_std__string_(newValue) {
571
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
572
+ return String(__unwrapped)
573
+ } else {
574
+ return nil
575
+ }
576
+ }()
577
+ }
578
+ }
579
+
556
580
  public final var returnKeyType: bridge.std__optional_std__string_ {
557
581
  @inline(__always)
558
582
  get {
@@ -50,6 +50,8 @@ namespace margelo::nitro::autosizeinput {
50
50
  prototype.registerHybridSetter("editable", &HybridAutoSizeInputSpec::setEditable);
51
51
  prototype.registerHybridGetter("keyboardType", &HybridAutoSizeInputSpec::getKeyboardType);
52
52
  prototype.registerHybridSetter("keyboardType", &HybridAutoSizeInputSpec::setKeyboardType);
53
+ prototype.registerHybridGetter("keyboardAppearance", &HybridAutoSizeInputSpec::getKeyboardAppearance);
54
+ prototype.registerHybridSetter("keyboardAppearance", &HybridAutoSizeInputSpec::setKeyboardAppearance);
53
55
  prototype.registerHybridGetter("returnKeyType", &HybridAutoSizeInputSpec::getReturnKeyType);
54
56
  prototype.registerHybridSetter("returnKeyType", &HybridAutoSizeInputSpec::setReturnKeyType);
55
57
  prototype.registerHybridGetter("autoCorrect", &HybridAutoSizeInputSpec::getAutoCorrect);
@@ -82,6 +82,8 @@ namespace margelo::nitro::autosizeinput {
82
82
  virtual void setEditable(std::optional<bool> editable) = 0;
83
83
  virtual std::optional<std::string> getKeyboardType() = 0;
84
84
  virtual void setKeyboardType(const std::optional<std::string>& keyboardType) = 0;
85
+ virtual std::optional<std::string> getKeyboardAppearance() = 0;
86
+ virtual void setKeyboardAppearance(const std::optional<std::string>& keyboardAppearance) = 0;
85
87
  virtual std::optional<std::string> getReturnKeyType() = 0;
86
88
  virtual void setReturnKeyType(const std::optional<std::string>& returnKeyType) = 0;
87
89
  virtual std::optional<bool> getAutoCorrect() = 0;
@@ -38,6 +38,7 @@ namespace margelo::nitro::autosizeinput::views {
38
38
  fontWeight(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "fontWeight", rawProps, sourceProps.fontWeight)),
39
39
  editable(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "editable", rawProps, sourceProps.editable)),
40
40
  keyboardType(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "keyboardType", rawProps, sourceProps.keyboardType)),
41
+ keyboardAppearance(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "keyboardAppearance", rawProps, sourceProps.keyboardAppearance)),
41
42
  returnKeyType(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "returnKeyType", rawProps, sourceProps.returnKeyType)),
42
43
  autoCorrect(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "autoCorrect", rawProps, sourceProps.autoCorrect)),
43
44
  autoCapitalize(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "autoCapitalize", rawProps, sourceProps.autoCapitalize)),
@@ -73,6 +74,7 @@ namespace margelo::nitro::autosizeinput::views {
73
74
  case hashString("fontWeight"): return true;
74
75
  case hashString("editable"): return true;
75
76
  case hashString("keyboardType"): return true;
77
+ case hashString("keyboardAppearance"): return true;
76
78
  case hashString("returnKeyType"): return true;
77
79
  case hashString("autoCorrect"): return true;
78
80
  case hashString("autoCapitalize"): return true;
@@ -61,6 +61,7 @@ namespace margelo::nitro::autosizeinput::views {
61
61
  nitro::ReactProp<std::optional<std::string>> fontWeight;
62
62
  nitro::ReactProp<std::optional<bool>> editable;
63
63
  nitro::ReactProp<std::optional<std::string>> keyboardType;
64
+ nitro::ReactProp<std::optional<std::string>> keyboardAppearance;
64
65
  nitro::ReactProp<std::optional<std::string>> returnKeyType;
65
66
  nitro::ReactProp<std::optional<bool>> autoCorrect;
66
67
  nitro::ReactProp<std::optional<std::string>> autoCapitalize;
@@ -96,6 +97,7 @@ namespace margelo::nitro::autosizeinput::views {
96
97
  fontWeight.hasSameValue(other.fontWeight) &&
97
98
  editable.hasSameValue(other.editable) &&
98
99
  keyboardType.hasSameValue(other.keyboardType) &&
100
+ keyboardAppearance.hasSameValue(other.keyboardAppearance) &&
99
101
  returnKeyType.hasSameValue(other.returnKeyType) &&
100
102
  autoCorrect.hasSameValue(other.autoCorrect) &&
101
103
  autoCapitalize.hasSameValue(other.autoCapitalize) &&
@@ -132,6 +134,7 @@ namespace margelo::nitro::autosizeinput::views {
132
134
  fontWeight.isProvided() ||
133
135
  editable.isProvided() ||
134
136
  keyboardType.isProvided() ||
137
+ keyboardAppearance.isProvided() ||
135
138
  returnKeyType.isProvided() ||
136
139
  autoCorrect.isProvided() ||
137
140
  autoCapitalize.isProvided() ||
@@ -22,6 +22,7 @@
22
22
  "fontWeight": true,
23
23
  "editable": true,
24
24
  "keyboardType": true,
25
+ "keyboardAppearance": true,
25
26
  "returnKeyType": true,
26
27
  "autoCorrect": true,
27
28
  "autoCapitalize": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-auto-size-input",
3
- "version": "3.0.131",
3
+ "version": "3.0.133",
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",
@@ -34,6 +34,7 @@ export interface AutoSizeInputProps extends HybridViewProps {
34
34
 
35
35
  // Keyboard & input behavior
36
36
  keyboardType?: string;
37
+ keyboardAppearance?: string;
37
38
  returnKeyType?: string;
38
39
  autoCorrect?: boolean;
39
40
  autoCapitalize?: string;