react-native-nitro-input 0.2.0 → 0.3.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.
Files changed (222) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +132 -2
  3. package/android/CMakeLists.txt +4 -0
  4. package/android/gradle.properties +1 -1
  5. package/android/src/main/cpp/JReflowEngine.cpp +32 -0
  6. package/android/src/main/cpp/JReflowEngine.hpp +13 -0
  7. package/android/src/main/cpp/JRollingEngine.cpp +43 -2
  8. package/android/src/main/cpp/JRollingEngine.hpp +9 -1
  9. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +20 -0
  10. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +284 -0
  11. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +113 -0
  12. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextMeasure.kt +25 -0
  13. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +140 -0
  14. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputPackage.kt +2 -1
  15. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +69 -10
  16. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +522 -130
  17. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroTextView.kt +868 -0
  18. package/android/src/main/java/com/margelo/nitro/nitroinput/ReflowEngine.kt +21 -0
  19. package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +14 -2
  20. package/cpp/RollingEngine.cpp +102 -8
  21. package/cpp/RollingEngine.hpp +44 -3
  22. package/cpp/numberformat/HybridNitroNumberFormat.cpp +498 -0
  23. package/cpp/numberformat/HybridNitroNumberFormat.hpp +74 -0
  24. package/cpp/numberformat/HybridNitroNumberFormatFactory.hpp +11 -0
  25. package/cpp/numberformat/NumberFormatCore.cpp +629 -0
  26. package/cpp/numberformat/NumberFormatCore.hpp +154 -0
  27. package/cpp/numberformat/NumberFormatProbe.cpp +354 -0
  28. package/cpp/numberformat/NumberFormatProbe.hpp +63 -0
  29. package/ios/HybridNitroInputView.swift +15 -0
  30. package/ios/HybridNitroNumberFormatPlatform.swift +426 -0
  31. package/ios/HybridNitroNumberView.swift +101 -1
  32. package/ios/HybridNitroTextView.swift +134 -0
  33. package/ios/NitroInputView.swift +79 -19
  34. package/ios/NitroNumberView.swift +520 -147
  35. package/ios/NitroTextView.swift +583 -0
  36. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
  37. package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
  38. package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
  39. package/lib/commonjs/src/NitroInput.js +8 -6
  40. package/lib/commonjs/src/NitroNumber.js +54 -3
  41. package/lib/commonjs/src/NitroText.js +138 -0
  42. package/lib/commonjs/src/NitroTime.js +65 -0
  43. package/lib/commonjs/src/NumberFormat.js +525 -0
  44. package/lib/commonjs/src/formatProps.js +108 -0
  45. package/lib/commonjs/src/index.js +8 -1
  46. package/lib/commonjs/src/specs/NitroText.nitro.js +2 -0
  47. package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
  48. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
  49. package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
  50. package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
  51. package/lib/module/src/NitroInput.js +8 -6
  52. package/lib/module/src/NitroNumber.js +54 -3
  53. package/lib/module/src/NitroText.js +98 -0
  54. package/lib/module/src/NitroTime.js +29 -0
  55. package/lib/module/src/NumberFormat.js +521 -0
  56. package/lib/module/src/formatProps.js +104 -0
  57. package/lib/module/src/index.js +3 -0
  58. package/lib/module/src/specs/NitroText.nitro.js +1 -0
  59. package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
  60. package/lib/typescript/src/NitroInput.d.ts +22 -0
  61. package/lib/typescript/src/NitroNumber.d.ts +115 -2
  62. package/lib/typescript/src/NitroText.d.ts +67 -0
  63. package/lib/typescript/src/NitroTime.d.ts +19 -0
  64. package/lib/typescript/src/NumberFormat.d.ts +47 -0
  65. package/lib/typescript/src/formatProps.d.ts +47 -0
  66. package/lib/typescript/src/index.d.ts +6 -1
  67. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +10 -0
  68. package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +80 -1
  69. package/lib/typescript/src/specs/NitroText.nitro.d.ts +60 -0
  70. package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
  71. package/nitro.json +36 -0
  72. package/nitrogen/generated/android/NitroInput+autolinking.cmake +12 -0
  73. package/nitrogen/generated/android/NitroInputOnLoad.cpp +62 -0
  74. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +45 -0
  75. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +10 -0
  76. package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp +118 -0
  77. package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.hpp +64 -0
  78. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +297 -0
  79. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +52 -0
  80. package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
  81. package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
  82. package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.cpp +58 -0
  83. package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.hpp +64 -0
  84. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +253 -0
  85. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +104 -0
  86. package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +3 -0
  87. package/nitrogen/generated/android/c++/JNitroNumberShimmerDirection.hpp +61 -0
  88. package/nitrogen/generated/android/c++/JNitroNumberSignDisplay.hpp +67 -0
  89. package/nitrogen/generated/android/c++/JNumberFormatCompactDisplay.hpp +58 -0
  90. package/nitrogen/generated/android/c++/JNumberFormatCurrencyDisplay.hpp +64 -0
  91. package/nitrogen/generated/android/c++/JNumberFormatCurrencySign.hpp +58 -0
  92. package/nitrogen/generated/android/c++/JNumberFormatNotation.hpp +64 -0
  93. package/nitrogen/generated/android/c++/JNumberFormatPlatformOptions.hpp +161 -0
  94. package/nitrogen/generated/android/c++/JNumberFormatPlatformSymbols.hpp +89 -0
  95. package/nitrogen/generated/android/c++/JNumberFormatRoundingMode.hpp +79 -0
  96. package/nitrogen/generated/android/c++/JNumberFormatSignDisplay.hpp +67 -0
  97. package/nitrogen/generated/android/c++/JNumberFormatStyle.hpp +64 -0
  98. package/nitrogen/generated/android/c++/JNumberFormatUnitDisplay.hpp +61 -0
  99. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +25 -0
  100. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +130 -0
  101. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +174 -0
  102. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.hpp +54 -0
  103. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +30 -0
  104. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatformSpec.kt +60 -0
  105. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +172 -0
  106. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
  107. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextMeasureSpec.kt +60 -0
  108. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +179 -0
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +2 -1
  110. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberShimmerDirection.kt +24 -0
  111. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberSignDisplay.kt +26 -0
  112. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCompactDisplay.kt +23 -0
  113. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencyDisplay.kt +25 -0
  114. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencySign.kt +23 -0
  115. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatNotation.kt +25 -0
  116. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformOptions.kt +136 -0
  117. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformSymbols.kt +91 -0
  118. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatRoundingMode.kt +30 -0
  119. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatSignDisplay.kt +26 -0
  120. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatStyle.kt +25 -0
  121. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatUnitDisplay.kt +24 -0
  122. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewManager.kt +96 -0
  123. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewStateUpdater.kt +23 -0
  124. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +68 -0
  125. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +184 -0
  126. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +56 -0
  127. package/nitrogen/generated/ios/NitroInputAutolinking.mm +34 -0
  128. package/nitrogen/generated/ios/NitroInputAutolinking.swift +36 -0
  129. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +30 -0
  130. package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.cpp +11 -0
  131. package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.hpp +122 -0
  132. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +188 -0
  133. package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
  134. package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
  135. package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.cpp +11 -0
  136. package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.hpp +90 -0
  137. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.cpp +11 -0
  138. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +233 -0
  139. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
  140. package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +156 -0
  141. package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +264 -0
  142. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +5 -0
  143. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +55 -0
  144. package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec.swift +56 -0
  145. package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec_cxx.swift +159 -0
  146. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +26 -0
  147. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +658 -21
  148. package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
  149. package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
  150. package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec.swift +56 -0
  151. package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec_cxx.swift +150 -0
  152. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +75 -0
  153. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +608 -0
  154. package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +4 -0
  155. package/nitrogen/generated/ios/swift/NitroNumberShimmerDirection.swift +44 -0
  156. package/nitrogen/generated/ios/swift/NitroNumberSignDisplay.swift +52 -0
  157. package/nitrogen/generated/ios/swift/NumberFormatCompactDisplay.swift +40 -0
  158. package/nitrogen/generated/ios/swift/NumberFormatCurrencyDisplay.swift +48 -0
  159. package/nitrogen/generated/ios/swift/NumberFormatCurrencySign.swift +40 -0
  160. package/nitrogen/generated/ios/swift/NumberFormatNotation.swift +48 -0
  161. package/nitrogen/generated/ios/swift/NumberFormatPlatformOptions.swift +159 -0
  162. package/nitrogen/generated/ios/swift/NumberFormatPlatformSymbols.swift +69 -0
  163. package/nitrogen/generated/ios/swift/NumberFormatRoundingMode.swift +68 -0
  164. package/nitrogen/generated/ios/swift/NumberFormatSignDisplay.swift +52 -0
  165. package/nitrogen/generated/ios/swift/NumberFormatStyle.swift +48 -0
  166. package/nitrogen/generated/ios/swift/NumberFormatUnitDisplay.swift +44 -0
  167. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +10 -0
  168. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +10 -0
  169. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp +22 -0
  170. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.hpp +70 -0
  171. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp +22 -0
  172. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.hpp +70 -0
  173. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp +23 -0
  174. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.hpp +71 -0
  175. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +52 -0
  176. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +58 -0
  177. package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
  178. package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
  179. package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.cpp +22 -0
  180. package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.hpp +63 -0
  181. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +62 -0
  182. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +115 -0
  183. package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +4 -0
  184. package/nitrogen/generated/shared/c++/NitroNumberShimmerDirection.hpp +80 -0
  185. package/nitrogen/generated/shared/c++/NitroNumberSignDisplay.hpp +88 -0
  186. package/nitrogen/generated/shared/c++/NumberFormatCompactDisplay.hpp +76 -0
  187. package/nitrogen/generated/shared/c++/NumberFormatCurrencyDisplay.hpp +84 -0
  188. package/nitrogen/generated/shared/c++/NumberFormatCurrencySign.hpp +76 -0
  189. package/nitrogen/generated/shared/c++/NumberFormatGrouping.hpp +80 -0
  190. package/nitrogen/generated/shared/c++/NumberFormatNotation.hpp +84 -0
  191. package/nitrogen/generated/shared/c++/NumberFormatOptions.hpp +193 -0
  192. package/nitrogen/generated/shared/c++/NumberFormatPart.hpp +87 -0
  193. package/nitrogen/generated/shared/c++/NumberFormatPlatformOptions.hpp +176 -0
  194. package/nitrogen/generated/shared/c++/NumberFormatPlatformSymbols.hpp +115 -0
  195. package/nitrogen/generated/shared/c++/NumberFormatRoundingMode.hpp +104 -0
  196. package/nitrogen/generated/shared/c++/NumberFormatRoundingPriority.hpp +80 -0
  197. package/nitrogen/generated/shared/c++/NumberFormatSignDisplay.hpp +88 -0
  198. package/nitrogen/generated/shared/c++/NumberFormatStyle.hpp +84 -0
  199. package/nitrogen/generated/shared/c++/NumberFormatTrailingZeroDisplay.hpp +76 -0
  200. package/nitrogen/generated/shared/c++/NumberFormatUnitDisplay.hpp +80 -0
  201. package/nitrogen/generated/shared/c++/ResolvedNumberFormatOptions.hpp +197 -0
  202. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +10 -0
  203. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +15 -0
  204. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +52 -0
  205. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +80 -0
  206. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +74 -0
  207. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +149 -0
  208. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
  209. package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
  210. package/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
  211. package/package.json +2 -2
  212. package/src/NitroInput.tsx +42 -7
  213. package/src/NitroNumber.tsx +236 -12
  214. package/src/NitroText.tsx +166 -0
  215. package/src/NitroTime.tsx +68 -0
  216. package/src/NumberFormat.ts +563 -0
  217. package/src/formatProps.ts +149 -0
  218. package/src/index.ts +23 -0
  219. package/src/specs/NitroInput.nitro.ts +10 -0
  220. package/src/specs/NitroNumber.nitro.ts +82 -1
  221. package/src/specs/NitroText.nitro.ts +65 -0
  222. package/src/specs/NumberFormat.nitro.ts +145 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,92 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1
