react-native-nitro-list 0.1.2 → 0.1.3
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/README.md +16 -44
- package/ios/HybridNitroList.swift +7 -5
- package/lib/commonjs/index.js +31 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -1
- package/lib/commonjs/native/NitroListView.js +20 -0
- package/lib/commonjs/native/NitroListView.js.map +1 -0
- package/lib/commonjs/recycler/CellPool.js +5 -18
- package/lib/commonjs/recycler/CellPool.js.map +1 -1
- package/lib/commonjs/recycler/{RecyclerList.js → NitroList.js} +91 -92
- package/lib/commonjs/recycler/NitroList.js.map +1 -0
- package/lib/commonjs/scroll/useScrollVelocity.js +20 -0
- package/lib/commonjs/scroll/useScrollVelocity.js.map +1 -0
- package/lib/commonjs/{native/NitroList.types.js → specs/NitroList.nitro.js} +1 -1
- package/lib/commonjs/{native/NitroList.types.js.map → specs/NitroList.nitro.js.map} +1 -1
- package/lib/commonjs/types/CellType.js +25 -0
- package/lib/commonjs/types/CellType.js.map +1 -1
- package/lib/commonjs/types/recycler/CellPool.js +42 -0
- package/lib/commonjs/types/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/types/recycler/{RecyclerListProps.js → NitroListProps.js} +1 -1
- package/lib/commonjs/types/recycler/NitroListProps.js.map +1 -0
- package/lib/commonjs/types/recycler/{RecyclerCellInstance.js → RecyclerCell.js} +1 -1
- package/lib/commonjs/types/recycler/RecyclerCell.js.map +1 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js +22 -32
- package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -1
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/MutableLinearLayout.js.map +1 -1
- package/lib/module/native/NitroListView.js +17 -0
- package/lib/module/native/NitroListView.js.map +1 -0
- package/lib/module/recycler/CellPool.js +5 -18
- package/lib/module/recycler/CellPool.js.map +1 -1
- package/lib/module/recycler/NitroList.js +220 -0
- package/lib/module/recycler/NitroList.js.map +1 -0
- package/lib/module/scroll/useScrollVelocity.js +16 -0
- package/lib/module/scroll/useScrollVelocity.js.map +1 -0
- package/lib/module/specs/NitroList.nitro.js +4 -0
- package/lib/module/{native/NitroList.types.js.map → specs/NitroList.nitro.js.map} +1 -1
- package/lib/module/types/CellType.js +20 -0
- package/lib/module/types/CellType.js.map +1 -1
- package/lib/module/types/recycler/CellPool.js +37 -0
- package/lib/module/types/recycler/CellPool.js.map +1 -0
- package/lib/module/types/recycler/NitroListProps.js +4 -0
- package/lib/module/types/recycler/NitroListProps.js.map +1 -0
- package/lib/module/types/recycler/RecyclerCell.js +4 -0
- package/lib/module/types/recycler/RecyclerCell.js.map +1 -0
- package/lib/module/windowing/computeVisibleItemRange.js +22 -32
- package/lib/module/windowing/computeVisibleItemRange.js.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/NitroListView.d.ts +20 -0
- package/lib/typescript/src/native/NitroListView.d.ts.map +1 -0
- package/lib/typescript/src/recycler/CellPool.d.ts +4 -7
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -1
- package/lib/typescript/src/recycler/NitroList.d.ts +4 -0
- package/lib/typescript/src/recycler/NitroList.d.ts.map +1 -0
- package/lib/typescript/src/scroll/useScrollVelocity.d.ts +2 -0
- package/lib/typescript/src/scroll/useScrollVelocity.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroList.nitro.d.ts +26 -0
- package/lib/typescript/src/specs/NitroList.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types/CellKey.d.ts +1 -9
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -1
- package/lib/typescript/src/types/CellType.d.ts +12 -1
- package/lib/typescript/src/types/CellType.d.ts.map +1 -1
- package/lib/typescript/src/types/recycler/CellPool.d.ts +16 -0
- package/lib/typescript/src/types/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/{RecyclerListProps.d.ts → NitroListProps.d.ts} +3 -3
- package/lib/typescript/src/types/recycler/NitroListProps.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerCell.d.ts +12 -0
- package/lib/typescript/src/types/recycler/RecyclerCell.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +6 -2
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -1
- package/lib/typescript/src/types/recycler/index.d.ts +2 -2
- package/lib/typescript/src/types/recycler/index.d.ts.map +1 -1
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +16 -12
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -1
- package/nitro.json +5 -5
- package/nitrogen/generated/android/NitroList+autolinking.cmake +2 -2
- package/nitrogen/generated/android/NitroListOnLoad.cpp +2 -2
- package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.cpp → JHybridNitroListSpec.cpp} +15 -15
- package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.hpp → JHybridNitroListSpec.hpp} +11 -11
- package/nitrogen/generated/android/c++/{JLayoutRect.hpp → JItemLayout.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{HybridNitroLayoutEngineSpec.kt → HybridNitroListSpec.kt} +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRect.kt → ItemLayout.kt} +5 -5
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.cpp +9 -9
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +27 -27
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +8 -8
- package/nitrogen/generated/ios/c++/{HybridNitroLayoutEngineSpecSwift.cpp → HybridNitroListSpecSwift.cpp} +2 -2
- package/nitrogen/generated/ios/c++/{HybridNitroLayoutEngineSpecSwift.hpp → HybridNitroListSpecSwift.hpp} +16 -16
- package/nitrogen/generated/ios/swift/HybridNitroListSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/{HybridNitroLayoutEngineSpec_cxx.swift → HybridNitroListSpec_cxx.swift} +23 -23
- package/nitrogen/generated/ios/swift/{LayoutRect.swift → ItemLayout.swift} +5 -5
- package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.cpp → HybridNitroListSpec.cpp} +4 -4
- package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.hpp → HybridNitroListSpec.hpp} +13 -13
- package/nitrogen/generated/shared/c++/{LayoutRect.hpp → ItemLayout.hpp} +11 -11
- package/package.json +5 -5
- package/src/index.ts +7 -1
- package/src/layout/MutableLinearLayout.ts +1 -1
- package/src/native/NitroListView.ts +22 -0
- package/src/recycler/CellPool.ts +10 -24
- package/src/recycler/NitroList.tsx +317 -0
- package/src/scroll/useScrollVelocity.ts +16 -0
- package/src/specs/NitroList.nitro.ts +29 -0
- package/src/types/CellKey.ts +2 -9
- package/src/types/CellType.ts +8 -9
- package/src/types/recycler/CellPool.ts +45 -0
- package/src/types/recycler/{RecyclerListProps.ts → NitroListProps.ts} +2 -2
- package/src/types/recycler/RecyclerCell.ts +12 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +6 -2
- package/src/types/recycler/index.ts +2 -2
- package/src/windowing/computeVisibleItemRange.ts +42 -38
- package/lib/commonjs/NitroList.js +0 -9
- package/lib/commonjs/NitroList.js.map +0 -1
- package/lib/commonjs/native/NitroLayoutEngine.js +0 -9
- package/lib/commonjs/native/NitroLayoutEngine.js.map +0 -1
- package/lib/commonjs/native/NitroRecyclerView.js +0 -9
- package/lib/commonjs/native/NitroRecyclerView.js.map +0 -1
- package/lib/commonjs/recycler/RecyclerList.js.map +0 -1
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js +0 -6
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js.map +0 -1
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js.map +0 -1
- package/lib/commonjs/types/recycler/RecyclerListProps.js.map +0 -1
- package/lib/module/NitroList.js +0 -5
- package/lib/module/NitroList.js.map +0 -1
- package/lib/module/native/NitroLayoutEngine.js +0 -5
- package/lib/module/native/NitroLayoutEngine.js.map +0 -1
- package/lib/module/native/NitroList.types.js +0 -4
- package/lib/module/native/NitroRecyclerView.js +0 -5
- package/lib/module/native/NitroRecyclerView.js.map +0 -1
- package/lib/module/recycler/RecyclerList.js +0 -221
- package/lib/module/recycler/RecyclerList.js.map +0 -1
- package/lib/module/specs/nitro-layout-engine.nitro.js +0 -4
- package/lib/module/specs/nitro-layout-engine.nitro.js.map +0 -1
- package/lib/module/types/recycler/RecyclerCellInstance.js +0 -4
- package/lib/module/types/recycler/RecyclerCellInstance.js.map +0 -1
- package/lib/module/types/recycler/RecyclerListProps.js +0 -4
- package/lib/module/types/recycler/RecyclerListProps.js.map +0 -1
- package/lib/typescript/src/NitroList.d.ts +0 -5
- package/lib/typescript/src/NitroList.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts +0 -3
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroList.types.d.ts +0 -9
- package/lib/typescript/src/native/NitroList.types.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroRecyclerView.d.ts +0 -5
- package/lib/typescript/src/native/NitroRecyclerView.d.ts.map +0 -1
- package/lib/typescript/src/recycler/RecyclerList.d.ts +0 -4
- package/lib/typescript/src/recycler/RecyclerList.d.ts.map +0 -1
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +0 -14
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +0 -1
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts +0 -37
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts.map +0 -1
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts.map +0 -1
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +0 -56
- package/src/NitroList.ts +0 -8
- package/src/native/NitroLayoutEngine.ts +0 -7
- package/src/native/NitroList.types.ts +0 -13
- package/src/native/NitroRecyclerView.ts +0 -8
- package/src/recycler/RecyclerList.tsx +0 -304
- package/src/specs/nitro-layout-engine.nitro.ts +0 -17
- package/src/types/recycler/RecyclerCellInstance.ts +0 -40
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Computes
|
|
5
|
-
*
|
|
6
|
-
* Responsibilities:
|
|
7
|
-
* - Determine which items intersect the visible window
|
|
8
|
-
* - Stay independent of rendering and recycling
|
|
9
|
-
*
|
|
10
|
-
* Performance:
|
|
11
|
-
* - O(log n) to locate the first visible item
|
|
12
|
-
* - O(k) to expand to the last visible item (k = visible count)
|
|
4
|
+
* Computes visible item range using binary search + forward scan.
|
|
5
|
+
* Type-safe and defensive against invalid indices.
|
|
13
6
|
*/
|
|
14
7
|
export function computeVisibleItemRange(input) {
|
|
15
8
|
const {
|
|
@@ -19,49 +12,46 @@ export function computeVisibleItemRange(input) {
|
|
|
19
12
|
buffer,
|
|
20
13
|
isVertical
|
|
21
14
|
} = input;
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
15
|
+
const count = layouts.length;
|
|
16
|
+
if (count === 0) return null;
|
|
24
17
|
const windowStart = Math.max(0, offset - buffer);
|
|
25
18
|
const windowEnd = offset + viewportSize + buffer;
|
|
26
19
|
|
|
27
|
-
//
|
|
28
|
-
// Binary search:
|
|
29
|
-
//
|
|
30
|
-
// --------------------------------------------------
|
|
20
|
+
// ------------------------------
|
|
21
|
+
// Binary search: first visible
|
|
22
|
+
// ------------------------------
|
|
31
23
|
let low = 0;
|
|
32
|
-
let high =
|
|
33
|
-
let
|
|
24
|
+
let high = count - 1;
|
|
25
|
+
let first = count;
|
|
34
26
|
while (low <= high) {
|
|
35
27
|
const mid = low + high >>> 1;
|
|
36
28
|
const rect = layouts[mid];
|
|
29
|
+
if (!rect) break;
|
|
37
30
|
const start = isVertical ? rect.y : rect.x;
|
|
38
31
|
const size = isVertical ? rect.height : rect.width;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
firstVisibleIndex = mid;
|
|
32
|
+
if (start + size >= windowStart) {
|
|
33
|
+
first = mid;
|
|
42
34
|
high = mid - 1;
|
|
43
35
|
} else {
|
|
44
36
|
low = mid + 1;
|
|
45
37
|
}
|
|
46
38
|
}
|
|
47
|
-
if (
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
39
|
+
if (first === count) return null;
|
|
50
40
|
|
|
51
|
-
//
|
|
52
|
-
// Linear scan
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
for (let i = firstVisibleIndex + 1; i < itemCount; i++) {
|
|
41
|
+
// ------------------------------
|
|
42
|
+
// Linear scan: last visible
|
|
43
|
+
// ------------------------------
|
|
44
|
+
let last = first;
|
|
45
|
+
for (let i = first + 1; i < count; i++) {
|
|
57
46
|
const rect = layouts[i];
|
|
47
|
+
if (!rect) break;
|
|
58
48
|
const start = isVertical ? rect.y : rect.x;
|
|
59
49
|
if (start > windowEnd) break;
|
|
60
|
-
|
|
50
|
+
last = i;
|
|
61
51
|
}
|
|
62
52
|
return {
|
|
63
|
-
startIndex:
|
|
64
|
-
endIndex:
|
|
53
|
+
startIndex: first,
|
|
54
|
+
endIndex: last
|
|
65
55
|
};
|
|
66
56
|
}
|
|
67
57
|
//# sourceMappingURL=computeVisibleItemRange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["computeVisibleItemRange","input","layouts","offset","viewportSize","buffer","isVertical","
|
|
1
|
+
{"version":3,"names":["computeVisibleItemRange","input","layouts","offset","viewportSize","buffer","isVertical","count","length","windowStart","Math","max","windowEnd","low","high","first","mid","rect","start","y","x","size","height","width","last","i","startIndex","endIndex"],"sourceRoot":"../../../src","sources":["windowing/computeVisibleItemRange.ts"],"mappings":";;AAgBA;AACA;AACA;AACA;AACA,OAAO,SAASA,uBAAuBA,CACrCC,KAAY,EACS;EACrB,MAAM;IACJC,OAAO;IACPC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC;EACF,CAAC,GAAGL,KAAK;EAET,MAAMM,KAAK,GAAGL,OAAO,CAACM,MAAM;EAC5B,IAAID,KAAK,KAAK,CAAC,EAAE,OAAO,IAAI;EAE5B,MAAME,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAER,MAAM,GAAGE,MAAM,CAAC;EAChD,MAAMO,SAAS,GAAGT,MAAM,GAAGC,YAAY,GAAGC,MAAM;;EAEhD;EACA;EACA;EACA,IAAIQ,GAAG,GAAG,CAAC;EACX,IAAIC,IAAI,GAAGP,KAAK,GAAG,CAAC;EACpB,IAAIQ,KAAK,GAAGR,KAAK;EAEjB,OAAOM,GAAG,IAAIC,IAAI,EAAE;IAClB,MAAME,GAAG,GAAIH,GAAG,GAAGC,IAAI,KAAM,CAAC;IAC9B,MAAMG,IAAI,GAAGf,OAAO,CAACc,GAAG,CAAC;IACzB,IAAI,CAACC,IAAI,EAAE;IAEX,MAAMC,KAAK,GAAGZ,UAAU,GAAGW,IAAI,CAACE,CAAC,GAAGF,IAAI,CAACG,CAAC;IAC1C,MAAMC,IAAI,GAAGf,UAAU,GAAGW,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACM,KAAK;IAElD,IAAIL,KAAK,GAAGG,IAAI,IAAIZ,WAAW,EAAE;MAC/BM,KAAK,GAAGC,GAAG;MACXF,IAAI,GAAGE,GAAG,GAAG,CAAC;IAChB,CAAC,MAAM;MACLH,GAAG,GAAGG,GAAG,GAAG,CAAC;IACf;EACF;EAEA,IAAID,KAAK,KAAKR,KAAK,EAAE,OAAO,IAAI;;EAEhC;EACA;EACA;EACA,IAAIiB,IAAI,GAAGT,KAAK;EAEhB,KAAK,IAAIU,CAAC,GAAGV,KAAK,GAAG,CAAC,EAAEU,CAAC,GAAGlB,KAAK,EAAEkB,CAAC,EAAE,EAAE;IACtC,MAAMR,IAAI,GAAGf,OAAO,CAACuB,CAAC,CAAC;IACvB,IAAI,CAACR,IAAI,EAAE;IAEX,MAAMC,KAAK,GAAGZ,UAAU,GAAGW,IAAI,CAACE,CAAC,GAAGF,IAAI,CAACG,CAAC;IAC1C,IAAIF,KAAK,GAAGN,SAAS,EAAE;IAEvBY,IAAI,GAAGC,CAAC;EACV;EAEA,OAAO;IACLC,UAAU,EAAEX,KAAK;IACjBY,QAAQ,EAAEH;EACZ,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAC;AAEvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ViewProps } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the NitroListView.
|
|
4
|
+
* * We extend ViewProps so that developers can use standard styles
|
|
5
|
+
* like 'flex: 1' or 'backgroundColor' on the list.
|
|
6
|
+
*/
|
|
7
|
+
export type NitroListViewProps = ViewProps & {
|
|
8
|
+
/**
|
|
9
|
+
* The total number of items to be displayed in the list.
|
|
10
|
+
* This is passed to the native side (Swift/Kotlin) for layout math.
|
|
11
|
+
*/
|
|
12
|
+
itemCount: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The Native Component that maps to the physical view in Swift/Kotlin.
|
|
16
|
+
* * 'NitroListView' is the "Secret Handshake" name. It must match
|
|
17
|
+
* the name exported by your Native ViewManagers.
|
|
18
|
+
*/
|
|
19
|
+
export declare const NitroListView: import("react-native").HostComponent<NitroListViewProps>;
|
|
20
|
+
//# sourceMappingURL=NitroListView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroListView.d.ts","sourceRoot":"","sources":["../../../../src/native/NitroListView.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAErE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,0DACmC,CAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
+
import type { RecyclerCell } from '../types/recycler/RecyclerCell';
|
|
1
2
|
import type { CellType } from '../types/CellType';
|
|
2
|
-
|
|
3
|
-
export declare class CellPool {
|
|
3
|
+
export declare class CellPool<T extends RecyclerCell<any>> {
|
|
4
4
|
private readonly pools;
|
|
5
5
|
private readonly maxPerType;
|
|
6
|
-
/** ✅ NEW: check if a type is registered */
|
|
7
6
|
hasType(type: CellType): boolean;
|
|
8
7
|
registerType(type: CellType, maxCount: number): void;
|
|
9
|
-
acquire(type: CellType):
|
|
10
|
-
release(cell:
|
|
11
|
-
clear(): void;
|
|
12
|
-
getPoolSize(type: CellType): number;
|
|
8
|
+
acquire(type: CellType): T | null;
|
|
9
|
+
release(cell: T): void;
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=CellPool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellPool.d.ts","sourceRoot":"","sources":["../../../../src/recycler/CellPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"CellPool.d.ts","sourceRoot":"","sources":["../../../../src/recycler/CellPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,qBAAa,QAAQ,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IAEzD,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;IAIhC,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMpD,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,GAAG,IAAI;IAMjC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;CASvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroList.d.ts","sourceRoot":"","sources":["../../../../src/recycler/NitroList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAW1D,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AA0BrE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EACjC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GACvB,KAAK,CAAC,YAAY,CA6QpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollVelocity.d.ts","sourceRoot":"","sources":["../../../../src/scroll/useScrollVelocity.ts"],"names":[],"mappings":"AAAA,wBAAgB,2BAA2B,KAIb,QAAQ,MAAM,KAAG,MAAM,CAWpD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the physical area an item occupies on the screen.
|
|
4
|
+
* Standard: 'Layout' suffix tells the user this is a data object, not a logic object.
|
|
5
|
+
*/
|
|
6
|
+
export interface ItemLayout {
|
|
7
|
+
readonly x: number;
|
|
8
|
+
readonly y: number;
|
|
9
|
+
readonly width: number;
|
|
10
|
+
readonly height: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The high-performance layout engine for NitroList.
|
|
14
|
+
* This interface will be used by Nitro to generate your Swift and Kotlin code.
|
|
15
|
+
*/
|
|
16
|
+
export interface NitroList extends HybridObject<{
|
|
17
|
+
ios: 'swift';
|
|
18
|
+
android: 'kotlin';
|
|
19
|
+
}> {
|
|
20
|
+
/**
|
|
21
|
+
* Calculates exactly where every item should sit on the screen.
|
|
22
|
+
* Standard: Use descriptive parameter names so developers know what to provide.
|
|
23
|
+
*/
|
|
24
|
+
computeLayout(containerWidth: number, itemHeights: readonly number[]): readonly ItemLayout[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=NitroList.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroList.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroList.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,SACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IAEzD;;;OAGG;IACH,aAAa,CACX,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,SAAS,UAAU,EAAE,CAAA;CACzB"}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Stable identifier for a cell.
|
|
3
|
-
*
|
|
4
|
-
* Cross-platform equivalent:
|
|
5
|
-
* - Flutter: Key
|
|
6
|
-
* - Android: stableId
|
|
7
|
-
* - iOS: reuseIdentifier (logical)
|
|
8
|
-
*/
|
|
9
|
-
export type CellKey = string | number;
|
|
1
|
+
export type CellKey = number;
|
|
10
2
|
//# sourceMappingURL=CellKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellKey.d.ts","sourceRoot":"","sources":["../../../../src/types/CellKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CellKey.d.ts","sourceRoot":"","sources":["../../../../src/types/CellKey.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA"}
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
* Cross-platform equivalent:
|
|
7
7
|
* - Android: viewType
|
|
8
8
|
* - iOS: reuseIdentifier
|
|
9
|
+
*
|
|
10
|
+
* NOTE:
|
|
11
|
+
* This is a branded type to prevent accidental mixing
|
|
12
|
+
* with keys, indexes, or other strings/numbers.
|
|
13
|
+
*/
|
|
14
|
+
export type CellType = string & {
|
|
15
|
+
readonly __cellTypeBrand: unique symbol;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Helper to create a CellType safely.
|
|
19
|
+
* Keeps ergonomics simple for users.
|
|
9
20
|
*/
|
|
10
|
-
export
|
|
21
|
+
export declare const createCellType: (value: string) => CellType;
|
|
11
22
|
//# sourceMappingURL=CellType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellType.d.ts","sourceRoot":"","sources":["../../../../src/types/CellType.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CellType.d.ts","sourceRoot":"","sources":["../../../../src/types/CellType.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAC9B,QAAQ,CAAC,eAAe,EAAE,OAAO,MAAM,CAAA;CACxC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,KACZ,QAA6B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CellType } from "../CellType";
|
|
2
|
+
import type { RecyclerCell } from "./RecyclerCell";
|
|
3
|
+
/**
|
|
4
|
+
* Owns recycled physical cells.
|
|
5
|
+
* Enforces hard caps.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CellPool<T extends RecyclerCell> {
|
|
8
|
+
private readonly pools;
|
|
9
|
+
private readonly maxPerType;
|
|
10
|
+
hasType(type: CellType): boolean;
|
|
11
|
+
registerType(type: CellType, maxCount: number): void;
|
|
12
|
+
acquire(type: CellType): T | null;
|
|
13
|
+
release(cell: T): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=CellPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellPool.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/CellPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,YAAY;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IAEzD,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;IAIhC,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMpD,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,GAAG,IAAI;IAMjC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAWtB,KAAK,IAAI,IAAI;CAKd"}
|
|
@@ -3,12 +3,12 @@ import type { CellType } from '../CellType';
|
|
|
3
3
|
import type { MainAxisPadding } from '../layout';
|
|
4
4
|
import type { RecyclerItemRenderer } from './RecyclerItemRenderer';
|
|
5
5
|
/**
|
|
6
|
-
* Public props for
|
|
6
|
+
* Public props for NitroList.
|
|
7
7
|
*
|
|
8
8
|
* Generic, data-driven, layout-deterministic API.
|
|
9
9
|
* This surface is intentionally minimal and stable.
|
|
10
10
|
*/
|
|
11
|
-
export interface
|
|
11
|
+
export interface NitroListProps<T> {
|
|
12
12
|
/**
|
|
13
13
|
* Scroll direction.
|
|
14
14
|
* Defaults to 'vertical'.
|
|
@@ -63,4 +63,4 @@ export interface RecyclerListProps<T> {
|
|
|
63
63
|
*/
|
|
64
64
|
readonly renderItem: RecyclerItemRenderer<T>;
|
|
65
65
|
}
|
|
66
|
-
//# sourceMappingURL=
|
|
66
|
+
//# sourceMappingURL=NitroListProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroListProps.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/NitroListProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;IAE/B;;;;;;OAMG;IACH,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;IAEvC;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAA;IAE3B;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAA;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAA;IAElC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAE7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAE7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,QAAQ,CAAA;IAE1D;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;CAC7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CellType } from '../CellType';
|
|
2
|
+
import type { CellKey } from '../CellKey';
|
|
3
|
+
/**
|
|
4
|
+
* Public contract for a physical recycler cell.
|
|
5
|
+
* Key type MUST be generic / opaque.
|
|
6
|
+
*/
|
|
7
|
+
export interface RecyclerCell<K = CellKey> {
|
|
8
|
+
readonly key: K;
|
|
9
|
+
readonly type: CellType;
|
|
10
|
+
index: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=RecyclerCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecyclerCell.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/RecyclerCell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;IACf,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RecyclerCell } from './RecyclerCell';
|
|
3
|
+
/**
|
|
4
|
+
* Public renderItem signature for RecyclerList.
|
|
5
|
+
* Renderers receive a stable physical cell contract.
|
|
6
|
+
*/
|
|
3
7
|
export type RecyclerItemRenderer<T> = (params: {
|
|
4
8
|
item: T;
|
|
5
9
|
index: number;
|
|
6
|
-
cell:
|
|
10
|
+
cell: RecyclerCell;
|
|
7
11
|
}) => ReactNode;
|
|
8
12
|
//# sourceMappingURL=RecyclerItemRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecyclerItemRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/RecyclerItemRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RecyclerItemRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/RecyclerItemRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE;IAC7C,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,YAAY,CAAA;CACnB,KAAK,SAAS,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { NitroListProps } from './NitroListProps';
|
|
2
2
|
export type { RecyclerItemRenderer } from './RecyclerItemRenderer';
|
|
3
|
-
export type {
|
|
3
|
+
export type { RecyclerCell } from './RecyclerCell';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/recycler/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { LayoutRect } from "../types/layout";
|
|
2
|
+
export type VisibleRange = {
|
|
3
|
+
startIndex: number;
|
|
4
|
+
endIndex: number;
|
|
5
|
+
};
|
|
6
|
+
type Input = {
|
|
7
|
+
layouts: readonly LayoutRect[];
|
|
8
|
+
offset: number;
|
|
9
|
+
viewportSize: number;
|
|
10
|
+
buffer: number;
|
|
11
|
+
isVertical: boolean;
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
|
-
* Computes
|
|
5
|
-
*
|
|
6
|
-
* Responsibilities:
|
|
7
|
-
* - Determine which items intersect the visible window
|
|
8
|
-
* - Stay independent of rendering and recycling
|
|
9
|
-
*
|
|
10
|
-
* Performance:
|
|
11
|
-
* - O(log n) to locate the first visible item
|
|
12
|
-
* - O(k) to expand to the last visible item (k = visible count)
|
|
14
|
+
* Computes visible item range using binary search + forward scan.
|
|
15
|
+
* Type-safe and defensive against invalid indices.
|
|
13
16
|
*/
|
|
14
|
-
export declare function computeVisibleItemRange(input:
|
|
17
|
+
export declare function computeVisibleItemRange(input: Input): VisibleRange | null;
|
|
18
|
+
export {};
|
|
15
19
|
//# sourceMappingURL=computeVisibleItemRange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeVisibleItemRange.d.ts","sourceRoot":"","sources":["../../../../src/windowing/computeVisibleItemRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"computeVisibleItemRange.d.ts","sourceRoot":"","sources":["../../../../src/windowing/computeVisibleItemRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGjD,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,SAAS,UAAU,EAAE,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,KAAK,GACX,YAAY,GAAG,IAAI,CA2DrB"}
|
package/nitro.json
CHANGED
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
|
|
15
15
|
"autolinking": {
|
|
16
16
|
"views": {
|
|
17
|
-
"
|
|
17
|
+
"NitroList": {
|
|
18
18
|
"swift": "HybridNitroList",
|
|
19
19
|
"kotlin": "HybridNitroList"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"objects": {
|
|
23
|
-
"
|
|
24
|
-
"swift": "
|
|
25
|
-
"kotlin": "
|
|
23
|
+
"LayoutEngine": {
|
|
24
|
+
"swift": "HybridLayoutEngine",
|
|
25
|
+
"kotlin": "HybridLayoutEngine"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
"ignorePaths": ["**/node_modules"]
|
|
31
|
-
}
|
|
31
|
+
}
|
|
@@ -33,9 +33,9 @@ target_sources(
|
|
|
33
33
|
# Autolinking Setup
|
|
34
34
|
../nitrogen/generated/android/NitroListOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
|
-
../nitrogen/generated/shared/c++/
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridNitroListSpec.cpp
|
|
37
37
|
# Android-specific Nitrogen C++ sources
|
|
38
|
-
../nitrogen/generated/android/c++/
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridNitroListSpec.cpp
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
#include <fbjni/fbjni.h>
|
|
16
16
|
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
17
|
|
|
18
|
-
#include "
|
|
18
|
+
#include "JHybridNitroListSpec.hpp"
|
|
19
19
|
|
|
20
20
|
namespace margelo::nitro::nitrolist {
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ int initialize(JavaVM* vm) {
|
|
|
26
26
|
|
|
27
27
|
return facebook::jni::initialize(vm, [] {
|
|
28
28
|
// Register native JNI methods
|
|
29
|
-
margelo::nitro::nitrolist::
|
|
29
|
+
margelo::nitro::nitrolist::JHybridNitroListSpec::registerNatives();
|
|
30
30
|
|
|
31
31
|
// Register Nitro Hybrid Objects
|
|
32
32
|
|
package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.cpp → JHybridNitroListSpec.cpp}
RENAMED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// JHybridNitroListSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "JHybridNitroListSpec.hpp"
|
|
9
9
|
|
|
10
|
-
// Forward declaration of `
|
|
11
|
-
namespace margelo::nitro::nitrolist { struct
|
|
10
|
+
// Forward declaration of `ItemLayout` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::nitrolist { struct ItemLayout; }
|
|
12
12
|
|
|
13
|
-
#include "
|
|
13
|
+
#include "ItemLayout.hpp"
|
|
14
14
|
#include <vector>
|
|
15
|
-
#include "
|
|
15
|
+
#include "JItemLayout.hpp"
|
|
16
16
|
|
|
17
17
|
namespace margelo::nitro::nitrolist {
|
|
18
18
|
|
|
19
|
-
jni::local_ref<
|
|
19
|
+
jni::local_ref<JHybridNitroListSpec::jhybriddata> JHybridNitroListSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
20
20
|
return makeCxxInstance(jThis);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
void
|
|
23
|
+
void JHybridNitroListSpec::registerNatives() {
|
|
24
24
|
registerHybrid({
|
|
25
|
-
makeNativeMethod("initHybrid",
|
|
25
|
+
makeNativeMethod("initHybrid", JHybridNitroListSpec::initHybrid),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
size_t
|
|
29
|
+
size_t JHybridNitroListSpec::getExternalMemorySize() noexcept {
|
|
30
30
|
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
31
31
|
return method(_javaPart);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
void
|
|
34
|
+
void JHybridNitroListSpec::dispose() noexcept {
|
|
35
35
|
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
36
36
|
method(_javaPart);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
std::string
|
|
39
|
+
std::string JHybridNitroListSpec::toString() {
|
|
40
40
|
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
41
41
|
auto javaString = method(_javaPart);
|
|
42
42
|
return javaString->toStdString();
|
|
@@ -46,8 +46,8 @@ namespace margelo::nitro::nitrolist {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
// Methods
|
|
49
|
-
std::vector<
|
|
50
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<
|
|
49
|
+
std::vector<ItemLayout> JHybridNitroListSpec::computeLayout(double containerWidth, const std::vector<double>& itemHeights) {
|
|
50
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JItemLayout>>(double /* containerWidth */, jni::alias_ref<jni::JArrayDouble> /* itemHeights */)>("computeLayout");
|
|
51
51
|
auto __result = method(_javaPart, containerWidth, [&]() {
|
|
52
52
|
size_t __size = itemHeights.size();
|
|
53
53
|
jni::local_ref<jni::JArrayDouble> __array = jni::JArrayDouble::newArray(__size);
|
|
@@ -56,7 +56,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
56
56
|
}());
|
|
57
57
|
return [&]() {
|
|
58
58
|
size_t __size = __result->size();
|
|
59
|
-
std::vector<
|
|
59
|
+
std::vector<ItemLayout> __vector;
|
|
60
60
|
__vector.reserve(__size);
|
|
61
61
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
62
62
|
auto __element = __result->getElement(__i);
|
package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.hpp → JHybridNitroListSpec.hpp}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroListSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#include <NitroModules/JHybridObject.hpp>
|
|
11
11
|
#include <fbjni/fbjni.h>
|
|
12
|
-
#include "
|
|
12
|
+
#include "HybridNitroListSpec.hpp"
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -18,22 +18,22 @@ namespace margelo::nitro::nitrolist {
|
|
|
18
18
|
|
|
19
19
|
using namespace facebook;
|
|
20
20
|
|
|
21
|
-
class
|
|
22
|
-
|
|
21
|
+
class JHybridNitroListSpec: public jni::HybridClass<JHybridNitroListSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridNitroListSpec {
|
|
23
23
|
public:
|
|
24
|
-
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolist/
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolist/HybridNitroListSpec;";
|
|
25
25
|
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
26
|
static void registerNatives();
|
|
27
27
|
|
|
28
28
|
protected:
|
|
29
29
|
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
-
explicit
|
|
31
|
-
HybridObject(
|
|
30
|
+
explicit JHybridNitroListSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridNitroListSpec::TAG),
|
|
32
32
|
HybridBase(jThis),
|
|
33
33
|
_javaPart(jni::make_global(jThis)) {}
|
|
34
34
|
|
|
35
35
|
public:
|
|
36
|
-
~
|
|
36
|
+
~JHybridNitroListSpec() override {
|
|
37
37
|
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
38
|
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
39
|
}
|
|
@@ -44,7 +44,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
44
44
|
std::string toString() override;
|
|
45
45
|
|
|
46
46
|
public:
|
|
47
|
-
inline const jni::global_ref<
|
|
47
|
+
inline const jni::global_ref<JHybridNitroListSpec::javaobject>& getJavaPart() const noexcept {
|
|
48
48
|
return _javaPart;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -54,12 +54,12 @@ namespace margelo::nitro::nitrolist {
|
|
|
54
54
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
|
-
std::vector<
|
|
57
|
+
std::vector<ItemLayout> computeLayout(double containerWidth, const std::vector<double>& itemHeights) override;
|
|
58
58
|
|
|
59
59
|
private:
|
|
60
60
|
friend HybridBase;
|
|
61
61
|
using HybridBase::HybridBase;
|
|
62
|
-
jni::global_ref<
|
|
62
|
+
jni::global_ref<JHybridNitroListSpec::javaobject> _javaPart;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
} // namespace margelo::nitro::nitrolist
|