@onekeyfe/react-native-native-list 6.7.0-alpha.324 → 6.7.0-alpha.327

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -1
  2. package/docs/SPEC.md +15 -2
  3. package/ios/HybridNativeList.swift +11 -3
  4. package/ios/RNCNativeListView.swift +10 -6
  5. package/ios/tests/NativeListLifecycleTests.swift +28 -0
  6. package/lib/module/NativeList.js +2 -2
  7. package/lib/module/ScrollEdgeEffect.js +8 -0
  8. package/lib/module/index.js +1 -0
  9. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
  10. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
  11. package/lib/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
  12. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
  13. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
  14. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
  15. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
  16. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
  17. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
  18. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
  19. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
  20. package/lib/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
  21. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
  22. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
  23. package/lib/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
  24. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
  25. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
  26. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
  27. package/lib/typescript/src/NativeList.nitro.d.ts +2 -1
  28. package/lib/typescript/src/NativeList.types.d.ts +3 -2
  29. package/lib/typescript/src/ScrollEdgeEffect.d.ts +5 -0
  30. package/lib/typescript/src/index.d.ts +1 -0
  31. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
  32. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
  33. package/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
  34. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
  37. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
  38. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
  39. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
  40. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
  41. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
  42. package/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
  43. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
  44. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
  45. package/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
  46. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
  47. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
  48. package/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
  49. package/package.json +3 -3
  50. package/react-native-native-list.podspec +4 -1
  51. package/src/NativeList.nitro.ts +3 -1
  52. package/src/NativeList.tsx +4 -2
  53. package/src/NativeList.types.ts +3 -2
  54. package/src/ScrollEdgeEffect.ts +4 -0
  55. package/src/index.ts +2 -0
@@ -52,7 +52,7 @@ class HybridNativeList(context: ThemedReactContext) : HybridNativeListSpec() {
52
52
  snapshot?.let { hostView.applySnapshot(it) }
53
53
  }
54
54
  }
55
- override var topScrollEdgeHard: Boolean = false
55
+ override var topScrollEdgeEffect: NativeListScrollEdgeEffect = NativeListScrollEdgeEffect.NONE
56
56
  override var topOverlayHeight: Double = 0.0
57
57
 
58
58
  override var snapshotJson: String = ""
package/docs/SPEC.md CHANGED
@@ -28,13 +28,14 @@ prevention; there is no automatic fitting or shrinking pass.
28
28
 
29
29
  ### iOS 26 fixed top scroll-edge overlay
30
30
 
31
- Standalone `NativeList` accepts optional `topScrollEdgeEffect="hard"` and
31
+ Standalone `NativeList` accepts optional
32
+ `topScrollEdgeEffect={ScrollEdgeEffect.Hard}` or `ScrollEdgeEffect.Soft` and
32
33
  `topOverlay` React content. Both are disabled by default. On iOS 26 or newer,
33
34
  the fixed overlay is a fourth native container slot, outside the row stream and
34
35
  outside the existing scrolling `listHeader`/`listEmpty`/`listFooter` slots.
35
36
  Fabric measures its height; the list owns an equal top inset on its collection
36
37
  view and binds UIKit's `UIScrollEdgeElementContainerInteraction` to that view,
37
- using the hard top edge style. The list restores its original inset and effect
38
+ using the requested top edge style. The list restores its original inset and effect
38
39
  on removal, disposal and reuse. The UI thread owns all view and UIKit state;
39
40
  there is no persistence, background-runtime state or per-frame JS callback.
40
41
  An invisible, noninteractive native label fills the overlay host so UIKit
@@ -45,6 +46,18 @@ existing layout and scrolling. Missing overlay or style changes nothing.
45
46
  Acceptance requires actual iOS 26 initial layout, long/short/empty scrolling,
46
47
  refresh and overlay replacement/removal, including dark mode.
47
48
 
