react-native-nitro-input 0.1.0 → 0.2.0

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 (116) hide show
  1. package/CHANGELOG.md +305 -3
  2. package/NitroInput.podspec +4 -4
  3. package/README.md +378 -53
  4. package/android/CMakeLists.txt +5 -3
  5. package/android/src/main/cpp/JOutlineGeometry.hpp +1 -1
  6. package/android/src/main/cpp/JReflowEngine.cpp +132 -0
  7. package/android/src/main/cpp/{JMorphEngine.hpp → JReflowEngine.hpp} +7 -7
  8. package/android/src/main/cpp/JRollingEngine.cpp +222 -0
  9. package/android/src/main/cpp/JRollingEngine.hpp +68 -0
  10. package/android/src/main/cpp/cpp-adapter.cpp +4 -2
  11. package/android/src/main/java/com/margelo/nitro/nitroinput/AmountFormatter.kt +1 -1
  12. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +1 -1
  13. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +471 -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 +38 -16
  16. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +1741 -0
  17. package/android/src/main/java/com/margelo/nitro/nitroinput/{MorphEngine.kt → ReflowEngine.kt} +2 -2
  18. package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +59 -0
  19. package/cpp/AmountFormatter.cpp +5 -0
  20. package/cpp/AmountFormatter.hpp +10 -2
  21. package/cpp/{MorphEngine.cpp → ReflowEngine.cpp} +52 -47
  22. package/cpp/{MorphEngine.hpp → ReflowEngine.hpp} +12 -4
  23. package/cpp/RollingEngine.cpp +1224 -0
  24. package/cpp/RollingEngine.hpp +468 -0
  25. package/cpp/SwiftNonCopyable.hpp +22 -0
  26. package/cpp/worklets/NitroInputWorkletsBridge.cpp +3 -3
  27. package/cpp/worklets/NitroInputWorkletsBridge.hpp +1 -1
  28. package/ios/{HybridMorphInputView.swift → HybridNitroInputView.swift} +1 -1
  29. package/ios/HybridNitroNumberView.swift +439 -0
  30. package/ios/NitroInputView.swift +69 -45
  31. package/ios/NitroNumberView.swift +1934 -0
  32. package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
  33. package/lib/commonjs/src/NitroInput.js +21 -52
  34. package/lib/commonjs/src/NitroNumber.js +139 -0
  35. package/lib/commonjs/src/index.js +4 -3
  36. package/lib/commonjs/src/specs/NitroNumber.nitro.js +2 -0
  37. package/lib/commonjs/src/styleHelpers.js +36 -0
  38. package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
  39. package/lib/module/src/NitroInput.js +12 -43
  40. package/lib/module/src/NitroNumber.js +100 -0
  41. package/lib/module/src/index.js +1 -1
  42. package/lib/module/src/specs/NitroNumber.nitro.js +1 -0
  43. package/lib/module/src/styleHelpers.js +32 -0
  44. package/lib/typescript/src/NitroInput.d.ts +28 -21
  45. package/lib/typescript/src/NitroNumber.d.ts +211 -0
  46. package/lib/typescript/src/index.d.ts +3 -2
  47. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +9 -9
  48. package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +238 -0
  49. package/lib/typescript/src/styleHelpers.d.ts +3 -0
  50. package/nitro.json +10 -0
  51. package/nitrogen/generated/android/NitroInput+autolinking.cmake +4 -0
  52. package/nitrogen/generated/android/NitroInputOnLoad.cpp +20 -0
  53. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  54. package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +10 -10
  55. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +536 -0
  56. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +156 -0
  57. package/nitrogen/generated/android/c++/JNitroNumberAffixAlign.hpp +64 -0
  58. package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +61 -0
  59. package/nitrogen/generated/android/c++/JNitroNumberEasing.hpp +67 -0
  60. package/nitrogen/generated/android/c++/JNitroNumberRevealStyle.hpp +58 -0
  61. package/nitrogen/generated/android/c++/JNitroNumberTextAlign.hpp +64 -0
  62. package/nitrogen/generated/android/c++/JNitroNumberTransition.hpp +61 -0
  63. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +299 -0
  64. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.hpp +54 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void.kt +78 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_double_double.kt +9 -9
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +363 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberAffixAlign.kt +25 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +24 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberEasing.kt +26 -0
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberRevealStyle.kt +23 -0
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberTextAlign.kt +25 -0
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberTransition.kt +24 -0
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroNumberViewManager.kt +96 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroNumberViewStateUpdater.kt +23 -0
  76. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +25 -0
  77. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +248 -0
  78. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +23 -0
  79. package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
  80. package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
  81. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.cpp +11 -0
  82. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +432 -0
  83. package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +414 -0
  84. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  85. package/nitrogen/generated/ios/swift/Func_void_double_double.swift +5 -5
  86. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +102 -0
  87. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +1243 -0
  88. package/nitrogen/generated/ios/swift/NitroNumberAffixAlign.swift +48 -0
  89. package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +44 -0
  90. package/nitrogen/generated/ios/swift/NitroNumberEasing.swift +52 -0
  91. package/nitrogen/generated/ios/swift/NitroNumberRevealStyle.swift +40 -0
  92. package/nitrogen/generated/ios/swift/NitroNumberTextAlign.swift +48 -0
  93. package/nitrogen/generated/ios/swift/NitroNumberTransition.swift +44 -0
  94. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +115 -0
  95. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +175 -0
  96. package/nitrogen/generated/shared/c++/NitroNumberAffixAlign.hpp +84 -0
  97. package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +80 -0
  98. package/nitrogen/generated/shared/c++/NitroNumberEasing.hpp +88 -0
  99. package/nitrogen/generated/shared/c++/NitroNumberRevealStyle.hpp +76 -0
  100. package/nitrogen/generated/shared/c++/NitroNumberTextAlign.hpp +84 -0
  101. package/nitrogen/generated/shared/c++/NitroNumberTransition.hpp +80 -0
  102. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +124 -0
  103. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +227 -0
  104. package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
  105. package/package.json +15 -7
  106. package/src/NitroInput.tsx +37 -60
  107. package/src/NitroNumber.tsx +481 -0
  108. package/src/index.ts +20 -6
  109. package/src/specs/NitroInput.nitro.ts +9 -9
  110. package/src/specs/NitroNumber.nitro.ts +259 -0
  111. package/src/styleHelpers.ts +32 -0
  112. package/android/src/main/cpp/JMorphEngine.cpp +0 -132
  113. package/lib/commonjs/src/MorphInput.js +0 -42
  114. package/lib/module/src/MorphInput.js +0 -6
  115. package/lib/typescript/src/MorphInput.d.ts +0 -18
  116. package/src/MorphInput.tsx +0 -30
