@onekeyfe/react-native-native-list 3.0.105

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 (181) hide show
  1. package/README.md +342 -0
  2. package/android/CMakeLists.txt +20 -0
  3. package/android/build.gradle +105 -0
  4. package/android/gradle.properties +4 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  7. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +125 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +165 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +147 -0
  10. package/android/src/main/java/com/onekey/nativelist/NativeListPackage.kt +25 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +2939 -0
  12. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1794 -0
  13. package/common/fonts/Roobert-Bold.ttf +0 -0
  14. package/common/fonts/Roobert-Medium.ttf +0 -0
  15. package/common/fonts/Roobert-Regular.ttf +0 -0
  16. package/common/fonts/Roobert-SemiBold.ttf +0 -0
  17. package/docs/DESIGN.md +129 -0
  18. package/ios/HybridNativeList.swift +131 -0
  19. package/ios/NativeListCell.swift +2858 -0
  20. package/ios/NativeListDesignAssets.swift +110 -0
  21. package/ios/NativeListModels.swift +215 -0
  22. package/ios/RNCNativeListView.swift +1737 -0
  23. package/ios/Resources/NativeListIcons.xcassets/Contents.json +1 -0
  24. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +1 -0
  25. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +1 -0
  26. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +1 -0
  27. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +1 -0
  28. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +1 -0
  29. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +1 -0
  30. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +1 -0
  31. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +1 -0
  32. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +1 -0
  33. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +1 -0
  34. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +1 -0
  35. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +1 -0
  36. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +1 -0
  37. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +1 -0
  38. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +1 -0
  39. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +1 -0
  40. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +1 -0
  41. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +1 -0
  42. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +1 -0
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +1 -0
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +1 -0
  45. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +1 -0
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +1 -0
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +1 -0
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +1 -0
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +1 -0
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +1 -0
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +1 -0
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +1 -0
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +1 -0
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +1 -0
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +1 -0
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +1 -0
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +1 -0
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +1 -0
  59. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +1 -0
  60. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +1 -0
  61. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +1 -0
  62. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +1 -0
  63. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +1 -0
  64. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +1 -0
  65. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +1 -0
  66. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +1 -0
  67. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +1 -0
  68. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +1 -0
  69. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +1 -0
  70. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +1 -0
  71. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +1 -0
  72. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +1 -0
  73. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +1 -0
  74. package/lib/module/NativeList.js +183 -0
  75. package/lib/module/NativeList.nitro.js +4 -0
  76. package/lib/module/NativeList.types.js +4 -0
  77. package/lib/module/NativeList.web.js +167 -0
  78. package/lib/module/index.js +6 -0
  79. package/lib/module/models.js +2 -0
  80. package/lib/module/package.json +1 -0
  81. package/lib/module/scrolling.js +121 -0
  82. package/lib/module/selection.js +85 -0
  83. package/lib/module/validation.js +562 -0
  84. package/lib/module/web/NativeListWebEngine.js +2238 -0
  85. package/lib/nitrogen/generated/.gitattributes +1 -0
  86. package/lib/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  87. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +201 -0
  88. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +84 -0
  89. package/lib/nitrogen/generated/android/c++/JNativeListScrollAlignment.hpp +64 -0
  90. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +104 -0
  91. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.hpp +54 -0
  92. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt +78 -0
  93. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +177 -0
  94. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollAlignment.kt +25 -0
  95. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/nativelistOnLoad.kt +35 -0
  96. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +96 -0
  97. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListStateUpdater.kt +23 -0
  98. package/lib/nitrogen/generated/android/nativelist+autolinking.cmake +83 -0
  99. package/lib/nitrogen/generated/android/nativelist+autolinking.gradle +27 -0
  100. package/lib/nitrogen/generated/android/nativelistOnLoad.cpp +58 -0
  101. package/lib/nitrogen/generated/android/nativelistOnLoad.hpp +34 -0
  102. package/lib/nitrogen/generated/ios/NativeListModule+autolinking.rb +62 -0
  103. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +41 -0
  104. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +91 -0
  105. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +49 -0
  106. package/lib/nitrogen/generated/ios/NativeListModuleAutolinking.mm +33 -0
  107. package/lib/nitrogen/generated/ios/NativeListModuleAutolinking.swift +26 -0
  108. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.cpp +11 -0
  109. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +180 -0
  110. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +180 -0
  111. package/lib/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  112. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +69 -0
  113. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +447 -0
  114. package/lib/nitrogen/generated/ios/swift/NativeListScrollAlignment.swift +48 -0
  115. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +43 -0
  116. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +87 -0
  117. package/lib/nitrogen/generated/shared/c++/NativeListScrollAlignment.hpp +84 -0
  118. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +46 -0
  119. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +103 -0
  120. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +16 -0
  121. package/lib/typescript/package.json +1 -0
  122. package/lib/typescript/src/NativeList.d.ts +18 -0
  123. package/lib/typescript/src/NativeList.nitro.d.ts +29 -0
  124. package/lib/typescript/src/NativeList.types.d.ts +87 -0
  125. package/lib/typescript/src/NativeList.web.d.ts +19 -0
  126. package/lib/typescript/src/index.d.ts +7 -0
  127. package/lib/typescript/src/models.d.ts +456 -0
  128. package/lib/typescript/src/scrolling.d.ts +32 -0
  129. package/lib/typescript/src/selection.d.ts +27 -0
  130. package/lib/typescript/src/validation.d.ts +7 -0
  131. package/lib/typescript/src/web/NativeListWebEngine.d.ts +203 -0
  132. package/nitro.json +23 -0
  133. package/nitrogen/generated/.gitattributes +1 -0
  134. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  135. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +201 -0
  136. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +84 -0
  137. package/nitrogen/generated/android/c++/JNativeListScrollAlignment.hpp +64 -0
  138. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +104 -0
  139. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.hpp +54 -0
  140. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt +78 -0
  141. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +177 -0
  142. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollAlignment.kt +25 -0
  143. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/nativelistOnLoad.kt +35 -0
  144. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +96 -0
  145. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListStateUpdater.kt +23 -0
  146. package/nitrogen/generated/android/nativelist+autolinking.cmake +83 -0
  147. package/nitrogen/generated/android/nativelist+autolinking.gradle +27 -0
  148. package/nitrogen/generated/android/nativelistOnLoad.cpp +58 -0
  149. package/nitrogen/generated/android/nativelistOnLoad.hpp +34 -0
  150. package/nitrogen/generated/ios/NativeListModule+autolinking.rb +62 -0
  151. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +41 -0
  152. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +91 -0
  153. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +49 -0
  154. package/nitrogen/generated/ios/NativeListModuleAutolinking.mm +33 -0
  155. package/nitrogen/generated/ios/NativeListModuleAutolinking.swift +26 -0
  156. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.cpp +11 -0
  157. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +180 -0
  158. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +180 -0
  159. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  160. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +69 -0
  161. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +447 -0
  162. package/nitrogen/generated/ios/swift/NativeListScrollAlignment.swift +48 -0
  163. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +43 -0
  164. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +87 -0
  165. package/nitrogen/generated/shared/c++/NativeListScrollAlignment.hpp +84 -0
  166. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +46 -0
  167. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +103 -0
  168. package/nitrogen/generated/shared/json/NativeListConfig.json +16 -0
  169. package/package.json +126 -0
  170. package/react-native-native-list.podspec +38 -0
  171. package/react-native.config.js +19 -0
  172. package/src/NativeList.nitro.ts +48 -0
  173. package/src/NativeList.tsx +298 -0
  174. package/src/NativeList.types.ts +125 -0
  175. package/src/NativeList.web.tsx +258 -0
  176. package/src/index.ts +35 -0
  177. package/src/models.ts +604 -0
  178. package/src/scrolling.ts +189 -0
  179. package/src/selection.ts +159 -0
  180. package/src/validation.ts +877 -0
  181. package/src/web/NativeListWebEngine.ts +3767 -0
