react-native-nitro-input 0.3.8 → 0.4.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 +89 -0
- package/README.md +5 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputMeasure.kt +52 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +74 -80
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +18 -18
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +14 -14
- package/android/src/main/java/com/margelo/nitro/nitroinput/InputFonts.kt +199 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/InputSizing.kt +398 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +112 -333
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +178 -30
- package/ios/HybridNitroInputView.swift +69 -75
- package/ios/HybridNitroNumberView.swift +18 -18
- package/ios/HybridNitroTextView.swift +14 -14
- package/ios/InputSizing.swift +534 -0
- package/ios/NitroInputView.swift +102 -198
- package/ios/NitroNumberView.swift +98 -23
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
- package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
- package/lib/commonjs/src/NitroInput.js +164 -23
- package/lib/commonjs/src/NitroNumber.js +1 -1
- package/lib/commonjs/src/NitroText.js +6 -6
- package/lib/commonjs/src/specs/NitroInputMeasure.nitro.js +2 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
- package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
- package/lib/module/src/NitroInput.js +165 -24
- package/lib/module/src/NitroNumber.js +1 -1
- package/lib/module/src/NitroText.js +6 -6
- package/lib/module/src/specs/NitroInputMeasure.nitro.js +1 -0
- package/lib/typescript/src/NitroInput.d.ts +9 -16
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +17 -8
- package/lib/typescript/src/specs/NitroInputMeasure.nitro.d.ts +67 -0
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +6 -6
- package/lib/typescript/src/specs/NitroText.nitro.d.ts +6 -6
- package/nitro.json +10 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +2 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +16 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.cpp +93 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +76 -40
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +24 -16
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +30 -30
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +12 -12
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +30 -30
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +12 -12
- package/nitrogen/generated/android/c++/JNitroInputSize.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputSizing.hpp +284 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +44 -24
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +18 -18
- package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +18 -18
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputMeasureSpec.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +32 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSize.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSizing.kt +246 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +29 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +11 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.hpp +112 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +56 -32
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +24 -24
- package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +24 -24
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +56 -32
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +24 -24
- package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +24 -24
- package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec_cxx.swift +138 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +12 -8
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +68 -24
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +18 -18
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +18 -18
- package/nitrogen/generated/ios/swift/NitroInputSize.swift +34 -0
- package/nitrogen/generated/ios/swift/NitroInputSizing.swift +242 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +24 -16
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +24 -16
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +12 -12
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +12 -12
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +12 -12
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +12 -12
- package/nitrogen/generated/shared/c++/NitroInputSize.hpp +87 -0
- package/nitrogen/generated/shared/c++/NitroInputSizing.hpp +263 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +24 -16
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +36 -24
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +12 -12
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +18 -18
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +12 -12
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +18 -18
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
- package/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
- package/package.json +4 -2
- package/src/NitroInput.tsx +201 -64
- package/src/NitroNumber.tsx +6 -6
- package/src/NitroText.tsx +6 -6
- package/src/specs/NitroInput.nitro.ts +17 -8
- package/src/specs/NitroInputMeasure.nitro.ts +76 -0
- package/src/specs/NitroNumber.nitro.ts +6 -6
- package/src/specs/NitroText.nitro.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- **Android: `NitroNumber`'s numeric transition no longer blocks the UI
|
|
6
|
+
thread (ANRs).** A glyph mask the warm thread had not made yet was blurred
|
|
7
|
+
in `onDraw`, and the shared mask cache made every mask inside its lock. Two
|
|
8
|
+
ANRs on low-end phones followed: the UI thread `Blocked` in the cache's
|
|
9
|
+
`get` behind the warm thread (which runs at `MIN_PRIORITY`), and the UI
|
|
10
|
+
thread waiting for a GC while the blur allocated two float copies of a large
|
|
11
|
+
glyph. Now masks are made outside the lock, the UI thread never blurs (a
|
|
12
|
+
mask not warmed yet is drawn sharp for a frame while the warm thread makes
|
|
13
|
+
it), and the blur reuses per-thread buffers instead of allocating per mask.
|
|
14
|
+
A mask the screen is waiting on is made ahead of the warm-up's queue (it
|
|
15
|
+
waited behind every digit at every blur level, ~50 ms), the warm thread runs
|
|
16
|
+
at background priority rather than the lowest, and a mask that cannot be
|
|
17
|
+
made is skipped rather than crashing the app.
|
|
18
|
+
- **iOS: the numeric transition no longer blurs on the main thread.** Its
|
|
19
|
+
digits were blurred and rasterized ahead of the first swap, but on the main
|
|
20
|
+
queue: opening a screen of numeric figures spent ~1 s of the main thread on
|
|
21
|
+
it (Release, simulator), in blocks of up to ~180 ms, and a prefix or suffix
|
|
22
|
+
that changed text was blurred on demand mid-frame. The warm-up now runs on
|
|
23
|
+
a background queue, a blur the screen is waiting on on a second one ahead
|
|
24
|
+
of it (drawn sharp until it lands), and the shared glyph caches are
|
|
25
|
+
thread-safe.
|
|
26
|
+
- **`NitroInput` lays out at its real size in the commit that mounts it.**
|
|
27
|
+
Its size came from the view, through `onSizeChange` and a React commit, so
|
|
28
|
+
the first layout had none: an `autoWidth` field took its parent's width (or
|
|
29
|
+
none) for a commit, and every field without a fixed height moved by a pixel
|
|
30
|
+
or two as its line box arrived. Now a single-line field is measured on the JS
|
|
31
|
+
thread before its view exists (a new `NitroInputMeasure`), with the code the
|
|
32
|
+
view sizes itself with - fonts, affixes and their seams, number and mask
|
|
33
|
+
formatting, the placeholder and `keepPlaceholder`'s tail - as React
|
|
34
|
+
Native's `TextInput` measures in its shadow node. About 0.1 ms per field;
|
|
35
|
+
the view's own report then matches and no longer costs a commit. A wrapping
|
|
36
|
+
field, a `transform` worklet and a style that sets both sides keep the old
|
|
37
|
+
path.
|
|
38
|
+
- **A framed field sizes itself.** With no width or height from its style,
|
|
39
|
+
an `outlined` or `filled` field took the size of its text line alone: the
|
|
40
|
+
frame's side insets and the label were left out, so a resting label was
|
|
41
|
+
drawn outside the field and a filled one cut its text off. Its size now
|
|
42
|
+
includes the frame: the side insets either side of the text or the resting
|
|
43
|
+
label, whichever is wider, and above and below it the same 16 of padding
|
|
44
|
+
(and a filled field's label line) a wrapping field already had. A field
|
|
45
|
+
given a height in its style is unchanged.
|
|
46
|
+
- **A secure field fits its bullets.** Android set the password input type
|
|
47
|
+
after the typeface, which switches the field to monospace, so its bullets
|
|
48
|
+
were wider than the field measured them; the typeface is now put back, as
|
|
49
|
+
React Native's `TextInput` does. On iOS the field measured its text as
|
|
50
|
+
bullets in its own font, but UIKit draws U+2219 in the system font; it now
|
|
51
|
+
measures those. An `autoWidth` secure field showed `●●●●…` for 8 characters
|
|
52
|
+
on iOS and 5 bullets on Android.
|
|
53
|
+
- **No size jump on mount, and no amount sliding in on a reused field.** A
|
|
54
|
+
size the view reported before its props were applied (the defaults', or a
|
|
55
|
+
recycled view's last element's) reached JS and made the field jump to it and
|
|
56
|
+
back. And on iOS a recycled view took the empty text its props reset fed the
|
|
57
|
+
engine for its first, so a reflowing amount on a reused view slid in instead
|
|
58
|
+
of showing as it is.
|
|
59
|
+
- **Android: `keepPlaceholder`'s greyed tail stays inside the field.** The
|
|
60
|
+
rest of the placeholder, drawn after what was typed, was not clipped to the
|
|
61
|
+
text area as the field's own text and hint are: in a padded field narrower
|
|
62
|
+
than its placeholder (or once the typed text filled it), the tail ran over
|
|
63
|
+
the padding to the field's edge. iOS already clipped it.
|
|
64
|
+
- **A `TextInput` style no longer crashes a field, and `NitroInput` reads
|
|
65
|
+
its typography from it.** Fabric hands a view its style's keys as props,
|
|
66
|
+
and six to eight of each view's native props shared a name with a text
|
|
67
|
+
style key: `style={{ fontWeight: '700' }}` threw ("Value is a string,
|
|
68
|
+
expected a number") on `NitroInput`, `NitroNumber` and `NitroText`, and a
|
|
69
|
+
numeric `fontSize` or `color` there was fought over by the style and the
|
|
70
|
+
prop. The native props are renamed (`textSize`, `textWeight`,
|
|
71
|
+
`textFamily`, `textColor`, `textLetterSpacing`, `textLineHeight`,
|
|
72
|
+
`textAlignment`, `textVerticalAlignment`); the components' own props keep
|
|
73
|
+
their names. A test now fails if any native prop shares a name with a React
|
|
74
|
+
Native style key or view prop. `NitroInput` also takes `fontSize`,
|
|
75
|
+
`fontWeight`, `fontFamily`, `color`, `letterSpacing`, `lineHeight`,
|
|
76
|
+
`textAlign` and `textAlignVertical` from `style`, as `TextInput` does (its
|
|
77
|
+
`style` is typed as `TextInput`'s); the props of the same name win.
|
|
78
|
+
- **`NitroInput` matches `TextInput` in three more places**, found by a
|
|
79
|
+
visual comparison of the two side by side:
|
|
80
|
+
- Android: `textAlign` `center` / `right` on a plain field did nothing; the
|
|
81
|
+
alignment set when the field became plain (before `textAlign` arrived in
|
|
82
|
+
the same commit) overrode it.
|
|
83
|
+
- A `style` padding or border insets the text and adds to the size the
|
|
84
|
+
field works out for itself, as `TextInput`'s does. An `autoWidth` field
|
|
85
|
+
with `paddingHorizontal: 8` squeezed its text to "…" on iOS; on Android
|
|
86
|
+
the padding did not inset the text at all (React Native never hands a
|
|
87
|
+
Nitro view its padding there, so the view now insets its text, overlay and
|
|
88
|
+
frame itself).
|
|
89
|
+
- iOS: `lineHeight` sets a single line's height, as on Android; it was the
|
|
90
|
+
font's own line box whatever the prop said.
|
|
91
|
+
|
|
3
92
|
## 0.3.8
|
|
4
93
|
|
|
5
94
|
- **`NitroNumber` shows what its `format` prints, value by value.** It read the
|
package/README.md
CHANGED
|
@@ -173,6 +173,10 @@ interpolate between them.
|
|
|
173
173
|
`variant="filled"` gives a filled field instead: a `fillColor`
|
|
174
174
|
background with a square bottom and an indicator rule along it.
|
|
175
175
|
|
|
176
|
+
Without a size in its style the field sizes itself to the frame: its text (or
|
|
177
|
+
its resting label, if wider) between the side insets, and 16 of padding above
|
|
178
|
+
and below the line, plus a line for a filled field's floated label.
|
|
179
|
+
|
|
176
180
|
The label runs 200 ms on a decelerate curve, and the notch is staggered 50 ms behind it opening and closes in 50 ms,
|
|
177
181
|
so the gap is never open under a label that has not arrived. All of it runs
|
|
178
182
|
inside the view, off a native focus callback — there is no React state to
|
|
@@ -583,7 +587,7 @@ screen behaves like theirs with these settings:
|
|
|
583
587
|
| `onKeyPress` | `(event) => void` | – | Before the text changes: the character, `'Backspace'` or `'Enter'`. |
|
|
584
588
|
| `onNativeRef` | `(ref) => void` | – | Receives the Nitro object on mount. |
|
|
585
589
|
| `id` / `aria-label` | `string` | – | React Native's HTML-style aliases for `nativeID` / `accessibilityLabel`, resolved here because a Nitro view is handed the raw props; each wins over the older spelling. |
|
|
586
|
-
| `style`, `testID`, … | `ViewProps` | – | Regular view props. `testID` and the accessibility label are forwarded to the system field, the element VoiceOver, TalkBack and e2e tools interact with. The field takes its width from its parent like a `TextInput`; see `autoWidth`. |
|
|
590
|
+
| `style`, `testID`, … | `ViewProps`; `style` as `TextInput`'s | – | Regular view props. `testID` and the accessibility label are forwarded to the system field, the element VoiceOver, TalkBack and e2e tools interact with. The field takes its width from its parent like a `TextInput`; see `autoWidth`. As on a `TextInput`, `style` can carry the typography (`fontSize`, `fontWeight`, `fontFamily`, `color`, `letterSpacing`, `lineHeight`, `textAlign`, `textAlignVertical`; the props of the same name win), and its padding and border inset the text and add to a size the field works out for itself. Two deliberate differences: digits are always tabular (Android's Roboto has them anyway, and a field keeps its width whether it reflows or not), and Android gets no default padding (iOS's `TextInput` has none; React Native's Android one keeps the platform field's). |
|
|
587
591
|
|
|
588
592
|
`keyboardType`: `'default' | 'number-pad' | 'decimal-pad' | 'numeric' | 'email-address' | 'phone-pad' | 'url' | 'ascii-capable' | 'numbers-and-punctuation'`.
|
|
589
593
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package com.margelo.nitro.nitroinput
|
|
2
|
+
|
|
3
|
+
import android.content.res.Resources
|
|
4
|
+
import android.graphics.Color
|
|
5
|
+
import androidx.annotation.Keep
|
|
6
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
7
|
+
import com.margelo.nitro.NitroModules
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Measures a single-line field on the JS thread, before its view exists, with
|
|
11
|
+
* [InputFonts], [InputText] and [InputGlyphs] - the code the view sizes itself
|
|
12
|
+
* with - so it lays out at its real size in the commit that mounts it.
|
|
13
|
+
* `Paint`, `ReactFontManager` and the C++ engines are safe off the main
|
|
14
|
+
* thread, as React Native's own text measurement relies on.
|
|
15
|
+
*
|
|
16
|
+
* Mirrors `HybridNitroInputMeasure` on iOS.
|
|
17
|
+
*/
|
|
18
|
+
@Keep
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
class HybridNitroInputMeasure : HybridNitroInputMeasureSpec() {
|
|
21
|
+
// Reused across calls and reconfigured by each: measures come one at a
|
|
22
|
+
// time from the JS thread, and the lock keeps a second runtime out.
|
|
23
|
+
private val formatter = AmountFormatter()
|
|
24
|
+
private val maskEngine = MaskEngine()
|
|
25
|
+
|
|
26
|
+
@Synchronized
|
|
27
|
+
override fun measure(sizing: NitroInputSizing): NitroInputSize {
|
|
28
|
+
val context = NitroModules.applicationContext
|
|
29
|
+
val resources = context?.resources ?: Resources.getSystem()
|
|
30
|
+
val density = resources.displayMetrics.density
|
|
31
|
+
val props = SizingProps(sizing)
|
|
32
|
+
val format = formatOf(props)
|
|
33
|
+
val fonts = InputFonts(sizingTypographyOf(props, density), density, resources.configuration.fontScale, context?.assets, Color.BLACK)
|
|
34
|
+
InputText.configure(formatter, maskEngine, null, format)
|
|
35
|
+
val text = InputText.conform(sizing.text, format, formatter, maskEngine, clampedInt(sizing.maxLength, 0, Int.MAX_VALUE, 0))
|
|
36
|
+
val frame = sizingFrameOf(props)
|
|
37
|
+
// Unfocused, as a field mounts: a label resting inside it hides the placeholder.
|
|
38
|
+
val labelFloats = frame.labelBehavior == NitroInputView.LabelBehavior.ALWAYS || text.isNotEmpty()
|
|
39
|
+
val hint = if (frame.hasLabel && !labelFloats) "" else InputText.basePlaceholder(format, maskEngine)
|
|
40
|
+
val tail = InputText.ghostTail(text, format, maskEngine, sizing.secureTextEntry)
|
|
41
|
+
val width = if (sizing.plain) {
|
|
42
|
+
InputSizing.plainWidthPx(fonts, format, InputSizing.plainBody(text, hint, tail, sizing.secureTextEntry))
|
|
43
|
+
} else {
|
|
44
|
+
InputSizing.reflowWidthPx(fonts, format, text, hint, tail, sizing.secureTextEntry)
|
|
45
|
+
}
|
|
46
|
+
return InputSizing.reported(
|
|
47
|
+
InputFrame.widthPx(width, frame, fonts, density),
|
|
48
|
+
InputFrame.singleLineHeightPx(fonts.lineHeight, frame, fonts, density),
|
|
49
|
+
density,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -14,7 +14,7 @@ import com.margelo.nitro.views.RecyclableView
|
|
|
14
14
|
*/
|
|
15
15
|
@Keep
|
|
16
16
|
@DoNotStrip
|
|
17
|
-
class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitroInputViewSpec(), RecyclableView {
|
|
17
|
+
class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitroInputViewSpec(), RecyclableView, InputSizingProps {
|
|
18
18
|
private val mainHandler = Handler(Looper.getMainLooper())
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -73,7 +73,7 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
73
73
|
}
|
|
74
74
|
inputView.onKeyPress = { key -> onKeyPress?.invoke(key) }
|
|
75
75
|
inputView.onIntrinsicSizeChange = { width, height ->
|
|
76
|
-
onSizeChange?.invoke(width.toDouble(), height.toDouble())
|
|
76
|
+
if (!configured || committing) sizeHeld = true else onSizeChange?.invoke(width.toDouble(), height.toDouble())
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -127,7 +127,7 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
127
127
|
set(v) { field = v; markConfigDirty() }
|
|
128
128
|
override var suffixAlign: NitroInputAffixAlign = NitroInputAffixAlign.BASELINE
|
|
129
129
|
set(v) { field = v; markConfigDirty() }
|
|
130
|
-
override var
|
|
130
|
+
override var textLetterSpacing: Double = 0.0
|
|
131
131
|
set(v) { field = v; markConfigDirty() }
|
|
132
132
|
override var prefixSpacing: Double = Double.POSITIVE_INFINITY
|
|
133
133
|
set(v) { field = v; markConfigDirty() }
|
|
@@ -171,17 +171,17 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
171
171
|
set(v) { field = v; markConfigDirty() }
|
|
172
172
|
override var effect: NitroInputEffect = NitroInputEffect.AUTO
|
|
173
173
|
set(v) { field = v; markConfigDirty() }
|
|
174
|
-
override var
|
|
174
|
+
override var textSize: Double = 32.0
|
|
175
175
|
set(v) { field = v; markConfigDirty() }
|
|
176
|
-
override var
|
|
176
|
+
override var textLineHeight: Double = 0.0
|
|
177
177
|
set(v) { field = v; markConfigDirty() }
|
|
178
|
-
override var
|
|
178
|
+
override var textWeight: Double = 400.0
|
|
179
179
|
set(v) { field = v; markConfigDirty() }
|
|
180
|
-
override var
|
|
180
|
+
override var textFamily: String = ""
|
|
181
181
|
set(v) { field = v; markConfigDirty() }
|
|
182
|
-
override var
|
|
182
|
+
override var textColor: Double = Double.NaN
|
|
183
183
|
set(v) { field = v; markConfigDirty() }
|
|
184
|
-
override var
|
|
184
|
+
override var textAlignment: NitroInputTextAlign = NitroInputTextAlign.AUTO
|
|
185
185
|
set(v) { field = v; markConfigDirty() }
|
|
186
186
|
override var rightToLeft: Boolean = false
|
|
187
187
|
set(v) { field = v; markConfigDirty() }
|
|
@@ -213,7 +213,15 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
213
213
|
set(v) { field = v; markConfigDirty() }
|
|
214
214
|
override var numberOfLines: Double = 0.0
|
|
215
215
|
set(v) { field = v; markConfigDirty() }
|
|
216
|
-
override var
|
|
216
|
+
override var textVerticalAlignment: NitroInputTextAlignVertical = NitroInputTextAlignVertical.AUTO
|
|
217
|
+
set(v) { field = v; markConfigDirty() }
|
|
218
|
+
override var textInsetLeft: Double = 0.0
|
|
219
|
+
set(v) { field = v; markConfigDirty() }
|
|
220
|
+
override var textInsetTop: Double = 0.0
|
|
221
|
+
set(v) { field = v; markConfigDirty() }
|
|
222
|
+
override var textInsetRight: Double = 0.0
|
|
223
|
+
set(v) { field = v; markConfigDirty() }
|
|
224
|
+
override var textInsetBottom: Double = 0.0
|
|
217
225
|
set(v) { field = v; markConfigDirty() }
|
|
218
226
|
override var scrollEnabled: Boolean = true
|
|
219
227
|
set(v) { field = v; markConfigDirty() }
|
|
@@ -285,7 +293,7 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
285
293
|
override var onSizeChange: ((width: Double, height: Double) -> Unit)? = null
|
|
286
294
|
set(v) {
|
|
287
295
|
field = v
|
|
288
|
-
onMain { inputView.resendIntrinsicSize() }
|
|
296
|
+
onMain { if (configured) inputView.resendIntrinsicSize() }
|
|
289
297
|
}
|
|
290
298
|
|
|
291
299
|
// endregion
|
|
@@ -414,7 +422,7 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
414
422
|
prefixFontSize = Double.NaN
|
|
415
423
|
suffixFontSize = Double.NaN
|
|
416
424
|
signPlacement = NitroInputSignPlacement.BEFOREAFFIX
|
|
417
|
-
|
|
425
|
+
textLetterSpacing = 0.0
|
|
418
426
|
prefixSpacing = Double.POSITIVE_INFINITY
|
|
419
427
|
suffixSpacing = Double.POSITIVE_INFINITY
|
|
420
428
|
prefixOffset = 0.0
|
|
@@ -438,12 +446,12 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
438
446
|
easing = NitroInputEasing.EXPO
|
|
439
447
|
bounce = 0.15
|
|
440
448
|
effect = NitroInputEffect.AUTO
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
449
|
+
textSize = 32.0
|
|
450
|
+
textLineHeight = 0.0
|
|
451
|
+
textWeight = 400.0
|
|
452
|
+
textFamily = ""
|
|
453
|
+
textColor = Double.NaN
|
|
454
|
+
textAlignment = NitroInputTextAlign.AUTO
|
|
447
455
|
rightToLeft = false
|
|
448
456
|
caretColor = Double.NaN
|
|
449
457
|
selectionColor = Double.NaN
|
|
@@ -459,7 +467,11 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
459
467
|
editable = true
|
|
460
468
|
multiline = false
|
|
461
469
|
numberOfLines = 0.0
|
|
462
|
-
|
|
470
|
+
textVerticalAlignment = NitroInputTextAlignVertical.AUTO
|
|
471
|
+
textInsetLeft = 0.0
|
|
472
|
+
textInsetTop = 0.0
|
|
473
|
+
textInsetRight = 0.0
|
|
474
|
+
textInsetBottom = 0.0
|
|
463
475
|
scrollEnabled = true
|
|
464
476
|
autoFocus = false
|
|
465
477
|
plain = false
|
|
@@ -505,7 +517,10 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
505
517
|
configDirty = true
|
|
506
518
|
textDirty = true
|
|
507
519
|
isBatching = false
|
|
508
|
-
onMain {
|
|
520
|
+
onMain {
|
|
521
|
+
configured = false
|
|
522
|
+
inputView.resetForRecycle()
|
|
523
|
+
}
|
|
509
524
|
}
|
|
510
525
|
|
|
511
526
|
// endregion
|
|
@@ -565,12 +580,35 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
565
580
|
else -> null
|
|
566
581
|
}
|
|
567
582
|
|
|
583
|
+
/**
|
|
584
|
+
* Whether the props have been applied since the view was made or recycled.
|
|
585
|
+
* Until then its size is the defaults' (or the last element's), and JS, which
|
|
586
|
+
* lays the field out at its measured size from the first commit, must not
|
|
587
|
+
* see it: a stray report made the field jump to it and back.
|
|
588
|
+
*/
|
|
589
|
+
private var configured = false
|
|
590
|
+
/** Inside [commit], where a size is of half-applied props. */
|
|
591
|
+
private var committing = false
|
|
592
|
+
/** A size was held back by the two above, so the settled one is sent after. */
|
|
593
|
+
private var sizeHeld = false
|
|
594
|
+
|
|
568
595
|
private fun commit() {
|
|
569
596
|
onMain {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
597
|
+
committing = true
|
|
598
|
+
try {
|
|
599
|
+
inputView.batch {
|
|
600
|
+
flushConfigIfNeeded()
|
|
601
|
+
flushTextIfNeeded()
|
|
602
|
+
flushSelectionIfNeeded()
|
|
603
|
+
}
|
|
604
|
+
} finally {
|
|
605
|
+
committing = false
|
|
606
|
+
}
|
|
607
|
+
// Once after the first commit, so JS always hears the view's size.
|
|
608
|
+
if (!configured || sizeHeld) {
|
|
609
|
+
configured = true
|
|
610
|
+
sizeHeld = false
|
|
611
|
+
inputView.resendIntrinsicSize()
|
|
574
612
|
}
|
|
575
613
|
}
|
|
576
614
|
}
|
|
@@ -601,54 +639,18 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
601
639
|
if (!configDirty) return
|
|
602
640
|
configDirty = false
|
|
603
641
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
else -> NitroInputView.Mode.TEXT
|
|
610
|
-
},
|
|
611
|
-
mask = mask,
|
|
612
|
-
maskNotations = maskNotations.map {
|
|
613
|
-
NitroInputView.MaskNotation(it.character, it.characterSet, it.isOptional)
|
|
614
|
-
},
|
|
615
|
-
maskAutocomplete = maskAutocomplete,
|
|
616
|
-
maskAutoSkip = maskAutoSkip,
|
|
617
|
-
maskAffinityFormats = maskAffinityFormats.toList(),
|
|
618
|
-
maskAffinityStrategy = maskAffinityStrategy.value,
|
|
619
|
-
maskTextCase = maskTextCase.value,
|
|
620
|
-
maskCharacterMap = maskCharacterMap.map { NitroInputView.MaskMapping(it.from, it.to) },
|
|
621
|
-
maskSlotPlaceholder = maskSlotPlaceholder,
|
|
622
|
-
keepPlaceholder = keepPlaceholder,
|
|
623
|
-
fractionDigits = clampInt(fractionDigits, 0, 9, 2),
|
|
624
|
-
maxIntegerDigits = clampInt(maxIntegerDigits, 1, 30, 15),
|
|
625
|
-
groupingSeparator = groupingSeparator,
|
|
626
|
-
decimalSeparator = decimalSeparator,
|
|
627
|
-
prefix = prefix,
|
|
628
|
-
suffix = suffix,
|
|
629
|
-
signBeforeAffix = signPlacement != NitroInputSignPlacement.AFTERAFFIX,
|
|
630
|
-
placeholder = placeholder,
|
|
631
|
-
)
|
|
632
|
-
inputView.typography = NitroInputView.Typography(
|
|
633
|
-
fontSize = size,
|
|
634
|
-
lineHeightPx = (Math.max(0.0, finite(lineHeight, 0.0)) * inputView.resources.displayMetrics.density).toFloat(),
|
|
635
|
-
prefixFontSize = finite(prefixFontSize, size.toDouble()).toFloat(),
|
|
636
|
-
suffixFontSize = finite(suffixFontSize, size.toDouble()).toFloat(),
|
|
637
|
-
fontWeight = clampInt(fontWeight, 100, 900, 400),
|
|
638
|
-
fontFamily = fontFamily.ifEmpty { null },
|
|
639
|
-
color = colorFromARGB(color),
|
|
642
|
+
// The sizing half of the mapping is shared with HybridNitroInputMeasure,
|
|
643
|
+
// which sizes the field before this view exists.
|
|
644
|
+
inputView.format = formatOf(this)
|
|
645
|
+
inputView.typography = sizingTypographyOf(this, inputView.resources.displayMetrics.density).copy(
|
|
646
|
+
color = colorFromARGB(textColor),
|
|
640
647
|
placeholderColor = colorFromARGB(placeholderColor),
|
|
641
648
|
prefixAlign = mapAffixAlign(prefixAlign),
|
|
642
649
|
suffixAlign = mapAffixAlign(suffixAlign),
|
|
643
|
-
letterSpacing = if (letterSpacing.isFinite()) letterSpacing.toFloat() else 0f,
|
|
644
|
-
prefixSpacing = prefixSpacing.takeIf { it.isFinite() }?.toFloat(),
|
|
645
|
-
suffixSpacing = suffixSpacing.takeIf { it.isFinite() }?.toFloat(),
|
|
646
650
|
prefixOffset = if (prefixOffset.isFinite()) prefixOffset.toFloat() else 0f,
|
|
647
651
|
suffixOffset = if (suffixOffset.isFinite()) suffixOffset.toFloat() else 0f,
|
|
648
652
|
adjustsFontSizeToFit = adjustsFontSizeToFit,
|
|
649
653
|
minimumFontScale = finite(minimumFontScale, 0.5).coerceIn(0.05, 1.0).toFloat(),
|
|
650
|
-
allowFontScaling = allowFontScaling,
|
|
651
|
-
maxFontSizeMultiplier = Math.max(0.0, finite(maxFontSizeMultiplier, 0.0)).toFloat(),
|
|
652
654
|
)
|
|
653
655
|
inputView.worklets = NitroInputView.Worklets(
|
|
654
656
|
transform = clampInt(transformWorklet, 0, Int.MAX_VALUE, 0),
|
|
@@ -709,7 +711,7 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
709
711
|
plain = plain,
|
|
710
712
|
multiline = multiline,
|
|
711
713
|
numberOfLines = clampInt(numberOfLines, 0, 1000, 0),
|
|
712
|
-
textAlignVertical = when (
|
|
714
|
+
textAlignVertical = when (textVerticalAlignment) {
|
|
713
715
|
NitroInputTextAlignVertical.TOP -> NitroInputView.TextAlignVertical.TOP
|
|
714
716
|
NitroInputTextAlignVertical.CENTER -> NitroInputView.TextAlignVertical.CENTER
|
|
715
717
|
NitroInputTextAlignVertical.BOTTOM -> NitroInputView.TextAlignVertical.BOTTOM
|
|
@@ -737,27 +739,19 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
737
739
|
selectionColor = colorFromARGB(selectionColor),
|
|
738
740
|
hidden = caretHidden,
|
|
739
741
|
)
|
|
740
|
-
inputView.inputFrame =
|
|
741
|
-
variant = when (variant) {
|
|
742
|
-
NitroInputVariant.OUTLINED -> NitroInputView.Variant.OUTLINED
|
|
743
|
-
NitroInputVariant.FILLED -> NitroInputView.Variant.FILLED
|
|
744
|
-
NitroInputVariant.NONE -> NitroInputView.Variant.NONE
|
|
745
|
-
},
|
|
746
|
-
label = label,
|
|
747
|
-
labelBehavior = when (labelBehavior) {
|
|
748
|
-
NitroInputLabelBehavior.ALWAYS -> NitroInputView.LabelBehavior.ALWAYS
|
|
749
|
-
NitroInputLabelBehavior.FLOAT -> NitroInputView.LabelBehavior.FLOAT
|
|
750
|
-
},
|
|
742
|
+
inputView.inputFrame = sizingFrameOf(this).copy(
|
|
751
743
|
labelColor = colorFromARGB(labelColor),
|
|
752
744
|
labelFocusedColor = colorFromARGB(labelFocusedColor),
|
|
753
|
-
labelFontSize = Math.max(0.0, finite(labelFontSize, 0.0)).toFloat(),
|
|
754
745
|
strokeColor = colorFromARGB(strokeColor),
|
|
755
746
|
focusedStrokeColor = colorFromARGB(focusedStrokeColor),
|
|
756
747
|
strokeWidth = Math.max(0.0, finite(strokeWidth, 1.0)).toFloat(),
|
|
757
|
-
cornerRadius = Math.max(0.0, finite(cornerRadius, 8.0)).toFloat(),
|
|
758
748
|
fillColor = colorFromARGB(fillColor),
|
|
759
749
|
)
|
|
760
|
-
inputView.
|
|
750
|
+
inputView.contentInsets = android.graphics.RectF(
|
|
751
|
+
Math.max(0.0, finite(textInsetLeft, 0.0)).toFloat(), Math.max(0.0, finite(textInsetTop, 0.0)).toFloat(),
|
|
752
|
+
Math.max(0.0, finite(textInsetRight, 0.0)).toFloat(), Math.max(0.0, finite(textInsetBottom, 0.0)).toFloat(),
|
|
753
|
+
)
|
|
754
|
+
inputView.alignment = when (textAlignment) {
|
|
761
755
|
NitroInputTextAlign.CENTER -> NitroInputView.Alignment.CENTER
|
|
762
756
|
NitroInputTextAlign.RIGHT -> NitroInputView.Alignment.RIGHT
|
|
763
757
|
NitroInputTextAlign.LEFT -> NitroInputView.Alignment.LEFT
|
|
@@ -141,7 +141,7 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
141
141
|
set(v) { field = v; markConfigDirty() }
|
|
142
142
|
override var shimmerDelay: Double? = null
|
|
143
143
|
set(v) { field = v; markConfigDirty() }
|
|
144
|
-
override var
|
|
144
|
+
override var textSize: Double? = null
|
|
145
145
|
set(v) { field = v; markConfigDirty() }
|
|
146
146
|
override var prefixFontSize: Double? = null
|
|
147
147
|
set(v) { field = v; markConfigDirty() }
|
|
@@ -153,7 +153,7 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
153
153
|
set(v) { field = v; markConfigDirty() }
|
|
154
154
|
override var suffixAlign: NitroNumberAffixAlign? = null
|
|
155
155
|
set(v) { field = v; markConfigDirty() }
|
|
156
|
-
override var
|
|
156
|
+
override var textLetterSpacing: Double? = null
|
|
157
157
|
set(v) { field = v; markConfigDirty() }
|
|
158
158
|
override var prefixSpacing: Double? = null
|
|
159
159
|
set(v) { field = v; markConfigDirty() }
|
|
@@ -201,13 +201,13 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
201
201
|
set(v) { field = v; markConfigDirty() }
|
|
202
202
|
override var maxFontSizeMultiplier: Double? = null
|
|
203
203
|
set(v) { field = v; markConfigDirty() }
|
|
204
|
-
override var
|
|
204
|
+
override var textWeight: Double? = null
|
|
205
205
|
set(v) { field = v; markConfigDirty() }
|
|
206
|
-
override var
|
|
206
|
+
override var textFamily: String? = null
|
|
207
207
|
set(v) { field = v; markConfigDirty() }
|
|
208
|
-
override var
|
|
208
|
+
override var textColor: Double? = null
|
|
209
209
|
set(v) { field = v; markConfigDirty() }
|
|
210
|
-
override var
|
|
210
|
+
override var textAlignment: NitroNumberTextAlign? = null
|
|
211
211
|
set(v) { field = v; markConfigDirty() }
|
|
212
212
|
override var rightToLeft: Boolean? = null
|
|
213
213
|
set(v) { field = v; markConfigDirty() }
|
|
@@ -360,13 +360,13 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
360
360
|
shimmerBaseColor = null
|
|
361
361
|
shimmerDirection = null
|
|
362
362
|
shimmerDelay = null
|
|
363
|
-
|
|
363
|
+
textSize = null
|
|
364
364
|
prefixFontSize = null
|
|
365
365
|
suffixFontSize = null
|
|
366
366
|
affixAlign = null
|
|
367
367
|
prefixAlign = null
|
|
368
368
|
suffixAlign = null
|
|
369
|
-
|
|
369
|
+
textLetterSpacing = null
|
|
370
370
|
prefixSpacing = null
|
|
371
371
|
suffixSpacing = null
|
|
372
372
|
prefixOffset = null
|
|
@@ -391,10 +391,10 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
391
391
|
minimumFontScale = null
|
|
392
392
|
allowFontScaling = null
|
|
393
393
|
maxFontSizeMultiplier = null
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
394
|
+
textWeight = null
|
|
395
|
+
textFamily = null
|
|
396
|
+
textColor = null
|
|
397
|
+
textAlignment = null
|
|
398
398
|
rightToLeft = null
|
|
399
399
|
onSizeChange = null
|
|
400
400
|
configDirty = true
|
|
@@ -447,15 +447,15 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
447
447
|
configDirty = false
|
|
448
448
|
|
|
449
449
|
rollingView.typography = NitroNumberView.Typography(
|
|
450
|
-
fontSize = (
|
|
450
|
+
fontSize = (textSize ?: 32.0).toFloat(),
|
|
451
451
|
prefixFontSize = prefixFontSize?.toFloat(),
|
|
452
452
|
suffixFontSize = suffixFontSize?.toFloat(),
|
|
453
|
-
fontWeight = clampInt(
|
|
454
|
-
fontFamily =
|
|
455
|
-
color =
|
|
453
|
+
fontWeight = clampInt(textWeight, 100, 900, 400),
|
|
454
|
+
fontFamily = textFamily,
|
|
455
|
+
color = textColor?.let { colorFromARGB(it) },
|
|
456
456
|
prefixAlign = mapAffixAlign(prefixAlign ?: affixAlign),
|
|
457
457
|
suffixAlign = mapAffixAlign(suffixAlign ?: affixAlign),
|
|
458
|
-
letterSpacing = (
|
|
458
|
+
letterSpacing = (textLetterSpacing ?: 0.0).takeIf { it.isFinite() }?.toFloat() ?: 0f,
|
|
459
459
|
prefixSpacing = prefixSpacing?.takeIf { it.isFinite() }?.toFloat(),
|
|
460
460
|
suffixSpacing = suffixSpacing?.takeIf { it.isFinite() }?.toFloat(),
|
|
461
461
|
prefixOffset = (prefixOffset ?: 0.0).takeIf { it.isFinite() }?.toFloat() ?: 0f,
|
|
@@ -545,7 +545,7 @@ class HybridNitroNumberView(private val context: ThemedReactContext) : HybridNit
|
|
|
545
545
|
downColor = flashDownColor?.let { colorFromARGB(it) },
|
|
546
546
|
durationMs = Math.max(50.0, flashDuration ?: 600.0).toLong(),
|
|
547
547
|
)
|
|
548
|
-
rollingView.alignment = when (
|
|
548
|
+
rollingView.alignment = when (textAlignment) {
|
|
549
549
|
NitroNumberTextAlign.CENTER -> NitroNumberView.Alignment.CENTER
|
|
550
550
|
NitroNumberTextAlign.RIGHT -> NitroNumberView.Alignment.RIGHT
|
|
551
551
|
NitroNumberTextAlign.LEFT -> NitroNumberView.Alignment.LEFT
|
|
@@ -26,12 +26,12 @@ class HybridNitroTextView(private val context: ThemedReactContext) : HybridNitro
|
|
|
26
26
|
|
|
27
27
|
override var text: String = ""
|
|
28
28
|
// Unset unless the element set it: the wrapper sends only those.
|
|
29
|
-
override var
|
|
30
|
-
override var
|
|
31
|
-
override var
|
|
32
|
-
override var
|
|
33
|
-
override var
|
|
34
|
-
override var
|
|
29
|
+
override var textSize: Double? = null
|
|
30
|
+
override var textWeight: Double? = null
|
|
31
|
+
override var textFamily: String? = null
|
|
32
|
+
override var textColor: Double? = null
|
|
33
|
+
override var textLetterSpacing: Double? = null
|
|
34
|
+
override var textAlignment: NitroNumberTextAlign? = null
|
|
35
35
|
override var rightToLeft: Boolean? = null
|
|
36
36
|
override var duration: Double? = null
|
|
37
37
|
override var easing: NitroInputEasing? = null
|
|
@@ -57,12 +57,12 @@ class HybridNitroTextView(private val context: ThemedReactContext) : HybridNitro
|
|
|
57
57
|
|
|
58
58
|
private fun apply() {
|
|
59
59
|
textView.style = NitroTextView.Style(
|
|
60
|
-
fontSize =
|
|
61
|
-
fontWeight =
|
|
62
|
-
fontFamily =
|
|
63
|
-
color =
|
|
64
|
-
letterSpacing = (
|
|
65
|
-
textAlign = when (
|
|
60
|
+
fontSize = textSize?.takeIf { it.isFinite() && it > 0 } ?: 17.0,
|
|
61
|
+
fontWeight = textWeight?.takeIf { it.isFinite() } ?: 400.0,
|
|
62
|
+
fontFamily = textFamily ?: "",
|
|
63
|
+
color = textColor?.let(::colorFromARGB),
|
|
64
|
+
letterSpacing = (textLetterSpacing?.takeIf { it.isFinite() } ?: 0.0).toFloat(),
|
|
65
|
+
textAlign = when (textAlignment) {
|
|
66
66
|
NitroNumberTextAlign.LEFT -> NitroNumberView.Alignment.LEFT
|
|
67
67
|
NitroNumberTextAlign.CENTER -> NitroNumberView.Alignment.CENTER
|
|
68
68
|
NitroNumberTextAlign.RIGHT -> NitroNumberView.Alignment.RIGHT
|
|
@@ -116,8 +116,8 @@ class HybridNitroTextView(private val context: ThemedReactContext) : HybridNitro
|
|
|
116
116
|
override fun prepareForRecycle() {
|
|
117
117
|
// The next element's props arrive as a first mount's do, only the ones it set.
|
|
118
118
|
text = ""
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
textSize = null; textWeight = null; textFamily = null; textColor = null; textLetterSpacing = null
|
|
120
|
+
textAlignment = null; rightToLeft = null
|
|
121
121
|
duration = null; easing = null; bounce = null; effect = null; respectReduceMotion = null
|
|
122
122
|
loading = null
|
|
123
123
|
shimmerColor = null; shimmerDuration = null; shimmerAngle = null; shimmerWidth = null
|