react-native-nitro-input 0.1.0 → 0.3.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.
- package/CHANGELOG.md +343 -3
- package/NitroInput.podspec +4 -4
- package/README.md +420 -53
- package/android/CMakeLists.txt +9 -3
- package/android/gradle.properties +1 -1
- package/android/src/main/cpp/JOutlineGeometry.hpp +1 -1
- package/android/src/main/cpp/JReflowEngine.cpp +132 -0
- package/android/src/main/cpp/{JMorphEngine.hpp → JReflowEngine.hpp} +7 -7
- package/android/src/main/cpp/JRollingEngine.cpp +223 -0
- package/android/src/main/cpp/JRollingEngine.hpp +68 -0
- package/android/src/main/cpp/cpp-adapter.cpp +4 -2
- package/android/src/main/java/com/margelo/nitro/nitroinput/AmountFormatter.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +21 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +209 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +496 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputPackage.kt +2 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +107 -26
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +1881 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/{MorphEngine.kt → ReflowEngine.kt} +2 -2
- package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +60 -0
- package/cpp/AmountFormatter.cpp +5 -0
- package/cpp/AmountFormatter.hpp +10 -2
- package/cpp/{MorphEngine.cpp → ReflowEngine.cpp} +52 -47
- package/cpp/{MorphEngine.hpp → ReflowEngine.hpp} +12 -4
- package/cpp/RollingEngine.cpp +1234 -0
- package/cpp/RollingEngine.hpp +475 -0
- package/cpp/SwiftNonCopyable.hpp +22 -0
- package/cpp/numberformat/HybridNitroNumberFormat.cpp +498 -0
- package/cpp/numberformat/HybridNitroNumberFormat.hpp +74 -0
- package/cpp/numberformat/HybridNitroNumberFormatFactory.hpp +11 -0
- package/cpp/numberformat/NumberFormatCore.cpp +629 -0
- package/cpp/numberformat/NumberFormatCore.hpp +154 -0
- package/cpp/numberformat/NumberFormatProbe.cpp +354 -0
- package/cpp/numberformat/NumberFormatProbe.hpp +63 -0
- package/cpp/worklets/NitroInputWorkletsBridge.cpp +3 -3
- package/cpp/worklets/NitroInputWorkletsBridge.hpp +1 -1
- package/ios/{HybridMorphInputView.swift → HybridNitroInputView.swift} +16 -1
- package/ios/HybridNitroNumberFormatPlatform.swift +348 -0
- package/ios/HybridNitroNumberView.swift +458 -0
- package/ios/NitroInputView.swift +148 -64
- package/ios/NitroNumberView.swift +2074 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +61 -0
- package/lib/commonjs/src/NitroInput.js +27 -56
- package/lib/commonjs/src/NitroNumber.js +141 -0
- package/lib/commonjs/src/NumberFormat.js +525 -0
- package/lib/commonjs/src/formatProps.js +48 -0
- package/lib/commonjs/src/index.js +6 -3
- package/lib/commonjs/src/specs/NitroNumber.nitro.js +2 -0
- package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
- package/lib/commonjs/src/styleHelpers.js +36 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +61 -0
- package/lib/module/src/NitroInput.js +18 -47
- package/lib/module/src/NitroNumber.js +102 -0
- package/lib/module/src/NumberFormat.js +521 -0
- package/lib/module/src/formatProps.js +45 -0
- package/lib/module/src/index.js +2 -1
- package/lib/module/src/specs/NitroNumber.nitro.js +1 -0
- package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
- package/lib/module/src/styleHelpers.js +32 -0
- package/lib/typescript/src/NitroInput.d.ts +50 -21
- package/lib/typescript/src/NitroNumber.d.ts +246 -0
- package/lib/typescript/src/NumberFormat.d.ts +47 -0
- package/lib/typescript/src/formatProps.d.ts +21 -0
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +19 -9
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +250 -0
- package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
- package/lib/typescript/src/styleHelpers.d.ts +3 -0
- package/nitro.json +26 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +10 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +48 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +10 -10
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp +118 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +590 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +168 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberAffixAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberEasing.hpp +67 -0
- package/nitrogen/generated/android/c++/JNitroNumberRevealStyle.hpp +58 -0
- package/nitrogen/generated/android/c++/JNitroNumberTextAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberTransition.hpp +61 -0
- package/nitrogen/generated/android/c++/JNumberFormatCompactDisplay.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencyDisplay.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencySign.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatNotation.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformOptions.hpp +161 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformSymbols.hpp +89 -0
- package/nitrogen/generated/android/c++/JNumberFormatRoundingMode.hpp +79 -0
- package/nitrogen/generated/android/c++/JNumberFormatSignDisplay.hpp +67 -0
- package/nitrogen/generated/android/c++/JNumberFormatStyle.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatUnitDisplay.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +25 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +329 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_double_double.kt +9 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatformSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +399 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberAffixAlign.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberEasing.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberRevealStyle.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberTextAlign.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberTransition.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCompactDisplay.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencyDisplay.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencySign.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatNotation.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformOptions.kt +136 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformSymbols.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatRoundingMode.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatSignDisplay.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatStyle.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatUnitDisplay.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroNumberViewManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroNumberViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +59 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +311 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +63 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +26 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +24 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.hpp +122 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +474 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +450 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +5 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec_cxx.swift +159 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +108 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +1387 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/NitroNumberAffixAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberEasing.swift +52 -0
- package/nitrogen/generated/ios/swift/NitroNumberRevealStyle.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroNumberTextAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberTransition.swift +44 -0
- package/nitrogen/generated/ios/swift/NumberFormatCompactDisplay.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencyDisplay.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencySign.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatNotation.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformOptions.swift +159 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformSymbols.swift +69 -0
- package/nitrogen/generated/ios/swift/NumberFormatRoundingMode.swift +68 -0
- package/nitrogen/generated/ios/swift/NumberFormatSignDisplay.swift +52 -0
- package/nitrogen/generated/ios/swift/NumberFormatStyle.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatUnitDisplay.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +127 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +187 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/NitroNumberAffixAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberEasing.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroNumberRevealStyle.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroNumberTextAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberTransition.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatCompactDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencyDisplay.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencySign.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatGrouping.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatNotation.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatOptions.hpp +193 -0
- package/nitrogen/generated/shared/c++/NumberFormatPart.hpp +87 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformOptions.hpp +176 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformSymbols.hpp +115 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingMode.hpp +104 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingPriority.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatSignDisplay.hpp +88 -0
- package/nitrogen/generated/shared/c++/NumberFormatStyle.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatTrailingZeroDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatUnitDisplay.hpp +80 -0
- package/nitrogen/generated/shared/c++/ResolvedNumberFormatOptions.hpp +197 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +10 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +15 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +136 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +245 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +61 -0
- package/package.json +15 -7
- package/src/NitroInput.tsx +79 -67
- package/src/NitroNumber.tsx +531 -0
- package/src/NumberFormat.ts +563 -0
- package/src/formatProps.ts +59 -0
- package/src/index.ts +38 -6
- package/src/specs/NitroInput.nitro.ts +19 -9
- package/src/specs/NitroNumber.nitro.ts +271 -0
- package/src/specs/NumberFormat.nitro.ts +145 -0
- package/src/styleHelpers.ts +32 -0
- package/android/src/main/cpp/JMorphEngine.cpp +0 -132
- package/lib/commonjs/src/MorphInput.js +0 -42
- package/lib/module/src/MorphInput.js +0 -6
- package/lib/typescript/src/MorphInput.d.ts +0 -18
- package/src/MorphInput.tsx +0 -30
|
@@ -0,0 +1,250 @@
|
|
|
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' | 'shortest';
|
|
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
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. Default: `0`. */
|
|
173
|
+
letterSpacing?: number;
|
|
174
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
175
|
+
prefixSpacing?: number;
|
|
176
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
177
|
+
suffixSpacing?: number;
|
|
178
|
+
/** Points the prefix is moved down after its alignment (negative: up). Default: `0`. */
|
|
179
|
+
prefixOffset?: number;
|
|
180
|
+
/** Points the suffix is moved down after its alignment (negative: up). Default: `0`. */
|
|
181
|
+
suffixOffset?: number;
|
|
182
|
+
/** Every digit as wide as the widest (`true`, the default), or each digit at its own width. */
|
|
183
|
+
tabularNums?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* When the view is narrower than the number (e.g. it has a fixed `width` or
|
|
186
|
+
* `maxWidth`), scale the whole number down so it fits. Default: `false`.
|
|
187
|
+
*/
|
|
188
|
+
adjustsFontSizeToFit?: boolean;
|
|
189
|
+
/** Smallest scale `adjustsFontSizeToFit` may apply, `0`–`1`. Default: `0.5`. */
|
|
190
|
+
minimumFontScale?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Scale the fonts with the user's system text size (Dynamic Type / Android
|
|
193
|
+
* font scale), like `Text`. Off by default so amounts keep their design size.
|
|
194
|
+
*/
|
|
195
|
+
allowFontScaling?: boolean;
|
|
196
|
+
/** Upper bound for `allowFontScaling`, e.g. `1.3`. `0` means no cap. Default: `0`. */
|
|
197
|
+
maxFontSizeMultiplier?: number;
|
|
198
|
+
/** Numeric font weight, `100`–`900`. Default: `400`. */
|
|
199
|
+
fontWeight?: number;
|
|
200
|
+
/** Font family name. Defaults to the system font. */
|
|
201
|
+
fontFamily?: string;
|
|
202
|
+
/** Text color as a processed ARGB integer (from `processColor`). Defaults to the platform label color. */
|
|
203
|
+
color?: number;
|
|
204
|
+
/** Where the number sits inside the view when the view is wider than the number. Default: `'auto'`, the start edge. */
|
|
205
|
+
textAlign?: NitroNumberTextAlign;
|
|
206
|
+
/**
|
|
207
|
+
* Lay the figure out right-to-left: `'auto'` alignment resolves to the right
|
|
208
|
+
* edge, the prefix moves to the right and the suffix to the left, and the
|
|
209
|
+
* digits still read left to right. Fabric does not hand a Hybrid View its
|
|
210
|
+
* layout direction, so the JS side resolves it - from the view's
|
|
211
|
+
* `style.direction`, else `I18nManager.isRTL` - the way React Native
|
|
212
|
+
* resolves its own views. Default: `false`.
|
|
213
|
+
*/
|
|
214
|
+
rightToLeft?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Called whenever the settled (target) intrinsic size of the number changes,
|
|
217
|
+
* e.g. after the first layout, when a digit column appears/disappears, or
|
|
218
|
+
* when the font changes. `NitroNumber` uses this to size itself.
|
|
219
|
+
*/
|
|
220
|
+
onSizeChange?: (width: number, height: number) => void;
|
|
221
|
+
/**
|
|
222
|
+
* Called when a reveal has landed: the count reached `value` and the landing
|
|
223
|
+
* pop has rung out. Sequence whatever follows the figure (a haptic, the next
|
|
224
|
+
* block of copy) from here.
|
|
225
|
+
*/
|
|
226
|
+
onRevealEnd?: () => void;
|
|
227
|
+
/**
|
|
228
|
+
* Called when a count-style reveal reaches a milestone, with its index in
|
|
229
|
+
* the sorted usable milestones and its value: the moment to swap the win
|
|
230
|
+
* banner, fire the confetti and play the sting.
|
|
231
|
+
*/
|
|
232
|
+
onRevealMilestone?: (index: number, value: number) => void;
|
|
233
|
+
}
|
|
234
|
+
export interface NitroNumberMethods extends HybridViewMethods {
|
|
235
|
+
/**
|
|
236
|
+
* Displays `value` immediately, positioning the digit columns continuously
|
|
237
|
+
* (odometer style: `12.5` shows the last digit half way between `2` and `3`).
|
|
238
|
+
* No animation is started and any running roll is cancelled. Useful for
|
|
239
|
+
* scrubbing (scroll / drag handlers). Safe to call from any thread.
|
|
240
|
+
*/
|
|
241
|
+
jumpTo(value: number): void;
|
|
242
|
+
/** Rolls to `value` natively, exactly like changing the `value` prop. Safe to call from any thread. */
|
|
243
|
+
animateTo(value: number): void;
|
|
244
|
+
/**
|
|
245
|
+
* Plays a jackpot reveal to `value` in the current `revealStyle` (see the
|
|
246
|
+
* `reveal` prop) regardless of the prop's state. Safe to call from any thread.
|
|
247
|
+
*/
|
|
248
|
+
revealTo(value: number): void;
|
|
249
|
+
}
|
|
250
|
+
export type NitroNumberView = HybridView<NitroNumberProps, NitroNumberMethods>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { HybridObject, Int64 } from 'react-native-nitro-modules';
|
|
2
|
+
export type NumberFormatStyle = 'decimal' | 'currency' | 'percent' | 'unit';
|
|
3
|
+
export type NumberFormatCurrencyDisplay = 'symbol' | 'narrowSymbol' | 'code' | 'name';
|
|
4
|
+
export type NumberFormatCurrencySign = 'standard' | 'accounting';
|
|
5
|
+
export type NumberFormatUnitDisplay = 'short' | 'narrow' | 'long';
|
|
6
|
+
export type NumberFormatNotation = 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
7
|
+
export type NumberFormatCompactDisplay = 'short' | 'long';
|
|
8
|
+
export type NumberFormatSignDisplay = 'auto' | 'never' | 'always' | 'exceptZero' | 'negative';
|
|
9
|
+
export type NumberFormatRoundingMode = 'ceil' | 'floor' | 'expand' | 'trunc' | 'halfCeil' | 'halfFloor' | 'halfExpand' | 'halfTrunc' | 'halfEven';
|
|
10
|
+
export type NumberFormatRoundingPriority = 'auto' | 'morePrecision' | 'lessPrecision';
|
|
11
|
+
export type NumberFormatTrailingZeroDisplay = 'auto' | 'stripIfInteger';
|
|
12
|
+
export type NumberFormatGrouping = 'always' | 'auto' | 'min2';
|
|
13
|
+
/** `Intl.NumberFormatOptions`, less `localeMatcher` (the lookup matcher is always used). */
|
|
14
|
+
export interface NumberFormatOptions {
|
|
15
|
+
numberingSystem?: string;
|
|
16
|
+
style?: NumberFormatStyle;
|
|
17
|
+
currency?: string;
|
|
18
|
+
currencyDisplay?: NumberFormatCurrencyDisplay;
|
|
19
|
+
currencySign?: NumberFormatCurrencySign;
|
|
20
|
+
unit?: string;
|
|
21
|
+
unitDisplay?: NumberFormatUnitDisplay;
|
|
22
|
+
minimumIntegerDigits?: number;
|
|
23
|
+
minimumFractionDigits?: number;
|
|
24
|
+
maximumFractionDigits?: number;
|
|
25
|
+
minimumSignificantDigits?: number;
|
|
26
|
+
maximumSignificantDigits?: number;
|
|
27
|
+
roundingPriority?: NumberFormatRoundingPriority;
|
|
28
|
+
roundingIncrement?: number;
|
|
29
|
+
roundingMode?: NumberFormatRoundingMode;
|
|
30
|
+
trailingZeroDisplay?: NumberFormatTrailingZeroDisplay;
|
|
31
|
+
notation?: NumberFormatNotation;
|
|
32
|
+
compactDisplay?: NumberFormatCompactDisplay;
|
|
33
|
+
useGrouping?: boolean | NumberFormatGrouping;
|
|
34
|
+
signDisplay?: NumberFormatSignDisplay;
|
|
35
|
+
}
|
|
36
|
+
/** `Intl.ResolvedNumberFormatOptions`. */
|
|
37
|
+
export interface ResolvedNumberFormatOptions {
|
|
38
|
+
locale: string;
|
|
39
|
+
numberingSystem: string;
|
|
40
|
+
style: NumberFormatStyle;
|
|
41
|
+
currency?: string;
|
|
42
|
+
currencyDisplay?: NumberFormatCurrencyDisplay;
|
|
43
|
+
currencySign?: NumberFormatCurrencySign;
|
|
44
|
+
unit?: string;
|
|
45
|
+
unitDisplay?: NumberFormatUnitDisplay;
|
|
46
|
+
minimumIntegerDigits: number;
|
|
47
|
+
minimumFractionDigits?: number;
|
|
48
|
+
maximumFractionDigits?: number;
|
|
49
|
+
minimumSignificantDigits?: number;
|
|
50
|
+
maximumSignificantDigits?: number;
|
|
51
|
+
useGrouping: boolean | NumberFormatGrouping;
|
|
52
|
+
notation: NumberFormatNotation;
|
|
53
|
+
compactDisplay?: NumberFormatCompactDisplay;
|
|
54
|
+
signDisplay: NumberFormatSignDisplay;
|
|
55
|
+
roundingIncrement: number;
|
|
56
|
+
roundingMode: NumberFormatRoundingMode;
|
|
57
|
+
roundingPriority: NumberFormatRoundingPriority;
|
|
58
|
+
trailingZeroDisplay: NumberFormatTrailingZeroDisplay;
|
|
59
|
+
}
|
|
60
|
+
/** One piece of a formatted number, as `Intl.NumberFormat#formatToParts` reports it. */
|
|
61
|
+
export interface NumberFormatPart {
|
|
62
|
+
type: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A number formatter with the API of `Intl.NumberFormat`. It learns a
|
|
67
|
+
* locale's format once from the platform (Foundation on iOS, ICU on Android)
|
|
68
|
+
* and formats in C++ from then on, without calling into the platform per
|
|
69
|
+
* number. Instances are immutable and shared: the same locales and options
|
|
70
|
+
* return the same object.
|
|
71
|
+
*/
|
|
72
|
+
export interface NitroNumberFormat extends HybridObject<{
|
|
73
|
+
ios: 'c++';
|
|
74
|
+
android: 'c++';
|
|
75
|
+
}> {
|
|
76
|
+
format(value: number | Int64 | string): string;
|
|
77
|
+
formatToParts(value: number | Int64 | string): NumberFormatPart[];
|
|
78
|
+
resolvedOptions(): ResolvedNumberFormatOptions;
|
|
79
|
+
}
|
|
80
|
+
export interface NitroNumberFormatFactory extends HybridObject<{
|
|
81
|
+
ios: 'c++';
|
|
82
|
+
android: 'c++';
|
|
83
|
+
}> {
|
|
84
|
+
create(locales: string[], options: NumberFormatOptions): NitroNumberFormat;
|
|
85
|
+
supportedLocalesOf(locales: string[]): string[];
|
|
86
|
+
}
|
|
87
|
+
export interface NumberFormatPlatformOptions {
|
|
88
|
+
locales: string[];
|
|
89
|
+
numberingSystem?: string;
|
|
90
|
+
style: NumberFormatStyle;
|
|
91
|
+
currency?: string;
|
|
92
|
+
currencyDisplay: NumberFormatCurrencyDisplay;
|
|
93
|
+
currencySign: NumberFormatCurrencySign;
|
|
94
|
+
unit?: string;
|
|
95
|
+
unitDisplay: NumberFormatUnitDisplay;
|
|
96
|
+
notation: NumberFormatNotation;
|
|
97
|
+
compactDisplay: NumberFormatCompactDisplay;
|
|
98
|
+
useGrouping: boolean;
|
|
99
|
+
minimumIntegerDigits: number;
|
|
100
|
+
minimumFractionDigits: number;
|
|
101
|
+
maximumFractionDigits: number;
|
|
102
|
+
/** 0 when significant digits are not used. */
|
|
103
|
+
minimumSignificantDigits: number;
|
|
104
|
+
maximumSignificantDigits: number;
|
|
105
|
+
roundingMode: NumberFormatRoundingMode;
|
|
106
|
+
signDisplay: NumberFormatSignDisplay;
|
|
107
|
+
}
|
|
108
|
+
export interface NumberFormatPlatformSymbols {
|
|
109
|
+
/** The locale the platform resolved the request to, as a BCP 47 tag. */
|
|
110
|
+
locale: string;
|
|
111
|
+
numberingSystem: string;
|
|
112
|
+
minusSign: string;
|
|
113
|
+
plusSign: string;
|
|
114
|
+
percentSign: string;
|
|
115
|
+
/** The currency as this formatter shows it (symbol, narrow symbol or code). */
|
|
116
|
+
currency: string;
|
|
117
|
+
/** The locale's symbol for NaN. */
|
|
118
|
+
nan: string;
|
|
119
|
+
/** The locale's symbol for infinity, without a sign. */
|
|
120
|
+
infinity: string;
|
|
121
|
+
/** The "E" of scientific notation. */
|
|
122
|
+
exponentSeparator: string;
|
|
123
|
+
}
|
|
124
|
+
export interface NitroPlatformNumberFormatter extends HybridObject<{
|
|
125
|
+
ios: 'swift';
|
|
126
|
+
android: 'kotlin';
|
|
127
|
+
}> {
|
|
128
|
+
readonly symbols: NumberFormatPlatformSymbols;
|
|
129
|
+
format(value: number): string;
|
|
130
|
+
/** A decimal string, formatted without going through a double. */
|
|
131
|
+
formatDecimal(value: string): string;
|
|
132
|
+
}
|
|
133
|
+
export interface NitroNumberFormatPlatform extends HybridObject<{
|
|
134
|
+
ios: 'swift';
|
|
135
|
+
android: 'kotlin';
|
|
136
|
+
}> {
|
|
137
|
+
create(options: NumberFormatPlatformOptions): NitroPlatformNumberFormatter;
|
|
138
|
+
supportedLocalesOf(locales: string[]): string[];
|
|
139
|
+
}
|
package/nitro.json
CHANGED
|
@@ -28,6 +28,32 @@
|
|
|
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
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"NitroNumberFormatFactory": {
|
|
43
|
+
"all": {
|
|
44
|
+
"language": "c++",
|
|
45
|
+
"implementationClassName": "HybridNitroNumberFormatFactory"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"NitroNumberFormatPlatform": {
|
|
49
|
+
"ios": {
|
|
50
|
+
"language": "swift",
|
|
51
|
+
"implementationClassName": "HybridNitroNumberFormatPlatform"
|
|
52
|
+
},
|
|
53
|
+
"android": {
|
|
54
|
+
"language": "kotlin",
|
|
55
|
+
"implementationClassName": "HybridNitroNumberFormatPlatform"
|
|
56
|
+
}
|
|
31
57
|
}
|
|
32
58
|
},
|
|
33
59
|
"ignorePaths": [
|
|
@@ -36,9 +36,19 @@ 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
|
|
41
|
+
../nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp
|
|
42
|
+
../nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp
|
|
43
|
+
../nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp
|
|
44
|
+
../nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp
|
|
39
45
|
# Android-specific Nitrogen C++ sources
|
|
40
46
|
../nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp
|
|
41
47
|
../nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp
|
|
48
|
+
../nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp
|
|
49
|
+
../nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp
|
|
50
|
+
../nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp
|
|
51
|
+
../nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp
|
|
42
52
|
)
|
|
43
53
|
|
|
44
54
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -23,8 +23,14 @@
|
|
|
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"
|
|
29
|
+
#include "JHybridNitroPlatformNumberFormatterSpec.hpp"
|
|
30
|
+
#include "JHybridNitroNumberFormatPlatformSpec.hpp"
|
|
26
31
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
27
32
|
#include "HybridNitroInputWorklets.hpp"
|
|
33
|
+
#include "HybridNitroNumberFormatFactory.hpp"
|
|
28
34
|
|
|
29
35
|
namespace margelo::nitro::nitroinput {
|
|
30
36
|
|
|
@@ -42,6 +48,22 @@ struct JHybridNitroInputViewSpecImpl: public jni::JavaClass<JHybridNitroInputVie
|
|
|
42
48
|
return javaPart->getJHybridNitroInputViewSpec();
|
|
43
49
|
}
|
|
44
50
|
};
|
|
51
|
+
struct JHybridNitroNumberViewSpecImpl: public jni::JavaClass<JHybridNitroNumberViewSpecImpl, JHybridNitroNumberViewSpec::JavaPart> {
|
|
52
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/HybridNitroNumberView;";
|
|
53
|
+
static std::shared_ptr<JHybridNitroNumberViewSpec> create() {
|
|
54
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroNumberViewSpecImpl::javaobject()>();
|
|
55
|
+
jni::local_ref<JHybridNitroNumberViewSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
56
|
+
return javaPart->getJHybridNitroNumberViewSpec();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
struct JHybridNitroNumberFormatPlatformSpecImpl: public jni::JavaClass<JHybridNitroNumberFormatPlatformSpecImpl, JHybridNitroNumberFormatPlatformSpec::JavaPart> {
|
|
60
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform;";
|
|
61
|
+
static std::shared_ptr<JHybridNitroNumberFormatPlatformSpec> create() {
|
|
62
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroNumberFormatPlatformSpecImpl::javaobject()>();
|
|
63
|
+
jni::local_ref<JHybridNitroNumberFormatPlatformSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
64
|
+
return javaPart->getJHybridNitroNumberFormatPlatformSpec();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
45
67
|
|
|
46
68
|
void registerAllNatives() {
|
|
47
69
|
using namespace margelo::nitro;
|
|
@@ -56,6 +78,11 @@ void registerAllNatives() {
|
|
|
56
78
|
margelo::nitro::nitroinput::JFunc_void_std__string_cxx::registerNatives();
|
|
57
79
|
margelo::nitro::nitroinput::JFunc_void_double_double_cxx::registerNatives();
|
|
58
80
|
margelo::nitro::nitroinput::views::JHybridNitroInputViewStateUpdater::registerNatives();
|
|
81
|
+
margelo::nitro::nitroinput::JHybridNitroNumberViewSpec::CxxPart::registerNatives();
|
|
82
|
+
margelo::nitro::nitroinput::JFunc_void_cxx::registerNatives();
|
|
83
|
+
margelo::nitro::nitroinput::views::JHybridNitroNumberViewStateUpdater::registerNatives();
|
|
84
|
+
margelo::nitro::nitroinput::JHybridNitroPlatformNumberFormatterSpec::CxxPart::registerNatives();
|
|
85
|
+
margelo::nitro::nitroinput::JHybridNitroNumberFormatPlatformSpec::CxxPart::registerNatives();
|
|
59
86
|
|
|
60
87
|
// Register Nitro Hybrid Objects
|
|
61
88
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -73,6 +100,27 @@ void registerAllNatives() {
|
|
|
73
100
|
return std::make_shared<HybridNitroInputWorklets>();
|
|
74
101
|
}
|
|
75
102
|
);
|
|
103
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
104
|
+
"NitroNumberView",
|
|
105
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
106
|
+
return JHybridNitroNumberViewSpecImpl::create();
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
110
|
+
"NitroNumberFormatFactory",
|
|
111
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
112
|
+
static_assert(std::is_default_constructible_v<HybridNitroNumberFormatFactory>,
|
|
113
|
+
"The HybridObject \"HybridNitroNumberFormatFactory\" is not default-constructible! "
|
|
114
|
+
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
115
|
+
return std::make_shared<HybridNitroNumberFormatFactory>();
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
119
|
+
"NitroNumberFormatPlatform",
|
|
120
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
121
|
+
return JHybridNitroNumberFormatPlatformSpecImpl::create();
|
|
122
|
+
}
|
|
123
|
+
);
|
|
76
124
|
}
|
|
77
125
|
|
|
78
126
|
} // 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 `(
|
|
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
|
|
33
|
-
static const auto method = javaClassStatic()->getMethod<void(double /*
|
|
34
|
-
method(self(),
|
|
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 /*
|
|
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
|
|
52
|
-
_func(
|
|
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 /*
|
|
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 /*
|
|
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 /*
|
|
72
|
+
std::function<void(double /* width */, double /* height */)> _func;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
} // namespace margelo::nitro::nitroinput
|