@@ -0,0 +1,203 @@
1
+ import type { ActionAnchorInvalidatedEvent, NativeListSnapshot, NativeListActionAnchor, NativeListActionSource, ReorderEvent, RowActionEvent, RowModel, RowPatch, SelectionDeltaEvent, VisibleRangeChangedEvent } from '../models';
2
+ import type { ActionAnchorState, ScrollToIndexFailedInfo, ScrollToLocationParams } from '../NativeList.types';
3
+ import { type NormalizedPositionScroll } from '../scrolling';
4
+ export declare const WEB_REORDER_ANIMATION: {
5
+ readonly outOfWayDurationMs: 200;
6
+ readonly outOfWayTimingFunction: "cubic-bezier(0.2, 0, 0, 1)";
7
+ readonly dropDurationMs: 80;
8
+ readonly dropTimingFunction: "ease";
9
+ };
10
+ export type WebLayoutItem = Readonly<{
11
+ index: number;
12
+ key: string;
13
+ x: number;
14
+ y: number;
15
+ width: number;
16
+ height: number;
17
+ }>;
18
+ export type WebListLayout = Readonly<{
19
+ items: readonly WebLayoutItem[];
20
+ contentWidth: number;
21
+ contentHeight: number;
22
+ horizontal: boolean;
23
+ }>;
24
+ export type NativeListWebCallbacks = Readonly<{
25
+ onRowAction?: (event: RowActionEvent) => void;
26
+ onActionAnchorInvalidated?: (event: ActionAnchorInvalidatedEvent) => void;
27
+ onSelectionDelta?: (event: SelectionDeltaEvent) => void;
28
+ onReorder?: (event: ReorderEvent) => void;
29
+ onEndReached?: (event: {
30
+ generation: number;
31
+ lastKey?: string;
32
+ }) => void;
33
+ onVisibleRangeChanged?: (event: VisibleRangeChangedEvent) => void;
34
+ onRefresh?: () => void;
35
+ onScrollToIndexFailed?: (info: ScrollToIndexFailedInfo) => void;
36
+ }>;
37
+ export declare function webActionAnchorPayload(token: string, rect: Readonly<{
38
+ left: number;
39
+ top: number;
40
+ width: number;
41
+ height: number;
42
+ }>, source: NativeListActionSource, generation: number, layoutDirection: 'ltr' | 'rtl', slot?: number): NativeListActionAnchor;
43
+ export declare function isWebRowReorderable(snapshot: NativeListSnapshot, row: RowModel): boolean;
44
+ export declare function moveWebReorderRow(rows: readonly RowModel[], fromIndex: number, toIndex: number): readonly RowModel[];
45
+ export declare function cancelWebReorderRows(originalRows: readonly RowModel[]): readonly RowModel[];
46
+ export declare function webReorderEventForRows(originalRows: readonly RowModel[], finalRows: readonly RowModel[], key: string): ReorderEvent | undefined;
47
+ export declare function webReorderAutoScrollVelocity(point: number, start: number, end: number, elapsedMs: number): number;
48
+ export declare function hasExceededWebReorderMouseThreshold(deltaX: number, deltaY: number): boolean;
49
+ export declare function estimateWebRowHeight(row: RowModel, snapshot: NativeListSnapshot, availableWidth: number): number;
50
+ export declare function computeWebListLayout(snapshot: NativeListSnapshot, viewportWidth: number, viewportHeight: number, compactRowKey?: string): WebListLayout;
51
+ export declare function webWalletGroupReorderBadge(row: RowModel): string | undefined;
52
+ export declare function visibleWebLayoutItems(layout: WebListLayout, offset: number, viewportLength: number, overscan?: number): readonly WebLayoutItem[];
53
+ export declare function webLayoutItemsForMount(layout: WebListLayout, offset: number, viewportLength: number, virtualizationEnabled: boolean, overscan?: number): readonly WebLayoutItem[];
54
+ export declare function webRowRenderSignature(row: RowModel): string;
55
+ export declare const WEB_LIST_CSS: string;
56
+ export declare class NativeListWebEngine {
57
+ private readonly document;
58
+ private readonly root;
59
+ private readonly viewportFrame;
60
+ private readonly viewport;
61
+ private readonly content;
62
+ private readonly footer;
63
+ private readonly sticky;
64
+ private readonly indexRail;
65
+ private readonly indexPreview;
66
+ private readonly refreshIndicator;
67
+ private readonly reorderPreview;
68
+ private readonly previousHostPosition;
69
+ private snapshot;
70
+ private rows;
71
+ private selectedKeys;
72
+ private callbacks;
73
+ private layout;
74
+ private readonly mounted;
75
+ private readonly pool;
76
+ private frameHandle;
77
+ private resizeObserver;
78
+ private pendingScroll;
79
+ private lastVisibleSignature;
80
+ private reachedGeneration;
81
+ private stickyKey;
82
+ private previewTimer;
83
+ private pointerReorder;
84
+ private keyboardReorder;
85
+ private reorderMoveFrame;
86
+ private reorderAutoScrollFrame;
87
+ private reorderDropTimer;
88
+ private reorderMovementTimer;
89
+ private reorderSettlingKey;
90
+ private reorderCompactKey;
91
+ private reorderExpandingKey;
92
+ private suppressClickUntil;
93
+ private pullStartY;
94
+ private pullDistance;
95
+ private virtualizationEnabled;
96
+ private actionAnchor;
97
+ private readonly actionAnchorInstanceId;
98
+ private actionAnchorCounter;
99
+ private bindingEpochCounter;
100
+ private lastViewportWidth;
101
+ private lastViewportHeight;
102
+ private destroyed;
103
+ constructor(host: HTMLElement, snapshot: NativeListSnapshot, callbacks: NativeListWebCallbacks, virtualizationEnabled?: boolean);
104
+ updateCallbacks(callbacks: NativeListWebCallbacks): void;
105
+ setVirtualizationEnabled(enabled: boolean): void;
106
+ applySnapshot(snapshot: NativeListSnapshot): void;
107
+ applyPatches(patches: readonly RowPatch[]): void;
108
+ reconcileSelection(keys: readonly string[]): void;
109
+ scrollToIndex(index: number, scroll: NormalizedPositionScroll): void;
110
+ scrollToKey(key: string, scroll: NormalizedPositionScroll): void;
111
+ scrollToOffset(offset: number, animated: boolean): void;
112
+ scrollToEnd(animated: boolean): void;
113
+ scrollToLocation(params: ScrollToLocationParams, scroll: NormalizedPositionScroll): void;
114
+ setRefreshing(refreshing: boolean): void;
115
+ setActionAnchorState(state: ActionAnchorState): void;
116
+ destroy(): void;
117
+ private setSnapshot;
118
+ private applyTheme;
119
+ private recomputeLayout;
120
+ private renderWindow;
121
+ private positionElement;
122
+ private renderElement;
123
+ private renderFooter;
124
+ private renderSectionIndex;
125
+ private updateVisibleSelection;
126
+ private updateVisibleState;
127
+ private updateStickyHeader;
128
+ private updateSectionIndex;
129
+ private checkEndReached;
130
+ private emitScrollFailure;
131
+ private canScroll;
132
+ private viewportLength;
133
+ private contentLength;
134
+ private currentOffset;
135
+ private scrollToAbsoluteOffset;
136
+ private performPendingScroll;
137
+ private rowAtElement;
138
+ private rowLabel;
139
+ private isReorderable;
140
+ private activateSelection;
141
+ private emitRowAction;
142
+ private createActionAnchor;
143
+ private isActionAnchorValid;
144
+ private invalidateActionAnchorForElement;
145
+ private invalidateActionAnchor;
146
+ private emitActionAnchorInvalidated;
147
+ private handleRowPress;
148
+ private handleClick;
149
+ private handleKeyDown;
150
+ private startKeyboardReorder;
151
+ private moveKeyboardReorder;
152
+ private finishKeyboardReorder;
153
+ private cancelKeyboardReorder;
154
+ private handleScroll;
155
+ private handleWindowResize;
156
+ private scheduleFrame;
157
+ private requestFrame;
158
+ private cancelFrame;
159
+ private selectIndexPosition;
160
+ private indexButtonAtEvent;
161
+ private handleIndexPointer;
162
+ private handleIndexClick;
163
+ private handlePullStart;
164
+ private handlePullMove;
165
+ private handlePullEnd;
166
+ private updateRefreshIndicator;
167
+ private handleReorderPointerDown;
168
+ private activatePointerReorder;
169
+ private captureReorderPointer;
170
+ private releaseReorderPointer;
171
+ private clearReorderLongPress;
172
+ private handleReorderPointerMove;
173
+ private handleReorderTouchMove;
174
+ private handleReorderTouchEnd;
175
+ private handleReorderTouchCancel;
176
+ private setCurrentOffset;
177
+ private showReorderPreview;
178
+ private animateReorderPreviewToCurrent;
179
+ private clearReorderPreviewVisual;
180
+ private finishReorderDrop;
181
+ private hideReorderPreview;
182
+ private updateReorderPreview;
183
+ private reorderViewportRect;
184
+ private scheduleReorderMove;
185
+ private runReorderMove;
186
+ private flushReorderMove;
187
+ private stopReorderMove;
188
+ private reorderIndexAtPointer;
189
+ private movePointerReorderTo;
190
+ private canReuseReorderLayout;
191
+ private remapMountedRowsForMove;
192
+ private reorderAutoScrollVelocity;
193
+ private scheduleReorderAutoScroll;
194
+ private runReorderAutoScroll;
195
+ private handleReorderPointerEnd;
196
+ private completePointerReorder;
197
+ private handleReorderPointerCancel;
198
+ private stopReorderAutoScroll;
199
+ private cancelPointerReorder;
200
+ private remapMountedRows;
201
+ private updateReorderVisualState;
202
+ }
203
+ //# sourceMappingURL=NativeListWebEngine.d.ts.map
package/nitro.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "cxxNamespace": ["nativelist"],
3
+ "ios": {
4
+ "iosModuleName": "NativeListModule"
5
+ },
6
+ "android": {
7
+ "androidNamespace": ["nativelist"],
8
+ "androidCxxLibName": "nativelist"
9
+ },
10
+ "autolinking": {
11
+ "NativeList": {
12
+ "ios": {
13
+ "language": "swift",
14
+ "implementationClassName": "HybridNativeList"
15
+ },
16
+ "android": {
17
+ "language": "kotlin",
18
+ "implementationClassName": "HybridNativeList"
19
+ }
20
+ }
21
+ },
22
+ "ignorePaths": ["node_modules"]
23
+ }
@@ -0,0 +1 @@
1
+ ** linguist-generated=true
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// JFunc_void_std__string.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <string>
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+
17
+ namespace margelo::nitro::nativelist {
18
+
19
+ using namespace facebook;
20
+
21
+ /**
22
+ * Represents the Java/Kotlin callback `(payloadJson: String) -> Unit`.
23
+ * This can be passed around between C++ and Java/Kotlin.
24
+ */
25
+ struct JFunc_void_std__string: public jni::JavaClass<JFunc_void_std__string> {
26
+ public:
27
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/Func_void_std__string;";
28
+
29
+ public:
30
+ /**
31
+ * Invokes the function this `JFunc_void_std__string` instance holds through JNI.
32
+ */
33
+ void invoke(const std::string& payloadJson) const {
34
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* payloadJson */)>("invoke");
35
+ method(self(), jni::make_jstring(payloadJson));
36
+ }
37
+ };
38
+
39
+ /**
40
+ * An implementation of Func_void_std__string that is backed by a C++ implementation (using `std::function<...>`)
41
+ */
42
+ class JFunc_void_std__string_cxx final: public jni::HybridClass<JFunc_void_std__string_cxx, JFunc_void_std__string> {
43
+ public:
44
+ static jni::local_ref<JFunc_void_std__string::javaobject> fromCpp(const std::function<void(const std::string& /* payloadJson */)>& func) {
45
+ return JFunc_void_std__string_cxx::newObjectCxxArgs(func);
46
+ }
47
+
48
+ public:
49
+ /**
50
+ * Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds.
51
+ */
52
+ void invoke_cxx(jni::alias_ref<jni::JString> payloadJson) {
53
+ _func(payloadJson->toStdString());
54
+ }
55
+
56
+ public:
57
+ [[nodiscard]]
58
+ inline const std::function<void(const std::string& /* payloadJson */)>& getFunction() const {
59
+ return _func;
60
+ }
61
+
62
+ public:
63
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/Func_void_std__string_cxx;";
64
+ static void registerNatives() {
65
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_cxx::invoke_cxx)});
66
+ }
67
+
68
+ private:
69
+ explicit JFunc_void_std__string_cxx(const std::function<void(const std::string& /* payloadJson */)>& func): _func(func) { }
70
+
71
+ private:
72
+ friend HybridBase;
73
+ std::function<void(const std::string& /* payloadJson */)> _func;
74
+ };
75
+
76
+ } // namespace margelo::nitro::nativelist
@@ -0,0 +1,201 @@
1
+ ///
2
+ /// JHybridNativeListSpec.cpp
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
+ #include "JHybridNativeListSpec.hpp"
9
+
10
+ // Forward declaration of `NativeListScrollAlignment` to properly resolve imports.
11
+ namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
12
+
13
+ #include <string>
14
+ #include <functional>
15
+ #include <optional>
16
+ #include "JFunc_void_std__string.hpp"
17
+ #include <NitroModules/JNICallable.hpp>
18
+ #include "NativeListScrollAlignment.hpp"
19
+ #include "JNativeListScrollAlignment.hpp"
20
+
21
+ namespace margelo::nitro::nativelist {
22
+
23
+ std::shared_ptr<JHybridNativeListSpec> JHybridNativeListSpec::JavaPart::getJHybridNativeListSpec() {
24
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
25
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridNativeListSpec>(hybridObject);
26
+ if (castHybridObject == nullptr) [[unlikely]] {
27
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridNativeListSpec!");
28
+ }
29
+ return castHybridObject;
30
+ }
31
+
32
+ jni::local_ref<JHybridNativeListSpec::CxxPart::jhybriddata> JHybridNativeListSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
33
+ return makeCxxInstance(jThis);
34
+ }
35
+
36
+ std::shared_ptr<JHybridObject> JHybridNativeListSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
37
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridNativeListSpec::JavaPart>(javaPart);
38
+ if (castJavaPart == nullptr) [[unlikely]] {
39
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridNativeListSpec::JavaPart!");
40
+ }
41
+ return std::make_shared<JHybridNativeListSpec>(castJavaPart);
42
+ }
43
+
44
+ void JHybridNativeListSpec::CxxPart::registerNatives() {
45
+ registerHybrid({
46
+ makeNativeMethod("initHybrid", JHybridNativeListSpec::CxxPart::initHybrid),
47
+ });
48
+ }
49
+
50
+ // Properties
51
+ std::string JHybridNativeListSpec::getSnapshotJson() {
52
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getSnapshotJson");
53
+ auto __result = method(_javaPart);
54
+ return __result->toStdString();
55
+ }
56
+ void JHybridNativeListSpec::setSnapshotJson(const std::string& snapshotJson) {
57
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* snapshotJson */)>("setSnapshotJson");
58
+ method(_javaPart, jni::make_jstring(snapshotJson));
59
+ }
60
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnRowAction() {
61
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnRowAction_cxx");
62
+ auto __result = method(_javaPart);
63
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
64
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
65
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
66
+ return downcast->cthis()->getFunction();
67
+ } else {
68
+ auto __resultRef = jni::make_global(__result);
69
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
70
+ }
71
+ }()) : std::nullopt;
72
+ }
73
+ void JHybridNativeListSpec::setOnRowAction(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onRowAction) {
74
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onRowAction */)>("setOnRowAction_cxx");
75
+ method(_javaPart, onRowAction.has_value() ? JFunc_void_std__string_cxx::fromCpp(onRowAction.value()) : nullptr);
76
+ }
77
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnActionAnchorInvalidated() {
78
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnActionAnchorInvalidated_cxx");
79
+ auto __result = method(_javaPart);
80
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
81
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
82
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
83
+ return downcast->cthis()->getFunction();
84
+ } else {
85
+ auto __resultRef = jni::make_global(__result);
86
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
87
+ }
88
+ }()) : std::nullopt;
89
+ }
90
+ void JHybridNativeListSpec::setOnActionAnchorInvalidated(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onActionAnchorInvalidated) {
91
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onActionAnchorInvalidated */)>("setOnActionAnchorInvalidated_cxx");
92
+ method(_javaPart, onActionAnchorInvalidated.has_value() ? JFunc_void_std__string_cxx::fromCpp(onActionAnchorInvalidated.value()) : nullptr);
93
+ }
94
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnSelectionDelta() {
95
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnSelectionDelta_cxx");
96
+ auto __result = method(_javaPart);
97
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
98
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
99
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
100
+ return downcast->cthis()->getFunction();
101
+ } else {
102
+ auto __resultRef = jni::make_global(__result);
103
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
104
+ }
105
+ }()) : std::nullopt;
106
+ }
107
+ void JHybridNativeListSpec::setOnSelectionDelta(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onSelectionDelta) {
108
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onSelectionDelta */)>("setOnSelectionDelta_cxx");
109
+ method(_javaPart, onSelectionDelta.has_value() ? JFunc_void_std__string_cxx::fromCpp(onSelectionDelta.value()) : nullptr);
110
+ }
111
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnReorder() {
112
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnReorder_cxx");
113
+ auto __result = method(_javaPart);
114
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
115
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
116
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
117
+ return downcast->cthis()->getFunction();
118
+ } else {
119
+ auto __resultRef = jni::make_global(__result);
120
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
121
+ }
122
+ }()) : std::nullopt;
123
+ }
124
+ void JHybridNativeListSpec::setOnReorder(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onReorder) {
125
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onReorder */)>("setOnReorder_cxx");
126
+ method(_javaPart, onReorder.has_value() ? JFunc_void_std__string_cxx::fromCpp(onReorder.value()) : nullptr);
127
+ }
128
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnEndReached() {
129
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnEndReached_cxx");
130
+ auto __result = method(_javaPart);
131
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
132
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
133
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
134
+ return downcast->cthis()->getFunction();
135
+ } else {
136
+ auto __resultRef = jni::make_global(__result);
137
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
138
+ }
139
+ }()) : std::nullopt;
140
+ }
141
+ void JHybridNativeListSpec::setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) {
142
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onEndReached */)>("setOnEndReached_cxx");
143
+ method(_javaPart, onEndReached.has_value() ? JFunc_void_std__string_cxx::fromCpp(onEndReached.value()) : nullptr);
144
+ }
145
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnVisibleRangeChanged() {
146
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnVisibleRangeChanged_cxx");
147
+ auto __result = method(_javaPart);
148
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
149
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
150
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
151
+ return downcast->cthis()->getFunction();
152
+ } else {
153
+ auto __resultRef = jni::make_global(__result);
154
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
155
+ }
156
+ }()) : std::nullopt;
157
+ }
158
+ void JHybridNativeListSpec::setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) {
159
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onVisibleRangeChanged */)>("setOnVisibleRangeChanged_cxx");
160
+ method(_javaPart, onVisibleRangeChanged.has_value() ? JFunc_void_std__string_cxx::fromCpp(onVisibleRangeChanged.value()) : nullptr);
161
+ }
162
+
163
+ // Methods
164
+ void JHybridNativeListSpec::applySnapshot(const std::string& snapshotJson) {
165
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* snapshotJson */)>("applySnapshot");
166
+ method(_javaPart, jni::make_jstring(snapshotJson));
167
+ }
168
+ void JHybridNativeListSpec::applyPatches(const std::string& patchesJson) {
169
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* patchesJson */)>("applyPatches");
170
+ method(_javaPart, jni::make_jstring(patchesJson));
171
+ }
172
+ void JHybridNativeListSpec::reconcileSelection(const std::string& selectedKeysJson) {
173
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* selectedKeysJson */)>("reconcileSelection");
174
+ method(_javaPart, jni::make_jstring(selectedKeysJson));
175
+ }
176
+ void JHybridNativeListSpec::scrollToKey(const std::string& key, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) {
177
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* key */, jboolean /* animated */, jni::alias_ref<JNativeListScrollAlignment> /* alignment */, double /* viewPosition */, double /* viewOffset */)>("scrollToKey");
178
+ method(_javaPart, jni::make_jstring(key), animated, JNativeListScrollAlignment::fromCpp(alignment), viewPosition, viewOffset);
179
+ }
180
+ void JHybridNativeListSpec::scrollToIndex(double index, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) {
181
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* index */, jboolean /* animated */, jni::alias_ref<JNativeListScrollAlignment> /* alignment */, double /* viewPosition */, double /* viewOffset */)>("scrollToIndex");
182
+ method(_javaPart, index, animated, JNativeListScrollAlignment::fromCpp(alignment), viewPosition, viewOffset);
183
+ }
184
+ void JHybridNativeListSpec::scrollToOffset(double offset, bool animated) {
185
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* offset */, jboolean /* animated */)>("scrollToOffset");
186
+ method(_javaPart, offset, animated);
187
+ }
188
+ void JHybridNativeListSpec::scrollToEnd(bool animated) {
189
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* animated */)>("scrollToEnd");
190
+ method(_javaPart, animated);
191
+ }
192
+ void JHybridNativeListSpec::setActionAnchorState(const std::string& stateJson) {
193
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* stateJson */)>("setActionAnchorState");
194
+ method(_javaPart, jni::make_jstring(stateJson));
195
+ }
196
+ void JHybridNativeListSpec::setRefreshing(bool refreshing) {
197
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* refreshing */)>("setRefreshing");
198
+ method(_javaPart, refreshing);
199
+ }
200
+
201
+ } // namespace margelo::nitro::nativelist
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// HybridNativeListSpec.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 <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridNativeListSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::nativelist {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridNativeListSpec: public virtual HybridNativeListSpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/HybridNativeListSpec;";
25
+ std::shared_ptr<JHybridNativeListSpec> getJHybridNativeListSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/HybridNativeListSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridNativeListSpec(const jni::local_ref<JHybridNativeListSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridNativeListSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridNativeListSpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridNativeListSpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+ std::string getSnapshotJson() override;
54
+ void setSnapshotJson(const std::string& snapshotJson) override;
55
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnRowAction() override;
56
+ void setOnRowAction(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onRowAction) override;
57
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnActionAnchorInvalidated() override;
58
+ void setOnActionAnchorInvalidated(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onActionAnchorInvalidated) override;
59
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnSelectionDelta() override;
60
+ void setOnSelectionDelta(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onSelectionDelta) override;
61
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnReorder() override;
62
+ void setOnReorder(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onReorder) override;
63
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnEndReached() override;
64
+ void setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) override;
65
+ std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnVisibleRangeChanged() override;
66
+ void setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) override;
67
+
68
+ public:
69
+ // Methods
70
+ void applySnapshot(const std::string& snapshotJson) override;
71
+ void applyPatches(const std::string& patchesJson) override;
72
+ void reconcileSelection(const std::string& selectedKeysJson) override;
73
+ void scrollToKey(const std::string& key, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) override;
74
+ void scrollToIndex(double index, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) override;
75
+ void scrollToOffset(double offset, bool animated) override;
76
+ void scrollToEnd(bool animated) override;
77
+ void setActionAnchorState(const std::string& stateJson) override;
78
+ void setRefreshing(bool refreshing) override;
79
+
80
+ private:
81
+ jni::global_ref<JHybridNativeListSpec::JavaPart> _javaPart;
82
+ };
83
+
84
+ } // namespace margelo::nitro::nativelist
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JNativeListScrollAlignment.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 "NativeListScrollAlignment.hpp"
12
+
13
+ namespace margelo::nitro::nativelist {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "NativeListScrollAlignment" and the Kotlin enum "NativeListScrollAlignment".
19
+ */
20
+ struct JNativeListScrollAlignment final: public jni::JavaClass<JNativeListScrollAlignment> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/NativeListScrollAlignment;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum NativeListScrollAlignment.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ NativeListScrollAlignment 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<NativeListScrollAlignment>(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<JNativeListScrollAlignment> fromCpp(NativeListScrollAlignment value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case NativeListScrollAlignment::START:
46
+ static const auto fieldSTART = clazz->getStaticField<JNativeListScrollAlignment>("START");
47
+ return clazz->getStaticFieldValue(fieldSTART);
48
+ case NativeListScrollAlignment::CENTER:
49
+ static const auto fieldCENTER = clazz->getStaticField<JNativeListScrollAlignment>("CENTER");
50
+ return clazz->getStaticFieldValue(fieldCENTER);
51
+ case NativeListScrollAlignment::END:
52
+ static const auto fieldEND = clazz->getStaticField<JNativeListScrollAlignment>("END");
53
+ return clazz->getStaticFieldValue(fieldEND);
54
+ case NativeListScrollAlignment::NEAREST:
55
+ static const auto fieldNEAREST = clazz->getStaticField<JNativeListScrollAlignment>("NEAREST");
56
+ return clazz->getStaticFieldValue(fieldNEAREST);
57
+ default:
58
+ std::string stringValue = std::to_string(static_cast<int>(value));
59
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
60
+ }
61
+ }
62
+ };
63
+
64
+ } // namespace margelo::nitro::nativelist