@@ -0,0 +1,238 @@
1
+ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules';
2
+ /** Horizontal alignment of the number inside the view's frame. */
3
+ /**
4
+ * `'auto'` is the start edge of the layout direction - left in a left-to-right
5
+ * app, right in a right-to-left one - which is what `Text` does with no
6
+ * `textAlign`; in a view that hugs the number it is the edge the parent keeps
7
+ * the view to (the end of a row: right), so the digits open and close against
8
+ * it. `'left'` and `'right'` are absolute, whatever the direction.
9
+ */
10
+ export type NitroNumberTextAlign = 'auto' | 'left' | 'center' | 'right';
11
+ /** Timing curve used when a value change is rolled natively. */
12
+ export type NitroNumberEasing = 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' | 'spring';
13
+ /** Which way the digits roll: `'auto'` follows the sign of the change. */
14
+ export type NitroNumberDirection = 'auto' | 'up' | 'down';
15
+ /**
16
+ * How a value change plays. `'roll'` is the odometer: every changed digit
17
+ * rolls through the digits between its old and new glyph. `'numeric'` is the
18
+ * numeric transition of SwiftUI's `.contentTransition(.numericText())`: each
19
+ * changed glyph swaps in place, the old one softening, shrinking and sliding
20
+ * out while the new one slides in from the other side and comes into focus,
21
+ * digits cascading from the left; the unchanged digits stay put. `'scramble'`
22
+ * shows a different random digit every few frames until each changed digit
23
+ * locks on its target, from the left.
24
+ */
25
+ export type NitroNumberTransition = 'roll' | 'numeric' | 'scramble';
26
+ /**
27
+ * How a jackpot reveal plays: `'count'` is the casino win-meter rollup (the
28
+ * figure counts up from 0, digits swapping in place); `'spin'` is the jackpot
29
+ * reels (every digit spins like a slot reel, then the reels lock one at a
30
+ * time from the left).
31
+ */
32
+ export type NitroNumberRevealStyle = 'count' | 'spin';
33
+ /**
34
+ * How a prefix/suffix drawn at a different size lines up with the digits:
35
+ * `top` pins glyph tops (cap height), `bottom` pins the bottom of the line
36
+ * boxes, `baseline` shares the digits' baseline, `center` centres the boxes.
37
+ */
38
+ export type NitroNumberAffixAlign = 'baseline' | 'center' | 'top' | 'bottom';
39
+ export interface NitroNumberProps extends HybridViewProps {
40
+ /**
41
+ * The number to display.
42
+ *
43
+ * When this prop changes, every digit rolls natively from its old glyph to
44
+ * its new glyph (in the direction of the change), using `duration` and
45
+ * `easing`. The very first value is displayed without an animation.
46
+ *
47
+ * Reading it on the hybrid ref returns the value the view is currently
48
+ * showing or rolling towards (also after `jumpTo` / `animateTo`).
49
+ *
50
+ * At most 18 digits are shown: `|value| × 10^fractionDigits` is clamped at
51
+ * 10^17 (the same limit for a jump and a roll), and a JS number carries exact
52
+ * integers only up to 2^53.
53
+ */
54
+ value: number;
55
+ /** Digits shown after the decimal separator. Default: `0`. */
56
+ fractionDigits?: number;
57
+ /** Zero-pads the integer part to at least this many digits. Default: `1`. */
58
+ minimumIntegerDigits?: number;
59
+ /** Inserted between every three integer digits. Empty string disables grouping. Default: `''`. */
60
+ groupingSeparator?: string;
61
+ /** Placed between the integer and fraction digits. Default: `'.'`. */
62
+ decimalSeparator?: string;
63
+ /** Static text drawn before the number (e.g. `'$'`). Default: `''`. */
64
+ prefix?: string;
65
+ /** Static text drawn after the number (e.g. `'%'`). Default: `''`. */
66
+ suffix?: string;
67
+ /**
68
+ * Duration in milliseconds of the native roll that plays when `value` changes.
69
+ * `0` snaps to the new value immediately. Default: `500`.
70
+ */
71
+ duration?: number;
72
+ /** Timing curve of the native roll. Default: `'easeInOut'`. */
73
+ easing?: NitroNumberEasing;
74
+ /** Overshoot of the `'spring'` easing, from `0` (none) to `1`. Default: `0.15`. */
75
+ bounce?: number;
76
+ /**
77
+ * Delay in ms between the start of each digit's roll, from the least
78
+ * significant digit upwards (a cascading carry). Default: `0`.
79
+ */
80
+ stagger?: number;
81
+ /**
82
+ * How a value change plays: the odometer roll, or the numeric transition
83
+ * (glyphs swap in place). Default: `'roll'`.
84
+ */
85
+ transition?: NitroNumberTransition;
86
+ /**
87
+ * The change flash: every digit whose glyph changes lights up in this
88
+ * colour when the value grew, fading back over `flashDuration`. A processed
89
+ * ARGB integer; `Infinity` (the wrapper's "unset") turns the flash off.
90
+ */
91
+ flashUpColor?: number;
92
+ /** The change flash's colour when the value shrank. `Infinity` = off. */
93
+ flashDownColor?: number;
94
+ /** Milliseconds a change flash takes to fade. Default: `600`. */
95
+ flashDuration?: number;
96
+ /**
97
+ * A punch of the whole figure on every value change, its peak overshoot
98
+ * as a fraction of the size, `0` (none, the default) to `1`; rung out like
99
+ * the reveal's landing pop.
100
+ */
101
+ popOnChange?: number;
102
+ /**
103
+ * Which way the digits roll. Default: `'auto'`.
104
+ *
105
+ * Named `rollDirection` and not `direction` because a Hybrid View's props
106
+ * derive from `react::ViewProps`, so React Native parses every name we
107
+ * declare as well: `direction` is Yoga's layout property, and it logged
108
+ * `Could not parse yoga::Direction: up` on every update. The public prop the
109
+ * wrapper exposes is still `direction`; see `NitroNumber.tsx`.
110
+ */
111
+ rollDirection?: NitroNumberDirection;
112
+ /**
113
+ * Jackpot reveal state. `0` (default): a normal NitroNumber, `value`
114
+ * changes roll. `1`: the view shows the opening frame of `value`, its layout
115
+ * with every digit blank except the mandatory ones ("$0.00"). `2`: the
116
+ * figure plays its `revealStyle` (counts up from 0, or spins its reels) to
117
+ * `value` and lands with a pop. The JS wrapper maps its `reveal` boolean to
118
+ * this; it is a number so the wrapper can always pass it (an optional prop
119
+ * that is removed reaches native as `null`, which Nitro's parser rejects).
120
+ */
121
+ revealState?: number;
122
+ /** How the reveal plays. Default: `'count'`. */
123
+ revealStyle?: NitroNumberRevealStyle;
124
+ /** Duration of the reveal in ms (the count, or the time until the last reel locks). Default: `2200`. */
125
+ revealDuration?: number;
126
+ /** Peak overshoot of the reveal's landing pop, `0` (none) to `1`. Default: `0.12`. */
127
+ revealBounce?: number;
128
+ /**
129
+ * `'count'` style: how much smaller the figure opens, as a fraction of its
130
+ * size, growing to full size over the count (a big win's meter is enlarged
131
+ * as it climbs). `0` = no growth. Default: `0.2`.
132
+ */
133
+ revealGrow?: number;
134
+ /**
135
+ * `'spin'` style: delay in ms between one reel locking and the next, from
136
+ * the left. Shortened automatically when the reels wouldn't fit `revealDuration`. Default: `200`.
137
+ */
138
+ revealStagger?: number;
139
+ /**
140
+ * `'count'` style: win tiers, in the figure's units. When the count reaches
141
+ * one the figure punches, pauses on it for `revealMilestoneHold` and
142
+ * `onRevealMilestone` fires. Values at or above `value` are ignored.
143
+ */
144
+ revealMilestones?: number[];
145
+ /** `'count'` style: ms the count pauses on each milestone. Default: `0`. */
146
+ revealMilestoneHold?: number;
147
+ /**
148
+ * Shows a "shine" glint over the number: the ink keeps its color while a
149
+ * slanted, text-wide band of `shimmerColor` sweeps through the glyphs.
150
+ * Toggling fades the glint in/out. Default: `false`.
151
+ */
152
+ loading?: boolean;
153
+ /**
154
+ * Color of the glint's core as a processed ARGB integer. Defaults to a light
155
+ * neutral (`#D6D9E1`, or `#2B2E37` in dark mode).
156
+ */
157
+ shimmerColor?: number;
158
+ /** Duration of one sweep in ms (linear, repeating). Default: `950`. */
159
+ shimmerDuration?: number;
160
+ /** Font size of the digits in points. Default: `32`. */
161
+ fontSize?: number;
162
+ /** Font size of `prefix` in points. Defaults to `fontSize`. */
163
+ prefixFontSize?: number;
164
+ /** Font size of `suffix` in points. Defaults to `fontSize`. */
165
+ suffixFontSize?: number;
166
+ /** Vertical alignment of prefix and suffix relative to the digits. Default: `'baseline'`. */
167
+ affixAlign?: NitroNumberAffixAlign;
168
+ /** Vertical alignment of `prefix` only. Defaults to `affixAlign`. */
169
+ prefixAlign?: NitroNumberAffixAlign;
170
+ /** Vertical alignment of `suffix` only. Defaults to `affixAlign`. */
171
+ suffixAlign?: NitroNumberAffixAlign;
172
+ /**
173
+ * When the view is narrower than the number (e.g. it has a fixed `width` or
174
+ * `maxWidth`), scale the whole number down so it fits. Default: `false`.
175
+ */
176
+ adjustsFontSizeToFit?: boolean;
177
+ /** Smallest scale `adjustsFontSizeToFit` may apply, `0`–`1`. Default: `0.5`. */
178
+ minimumFontScale?: number;
179
+ /**
180
+ * Scale the fonts with the user's system text size (Dynamic Type / Android
181
+ * font scale), like `Text`. Off by default so amounts keep their design size.
182
+ */
183
+ allowFontScaling?: boolean;
184
+ /** Upper bound for `allowFontScaling`, e.g. `1.3`. `0` means no cap. Default: `0`. */
185
+ maxFontSizeMultiplier?: number;
186
+ /** Numeric font weight, `100`–`900`. Default: `400`. */
187
+ fontWeight?: number;
188
+ /** Font family name. Defaults to the system font. */
189
+ fontFamily?: string;
190
+ /** Text color as a processed ARGB integer (from `processColor`). Defaults to the platform label color. */
191
+ color?: number;
192
+ /** Where the number sits inside the view when the view is wider than the number. Default: `'auto'`, the start edge. */
193
+ textAlign?: NitroNumberTextAlign;
194
+ /**
195
+ * Lay the figure out right-to-left: `'auto'` alignment resolves to the right
196
+ * edge, the prefix moves to the right and the suffix to the left, and the
197
+ * digits still read left to right. Fabric does not hand a Hybrid View its
198
+ * layout direction, so the JS side resolves it - from the view's
199
+ * `style.direction`, else `I18nManager.isRTL` - the way React Native
200
+ * resolves its own views. Default: `false`.
201
+ */
202
+ rightToLeft?: boolean;
203
+ /**
204
+ * Called whenever the settled (target) intrinsic size of the number changes,
205
+ * e.g. after the first layout, when a digit column appears/disappears, or
206
+ * when the font changes. `NitroNumber` uses this to size itself.
207
+ */
208
+ onSizeChange?: (width: number, height: number) => void;
209
+ /**
210
+ * Called when a reveal has landed: the count reached `value` and the landing
211
+ * pop has rung out. Sequence whatever follows the figure (a haptic, the next
212
+ * block of copy) from here.
213
+ */
214
+ onRevealEnd?: () => void;
215
+ /**
216
+ * Called when a count-style reveal reaches a milestone, with its index in
217
+ * the sorted usable milestones and its value: the moment to swap the win
218
+ * banner, fire the confetti and play the sting.
219
+ */
220
+ onRevealMilestone?: (index: number, value: number) => void;
221
+ }
222
+ export interface NitroNumberMethods extends HybridViewMethods {
223
+ /**
224
+ * Displays `value` immediately, positioning the digit columns continuously
225
+ * (odometer style: `12.5` shows the last digit half way between `2` and `3`).
226
+ * No animation is started and any running roll is cancelled. Useful for
227
+ * scrubbing (scroll / drag handlers). Safe to call from any thread.
228
+ */
229
+ jumpTo(value: number): void;
230
+ /** Rolls to `value` natively, exactly like changing the `value` prop. Safe to call from any thread. */
231
+ animateTo(value: number): void;
232
+ /**
233
+ * Plays a jackpot reveal to `value` in the current `revealStyle` (see the
234
+ * `reveal` prop) regardless of the prop's state. Safe to call from any thread.
235
+ */
236
+ revealTo(value: number): void;
237
+ }
238
+ export type NitroNumberView = HybridView<NitroNumberProps, NitroNumberMethods>;
@@ -0,0 +1,3 @@
1
+ import { type ColorValue, type TextStyle } from 'react-native';
2
+ export declare function toNumericWeight(weight: TextStyle['fontWeight']): number | undefined;
3
+ export declare function toProcessedColor(color: ColorValue | undefined): number | undefined;
package/nitro.json CHANGED
@@ -28,6 +28,16 @@
28
28
  "language": "c++",