49
+ `ScrollEdgeEffect` is an exported string enum (`Hard = 'hard'`, `Soft = 'soft'`);
50
+ the corresponding string literals remain valid prop values. Hard includes
51
+ UIKit's dividing line; Soft uses the gradual blurred transition. Nitro receives
52
+ an enum (`none | hard | soft`, default `none`) rather than a hard-effect boolean.
53
+ Changing Hard ↔ Soft preserves the overlay, inset, logical scroll offset and
54
+ saved original effect. Clearing the prop, removing the overlay, detaching or
55
+ disposing restores the original effect. This bridge change requires rebuilding
56
+ the matching native host. Soft selection is implemented in the wrapper and
57
+ native host. Focused JS tests cover enum forwarding and disabling; UIKit tests
58
+ cover style switching, overlay geometry and restoring the previous style.
59
+ Visual runtime acceptance remains separate from source, type and build checks.
60
+
48
61
  [README.md](../README.md) documents the snapshot, patch, selection, events and
49
62
  imperative API; [STYLE_SPEC.md](STYLE_SPEC.md) defines normalization, omitted
50
63
  style defaults and platform differences. Height precedence is
@@ -43,19 +43,27 @@ final class HybridNativeList: HybridNativeListSpec {
43
43
  didSet { if fontFamiliesJson != oldValue { fontsChanged = true } }
44
44
  }
45
45
 