4
+
5
+ - **Signs**: `signDisplay` (`'auto'`, `'always'`, `'exceptZero'`,
6
+ `'negative'`, `'never'`, as `Intl.NumberFormat`'s) puts a plus on gains,
7
+ and a plus that turns into a minus swaps like any other glyph; `plusSign`
8
+ and `minusSign` set the glyphs. A `format` gives its sign display and its
9
+ locale's minus.
10
+ - **Styled parts**: `prefixColor`, `suffixColor`, and `fractionFontSize`,
11
+ `fractionColor` and `fractionAlign` for smaller, dimmer or superscript
12
+ cents.
13
+ - **`onAnimationStart` / `onAnimationEnd`**: when the figure sets off from
14
+ rest and when it comes to rest, once for a run of changes.
15
+ - **`NitroTime`**: seconds as a clock, timer or countdown (`m:ss`,
16
+ `h:mm:ss`…), its tens of seconds and minutes wrapping after 5 so 0:59 →
17
+ 1:00 turns them one step. Built on `digits` (the highest digit a position
18
+ shows before it wraps, as NumberFlow's) and `groupingSizes`, both open to
19
+ any figure.
20
+ - **Compact figures**: a compact `format` rolls the figure it shows and swaps
21
+ its suffix ("950" → "1.5K" → "2.3M").
22
+ - **`continuous`**: the wheels below the highest one that changes turn a full
23
+ turn too, so a roll seems to pass through every value between.
24
+ - **Native digits and grouping**: `digitGlyphs` and `groupingSizes`, or a
25
+ `format`'s numbering system and group sizes (`ar-EG`'s ٠١٢٣…, `en-IN`'s
26
+ 12,34,567).
27
+ - **`animated={false}`** shows every change at once, and
28
+ **`respectReduceMotion={false}`** animates under Reduce Motion.
29
+ - **`NitroText`**: a single line of text that morphs natively, shared
30
+ characters gliding to their new places ("Sign in" → "Signing in…",
31
+ "$1,204" → "$1,318"), as Torph does on the web. Its own native view: one
32
+ draw of cached glyphs at rest like a label, sized by a synchronous native
33
+ measurement in the render that mounts it, with the loading shimmer and its
34
+ options. Only the props you set cross to native, a static label never
35
+ touches the reflow engine, and a reused view keeps its drawn line: 1000
36
+ labels mount in 113 ms of main thread on an iPhone 11 Pro and 510 ms on a
37
+ Galaxy A22 (`Text`: 140 and 790, `react-native-plain-text`: 112 and 620).
38
+ - **Shimmer options**: `shimmerAngle`, `shimmerWidth`, `shimmerBaseColor`
39
+ (a skeleton), `shimmerDirection` (following the layout direction by
40
+ default, so a right-to-left layout now sweeps right to left) and
41
+ `shimmerDelay`.
42
+ - Fixed: on iOS the loading glint was drawn in the label colour (black
43
+ on dark text, so invisible) unless `shimmerColor` was given; it uses the
44
+ documented light neutral now.
45
+ - Fixed: `NumberFormat` with `notation: 'compact'` dropped the currency and
46
+ the percent sign ("950" for "$950"; Android printed a compact currency in
47
+ full) and signDisplay's plus. It prints them as V8 does now.
48
+ - Android: `NitroText` crosses JNI to the reflow engine once per text
49
+ change and once per frame, rather than once per character and several
50
+ times a frame.
51
+
52
+ ## 0.3.0
53
+
54
+ - **`NumberFormat`**: `Intl.NumberFormat`'s API, formatted natively.
55
+ `new NumberFormat(locales, options)` learns the locale's format once from
56
+ the platform's formatter (Foundation / ICU, the data Hermes' `Intl` uses)
57
+ and formats in C++ from then on: `format`, `formatToParts` (on iOS too),
58
+ `formatRange`, `formatRangeToParts`, `resolvedOptions` and
59
+ `supportedLocalesOf`, every option of `Intl.NumberFormatOptions` (compact
60
+ notation, units and currency names printed by the platform formatter),
61
+ numbers, bigints and decimal strings. It passes 242 of test262's 251
62
+ `intl402/NumberFormat` tests on iOS and 244 on Android (Hermes' own `Intl`:
63
+ 121 and 101). On a Galaxy A22 a formatter builds in 9 µs instead of 3.3 ms
64
+ and formats in 2.8 µs instead of 10 µs. Where Hermes departs from ECMA-402 (iOS rounds ties to even on
65
+ the binary double, and prints NaN and infinities without the currency;
66
+ Android shows narrow currency symbols in zh-CN) it follows the
67
+ specification, as V8 does.
68
+ - **`format`** on `NitroNumber` and `NitroInput`: pass a `NumberFormat`
69
+ and the component takes its prefix and suffix, separators, fraction digits
70
+ (and, for the input, where the sign goes) from it; the individual props
71
+ still override.
72
+ - **`letterSpacing`**, **`prefixSpacing` / `suffixSpacing`** and
73
+ **`prefixOffset` / `suffixOffset`** on both components: tracking like
74
+ `Text`'s (affixes in proportion to their size), an exact gap between an
75
+ affix and the digits, and a nudge of an affix after its alignment.
76
+ - **`tabularNums={false}`** on `NitroNumber`: each digit at its own width
77
+ (the font's proportional figures) instead of the widest digit's. A
78
+ changing column's width eases once from the old digit's to the new one's,
79
+ on the roll's own easing, and a reveal keeps its target's widths
80
+ throughout. Tabular stays the default.
81
+ - **`direction="shortest"`** on `NitroNumber`: each digit rolls its own
82
+ shorter way round (1 → 2 is one step up even when the value falls), which
83
+ keeps a big jump calm; `auto` still follows the sign of the change.
84
+ - An `accessibilityLabel` given to `NitroNumber` is what VoiceOver and
85
+ TalkBack read; the figure was read instead.
86
+ - **Breaking:** the Android `minSdkVersion` default is 24 (was 23), as
87
+ React Native's: `NumberFormat` reads the platform's formats through
88
+ `android.icu`.
89
+
3
90
  ## 0.2.0
4
91
 
5
92
  - `react-native-nitro-rolling-number` is part of this package now, and its
package/README.md CHANGED
@@ -11,6 +11,9 @@ one native module.
11
11
  - **[`NitroNumber`](#nitronumber)**: a number that animates its changes.
12
12
  Every digit is a wheel that rolls to its new glyph, or swaps in place the way
13
13
  SwiftUI's `.contentTransition(.numericText())` does.
14
+ - **[`NumberFormat`](#numberformat)**: `Intl.NumberFormat`, formatted
15
+ natively. It learns a locale's format once from the platform and formats in
16
+ C++, with Hermes' output and a fraction of its cost.
14
17
 
15
18
  Fabric only (new architecture), React Native ≥ 0.78, Nitro Modules ≥ 0.37.
16
19
 
@@ -416,6 +419,10 @@ rather than renumbering the columns.
416
419
  | `prefixFontSize` / `suffixFontSize` | `number` | `fontSize` | Their own sizes. |
417
420
  | `affixAlign` | `'baseline' \| 'center' \| 'top' \| 'bottom'` | `'baseline'` | How they line up with the text: `top` pins glyph tops, `bottom` the bottom of the ink (a currency code sits on the digits' baseline). |
418
421
  | `prefixAlign` / `suffixAlign` | same | `affixAlign` | Per-affix override. |
422
+ | `letterSpacing` | number | `0` | Points added after every glyph, like `Text`'s; a smaller affix gets it in proportion to its size. |
423
+ | `prefixSpacing` / `suffixSpacing` | number | the letter spacing | Points between the prefix and the text, and between the text and the suffix. |
424
+ | `prefixOffset` / `suffixOffset` | number | `0` | Points an affix is moved down after its alignment (negative: up). |
425
+ | `format` | `NumberFormat` | none | The amount follows it: prefix and suffix, separators, fraction digits, where the sign goes. Sets `mode="number"`; the individual props override it. |
419
426
  | `placeholder` | `string` | `''` | Shown while empty; the first character reflows it away. `'0'` reads well for amounts. |
420
427
  | `placeholderTextColor` | `ColorValue` | platform | Placeholder color. |
421
428
  | `transition` | `'none' \| 'reflow'` | `'none'` | `'reflow'` runs the glyph engine, so characters glide, slide and fade as the text changes. |
@@ -534,6 +541,13 @@ ticker), or SwiftUI's `.contentTransition(.numericText())`, or a scramble.
534
541
  - A currency switch plays as one change: prefix, suffix and separators blur
535
542
  across, decimal columns open and close, the digits swap or roll.
536
543
  - `animateTo` / `jumpTo` on the Nitro object work from a Reanimated worklet.
544
+ - Signs (`signDisplay`: a plus on gains that swaps into the minus), styled
545
+ affixes and cents (`prefixColor`, `fractionFontSize`, superscript
546
+ `fractionAlign`), native digits and grouping (`ar-EG`'s ٠١٢٣, `en-IN`'s
547
+ 12,34,567), compact figures that roll ("950" → "1.5K"), `continuous` rolls,
548
+ and `onAnimationStart` / `onAnimationEnd`.
549
+ - `NitroTime` shows seconds as a clock, timer or countdown whose tens wrap
550
+ after 5, as a clock's wheels do.
537
551
 
538
552
  Guide: **https://ronickg.github.io/react-native-nitro-input/docs/nitro-number**
539
553
 
@@ -719,6 +733,24 @@ Hand the final value back to React when the feed stops (`scheduleOnRN`) so the
719
733
  `value` prop matches the screen; posting every tick queues them up while JS is
720
734
  busy and replays them afterwards.
721
735
 
736
+ ### Clocks and timers
737
+
738
+ `NitroTime` is a `NitroNumber` with a number of seconds as its figure. The tens
739
+ of seconds and of minutes wrap after 5, so 0:59 → 1:00 turns them one step
740
+ instead of rolling back through 4, 3, 2, 1.
741
+
742
+ ```tsx
743
+ import { NitroTime } from 'react-native-nitro-input'
744
+
745
+ <NitroTime seconds={elapsed} /> // 12:07
746
+ <NitroTime seconds={remaining} timeFormat="h:mm:ss" /> // 1:00:05
747
+ ```
748
+
749
+ `timeFormat` is `'m:ss'` (the default; minutes run past 59), `'mm:ss'`,
750
+ `'h:mm:ss'` or `'hh:mm:ss'`; `separator` defaults to `':'`. Every other
751
+ `NitroNumber` prop applies. The wheels are open to any figure through `digits`
752
+ (a position's highest digit) and `groupingSizes`.
753
+
722
754
  ## NitroNumber props
723
755
 
724
756
  | Prop | Type | Default | Description |
@@ -726,9 +758,18 @@ busy and replays them afterwards.
726
758
  | `value` | `number` | – | The number to display. Shown with at most 18 digits: `|value| × 10^fractionDigits` is clamped at 10^17, and a JS number carries exact integers only up to 2^53. |
727
759
  | `fractionDigits` | `number` | `0` | Digits after the decimal separator. |
728
760
  | `minimumIntegerDigits` | `number` | `1` | Zero-pads the integer part. |
729
- | `groupingSeparator` | `string` | `''` | Inserted every three integer digits. |
761
+ | `groupingSeparator` | `string` | `''` | Inserted between digit groups. |
762
+ | `groupingSizes` | `number[]` | `[3]` | Group sizes from the decimal point: `[3, 2]` is Indian grouping (12,34,567). |
730
763
  | `decimalSeparator` | `string` | `'.'` | Between integer and fraction digits. |
731
764
  | `prefix` / `suffix` | `string` | `''` | Static text around the number. |
765
+ | `signDisplay` | `'auto' \| 'always' \| 'exceptZero' \| 'negative' \| 'never'` | `'auto'` | Which values carry a sign; `'exceptZero'` puts a plus on gains, and a plus that turns into a minus swaps. |
766
+ | `plusSign` / `minusSign` | `string` | `'+'` / `'-'` | The sign glyphs (e.g. `'−'`, U+2212). |
767
+ | `digitGlyphs` | `string[]` | `'0'`…`'9'` | Ten glyphs for native digits (Arabic-Indic, Devanagari…). |
768
+ | `digits` | `Record<number, { max }>` | – | The highest digit a position shows before it wraps (a clock's tens: `{ 1: { max: 5 } }`). |
769
+ | `continuous` | `boolean` | `false` | Rolls turn the lower wheels a full turn too, so the figure seems to pass through every value. |
770
+ | `animated` | `boolean` | `true` | `false` shows every change at once. |
771
+ | `respectReduceMotion` | `boolean` | `true` | Snap while the system's Reduce Motion is on. |
772
+ | `onAnimationStart` / `onAnimationEnd` | `() => void` / `(value) => void` | – | The figure set off from rest / came to rest, once for a run of changes. |
732
773
  | `duration` | `number` | `500` | Roll duration in ms; `0` snaps. |
733
774
  | `easing` | `'linear' \| 'easeIn' \| 'easeOut' \| 'easeInOut' \| 'spring'` | `'easeInOut'` | Roll timing curve. A value that arrives while the wheels are still rolling continues with the ease-out half of the curve, so rapid updates never stall. |
734
775
  | `bounce` | `number` | `0.15` | Overshoot of the `spring` easing (0–1). |
@@ -737,7 +778,7 @@ busy and replays them afterwards.
737
778
  | `flashUpColor`, `flashDownColor` | `ColorValue` | unset | The change flash: digits whose glyph changes light up in the up colour when the value grew, the down colour when it shrank, stay lit while they move, and fade back over `flashDuration` once they have landed. Unset: no flash. |
738
779
  | `flashDuration` | `number` | `600` | ms a change flash takes to fade, once the digit has landed. |
739
780
  | `popOnChange` | `number` | `0` | A punch of the whole figure on every change, peak overshoot 0–1, rung out like the reveal's landing pop. |
740
- | `direction` | `'auto' \| 'up' \| 'down'` | `'auto'` | Roll direction; `auto` follows the sign of the change. |
781
+ | `direction` | `'auto' \| 'up' \| 'down' \| 'shortest'` | `'auto'` | Roll direction; `auto` follows the sign of the change. `shortest` rolls each digit its own shorter way round. |
741
782
  | `reveal` | `boolean` | – | `false` holds the opening frame (`$0.00` in the final layout); `true` plays the reveal to `value`. Unset = a normal NitroNumber. |
742
783
  | `revealStyle` | `'count' \| 'spin'` | `'count'` | The win-meter rollup, or slot reels locking from the left. |
743
784
  | `revealDuration` | `number` | `2200` | ms of the count, or until the last reel locks (holds and the pop come on top). |
@@ -751,10 +792,23 @@ busy and replays them afterwards.
751
792
  | `loading` | `boolean` | `false` | "Shine" glint: a slanted, text-wide band sweeps through the ink; cross-fades on toggle. |
752
793
  | `shimmerColor` | `ColorValue` | light neutral | Color of the glint's core (`#D6D9E1`, `#2B2E37` in dark mode). |
753
794
  | `shimmerDuration` | `number` | `950` | ms per sweep (linear, repeating). |
795
+ | `shimmerAngle` | `number` | `31` | The band's slant in degrees (0 upright). |
796
+ | `shimmerWidth` | `number` | `1` | The band's width, a fraction of the number's. |
797
+ | `shimmerBaseColor` | `ColorValue` | `color` | The glyphs' colour outside the band: a skeleton. |
798
+ | `shimmerDirection` | `'auto' \| 'ltr' \| 'rtl'` | `'auto'` | Sweep direction; `'auto'` follows the layout direction. |
799
+ | `shimmerDelay` | `number` | `0` | ms of pause after each sweep. |
754
800
  | `fontSize` | `number` | `32` | Font size of the digits in points. |
755
801
  | `prefixFontSize` / `suffixFontSize` | `number` | `fontSize` | Smaller (or larger) prefix/suffix, e.g. a currency symbol or code. |
756
802
  | `affixAlign` | `'baseline' \| 'center' \| 'top' \| 'bottom'` | `'baseline'` | How prefix/suffix line up with the digits: `top` pins the glyph tops (cap height), `bottom` the bottom of the glyphs' ink (a currency code sits on the digits' baseline, not down where a comma's tail reaches). |
757
803
  | `prefixAlign` / `suffixAlign` | same | `affixAlign` | Per-affix override, e.g. `$` pinned top and `USD` pinned bottom. |
804
+ | `letterSpacing` | number | `0` | Points added after every glyph, like `Text`'s; a smaller affix gets it in proportion to its size. |
805
+ | `prefixSpacing` / `suffixSpacing` | number | the letter spacing | Points between the prefix and the digits, and between the digits and the suffix. |
806
+ | `prefixOffset` / `suffixOffset` | number | `0` | Points an affix is moved down after its alignment (negative: up). |
807
+ | `prefixColor` / `suffixColor` | `ColorValue` | `color` | The affixes' colours. |
808
+ | `fractionFontSize` / `fractionColor` | `number` / `ColorValue` | `fontSize` / `color` | Smaller, dimmer cents (the decimal separator follows). |
809
+ | `fractionAlign` | `'baseline' \| 'center' \| 'top' \| 'bottom'` | `'baseline'` | `'top'`: superscript cents. |
810
+ | `format` | `NumberFormat` | none | The number follows it: prefix and suffix, separators and group sizes, fraction and minimum integer digits, sign display, native digits; a compact format rolls its figure and swaps its suffix ("950" → "1.5K"). The individual props override it. |
811
+ | `tabularNums` | boolean | `true` | `false` lays each digit out at its own width (proportional figures); a changing column eases once from the old digit's width to the new one's. |
758
812
  | `adjustsFontSizeToFit` | `boolean` | `false` | Shrink the whole number to fit the view's fixed `width`; the view keeps its full height. |
759
813
  | `minimumFontScale` | `number` | `0.5` | Lower bound for `adjustsFontSizeToFit`. |
760
814
  | `allowFontScaling` | `boolean` | `false` | Follow the system text size like `Text` (off by default so amounts keep their design size). |
@@ -770,6 +824,44 @@ The view reports its intrinsic size from native and sizes itself. Give it an
770
824
  explicit `width` in `style` plus `textAlign="right"` if you don't want the layout
771
825
  to reflow while digits appear (e.g. a counter that grows past `999`).
772
826
 
827
+ ## NitroText
828
+
829
+ A single line of text that morphs to the next, natively: the characters two
830
+ strings share glide to their new places and the rest fade, as
831
+ [Torph](https://torph.lochie.me) does on the web. Digits match by place, so
832
+ "Total $1,204" → "Total $1,318" rolls the hundreds and tens.
833
+
834
+ ```tsx
835
+ import { NitroText } from 'react-native-nitro-input'
836
+
837
+ <NitroText fontSize={17} fontWeight="600">{busy ? 'Signing in…' : 'Sign in'}</NitroText>
838
+ ```
839
+
840
+ It is its own native view, not a text field: at rest it draws its line in one
841
+ pass, like a label, and only a morph draws each character on its own. It
842
+ measures its text natively while it renders, so it lays out in the commit that
843
+ mounts it, and only the props you set cross to native. Mounting 1000 labels
844
+ (Release, into reused views) costs about what `react-native-plain-text` does
845
+ and less than `Text`: 113 ms of main thread on an iPhone 11 Pro (PlainText
846
+ 112, Text 140) and 510 ms on a Galaxy A22 (PlainText 620, Text 790). A label
847
+ that never changes never touches the morph engine.
848
+
849
+ | Prop | Default | |
850
+ | --- | --- | --- |
851
+ | `children` | – | The text: a string or a number. A change morphs to it. |
852
+ | `fontSize` / `fontWeight` / `fontFamily` | `17` / `'normal'` / system | As `Text`'s. Digits are tabular, so a column keeps its width while it morphs. |
853
+ | `color` | label colour | |
854
+ | `letterSpacing` | `0` | Points after every character. |
855
+ | `textAlign` | `'auto'` | `'left'`, `'center'` or `'right'` in a wider view; `'auto'` is the start edge. |
856
+ | `allowFontScaling` / `maxFontSizeMultiplier` | `false` / none | Scale with the system text size, like `Text`. |
857
+ | `duration` / `easing` / `bounce` / `effect` | `400` / `'expo'` / `0.15` / `'auto'` | The morph's timing, as the [reflow](#how-the-reflow-decides-what-moves)'s. |
858
+ | `respectReduceMotion` | `true` | Snap while Reduce Motion (iOS) or "Remove animations" (Android) is on. |
859
+ | `loading` and `shimmer*` | `false` | The loading glint, with every option of `NitroNumber`'s. |
860
+
861
+ It is one line (no wrapping). Scripts that shape by context (Arabic, Indic)
862
+ and characters from fallback fonts (emoji, CJK) are drawn as strings, so they
863
+ render correctly, but they are laid out character by character.
864
+
773
865
  ## Accessibility and threading
774
866
 
775
867
  ### NitroInput
@@ -785,6 +877,14 @@ to reflow while digits appear (e.g. a counter that grows past `999`).
785
877
  `mostRecentEventCount` (the user typed since) is ignored, like React
786
878
  Native's own `TextInput`.
787
879
 
880
+ ### NitroText
881
+
882
+ - The view is the accessibility element, read as text with its string (and
883
+ "loading" while the shimmer runs); an `accessibilityLabel` replaces it.
884
+ - Reduce Motion (iOS) and "Remove animations" (Android) snap a morph.
885
+ - The view implements `RecyclableView`: a reused view keeps its drawn line, so
886
+ an element with the same text and style draws nothing.
887
+
788
888
  ### NitroNumber
789
889
 
790
890
  - VoiceOver / TalkBack read the formatted amount (prefix, sign, grouped digits,
@@ -839,6 +939,36 @@ to reflow while digits appear (e.g. a counter that grows past `999`).
839
939
  - Props are parsed by Nitro from JSI (no Fabric codegen); the view is a Fabric
840
940
  component, so `style`, `opacity`, `transform` and friends work as usual.
841
941
 
942
+ ## NumberFormat
943
+
944
+ `Intl.NumberFormat`'s API, formatted natively. The first formatter for a
945
+ locale and currency learns its format from the platform's own formatter
946
+ (Foundation on iOS, ICU on Android, the data Hermes' `Intl` uses); every number
947
+ after that is formatted in C++. It behaves as ECMA-402 specifies (callable
948
+ without `new`, a bound `format`, options read and checked in the specified
949
+ order) and passes test262's `intl402/NumberFormat` suite as far as the
950
+ platform's data goes: 242 of 251 tests on iOS and 244 on Android, where Hermes'
951
+ own `Intl` passes 121 and 101.
952
+
953
+ ```ts
954
+ import { NumberFormat, NitroNumber } from 'react-native-nitro-input'
955
+
956
+ const php = new NumberFormat('en-PH', { style: 'currency', currency: 'PHP' })
957
+ php.format(1234.5) // "₱1,234.50"
958
+ php.formatToParts(-12) // on iOS too
959
+ php.formatRange(3, 5) // "₱3.00 – ₱5.00"
960
+ [1, 2].map(php.format) // format is bound
961
+ php.format('12345678901234567890.125') // exact
962
+
963
+ <NitroNumber value={balance} format={php} />
964
+ ```
965
+
966
+ Building a formatter takes 9 µs on a Galaxy A22 against Hermes' 3.3 ms, and
967
+ `format()` 2.8 µs against 10 µs. Every option of `Intl.NumberFormatOptions` is
968
+ supported; compact notation, units and currency names are printed by the
969
+ platform formatter (iOS has no long compact form). Full guide:
970
+ https://ronickg.github.io/react-native-nitro-input/docs/number-format
971
+
842
972
  ## Credits
843
973
 
844
974
  The reflow is based on [Torph](https://torph.lochie.me) by
@@ -21,6 +21,9 @@ add_library(${PACKAGE_NAME} SHARED
21
21
  ../cpp/RollingEngine.cpp
22
22
  ../cpp/worklets/NitroInputWorkletsBridge.cpp
23
23
  ../cpp/worklets/HybridNitroInputWorklets.cpp
24
+ ../cpp/numberformat/NumberFormatCore.cpp
25
+ ../cpp/numberformat/NumberFormatProbe.cpp
26
+ ../cpp/numberformat/HybridNitroNumberFormat.cpp
24
27
  )
25
28
 
26
29
  # Add Nitrogen specs :)
@@ -31,6 +34,7 @@ include_directories(
31
34
  "src/main/cpp"
32
35
  "../cpp"
33
36
  "../cpp/worklets"
37
+ "../cpp/numberformat"
34
38
  )
35
39
 
36
40
  # Worklets are optional: with react-native-worklets installed the views can
@@ -1,4 +1,4 @@
1
- NitroInput_minSdkVersion=23
1
+ NitroInput_minSdkVersion=24
2
2
  NitroInput_targetSdkVersion=36
3
3
  NitroInput_compileSdkVersion=36
4
4
  NitroInput_ndkVersion=29.0.14206865
@@ -5,6 +5,8 @@
5
5
 
6
6
  #include "JReflowEngine.hpp"
7
7
 
8
+ #include <algorithm>
9
+
8
10
  namespace margelo::nitro::nitroinput {
9
11
 
10
12
  jni::local_ref<JReflowEngine::jhybriddata> JReflowEngine::initHybrid(jni::alias_ref<jhybridobject>) {
@@ -31,6 +33,8 @@ void JReflowEngine::registerNatives() {
31
33
  makeNativeMethod("caretX", JReflowEngine::caretX),
32
34
  makeNativeMethod("reset", JReflowEngine::reset),
33
35
  makeNativeMethod("frameInto", JReflowEngine::frameInto),
36
+ makeNativeMethod("commitLine", JReflowEngine::commitLine),
37
+ makeNativeMethod("tickInto", JReflowEngine::tickInto),
34
38
  });
35
39
  }
36
40
 
@@ -129,4 +133,32 @@ int JReflowEngine::frameInto(jni::alias_ref<jni::JArrayDouble> out) {
129
133
  return static_cast<int>(needed);
130
134
  }
131
135
 
136
+ bool JReflowEngine::commitLine(jni::alias_ref<jni::JArrayInt> characters, jni::alias_ref<jni::JArrayInt> kinds,
137
+ jni::alias_ref<jni::JArrayDouble> widths, int count, int role, bool reduceMotion,
138
+ int caret, double now) {
139
+ const size_t n = static_cast<size_t>(std::max(0, count));
140
+ lineChars_.resize(n);
141
+ lineKinds_.resize(n);
142
+ lineWidths_.resize(n);
143
+ if (n > 0) {
144
+ characters->getRegion(0, static_cast<jsize>(n), lineChars_.data());
145
+ kinds->getRegion(0, static_cast<jsize>(n), lineKinds_.data());
146
+ widths->getRegion(0, static_cast<jsize>(n), lineWidths_.data());
147
+ }
148
+ engine_.setReduceMotion(reduceMotion);
149
+ engine_.beginText();
150
+ for (size_t i = 0; i < n; ++i) {
151
+ engine_.addGlyph(static_cast<uint32_t>(lineChars_[i]), role, lineKinds_[i], lineWidths_[i], false);
152
+ }
153
+ engine_.commitText(caret, now);
154
+ return engine_.needsFrames();
155
+ }
156
+
157
+ int JReflowEngine::tickInto(double now, jni::alias_ref<jni::JArrayDouble> out) {
158
+ engine_.tick(now);
159
+ const int written = frameInto(out);
160
+ const int more = engine_.needsFrames() ? kMoreFrames : 0;
161
+ return written < 0 ? -1 : (written | more);
162
+ }
163
+
132
164
  } // namespace margelo::nitro::nitroinput
@@ -43,12 +43,25 @@ public:
43
43
  /// without allocating once warm; returns the number of doubles written, or
44
44
  /// -1 if `out` is too small.
45
45
  int frameInto(jni::alias_ref<jni::JArrayDouble> out);
46
+ /// A whole line in one crossing: `setReduceMotion`, `beginText`, an
47
+ /// `addGlyph` per character (in `role`, never a placeholder) and
48
+ /// `commitText`. Returns `needsFrames()`.
49
+ bool commitLine(jni::alias_ref<jni::JArrayInt> characters, jni::alias_ref<jni::JArrayInt> kinds,
50
+ jni::alias_ref<jni::JArrayDouble> widths, int count, int role, bool reduceMotion, int caret, double now);
51
+ /// `tick` and `frameInto` in one crossing: the number of doubles written
52
+ /// (or -1 if `out` is too small, after ticking), plus `kMoreFrames` while
53
+ /// the engine still needs frames.
54
+ int tickInto(double now, jni::alias_ref<jni::JArrayDouble> out);
55
+ static constexpr int kMoreFrames = 1 << 30;
46
56
 
47
57
  private:
48
58
  friend HybridBase;
49
59
  JReflowEngine() = default;
50
60
  ReflowEngine engine_;
51
61
  std::vector<double> scratch_;
62
+ std::vector<jint> lineChars_;
63
+ std::vector<jint> lineKinds_;
64
+ std::vector<double> lineWidths_;
52
65
  };
53
66
 
54
67
  } // namespace margelo::nitro::nitroinput
@@ -20,6 +20,13 @@ void JRollingEngine::registerNatives() {
20
20
  makeNativeMethod("setFlash", JRollingEngine::setFlash),
21
21
  makeNativeMethod("setPopOnChange", JRollingEngine::setPopOnChange),
22
22
  makeNativeMethod("setReduceMotion", JRollingEngine::setReduceMotion),
23
+ makeNativeMethod("setContinuous", JRollingEngine::setContinuous),
24
+ makeNativeMethod("setDigitMax", JRollingEngine::setDigitMax),
25
+ makeNativeMethod("clearDigitMax", JRollingEngine::clearDigitMax),
26
+ makeNativeMethod("wheelModulus", JRollingEngine::wheelModulus),
27
+ makeNativeMethod("setSignDisplay", JRollingEngine::setSignDisplay),
28
+ makeNativeMethod("signPositive", JRollingEngine::signPositive),
29
+ makeNativeMethod("signFactor", JRollingEngine::signFactor),
23
30
  makeNativeMethod("changeText", JRollingEngine::changeText),
24
31
  makeNativeMethod("changeFormat", JRollingEngine::changeFormat),
25
32
  makeNativeMethod("setValue", JRollingEngine::setValue),
@@ -73,6 +80,34 @@ void JRollingEngine::setReduceMotion(bool reduceMotion) {
73
80
  engine_.setReduceMotion(reduceMotion);
74
81
  }
75
82
 
83
+ void JRollingEngine::setContinuous(bool continuous) {
84
+ engine_.setContinuous(continuous);
85
+ }
86
+
87
+ void JRollingEngine::setDigitMax(int power, int max) {
88
+ engine_.setDigitMax(power, max);
89
+ }
90
+
91
+ void JRollingEngine::clearDigitMax() {
92
+ engine_.clearDigitMax();
93
+ }
94
+
95
+ int JRollingEngine::wheelModulus(int index) {
96
+ return engine_.wheelModulus(index);
97
+ }
98
+
99
+ void JRollingEngine::setSignDisplay(int mode) {
100
+ engine_.setSignDisplay(mode);
101
+ }
102
+
103
+ bool JRollingEngine::signPositive() {
104
+ return engine_.signPositive();
105
+ }
106
+
107
+ double JRollingEngine::signFactor() {
108
+ return engine_.signFactor();
109
+ }
110
+
76
111
  void JRollingEngine::changeText(int slot, double now) {
77
112
  engine_.changeText(slot, now);
78
113
  }
@@ -153,12 +188,15 @@ int JRollingEngine::frameInto(jni::alias_ref<jni::JArrayDouble> out) {
153
188
  const auto& wheels = engine_.wheels();
154
189
  const size_t count = wheels.size();
155
190
  constexpr size_t kMaxWheels = 32;
191
+ // Doubles per wheel: the engine's `Wheel`, then the places it wraps after
192
+ // (`wheelModulus`: 10, or fewer on a clock's wheel).
193
+ constexpr size_t kWheelFields = 15;
156
194
  // Then each text slot's swap (`RollingEngine::changeText`): grow, focus,
157
195
  // blurOut, active.
158
196
  // Then the decimal columns laid out and the decimal separator's factor.
159
197
  constexpr size_t kText = RollingEngine::kTextSlots * 4 + 2;
160
- double data[4 + kMaxWheels * 13 + kText];
161
- const size_t needed = 4 + count * 13 + kText;
198
+ double data[4 + kMaxWheels * kWheelFields + kText];
199
+ const size_t needed = 4 + count * kWheelFields + kText;
162
200
  if (count > kMaxWheels || static_cast<size_t>(out->size()) < needed) {
163
201
  return -1;
164
202
  }
@@ -167,6 +205,7 @@ int JRollingEngine::frameInto(jni::alias_ref<jni::JArrayDouble> out) {
167
205
  data[2] = engine_.revealScale();
168
206
  data[3] = static_cast<double>(count);
169
207
  size_t i = 4;
208
+ int index = 0;
170
209
  for (const auto& w : wheels) {
171
210
  data[i++] = w.position;
172
211
  data[i++] = w.width;
@@ -181,6 +220,8 @@ int JRollingEngine::frameInto(jni::alias_ref<jni::JArrayDouble> out) {
181
220
  data[i++] = w.focus;
182
221
  data[i++] = w.grow;
183
222
  data[i++] = w.blurOut;
223
+ data[i++] = w.progress;
224
+ data[i++] = static_cast<double>(engine_.wheelModulus(index++));
184
225
  }
185
226
  for (int slot = 0; slot < RollingEngine::kTextSlots; slot++) {
186
227
  const RollingEngine::TextChange t = engine_.textChange(slot);
@@ -28,6 +28,13 @@ public:
28
28
  void setFlash(double seconds);
29
29
  void setPopOnChange(double overshoot);
30
30
  void setReduceMotion(bool reduceMotion);
31
+ void setContinuous(bool continuous);
32
+ void setDigitMax(int power, int max);
33
+ void clearDigitMax();
34
+ int wheelModulus(int index);
35
+ void setSignDisplay(int mode);
36
+ bool signPositive();
37
+ double signFactor();
31
38
  void changeText(int slot, double now);
32
39
  void changeFormat(int fractionDigits, int minimumIntegerDigits, double now);
33
40
  void setValue(double value);
@@ -49,7 +56,8 @@ public:
49
56
  double revealMilestoneValue(int index);
50
57
  /// Writes the render state into `out` without allocating:
51
58
  /// `[signFactor, loadingProgress, revealScale, wheelCount, then (position,
52
- /// width, linear, blankZero) per wheel]`. Returns the number of doubles
59
+ /// width, linear, blankZero, …, progress, modulus) per wheel]`, then the
60
+ /// text slots and the decimal columns. Returns the number of doubles
53
61
  /// written, or -1 if `out` is too small.
54
62
  int frameInto(jni::alias_ref<jni::JArrayDouble> out);
55
63
  double shimmerPhase(double now, double periodSeconds);
@@ -115,6 +115,16 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
115
115
  set(v) { field = v; markConfigDirty() }
116
116
  override var suffixAlign: NitroInputAffixAlign = NitroInputAffixAlign.BASELINE
117
117
  set(v) { field = v; markConfigDirty() }
118
+ override var letterSpacing: Double = 0.0
119
+ set(v) { field = v; markConfigDirty() }
120
+ override var prefixSpacing: Double = Double.POSITIVE_INFINITY
121
+ set(v) { field = v; markConfigDirty() }
122
+ override var suffixSpacing: Double = Double.POSITIVE_INFINITY
123
+ set(v) { field = v; markConfigDirty() }
124
+ override var prefixOffset: Double = 0.0
125
+ set(v) { field = v; markConfigDirty() }
126
+ override var suffixOffset: Double = 0.0
127
+ set(v) { field = v; markConfigDirty() }
118
128
  override var placeholder: String = ""
119
129
  set(v) { field = v; markConfigDirty() }
120
130
  override var placeholderColor: Double = Double.NaN
@@ -373,6 +383,11 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
373
383
  prefixFontSize = Double.NaN
374
384
  suffixFontSize = Double.NaN
375
385
  signPlacement = NitroInputSignPlacement.BEFOREAFFIX
386
+ letterSpacing = 0.0
387
+ prefixSpacing = Double.POSITIVE_INFINITY
388
+ suffixSpacing = Double.POSITIVE_INFINITY
389
+ prefixOffset = 0.0
390
+ suffixOffset = 0.0
376
391
  prefixAlign = NitroInputAffixAlign.BASELINE
377
392
  suffixAlign = NitroInputAffixAlign.BASELINE
378
393
  placeholder = ""
@@ -575,6 +590,11 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
575
590
  placeholderColor = colorFromARGB(placeholderColor),
576
591
  prefixAlign = mapAffixAlign(prefixAlign),
577
592
  suffixAlign = mapAffixAlign(suffixAlign),
593
+ letterSpacing = if (letterSpacing.isFinite()) letterSpacing.toFloat() else 0f,
594
+ prefixSpacing = prefixSpacing.takeIf { it.isFinite() }?.toFloat(),
595
+ suffixSpacing = suffixSpacing.takeIf { it.isFinite() }?.toFloat(),
596
+ prefixOffset = if (prefixOffset.isFinite()) prefixOffset.toFloat() else 0f,
597
+ suffixOffset = if (suffixOffset.isFinite()) suffixOffset.toFloat() else 0f,
578
598
  adjustsFontSizeToFit = adjustsFontSizeToFit,
579
599
  minimumFontScale = finite(minimumFontScale, 0.5).coerceIn(0.05, 1.0).toFloat(),
580
600
  allowFontScaling = allowFontScaling,