29
29
  "implementationClassName": "HybridNitroInputWorklets"
30
30
  }
31
+ },
32
+ "NitroNumberView": {
33
+ "ios": {
34
+ "language": "swift",
35
+ "implementationClassName": "HybridNitroNumberView"
36
+ },
37
+ "android": {
38
+ "language": "kotlin",
39
+ "implementationClassName": "HybridNitroNumberView"
40
+ }
31
41
  }
32
42
  },
33
43
  "ignorePaths": [
@@ -36,9 +36,13 @@ target_sources(
36
36
  ../nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp
37
37
  ../nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp
38
38
  ../nitrogen/generated/shared/c++/HybridNitroInputWorkletsSpec.cpp
39
+ ../nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp
40
+ ../nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp
39
41
  # Android-specific Nitrogen C++ sources
40
42
  ../nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp
41
43
  ../nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp
44
+ ../nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp
45
+ ../nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp
42
46
  )
43
47
 
44
48
  # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
@@ -23,6 +23,9 @@
23
23
  #include "JFunc_void_std__string.hpp"
24
24
  #include "JFunc_void_double_double.hpp"
25
25
  #include "views/JHybridNitroInputViewStateUpdater.hpp"
26
+ #include "JHybridNitroNumberViewSpec.hpp"
27
+ #include "JFunc_void.hpp"
28
+ #include "views/JHybridNitroNumberViewStateUpdater.hpp"
26
29
  #include <NitroModules/DefaultConstructableObject.hpp>
27
30
  #include "HybridNitroInputWorklets.hpp"
28
31
 
@@ -42,6 +45,14 @@ struct JHybridNitroInputViewSpecImpl: public jni::JavaClass<JHybridNitroInputVie
42
45
  return javaPart->getJHybridNitroInputViewSpec();
43
46
  }
44
47
  };
48
+ struct JHybridNitroNumberViewSpecImpl: public jni::JavaClass<JHybridNitroNumberViewSpecImpl, JHybridNitroNumberViewSpec::JavaPart> {
49
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/HybridNitroNumberView;";
50
+ static std::shared_ptr<JHybridNitroNumberViewSpec> create() {
51
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroNumberViewSpecImpl::javaobject()>();
52
+ jni::local_ref<JHybridNitroNumberViewSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
53
+ return javaPart->getJHybridNitroNumberViewSpec();
54
+ }
55
+ };
45
56
 
46
57
  void registerAllNatives() {
47
58
  using namespace margelo::nitro;
@@ -56,6 +67,9 @@ void registerAllNatives() {
56
67
  margelo::nitro::nitroinput::JFunc_void_std__string_cxx::registerNatives();
57
68
  margelo::nitro::nitroinput::JFunc_void_double_double_cxx::registerNatives();
58
69
  margelo::nitro::nitroinput::views::JHybridNitroInputViewStateUpdater::registerNatives();
70
+ margelo::nitro::nitroinput::JHybridNitroNumberViewSpec::CxxPart::registerNatives();
71
+ margelo::nitro::nitroinput::JFunc_void_cxx::registerNatives();
72
+ margelo::nitro::nitroinput::views::JHybridNitroNumberViewStateUpdater::registerNatives();
59
73
 
60
74
  // Register Nitro Hybrid Objects
61
75
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -73,6 +87,12 @@ void registerAllNatives() {
73
87
  return std::make_shared<HybridNitroInputWorklets>();
74
88
  }
75
89
  );
90
+ HybridObjectRegistry::registerHybridObjectConstructor(
91
+ "NitroNumberView",
92
+ []() -> std::shared_ptr<HybridObject> {
93
+ return JHybridNitroNumberViewSpecImpl::create();
94
+ }
95
+ );
76
96
  }
77
97
 
78
98
  } // namespace margelo::nitro::nitroinput
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::nitroinput {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `() -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void: public jni::JavaClass<JFunc_void> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/Func_void;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void` instance holds through JNI.
31
+ */
32
+ void invoke() const {
33
+ static const auto method = javaClassStatic()->getMethod<void()>("invoke");
34
+ method(self());
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
42
+ public:
43
+ static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
44
+ return JFunc_void_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
50
+ */
51
+ void invoke_cxx() {
52
+ _func();
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void()>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/Func_void_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void()> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::nitroinput
@@ -18,7 +18,7 @@ namespace margelo::nitro::nitroinput {
18
18
  using namespace facebook;
19
19
 
20
20
  /**
21
- * Represents the Java/Kotlin callback `(start: Double, end: Double) -> Unit`.
21
+ * Represents the Java/Kotlin callback `(width: Double, height: Double) -> Unit`.
22
22
  * This can be passed around between C++ and Java/Kotlin.
23
23
  */
24
24
  struct JFunc_void_double_double: public jni::JavaClass<JFunc_void_double_double> {
@@ -29,9 +29,9 @@ namespace margelo::nitro::nitroinput {
29
29
  /**
30
30
  * Invokes the function this `JFunc_void_double_double` instance holds through JNI.
31
31
  */
32
- void invoke(double start, double end) const {
33
- static const auto method = javaClassStatic()->getMethod<void(double /* start */, double /* end */)>("invoke");
34
- method(self(), start, end);
32
+ void invoke(double width, double height) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* width */, double /* height */)>("invoke");
34
+ method(self(), width, height);
35
35
  }
36
36
  };
37
37
 
@@ -40,7 +40,7 @@ namespace margelo::nitro::nitroinput {
40
40
  */
41
41
  class JFunc_void_double_double_cxx final: public jni::HybridClass<JFunc_void_double_double_cxx, JFunc_void_double_double> {
42
42
  public:
43
- static jni::local_ref<JFunc_void_double_double::javaobject> fromCpp(const std::function<void(double /* start */, double /* end */)>& func) {
43
+ static jni::local_ref<JFunc_void_double_double::javaobject> fromCpp(const std::function<void(double /* width */, double /* height */)>& func) {
44
44
  return JFunc_void_double_double_cxx::newObjectCxxArgs(func);
45
45
  }
46
46
 
@@ -48,13 +48,13 @@ namespace margelo::nitro::nitroinput {
48
48
  /**
49
49
  * Invokes the C++ `std::function<...>` this `JFunc_void_double_double_cxx` instance holds.
50
50
  */
51
- void invoke_cxx(double start, double end) {
52
- _func(start, end);
51
+ void invoke_cxx(double width, double height) {
52
+ _func(width, height);
53
53
  }
54
54
 
55
55
  public:
56
56
  [[nodiscard]]
57
- inline const std::function<void(double /* start */, double /* end */)>& getFunction() const {
57
+ inline const std::function<void(double /* width */, double /* height */)>& getFunction() const {
58
58
  return _func;
59
59
  }
60
60
 
@@ -65,11 +65,11 @@ namespace margelo::nitro::nitroinput {
65
65
  }
66
66
 
67
67
  private:
68
- explicit JFunc_void_double_double_cxx(const std::function<void(double /* start */, double /* end */)>& func): _func(func) { }
68
+ explicit JFunc_void_double_double_cxx(const std::function<void(double /* width */, double /* height */)>& func): _func(func) { }
69
69
 
70
70
  private:
71
71
  friend HybridBase;
72
- std::function<void(double /* start */, double /* end */)> _func;
72
+ std::function<void(double /* width */, double /* height */)> _func;
73
73
  };
74
74
 
75
75
  } // namespace margelo::nitro::nitroinput