46
- var topScrollEdgeHard = false {
46
+ var topScrollEdgeEffect: NativeListScrollEdgeEffect = .none {
47
47
  didSet {
48
48
  runOnMain { [weak self] in
49
- self?.hostView?.setTopScrollEdge(hard: self?.topScrollEdgeHard ?? false,
49
+ self?.hostView?.setTopScrollEdge(effect: self?.topEdgeStyle ?? .none,
50
50
  overlayHeight: CGFloat(self?.topOverlayHeight ?? 0))
51
51
  }
52
52
  }
53
53
  }
54
54
 
55
+ private var topEdgeStyle: NativeListTopScrollEdgeEffect {
56
+ switch topScrollEdgeEffect {
57
+ case .none: return .none
58
+ case .hard: return .hard
59
+ case .soft: return .soft
60
+ }
61
+ }
62
+
55
63
  var topOverlayHeight: Double = 0 {
56
64
  didSet {
57
65
  runOnMain { [weak self] in
58
- self?.hostView?.setTopScrollEdge(hard: self?.topScrollEdgeHard ?? false,
66
+ self?.hostView?.setTopScrollEdge(effect: self?.topEdgeStyle ?? .none,
59
67
  overlayHeight: CGFloat(self?.topOverlayHeight ?? 0))
60
68
  }
61
69
  }
@@ -3,6 +3,10 @@ import CoreFoundation
3
3
  import UIKit
4
4
  import UniformTypeIdentifiers
5
5
 
6
+ enum NativeListTopScrollEdgeEffect {
7
+ case none, hard, soft
8
+ }
9
+
6
10
  final class NativeListView: UIView {
7
11
  private var fonts = NativeListFontFamilies()
8
12
 
@@ -36,7 +40,7 @@ final class NativeListView: UIView {
36
40
  private var topEdgeInteraction: UIInteraction?
37
41
  private var topEdgeMarker: UILabel?
38
42
  private var originalTopEdgeStyle: AnyObject?
39
- private var topScrollEdgeHard = false
43
+ private var topScrollEdgeEffect: NativeListTopScrollEdgeEffect = .none
40
44
  private var requestedTopOverlayHeight: CGFloat = 0
41
45
  private var appliedTopOverlayInset: CGFloat = 0
42
46
 
@@ -78,8 +82,8 @@ final class NativeListView: UIView {
78
82
  }
79
83
  }
80
84
 
81
- func setTopScrollEdge(hard: Bool, overlayHeight: CGFloat) {
82
- topScrollEdgeHard = hard
85
+ func setTopScrollEdge(effect: NativeListTopScrollEdgeEffect, overlayHeight: CGFloat) {
86
+ topScrollEdgeEffect = effect
83
87
  requestedTopOverlayHeight = overlayHeight.isFinite ? max(0, overlayHeight) : 0
84
88
  updateTopScrollEdge()
85
89
  setNeedsLayout()
@@ -87,7 +91,7 @@ final class NativeListView: UIView {
87
91
 
88
92
  private func updateTopScrollEdge() {
89
93
  if #available(iOS 26.0, *) {
90
- let hasOverlay = topScrollEdgeHard && topOverlayContent != nil
94
+ let hasOverlay = topScrollEdgeEffect != .none && topOverlayContent != nil
91
95
  let enabled = hasOverlay && window != nil
92
96
  let nextInset = hasOverlay ? requestedTopOverlayHeight : 0
93
97
  if nextInset != appliedTopOverlayInset {
@@ -134,7 +138,7 @@ final class NativeListView: UIView {
134
138
  }
135
139
  originalTopEdgeStyle = nil
136
140
  }
137
- if enabled { collectionView.topEdgeEffect.style = .hard }
141
+ if enabled { collectionView.topEdgeEffect.style = topScrollEdgeEffect == .soft ? .soft : .hard }
138
142
  }
139
143
  }
140
144
 
@@ -2107,7 +2111,7 @@ final class NativeListView: UIView {
2107
2111
 
2108
2112
  func dispose() {
2109
2113
  guard !disposed else { return }
2110
- setTopScrollEdge(hard: false, overlayHeight: 0)
2114
+ setTopScrollEdge(effect: .none, overlayHeight: 0)
2111
2115
  disposed = true
2112
2116
 
2113
2117
  disposeActionAnchor()
@@ -4,6 +4,34 @@ import XCTest
4
4
 
5
5
  @MainActor
6
6
  final class NativeListLifecycleTests: XCTestCase {
7
+ func testScrollEdgeStylesPreserveOverlayGeometryAndRestoreOriginalStyle() throws {
8
+ guard #available(iOS 26.0, *) else {
9
+ throw XCTSkip("Scroll-edge styles require iOS 26 or newer")
10
+ }
11
+ let view = try makeScrollingList()
12
+ let window = UIWindow(frame: view.frame)
13
+ window.addSubview(view)
14
+ let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
15
+ let originalStyle = list.topEdgeEffect.style
16
+ let originalInset = list.contentInset.top
17
+ let overlay = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 64))
18
+ view.mountContainerSlot(overlay, atIndex: 3)
19
+ view.setTopScrollEdge(effect: .hard, overlayHeight: 64)
20
+ XCTAssertEqual(list.topEdgeEffect.style, .hard)
21
+ XCTAssertEqual(list.contentInset.top, originalInset + 64, accuracy: 0.01)
22
+ let offset = list.contentOffset
23
+ view.setTopScrollEdge(effect: .soft, overlayHeight: 64)
24
+ XCTAssertEqual(list.topEdgeEffect.style, .soft)
25
+ XCTAssertEqual(list.contentInset.top, originalInset + 64, accuracy: 0.01)
26
+ XCTAssertEqual(list.contentOffset, offset)
27
+ XCTAssertNotNil(overlay.superview)
28
+ view.setTopScrollEdge(effect: .none, overlayHeight: 0)
29
+ XCTAssertEqual(list.topEdgeEffect.style, originalStyle)
30
+ XCTAssertEqual(list.contentInset.top, originalInset, accuracy: 0.01)
31
+ view.unmountContainerSlot(overlay)
32
+ view.removeFromSuperview()
33
+ }
34
+
7
35
  func testInvalidCommandsPreserveAcceptedAnimationCompletion() throws {
8
36
  for invalid in 0..<3 {
9
37
  let view = try makeScrollingList()
@@ -56,7 +56,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
56
56
  const fontFamiliesJson = useNativeListFontFamiliesJson();
57
57
  const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
58
58
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
59
- const hasTopOverlay = Platform?.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26 && topScrollEdgeEffect === 'hard' && topOverlay != null;
59
+ const hasTopOverlay = Platform?.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26 && (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') && topOverlay != null;
60
60
  const containerSlotHeightsJson = JSON.stringify(slotHeights);
61
61
  const slotInset = snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0;
62
62
  if (snapshot.layout.orientation === 'horizontal' && (listHeader || listEmpty || listFooter)) {
@@ -325,7 +325,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
325
325
  fontFamiliesJson: fontFamiliesJson,
326
326
  snapshotJson: snapshotJson,
327
327
  containerSlotHeightsJson: containerSlotHeightsJson,
328
- topScrollEdgeHard: hasTopOverlay,
328
+ topScrollEdgeEffect: hasTopOverlay ? topScrollEdgeEffect ?? 'none' : 'none',
329
329
  topOverlayHeight: hasTopOverlay ? topOverlayHeight : 0,
330
330
  scrollPositionThresholdsJson: scrollPositionThresholdsJson,
331
331
  keyboardDismissMode: keyboardDismissMode,
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ export let ScrollEdgeEffect = /*#__PURE__*/function (ScrollEdgeEffect) {
4
+ ScrollEdgeEffect["Hard"] = "hard";
5
+ ScrollEdgeEffect["Soft"] = "soft";
6
+ return ScrollEdgeEffect;
7
+ }({});
8
+ //# sourceMappingURL=ScrollEdgeEffect.js.map
@@ -4,4 +4,5 @@ export { NativeList, preloadNativeListAvatarImages } from './NativeList';
4
4
  export { applyRowPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot } from "./validation.js";
5
5
  export { checkboxStateForKeys, checkboxStateForSection, isSelectableRow, reduceSelection, selectionStateFromSnapshot } from "./selection.js";
6
6
  export { configureNativeListFonts } from "./fonts.js";
7
+ export { ScrollEdgeEffect } from "./ScrollEdgeEffect.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -7,6 +7,8 @@
7
7
 
8
8
  #include "JHybridNativeListSpec.hpp"
9
9
 
10
+ // Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
11
+ namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
10
12
  // Forward declaration of `NativeListKeyboardDismissMode` to properly resolve imports.
11
13
  namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode; }
12
14
  // Forward declaration of `NativeListKeyboardShouldPersistTaps` to properly resolve imports.
@@ -15,6 +17,8 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersis
15
17
  namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
16
18
 
17
19
  #include <string>
20
+ #include "NativeListScrollEdgeEffect.hpp"
21
+ #include "JNativeListScrollEdgeEffect.hpp"
18
22
  #include <functional>
19
23
  #include <optional>
20
24
  #include "JFunc_void_bool.hpp"
@@ -84,14 +88,14 @@ namespace margelo::nitro::nativelist {
84
88
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* containerSlotHeightsJson */)>("setContainerSlotHeightsJson");
85
89
  method(_javaPart, jni::make_jstring(containerSlotHeightsJson));
86
90
  }
87
- bool JHybridNativeListSpec::getTopScrollEdgeHard() {
88
- static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getTopScrollEdgeHard");
91
+ NativeListScrollEdgeEffect JHybridNativeListSpec::getTopScrollEdgeEffect() {
92
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JNativeListScrollEdgeEffect>()>("getTopScrollEdgeEffect");
89
93
  auto __result = method(_javaPart);
90
- return static_cast<bool>(__result);
94
+ return __result->toCpp();
91
95
  }
92
- void JHybridNativeListSpec::setTopScrollEdgeHard(bool topScrollEdgeHard) {
93
- static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* topScrollEdgeHard */)>("setTopScrollEdgeHard");
94
- method(_javaPart, topScrollEdgeHard);
96
+ void JHybridNativeListSpec::setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) {
97
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JNativeListScrollEdgeEffect> /* topScrollEdgeEffect */)>("setTopScrollEdgeEffect");
98
+ method(_javaPart, JNativeListScrollEdgeEffect::fromCpp(topScrollEdgeEffect));
95
99
  }
96
100
  double JHybridNativeListSpec::getTopOverlayHeight() {
97
101
  static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getTopOverlayHeight");
@@ -56,8 +56,8 @@ namespace margelo::nitro::nativelist {
56
56
  void setFontFamiliesJson(const std::string& fontFamiliesJson) override;
57
57
  std::string getContainerSlotHeightsJson() override;
58
58
  void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) override;
59
- bool getTopScrollEdgeHard() override;
60
- void setTopScrollEdgeHard(bool topScrollEdgeHard) override;
59
+ NativeListScrollEdgeEffect getTopScrollEdgeEffect() override;
60
+ void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) override;
61
61
  double getTopOverlayHeight() override;
62
62
  void setTopOverlayHeight(double topOverlayHeight) override;
63
63
  std::string getScrollPositionThresholdsJson() override;
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JNativeListScrollEdgeEffect.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 "NativeListScrollEdgeEffect.hpp"
12
+
13
+ namespace margelo::nitro::nativelist {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "NativeListScrollEdgeEffect" and the Kotlin enum "NativeListScrollEdgeEffect".
19
+ */
20
+ struct JNativeListScrollEdgeEffect final: public jni::JavaClass<JNativeListScrollEdgeEffect> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/NativeListScrollEdgeEffect;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum NativeListScrollEdgeEffect.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ NativeListScrollEdgeEffect toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<NativeListScrollEdgeEffect>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JNativeListScrollEdgeEffect> fromCpp(NativeListScrollEdgeEffect value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case NativeListScrollEdgeEffect::NONE:
46
+ static const auto fieldNONE = clazz->getStaticField<JNativeListScrollEdgeEffect>("NONE");
47
+ return clazz->getStaticFieldValue(fieldNONE);
48
+ case NativeListScrollEdgeEffect::HARD:
49
+ static const auto fieldHARD = clazz->getStaticField<JNativeListScrollEdgeEffect>("HARD");
50
+ return clazz->getStaticFieldValue(fieldHARD);
51
+ case NativeListScrollEdgeEffect::SOFT:
52
+ static const auto fieldSOFT = clazz->getStaticField<JNativeListScrollEdgeEffect>("SOFT");
53
+ return clazz->getStaticFieldValue(fieldSOFT);
54
+ default:
55
+ std::string stringValue = std::to_string(static_cast<int>(value));
56
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
57
+ }
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::nativelist
@@ -69,9 +69,9 @@ void JHybridNativeListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
69
69
  hybridView->setContainerSlotHeightsJson(newProps->containerSlotHeightsJson.get());
70
70
  }
71
71
  if (oldProps == nullptr
72
- ? newProps->topScrollEdgeHard.isProvided()
73
- : !newProps->topScrollEdgeHard.hasSameValue(oldProps->topScrollEdgeHard)) {
74
- hybridView->setTopScrollEdgeHard(newProps->topScrollEdgeHard.get());
72
+ ? newProps->topScrollEdgeEffect.isProvided()
73
+ : !newProps->topScrollEdgeEffect.hasSameValue(oldProps->topScrollEdgeEffect)) {
74
+ hybridView->setTopScrollEdgeEffect(newProps->topScrollEdgeEffect.get());
75
75
  }
76
76
  if (oldProps == nullptr
77
77
  ? newProps->topOverlayHeight.isProvided()
@@ -49,7 +49,7 @@ abstract class HybridNativeListSpec: HybridView() {
49
49
  @get:Keep
50
50
  @set:DoNotStrip
51
51
  @set:Keep
52
- abstract var topScrollEdgeHard: Boolean
52
+ abstract var topScrollEdgeEffect: NativeListScrollEdgeEffect
53
53
 
54
54
  @get:DoNotStrip
55
55
  @get:Keep
@@ -0,0 +1,24 @@
1
+ ///
2
+ /// NativeListScrollEdgeEffect.kt
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
+ package com.margelo.nitro.nativelist
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "NativeListScrollEdgeEffect".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class NativeListScrollEdgeEffect(@DoNotStrip @Keep val value: Int) {
19
+ NONE(0),
20
+ HARD(1),
21
+ SOFT(2);
22
+
23
+ companion object
24
+ }
@@ -16,12 +16,15 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode;
16
16
  namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersistTaps; }
17
17
  // Forward declaration of `NativeListScrollAlignment` to properly resolve imports.
18
18
  namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
19
+ // Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
20
+ namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
19
21
 
20
22
  // Include C++ defined types
21
23
  #include "HybridNativeListSpec.hpp"
22
24
  #include "NativeListKeyboardDismissMode.hpp"
23
25
  #include "NativeListKeyboardShouldPersistTaps.hpp"
24
26
  #include "NativeListScrollAlignment.hpp"
27
+ #include "NativeListScrollEdgeEffect.hpp"
25
28
  #include <NitroModules/Result.hpp>
26
29
  #include <exception>
27
30
  #include <functional>
@@ -12,6 +12,8 @@
12
12
  // Forward declaration of `HybridNativeListSpec_cxx` to properly resolve imports.
13
13
  namespace NativeListModule { class HybridNativeListSpec_cxx; }
14
14
 
15
+ // Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
16
+ namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
15
17
  // Forward declaration of `NativeListKeyboardDismissMode` to properly resolve imports.
16
18
  namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode; }
17
19
  // Forward declaration of `NativeListKeyboardShouldPersistTaps` to properly resolve imports.
@@ -20,6 +22,7 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersis
20
22
  namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
21
23
 
22
24
  #include <string>
25
+ #include "NativeListScrollEdgeEffect.hpp"
23
26
  #include <functional>
24
27
  #include <optional>
25
28
  #include "NativeListKeyboardDismissMode.hpp"
@@ -93,11 +96,12 @@ namespace margelo::nitro::nativelist {
93
96
  inline void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) noexcept override {
94
97
  _swiftPart.setContainerSlotHeightsJson(containerSlotHeightsJson);
95
98
  }
96
- inline bool getTopScrollEdgeHard() noexcept override {
97
- return _swiftPart.getTopScrollEdgeHard();
99
+ inline NativeListScrollEdgeEffect getTopScrollEdgeEffect() noexcept override {
100
+ auto __result = _swiftPart.getTopScrollEdgeEffect();
101
+ return static_cast<NativeListScrollEdgeEffect>(__result);
98
102
  }
99
- inline void setTopScrollEdgeHard(bool topScrollEdgeHard) noexcept override {
100
- _swiftPart.setTopScrollEdgeHard(std::forward<decltype(topScrollEdgeHard)>(topScrollEdgeHard));
103
+ inline void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) noexcept override {
104
+ _swiftPart.setTopScrollEdgeEffect(static_cast<int>(topScrollEdgeEffect));
101
105
  }
102
106
  inline double getTopOverlayHeight() noexcept override {
103
107
  return _swiftPart.getTopOverlayHeight();
@@ -130,11 +130,11 @@ using namespace margelo::nitro::nativelist::views;
130
130
  : !newViewProps.containerSlotHeightsJson.hasSameValue(oldViewProps->containerSlotHeightsJson)) {
131
131
  swiftPart.setContainerSlotHeightsJson(newViewProps.containerSlotHeightsJson.get());
132
132
  }
133
- // topScrollEdgeHard: boolean
133
+ // topScrollEdgeEffect: enum
134
134
  if (oldViewProps == nullptr
135
- ? newViewProps.topScrollEdgeHard.isProvided()
136
- : !newViewProps.topScrollEdgeHard.hasSameValue(oldViewProps->topScrollEdgeHard)) {
137
- swiftPart.setTopScrollEdgeHard(newViewProps.topScrollEdgeHard.get());
135
+ ? newViewProps.topScrollEdgeEffect.isProvided()
136
+ : !newViewProps.topScrollEdgeEffect.hasSameValue(oldViewProps->topScrollEdgeEffect)) {
137
+ swiftPart.setTopScrollEdgeEffect(static_cast<int>(newViewProps.topScrollEdgeEffect.get()));
138
138
  }
139
139
  // topOverlayHeight: number
140
140
  if (oldViewProps == nullptr
@@ -13,7 +13,7 @@ public protocol HybridNativeListSpec_protocol: HybridObject, HybridView {
13
13
  var snapshotJson: String { get set }
14
14
  var fontFamiliesJson: String { get set }
15
15
  var containerSlotHeightsJson: String { get set }
16
- var topScrollEdgeHard: Bool { get set }
16
+ var topScrollEdgeEffect: NativeListScrollEdgeEffect { get set }
17
17
  var topOverlayHeight: Double { get set }
18
18
  var scrollPositionThresholdsJson: String { get set }
19
19
  var onScrollPositionThresholdChange: ((_ isBeyondThreshold: Bool) -> Void)? { get set }
@@ -154,14 +154,14 @@ open class HybridNativeListSpec_cxx {
154
154
  }
155
155
  }
156
156
 
157
- public final var topScrollEdgeHard: Bool {
157
+ public final var topScrollEdgeEffect: Int32 {
158
158
  @inline(__always)
159
159
  get {
160
- return self.__implementation.topScrollEdgeHard
160
+ return self.__implementation.topScrollEdgeEffect.rawValue
161
161
  }
162
162
  @inline(__always)
163
163
  set {
164
- self.__implementation.topScrollEdgeHard = newValue
164
+ self.__implementation.topScrollEdgeEffect = margelo.nitro.nativelist.NativeListScrollEdgeEffect(rawValue: newValue)!
165
165
  }
166
166
  }
167
167
 
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// NativeListScrollEdgeEffect.swift
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
+ /**
9
+ * Represents the JS union `NativeListScrollEdgeEffect`, backed by a C++ enum.
10
+ */
11
+ public typealias NativeListScrollEdgeEffect = margelo.nitro.nativelist.NativeListScrollEdgeEffect
12
+
13
+ public extension NativeListScrollEdgeEffect {
14
+ /**
15
+ * Get a NativeListScrollEdgeEffect for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "none":
21
+ self = .none
22
+ case "hard":
23
+ self = .hard
24
+ case "soft":
25
+ self = .soft
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this NativeListScrollEdgeEffect represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .none:
37
+ return "none"
38
+ case .hard:
39
+ return "hard"
40
+ case .soft:
41
+ return "soft"
42
+ }
43
+ }
44
+ }
@@ -20,8 +20,8 @@ namespace margelo::nitro::nativelist {
20
20
  prototype.registerHybridSetter("fontFamiliesJson", &HybridNativeListSpec::setFontFamiliesJson);
21
21
  prototype.registerHybridGetter("containerSlotHeightsJson", &HybridNativeListSpec::getContainerSlotHeightsJson);
22
22
  prototype.registerHybridSetter("containerSlotHeightsJson", &HybridNativeListSpec::setContainerSlotHeightsJson);
23
- prototype.registerHybridGetter("topScrollEdgeHard", &HybridNativeListSpec::getTopScrollEdgeHard);
24
- prototype.registerHybridSetter("topScrollEdgeHard", &HybridNativeListSpec::setTopScrollEdgeHard);
23
+ prototype.registerHybridGetter("topScrollEdgeEffect", &HybridNativeListSpec::getTopScrollEdgeEffect);
24
+ prototype.registerHybridSetter("topScrollEdgeEffect", &HybridNativeListSpec::setTopScrollEdgeEffect);
25
25
  prototype.registerHybridGetter("topOverlayHeight", &HybridNativeListSpec::getTopOverlayHeight);
26
26
  prototype.registerHybridSetter("topOverlayHeight", &HybridNativeListSpec::setTopOverlayHeight);
27
27
  prototype.registerHybridGetter("scrollPositionThresholdsJson", &HybridNativeListSpec::getScrollPositionThresholdsJson);
@@ -13,6 +13,8 @@
13
13
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
14
  #endif
15
15
 
16
+ // Forward declaration of `NativeListScrollEdgeEffect` to properly resolve imports.
17
+ namespace margelo::nitro::nativelist { enum class NativeListScrollEdgeEffect; }
16
18
  // Forward declaration of `NativeListKeyboardDismissMode` to properly resolve imports.
17
19
  namespace margelo::nitro::nativelist { enum class NativeListKeyboardDismissMode; }
18
20
  // Forward declaration of `NativeListKeyboardShouldPersistTaps` to properly resolve imports.
@@ -21,6 +23,7 @@ namespace margelo::nitro::nativelist { enum class NativeListKeyboardShouldPersis
21
23
  namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
22
24
 
23
25
  #include <string>
26
+ #include "NativeListScrollEdgeEffect.hpp"
24
27
  #include <functional>
25
28
  #include <optional>
26
29
  #include "NativeListKeyboardDismissMode.hpp"
@@ -60,8 +63,8 @@ namespace margelo::nitro::nativelist {
60
63
  virtual void setFontFamiliesJson(const std::string& fontFamiliesJson) = 0;
61
64
  virtual std::string getContainerSlotHeightsJson() = 0;
62
65
  virtual void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) = 0;
63
- virtual bool getTopScrollEdgeHard() = 0;
64
- virtual void setTopScrollEdgeHard(bool topScrollEdgeHard) = 0;
66
+ virtual NativeListScrollEdgeEffect getTopScrollEdgeEffect() = 0;
67
+ virtual void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) = 0;
65
68
  virtual double getTopOverlayHeight() = 0;
66
69
  virtual void setTopOverlayHeight(double topOverlayHeight) = 0;
67
70
  virtual std::string getScrollPositionThresholdsJson() = 0;
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// NativeListScrollEdgeEffect.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nativelist {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (NativeListScrollEdgeEffect).
30
+ */
31
+ enum class NativeListScrollEdgeEffect {
32
+ NONE SWIFT_NAME(none) = 0,
33
+ HARD SWIFT_NAME(hard) = 1,
34
+ SOFT SWIFT_NAME(soft) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::nativelist
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ NativeListScrollEdgeEffect <> JS NativeListScrollEdgeEffect (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::nativelist::NativeListScrollEdgeEffect> final {
44
+ static inline margelo::nitro::nativelist::NativeListScrollEdgeEffect fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("none"): return margelo::nitro::nativelist::NativeListScrollEdgeEffect::NONE;
48
+ case hashString("hard"): return margelo::nitro::nativelist::NativeListScrollEdgeEffect::HARD;
49
+ case hashString("soft"): return margelo::nitro::nativelist::NativeListScrollEdgeEffect::SOFT;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum NativeListScrollEdgeEffect - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nativelist::NativeListScrollEdgeEffect arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::nativelist::NativeListScrollEdgeEffect::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
57
+ case margelo::nitro::nativelist::NativeListScrollEdgeEffect::HARD: return JSIConverter<std::string>::toJSI(runtime, "hard");
58
+ case margelo::nitro::nativelist::NativeListScrollEdgeEffect::SOFT: return JSIConverter<std::string>::toJSI(runtime, "soft");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert NativeListScrollEdgeEffect to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("none"):
71
+ case hashString("hard"):
72
+ case hashString("soft"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro