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.
- package/CHANGELOG.md +305 -3
- package/NitroInput.podspec +4 -4
- package/README.md +378 -53
- package/android/CMakeLists.txt +5 -3
- 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 +222 -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 +1 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +471 -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 +38 -16
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +1741 -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 +59 -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 +1224 -0
- package/cpp/RollingEngine.hpp +468 -0
- package/cpp/SwiftNonCopyable.hpp +22 -0
- package/cpp/worklets/NitroInputWorkletsBridge.cpp +3 -3
- package/cpp/worklets/NitroInputWorkletsBridge.hpp +1 -1
- package/ios/{HybridMorphInputView.swift → HybridNitroInputView.swift} +1 -1
- package/ios/HybridNitroNumberView.swift +439 -0
- package/ios/NitroInputView.swift +69 -45
- package/ios/NitroNumberView.swift +1934 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
- package/lib/commonjs/src/NitroInput.js +21 -52
- package/lib/commonjs/src/NitroNumber.js +139 -0
- package/lib/commonjs/src/index.js +4 -3
- package/lib/commonjs/src/specs/NitroNumber.nitro.js +2 -0
- package/lib/commonjs/src/styleHelpers.js +36 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
- package/lib/module/src/NitroInput.js +12 -43
- package/lib/module/src/NitroNumber.js +100 -0
- package/lib/module/src/index.js +1 -1
- package/lib/module/src/specs/NitroNumber.nitro.js +1 -0
- package/lib/module/src/styleHelpers.js +32 -0
- package/lib/typescript/src/NitroInput.d.ts +28 -21
- package/lib/typescript/src/NitroNumber.d.ts +211 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +9 -9
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +238 -0
- package/lib/typescript/src/styleHelpers.d.ts +3 -0
- package/nitro.json +10 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +4 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +20 -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++/JHybridNitroNumberViewSpec.cpp +536 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +156 -0
- package/nitrogen/generated/android/c++/JNitroNumberAffixAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +61 -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++/views/JHybridNitroNumberViewStateUpdater.cpp +299 -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/HybridNitroNumberViewSpec.kt +363 -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 +24 -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/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 +25 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +248 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +23 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +432 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +414 -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/HybridNitroNumberViewSpec.swift +102 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +1243 -0
- package/nitrogen/generated/ios/swift/NitroNumberAffixAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +44 -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/shared/c++/HybridNitroNumberViewSpec.cpp +115 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +175 -0
- package/nitrogen/generated/shared/c++/NitroNumberAffixAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +80 -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++/views/HybridNitroNumberViewComponent.cpp +124 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +227 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
- package/package.json +15 -7
- package/src/NitroInput.tsx +37 -60
- package/src/NitroNumber.tsx +481 -0
- package/src/index.ts +20 -6
- package/src/specs/NitroInput.nitro.ts +9 -9
- package/src/specs/NitroNumber.nitro.ts +259 -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,132 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JReflowEngine.cpp
|
|
3
|
+
// NitroInput
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#include "JReflowEngine.hpp"
|
|
7
|
+
|
|
8
|
+
namespace margelo::nitro::nitroinput {
|
|
9
|
+
|
|
10
|
+
jni::local_ref<JReflowEngine::jhybriddata> JReflowEngine::initHybrid(jni::alias_ref<jhybridobject>) {
|
|
11
|
+
return makeCxxInstance();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void JReflowEngine::registerNatives() {
|
|
15
|
+
registerHybrid({
|
|
16
|
+
makeNativeMethod("initHybrid", JReflowEngine::initHybrid),
|
|
17
|
+
makeNativeMethod("setTiming", JReflowEngine::setTiming),
|
|
18
|
+
makeNativeMethod("setEffect", JReflowEngine::setEffect),
|
|
19
|
+
makeNativeMethod("setReduceMotion", JReflowEngine::setReduceMotion),
|
|
20
|
+
makeNativeMethod("setRightToLeft", JReflowEngine::setRightToLeft),
|
|
21
|
+
makeNativeMethod("beginText", JReflowEngine::beginText),
|
|
22
|
+
makeNativeMethod("addGlyph", JReflowEngine::addGlyph),
|
|
23
|
+
makeNativeMethod("commitText", JReflowEngine::commitText),
|
|
24
|
+
makeNativeMethod("tick", JReflowEngine::tick),
|
|
25
|
+
makeNativeMethod("needsFrames", JReflowEngine::needsFrames),
|
|
26
|
+
makeNativeMethod("isAnimating", JReflowEngine::isAnimating),
|
|
27
|
+
makeNativeMethod("glyphCount", JReflowEngine::glyphCount),
|
|
28
|
+
makeNativeMethod("contentWidth", JReflowEngine::contentWidth),
|
|
29
|
+
makeNativeMethod("targetWidth", JReflowEngine::targetWidth),
|
|
30
|
+
makeNativeMethod("bodyCount", JReflowEngine::bodyCount),
|
|
31
|
+
makeNativeMethod("caretX", JReflowEngine::caretX),
|
|
32
|
+
makeNativeMethod("reset", JReflowEngine::reset),
|
|
33
|
+
makeNativeMethod("frameInto", JReflowEngine::frameInto),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void JReflowEngine::setTiming(double durationSeconds, int easing, double bounce) {
|
|
38
|
+
engine_.setTiming(durationSeconds, easing, bounce);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
void JReflowEngine::setEffect(int effect) {
|
|
42
|
+
engine_.setEffect(effect);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void JReflowEngine::setReduceMotion(bool reduceMotion) {
|
|
46
|
+
engine_.setReduceMotion(reduceMotion);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void JReflowEngine::setRightToLeft(bool rightToLeft) {
|
|
50
|
+
engine_.setRightToLeft(rightToLeft);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void JReflowEngine::beginText() {
|
|
54
|
+
engine_.beginText();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void JReflowEngine::addGlyph(int character, int role, int kind, double width, bool placeholder) {
|
|
58
|
+
engine_.addGlyph(static_cast<uint32_t>(character), role, kind, width, placeholder);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void JReflowEngine::commitText(int caret, double now) {
|
|
62
|
+
engine_.commitText(caret, now);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
bool JReflowEngine::tick(double now) {
|
|
66
|
+
return engine_.tick(now);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
bool JReflowEngine::needsFrames() {
|
|
70
|
+
return engine_.needsFrames();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
bool JReflowEngine::isAnimating() {
|
|
74
|
+
return engine_.isAnimating();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
int JReflowEngine::glyphCount() {
|
|
78
|
+
return engine_.glyphCount();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
double JReflowEngine::contentWidth() {
|
|
82
|
+
return engine_.contentWidth();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
double JReflowEngine::targetWidth() {
|
|
86
|
+
return engine_.targetWidth();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
int JReflowEngine::bodyCount() {
|
|
90
|
+
return engine_.bodyCount();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
double JReflowEngine::caretX(int index) {
|
|
94
|
+
return engine_.caretX(index);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void JReflowEngine::reset() {
|
|
98
|
+
engine_.reset();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
int JReflowEngine::frameInto(jni::alias_ref<jni::JArrayDouble> out) {
|
|
102
|
+
const auto& glyphs = engine_.glyphs();
|
|
103
|
+
const size_t count = glyphs.size();
|
|
104
|
+
constexpr size_t kPerGlyph = 11;
|
|
105
|
+
const size_t needed = 3 + count * kPerGlyph;
|
|
106
|
+
if (static_cast<size_t>(out->size()) < needed) {
|
|
107
|
+
return -1;
|
|
108
|
+
}
|
|
109
|
+
scratch_.resize(needed);
|
|
110
|
+
double* data = scratch_.data();
|
|
111
|
+
data[0] = static_cast<double>(count);
|
|
112
|
+
data[1] = engine_.contentWidth();
|
|
113
|
+
data[2] = engine_.targetWidth();
|
|
114
|
+
size_t i = 3;
|
|
115
|
+
for (const auto& g : glyphs) {
|
|
116
|
+
data[i++] = static_cast<double>(g.id);
|
|
117
|
+
data[i++] = static_cast<double>(g.character);
|
|
118
|
+
data[i++] = static_cast<double>(g.role);
|
|
119
|
+
data[i++] = static_cast<double>(g.kind);
|
|
120
|
+
data[i++] = g.width;
|
|
121
|
+
data[i++] = g.placeholder ? 1.0 : 0.0;
|
|
122
|
+
data[i++] = g.x;
|
|
123
|
+
data[i++] = g.y;
|
|
124
|
+
data[i++] = g.opacity;
|
|
125
|
+
data[i++] = g.scale;
|
|
126
|
+
data[i++] = g.exiting ? 1.0 : 0.0;
|
|
127
|
+
}
|
|
128
|
+
out->setRegion(0, needed, data);
|
|
129
|
+
return static_cast<int>(needed);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
} // namespace margelo::nitro::nitroinput
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// JReflowEngine.hpp
|
|
3
3
|
// NitroInput
|
|
4
4
|
//
|
|
5
|
-
// fbjni bridge that lets the Kotlin view drive the shared C++
|
|
5
|
+
// fbjni bridge that lets the Kotlin view drive the shared C++ ReflowEngine.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include "
|
|
10
|
+
#include "ReflowEngine.hpp"
|
|
11
11
|
#include <fbjni/fbjni.h>
|
|
12
12
|
#include <vector>
|
|
13
13
|
|
|
@@ -15,9 +15,9 @@ namespace margelo::nitro::nitroinput {
|
|
|
15
15
|
|
|
16
16
|
using namespace facebook;
|
|
17
17
|
|
|
18
|
-
class
|
|
18
|
+
class JReflowEngine final : public jni::HybridClass<JReflowEngine> {
|
|
19
19
|
public:
|
|
20
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/
|
|
20
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/ReflowEngine;";
|
|
21
21
|
|
|
22
22
|
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
|
|
23
23
|
static void registerNatives();
|
|
@@ -46,8 +46,8 @@ public:
|
|
|
46
46
|
|
|
47
47
|
private:
|
|
48
48
|
friend HybridBase;
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
JReflowEngine() = default;
|
|
50
|
+
ReflowEngine engine_;
|
|
51
51
|
std::vector<double> scratch_;
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JRollingEngine.cpp
|
|
3
|
+
// NitroInput
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#include "JRollingEngine.hpp"
|
|
7
|
+
|
|
8
|
+
namespace margelo::nitro::nitroinput {
|
|
9
|
+
|
|
10
|
+
jni::local_ref<JRollingEngine::jhybriddata> JRollingEngine::initHybrid(jni::alias_ref<jhybridobject>) {
|
|
11
|
+
return makeCxxInstance();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void JRollingEngine::registerNatives() {
|
|
15
|
+
registerHybrid({
|
|
16
|
+
makeNativeMethod("initHybrid", JRollingEngine::initHybrid),
|
|
17
|
+
makeNativeMethod("setFormat", JRollingEngine::setFormat),
|
|
18
|
+
makeNativeMethod("setTiming", JRollingEngine::setTiming),
|
|
19
|
+
makeNativeMethod("setTransition", JRollingEngine::setTransition),
|
|
20
|
+
makeNativeMethod("setFlash", JRollingEngine::setFlash),
|
|
21
|
+
makeNativeMethod("setPopOnChange", JRollingEngine::setPopOnChange),
|
|
22
|
+
makeNativeMethod("setReduceMotion", JRollingEngine::setReduceMotion),
|
|
23
|
+
makeNativeMethod("changeText", JRollingEngine::changeText),
|
|
24
|
+
makeNativeMethod("changeFormat", JRollingEngine::changeFormat),
|
|
25
|
+
makeNativeMethod("setValue", JRollingEngine::setValue),
|
|
26
|
+
makeNativeMethod("animateTo", JRollingEngine::animateTo),
|
|
27
|
+
makeNativeMethod("setLoading", JRollingEngine::setLoading),
|
|
28
|
+
makeNativeMethod("tick", JRollingEngine::tick),
|
|
29
|
+
makeNativeMethod("needsFrames", JRollingEngine::needsFrames),
|
|
30
|
+
makeNativeMethod("isRolling", JRollingEngine::isRolling),
|
|
31
|
+
makeNativeMethod("reset", JRollingEngine::reset),
|
|
32
|
+
makeNativeMethod("setRevealTiming", JRollingEngine::setRevealTiming),
|
|
33
|
+
makeNativeMethod("setRevealGrow", JRollingEngine::setRevealGrow),
|
|
34
|
+
makeNativeMethod("holdReveal", JRollingEngine::holdReveal),
|
|
35
|
+
makeNativeMethod("reveal", JRollingEngine::reveal),
|
|
36
|
+
makeNativeMethod("isRevealing", JRollingEngine::isRevealing),
|
|
37
|
+
makeNativeMethod("clearRevealMilestones", JRollingEngine::clearRevealMilestones),
|
|
38
|
+
makeNativeMethod("addRevealMilestone", JRollingEngine::addRevealMilestone),
|
|
39
|
+
makeNativeMethod("setRevealMilestoneHold", JRollingEngine::setRevealMilestoneHold),
|
|
40
|
+
makeNativeMethod("revealMilestonesReached", JRollingEngine::revealMilestonesReached),
|
|
41
|
+
makeNativeMethod("revealMilestoneValue", JRollingEngine::revealMilestoneValue),
|
|
42
|
+
makeNativeMethod("frameInto", JRollingEngine::frameInto),
|
|
43
|
+
makeNativeMethod("shimmerPhase", JRollingEngine::shimmerPhase),
|
|
44
|
+
makeNativeMethod("targetValue", JRollingEngine::targetValue),
|
|
45
|
+
makeNativeMethod("hasShownValue", JRollingEngine::hasShownValue),
|
|
46
|
+
makeNativeMethod("settledPowerCount", JRollingEngine::settledPowerCount),
|
|
47
|
+
makeNativeMethod("settledNegative", JRollingEngine::settledNegative),
|
|
48
|
+
makeNativeMethod("targetDigit", JRollingEngine::targetDigit),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void JRollingEngine::setFormat(int fractionDigits, int minimumIntegerDigits) {
|
|
53
|
+
engine_.setFormat(fractionDigits, minimumIntegerDigits);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void JRollingEngine::setTiming(double durationSeconds, int easing, double bounce, double staggerSeconds, int direction) {
|
|
57
|
+
engine_.setTiming(durationSeconds, easing, bounce, staggerSeconds, direction);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void JRollingEngine::setTransition(int transition) {
|
|
61
|
+
engine_.setTransition(transition);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void JRollingEngine::setFlash(double seconds) {
|
|
65
|
+
engine_.setFlash(seconds);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void JRollingEngine::setPopOnChange(double overshoot) {
|
|
69
|
+
engine_.setPopOnChange(overshoot);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void JRollingEngine::setReduceMotion(bool reduceMotion) {
|
|
73
|
+
engine_.setReduceMotion(reduceMotion);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void JRollingEngine::changeText(int slot, double now) {
|
|
77
|
+
engine_.changeText(slot, now);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void JRollingEngine::changeFormat(int fractionDigits, int minimumIntegerDigits, double now) {
|
|
81
|
+
engine_.changeFormat(fractionDigits, minimumIntegerDigits, now);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void JRollingEngine::setValue(double value) {
|
|
85
|
+
engine_.setValue(value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
void JRollingEngine::animateTo(double value, double now) {
|
|
89
|
+
engine_.animateTo(value, now);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void JRollingEngine::setLoading(bool loading, double now) {
|
|
93
|
+
engine_.setLoading(loading, now);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
bool JRollingEngine::tick(double now) {
|
|
97
|
+
return engine_.tick(now);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
bool JRollingEngine::isRolling() {
|
|
101
|
+
return engine_.isRolling();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
bool JRollingEngine::needsFrames() {
|
|
105
|
+
return engine_.needsFrames();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void JRollingEngine::reset() {
|
|
109
|
+
engine_.reset();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
void JRollingEngine::setRevealTiming(double durationSeconds, double bounce, int style, double staggerSeconds) {
|
|
113
|
+
engine_.setRevealTiming(durationSeconds, bounce, style, staggerSeconds);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void JRollingEngine::setRevealGrow(double grow) {
|
|
117
|
+
engine_.setRevealGrow(grow);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
void JRollingEngine::holdReveal(double value) {
|
|
121
|
+
engine_.holdReveal(value);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void JRollingEngine::reveal(double value, double now) {
|
|
125
|
+
engine_.reveal(value, now);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
bool JRollingEngine::isRevealing() {
|
|
129
|
+
return engine_.isRevealing();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
void JRollingEngine::clearRevealMilestones() {
|
|
133
|
+
engine_.clearRevealMilestones();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void JRollingEngine::addRevealMilestone(double value) {
|
|
137
|
+
engine_.addRevealMilestone(value);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
void JRollingEngine::setRevealMilestoneHold(double holdSeconds) {
|
|
141
|
+
engine_.setRevealMilestoneHold(holdSeconds);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
int JRollingEngine::revealMilestonesReached() {
|
|
145
|
+
return engine_.revealMilestonesReached();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
double JRollingEngine::revealMilestoneValue(int index) {
|
|
149
|
+
return engine_.revealMilestoneValue(index);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
int JRollingEngine::frameInto(jni::alias_ref<jni::JArrayDouble> out) {
|
|
153
|
+
const auto& wheels = engine_.wheels();
|
|
154
|
+
const size_t count = wheels.size();
|
|
155
|
+
constexpr size_t kMaxWheels = 32;
|
|
156
|
+
// Then each text slot's swap (`RollingEngine::changeText`): grow, focus,
|
|
157
|
+
// blurOut, active.
|
|
158
|
+
// Then the decimal columns laid out and the decimal separator's factor.
|
|
159
|
+
constexpr size_t kText = RollingEngine::kTextSlots * 4 + 2;
|
|
160
|
+
double data[4 + kMaxWheels * 13 + kText];
|
|
161
|
+
const size_t needed = 4 + count * 13 + kText;
|
|
162
|
+
if (count > kMaxWheels || static_cast<size_t>(out->size()) < needed) {
|
|
163
|
+
return -1;
|
|
164
|
+
}
|
|
165
|
+
data[0] = engine_.signFactor();
|
|
166
|
+
data[1] = engine_.loadingProgress();
|
|
167
|
+
data[2] = engine_.revealScale();
|
|
168
|
+
data[3] = static_cast<double>(count);
|
|
169
|
+
size_t i = 4;
|
|
170
|
+
for (const auto& w : wheels) {
|
|
171
|
+
data[i++] = w.position;
|
|
172
|
+
data[i++] = w.width;
|
|
173
|
+
data[i++] = w.linear ? 1.0 : 0.0;
|
|
174
|
+
data[i++] = w.blankZero ? 1.0 : 0.0;
|
|
175
|
+
data[i++] = w.fromGlyph;
|
|
176
|
+
data[i++] = w.toGlyph;
|
|
177
|
+
data[i++] = w.blend;
|
|
178
|
+
data[i++] = w.fromAbove ? 1.0 : 0.0;
|
|
179
|
+
data[i++] = w.flash;
|
|
180
|
+
data[i++] = w.flashUp ? 1.0 : 0.0;
|
|
181
|
+
data[i++] = w.focus;
|
|
182
|
+
data[i++] = w.grow;
|
|
183
|
+
data[i++] = w.blurOut;
|
|
184
|
+
}
|
|
185
|
+
for (int slot = 0; slot < RollingEngine::kTextSlots; slot++) {
|
|
186
|
+
const RollingEngine::TextChange t = engine_.textChange(slot);
|
|
187
|
+
data[i++] = t.grow;
|
|
188
|
+
data[i++] = t.focus;
|
|
189
|
+
data[i++] = t.blurOut;
|
|
190
|
+
data[i++] = t.active ? 1.0 : 0.0;
|
|
191
|
+
}
|
|
192
|
+
data[i++] = static_cast<double>(engine_.displayFractionDigits());
|
|
193
|
+
data[i++] = engine_.decimalFactor();
|
|
194
|
+
out->setRegion(0, needed, data);
|
|
195
|
+
return static_cast<int>(needed);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
double JRollingEngine::shimmerPhase(double now, double periodSeconds) {
|
|
199
|
+
return engine_.shimmerPhase(now, periodSeconds);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
double JRollingEngine::targetValue() {
|
|
203
|
+
return engine_.targetValue();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
bool JRollingEngine::hasShownValue() {
|
|
207
|
+
return engine_.hasShownValue();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
int JRollingEngine::settledPowerCount() {
|
|
211
|
+
return engine_.settledPowerCount();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
bool JRollingEngine::settledNegative() {
|
|
215
|
+
return engine_.settledNegative();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
int JRollingEngine::targetDigit(int power) {
|
|
219
|
+
return engine_.targetDigit(power);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
} // namespace margelo::nitro::nitroinput
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JRollingEngine.hpp
|
|
3
|
+
// NitroInput
|
|
4
|
+
//
|
|
5
|
+
// fbjni bridge that lets the Kotlin view drive the shared C++ RollingEngine.
|
|
6
|
+
// This is the only hand-written JNI in the library.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "RollingEngine.hpp"
|
|
12
|
+
#include <fbjni/fbjni.h>
|
|
13
|
+
|
|
14
|
+
namespace margelo::nitro::nitroinput {
|
|
15
|
+
|
|
16
|
+
using namespace facebook;
|
|
17
|
+
|
|
18
|
+
class JRollingEngine final : public jni::HybridClass<JRollingEngine> {
|
|
19
|
+
public:
|
|
20
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/RollingEngine;";
|
|
21
|
+
|
|
22
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
|
|
23
|
+
static void registerNatives();
|
|
24
|
+
|
|
25
|
+
void setFormat(int fractionDigits, int minimumIntegerDigits);
|
|
26
|
+
void setTiming(double durationSeconds, int easing, double bounce, double staggerSeconds, int direction);
|
|
27
|
+
void setTransition(int transition);
|
|
28
|
+
void setFlash(double seconds);
|
|
29
|
+
void setPopOnChange(double overshoot);
|
|
30
|
+
void setReduceMotion(bool reduceMotion);
|
|
31
|
+
void changeText(int slot, double now);
|
|
32
|
+
void changeFormat(int fractionDigits, int minimumIntegerDigits, double now);
|
|
33
|
+
void setValue(double value);
|
|
34
|
+
void animateTo(double value, double now);
|
|
35
|
+
void setLoading(bool loading, double now);
|
|
36
|
+
bool tick(double now);
|
|
37
|
+
bool needsFrames();
|
|
38
|
+
bool isRolling();
|
|
39
|
+
void reset();
|
|
40
|
+
void setRevealTiming(double durationSeconds, double bounce, int style, double staggerSeconds);
|
|
41
|
+
void setRevealGrow(double grow);
|
|
42
|
+
void holdReveal(double value);
|
|
43
|
+
void reveal(double value, double now);
|
|
44
|
+
bool isRevealing();
|
|
45
|
+
void clearRevealMilestones();
|
|
46
|
+
void addRevealMilestone(double value);
|
|
47
|
+
void setRevealMilestoneHold(double holdSeconds);
|
|
48
|
+
int revealMilestonesReached();
|
|
49
|
+
double revealMilestoneValue(int index);
|
|
50
|
+
/// Writes the render state into `out` without allocating:
|
|
51
|
+
/// `[signFactor, loadingProgress, revealScale, wheelCount, then (position,
|
|
52
|
+
/// width, linear, blankZero) per wheel]`. Returns the number of doubles
|
|
53
|
+
/// written, or -1 if `out` is too small.
|
|
54
|
+
int frameInto(jni::alias_ref<jni::JArrayDouble> out);
|
|
55
|
+
double shimmerPhase(double now, double periodSeconds);
|
|
56
|
+
double targetValue();
|
|
57
|
+
bool hasShownValue();
|
|
58
|
+
int settledPowerCount();
|
|
59
|
+
bool settledNegative();
|
|
60
|
+
int targetDigit(int power);
|
|
61
|
+
|
|
62
|
+
private:
|
|
63
|
+
friend HybridBase;
|
|
64
|
+
JRollingEngine() = default;
|
|
65
|
+
RollingEngine engine_;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro::nitroinput
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
#include <jni.h>
|
|
2
2
|
#include <fbjni/fbjni.h>
|
|
3
3
|
#include "NitroInputOnLoad.hpp"
|
|
4
|
-
#include "
|
|
4
|
+
#include "JReflowEngine.hpp"
|
|
5
5
|
#include "JAmountFormatter.hpp"
|
|
6
6
|
#include "JMaskEngine.hpp"
|
|
7
7
|
#include "JOutlineGeometry.hpp"
|
|
8
8
|
#include "JNitroInputWorklets.hpp"
|
|
9
|
+
#include "JRollingEngine.hpp"
|
|
9
10
|
|
|
10
11
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
11
12
|
return facebook::jni::initialize(vm, []() {
|
|
12
13
|
margelo::nitro::nitroinput::registerAllNatives();
|
|
13
|
-
margelo::nitro::nitroinput::
|
|
14
|
+
margelo::nitro::nitroinput::JReflowEngine::registerNatives();
|
|
14
15
|
margelo::nitro::nitroinput::JAmountFormatter::registerNatives();
|
|
15
16
|
margelo::nitro::nitroinput::JMaskEngine::registerNatives();
|
|
16
17
|
margelo::nitro::nitroinput::JOutlineGeometry::registerNatives();
|
|
17
18
|
margelo::nitro::nitroinput::JNitroInputWorklets::registerNatives();
|
|
19
|
+
margelo::nitro::nitroinput::JRollingEngine::registerNatives();
|
|
18
20
|
});
|
|
19
21
|
}
|
|
@@ -30,6 +30,6 @@ class AmountFormatter {
|
|
|
30
30
|
external fun format(value: Double): String
|
|
31
31
|
/** NaN when there are no digits. */
|
|
32
32
|
external fun value(text: String): Double
|
|
33
|
-
/**
|
|
33
|
+
/** ReflowEngine kind of a character in formatted text. */
|
|
34
34
|
external fun kindOf(codePoint: Int): Int
|
|
35
35
|
}
|
|
@@ -342,7 +342,7 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
342
342
|
* collection before and with them, and divides the difference; medians of
|
|
343
343
|
* three interleaved rounds, which differ by up to 50 KB a field. Galaxy
|
|
344
344
|
* A22, Android 13, 2026-09-22: a NitroInput is about 37 KB of malloc and
|
|
345
|
-
* 27 KB of Java heap per field (a `TextInput` 63 + 17); a
|
|
345
|
+
* 27 KB of Java heap per field (a `TextInput` 63 + 17); a reflowing one is
|
|
346
346
|
* within that noise, about 27 KB of malloc more by a native heap profile.
|
|
347
347
|
* One constant for both, because Nitro reads it once when the handle is
|
|
348
348
|
* created, before the props say which one this is.
|