mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
list/scroll事件对接modifier
Signed-off-by: Zhang-Dong-hui <zhangdonghui5@huawei.com> Change-Id: I56b741ec860a5e4fb90249855ff027bf8acd798e
This commit is contained in:
parent
e14a556055
commit
a94b9a71b9
@ -910,6 +910,8 @@ declare class ArkScrollComponent extends ArkComponent implements ScrollAttribute
|
||||
clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this;
|
||||
initialOffset(value: OffsetOptions): this;
|
||||
flingSpeedLimit(value: number): this;
|
||||
onReachStart(event: () => void): this;
|
||||
onReachEnd(event: () => void): this;
|
||||
}
|
||||
declare class ArkToggleComponent extends ArkComponent implements ToggleAttribute {
|
||||
constructor(nativePtr: KNode, classType?: ModifierType);
|
||||
@ -1773,10 +1775,7 @@ declare class ArkListComponent extends ArkComponent implements ListAttribute {
|
||||
clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this;
|
||||
onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): this;
|
||||
onScrollIndex(event: (start: number, end: number, center: number) => void): this;
|
||||
onReachStart(event: () => void): this;
|
||||
onReachEnd(event: () => void): this;
|
||||
onScrollStart(event: () => void): this;
|
||||
onScrollStop(event: () => void): this;
|
||||
onScrollVisibleContentChange(callback: OnScrollVisibleContentChangeCallback): this;
|
||||
onItemDelete(event: (index: number) => boolean): this;
|
||||
onItemMove(event: (from: number, to: number) => boolean): this;
|
||||
onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => void | (() => any)): this;
|
||||
@ -1787,6 +1786,13 @@ declare class ArkListComponent extends ArkComponent implements ListAttribute {
|
||||
onScrollFrameBegin(event: (offset: number, state: ScrollState) => {
|
||||
offsetRemain: number;
|
||||
}): this;
|
||||
onWillScroll(callback: (xOffset: number, yOffset: number,
|
||||
scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult): this;
|
||||
onDidScroll(callback: (xOffset: number, yOffset: number, scrollState: ScrollState) => void): this;
|
||||
onReachStart(event: () => void): this;
|
||||
onReachEnd(event: () => void): this;
|
||||
onScrollStart(event: () => void): this;
|
||||
onScrollStop(event: () => void): this;
|
||||
fadingEdge(value: boolean, options?: FadingEdgeOptions | undefined): this;
|
||||
childrenMainSize(value: ChildrenMainSize): this;
|
||||
}
|
||||
|
@ -383,6 +383,218 @@ class ListClipModifier extends ModifierWithKey<boolean | object> {
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnScrollIndexModifier extends ModifierWithKey<(start: number, end: number, center: number) => void> {
|
||||
constructor(value: (start: number, end: number, center: number) => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnScrollIndex');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollIndex(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollIndex(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnScrollVisibleContentChangeModifier extends ModifierWithKey<OnScrollVisibleContentChangeCallback> {
|
||||
constructor(value: OnScrollVisibleContentChangeCallback) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnScrollVisibleContentChange');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollVisibleContentChange(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollVisibleContentChange(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnReachStartModifier extends ModifierWithKey<() => void> {
|
||||
constructor(value: () => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnReachStart');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnReachStart(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnReachStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnReachEndModifier extends ModifierWithKey<() => void> {
|
||||
constructor(value: () => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnReachEnd');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnReachEnd(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnReachEnd(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnScrollStartModifier extends ModifierWithKey<() => void> {
|
||||
constructor(value: () => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnScrollStart');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollStart(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnScrollStopModifier extends ModifierWithKey<() => void> {
|
||||
constructor(value: () => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnScrollStop');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollStop(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollStop(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnItemMoveModifier extends ModifierWithKey<(from: number, to: number) => boolean> {
|
||||
constructor(value: (from: number, to: number) => boolean) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnItemMove');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemMove(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemMove(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnItemDragStartModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number) => void | (() => any)> {
|
||||
constructor(value: (event: ItemDragInfo, itemIndex: number) => void | (() => any)) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnItemDragStart');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragStart(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnItemDragEnterModifier extends ModifierWithKey<(event: ItemDragInfo) => void> {
|
||||
constructor(value: (event: ItemDragInfo) => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnItemDragEnter');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragEnter(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragEnter(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnItemDragMoveModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number, insertIndex: number) => void> {
|
||||
constructor(value: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnItemDragMove');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragMove(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragMove(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnItemDragLeaveModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number) => void> {
|
||||
constructor(value: (event: ItemDragInfo, itemIndex: number) => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnItemDragLeave');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragLeave(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragLeave(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnItemDropModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void> {
|
||||
constructor(value: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnItemDrop');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDrop(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDrop(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnScrollFrameBeginModifier extends ModifierWithKey<(offset: number, state: ScrollState) => { offsetRemain: number }> {
|
||||
constructor(value: (offset: number, state: ScrollState) => { offsetRemain: number; }) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnScrollFrameBegin');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollFrameBegin(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollFrameBegin(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnWillScrollModifier extends ModifierWithKey<(xOffset: number, yOffset: number,
|
||||
scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult> {
|
||||
constructor(value: (xOffset: number, yOffset: number,
|
||||
scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnWillScroll');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnWillScroll(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnWillScroll(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListOnDidScrollModifier extends ModifierWithKey<(xOffset: number, yOffset: number, scrollState: ScrollState) => void> {
|
||||
constructor(value: (xOffset: number, yOffset: number, scrollState: ScrollState) => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('listOnDidScroll');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnDidScroll(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnDidScroll(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListFadingEdgeModifier extends ModifierWithKey<ArkFadingEdge> {
|
||||
constructor(value: ArkFadingEdge) {
|
||||
super(value);
|
||||
@ -602,43 +814,68 @@ class ArkListComponent extends ArkScrollable<ListAttribute> implements ListAttri
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onScrollIndex(event: (start: number, end: number, center: number) => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollIndexModifier.identity, ListOnScrollIndexModifier, event);
|
||||
return this;
|
||||
}
|
||||
onReachStart(event: () => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onReachEnd(event: () => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onScrollStart(event: () => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onScrollStop(event: () => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
onScrollVisibleContentChange(callback: OnScrollVisibleContentChangeCallback): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollVisibleContentChangeModifier.identity, ListOnScrollVisibleContentChangeModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onItemDelete(event: (index: number) => boolean): this {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onItemMove(event: (from: number, to: number) => boolean): this {
|
||||
throw new Error('Method not implemented.');
|
||||
onItemMove(callback: (from: number, to: number) => boolean): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemMoveModifier.identity, ListOnItemMoveModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => void | (() => any)): this {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragStartModifier.identity, ListOnItemDragStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragEnter(event: (event: ItemDragInfo) => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragEnterModifier.identity, ListOnItemDragEnterModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragMoveModifier.identity, ListOnItemDragMoveModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragLeaveModifier.identity, ListOnItemDragLeaveModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void): this {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDropModifier.identity, ListOnItemDropModifier, event);
|
||||
return this;
|
||||
}
|
||||
onScrollFrameBegin(event: (offset: number, state: ScrollState) => { offsetRemain: number; }): this {
|
||||
throw new Error('Method not implemented.');
|
||||
onScrollFrameBegin(callback: (offset: number, state: ScrollState) => { offsetRemain: number }): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollFrameBeginModifier.identity, ListOnScrollFrameBeginModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onWillScroll(callback: (xOffset: number, yOffset: number,
|
||||
scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnWillScrollModifier.identity, ListOnWillScrollModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onDidScroll(callback: (xOffset: number, yOffset: number, scrollState: ScrollState) => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnDidScrollModifier.identity, ListOnDidScrollModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onReachStart(event: () => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnReachStartModifier.identity, ListOnReachStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
onReachEnd(event: () => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnReachEndModifier.identity, ListOnReachEndModifier, event);
|
||||
return this;
|
||||
}
|
||||
onScrollStart(event: () => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollStartModifier.identity, ListOnScrollStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
onScrollStop(event: () => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollStopModifier.identity, ListOnScrollStopModifier, event);
|
||||
return this;
|
||||
}
|
||||
fadingEdge(value: boolean, options?: FadingEdgeOptions | undefined): this {
|
||||
let fadingEdge: ArkFadingEdge = new ArkFadingEdge();
|
||||
|
@ -29,6 +29,34 @@ class ClipContentModifier extends ModifierWithKey<ContentClipMode | RectShape> {
|
||||
}
|
||||
}
|
||||
|
||||
class OnReachStartModifier extends ModifierWithKey<() => void> {
|
||||
constructor(value: () => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('onReachStart');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().scrollable.resetOnReachStart(node);
|
||||
} else {
|
||||
getUINativeModule().scrollable.setOnReachStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OnReachEndModifier extends ModifierWithKey<() => void> {
|
||||
constructor(value: () => void) {
|
||||
super(value);
|
||||
}
|
||||
static identity: Symbol = Symbol('onReachEnd');
|
||||
applyPeer(node: KNode, reset: boolean): void {
|
||||
if (reset) {
|
||||
getUINativeModule().scrollable.resetOnReachEnd(node);
|
||||
} else {
|
||||
getUINativeModule().scrollable.setOnReachEnd(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* base class of Grid, Scroll, List, and WaterFlow.
|
||||
*/
|
||||
@ -40,4 +68,13 @@ export class ArkScrollable<T> extends ArkComponent implements ScrollableCommonMe
|
||||
modifierWithKey(this._modifiersWithKeys, ClipContentModifier.identity, ClipContentModifier, clip);
|
||||
return this;
|
||||
}
|
||||
onReachStart(event: () => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, OnReachStartModifier.identity, OnReachStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
|
||||
onReachEnd(event: () => void): this {
|
||||
modifierWithKey(this._modifiersWithKeys, OnReachEndModifier.identity, OnReachEndModifier, event);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -5829,6 +5829,34 @@ class ClipContentModifier extends ModifierWithKey {
|
||||
}
|
||||
ClipContentModifier.identity = Symbol('clipContent');
|
||||
|
||||
class OnReachStartModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().scrollable.resetOnReachStart(node);
|
||||
} else {
|
||||
getUINativeModule().scrollable.setOnReachStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
OnReachStartModifier.identity = Symbol('onReachStart');
|
||||
|
||||
class OnReachEndModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().scrollable.resetOnReachEnd(node);
|
||||
} else {
|
||||
getUINativeModule().scrollable.setOnReachEnd(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
OnReachStartModifier.identity = Symbol('onReachEnd');
|
||||
|
||||
class ArkScrollable extends ArkComponent {
|
||||
constructor(nativePtr, classType) {
|
||||
super(nativePtr, classType);
|
||||
@ -5837,6 +5865,15 @@ class ArkScrollable extends ArkComponent {
|
||||
modifierWithKey(this._modifiersWithKeys, ClipContentModifier.identity, ClipContentModifier, clip);
|
||||
return this;
|
||||
}
|
||||
onReachStart(event) {
|
||||
modifierWithKey(this._modifiersWithKeys, OnReachStartModifier.identity, OnReachStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
|
||||
onReachEnd(event) {
|
||||
modifierWithKey(this._modifiersWithKeys, OnReachEndModifier.identity, OnReachEndModifier, event);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/// <reference path='./import.ts' />
|
||||
@ -27443,6 +27480,201 @@ class ListClipModifier extends ModifierWithKey {
|
||||
}
|
||||
}
|
||||
ListClipModifier.identity = Symbol('listClip');
|
||||
class ListOnScrollIndexModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollIndex(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollIndex(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnScrollIndexModifier.identity = Symbol('listOnScrollIndex');
|
||||
class ListOnScrollVisibleContentChangeModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollVisibleContentChange(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollVisibleContentChange(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnScrollVisibleContentChangeModifier.identity = Symbol('listOnScrollVisibleContentChange');
|
||||
class ListOnItemMoveModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemMove(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemMove(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnItemMoveModifier.identity = Symbol('listOnItemMove');
|
||||
class ListOnItemDragStartModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragStart(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnItemDragStartModifier.identity = Symbol('listOnItemDragStart');
|
||||
class ListOnItemDragEnterModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragEnter(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragEnter(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnItemDragEnterModifier.identity = Symbol('listOnItemDragEnter');
|
||||
class ListOnItemDragMoveModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragMove(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragMove(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnItemDragMoveModifier.identity = Symbol('listOnItemDragMove');
|
||||
class ListOnItemDragLeaveModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDragLeave(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDragLeave(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnItemDragLeaveModifier.identity = Symbol('listOnItemDragLeave');
|
||||
class ListOnItemDropModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnItemDrop(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnItemDrop(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnItemDropModifier.identity = Symbol('listOnItemDrop');
|
||||
class ListOnScrollFrameBeginModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollFrameBegin(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollFrameBegin(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnScrollFrameBeginModifier.identity = Symbol('listOnScrollFrameBegin');
|
||||
class ListOnWillScrollModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnWillScroll(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnWillScroll(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnWillScrollModifier.identity = Symbol('listOnWillScroll');
|
||||
class ListOnDidScrollModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnDidScroll(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnDidScroll(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnDidScrollModifier.identity = Symbol('listOnDidScroll');
|
||||
class ListOnReachStartModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnReachStart(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnReachStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnReachStartModifier.identity = Symbol('listOnReachStart');
|
||||
class ListOnReachEndModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnReachEnd(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnReachEnd(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnReachEndModifier.identity = Symbol('listOnReachEnd');
|
||||
class ListOnScrollStartModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollStart(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollStart(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnScrollStartModifier.identity = Symbol('listOnScrollStart');
|
||||
class ListOnScrollStopModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
}
|
||||
applyPeer(node, reset) {
|
||||
if (reset) {
|
||||
getUINativeModule().list.resetOnScrollStop(node);
|
||||
} else {
|
||||
getUINativeModule().list.setOnScrollStop(node, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListOnScrollStopModifier.identity = Symbol('listOnScrollStop');
|
||||
class ListFadingEdgeModifier extends ModifierWithKey {
|
||||
constructor(value) {
|
||||
super(value);
|
||||
@ -27661,43 +27893,67 @@ class ArkListComponent extends ArkScrollable {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onScrollIndex(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollIndexModifier.identity, ListOnScrollIndexModifier, event);
|
||||
return this;
|
||||
}
|
||||
onReachStart(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onReachEnd(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onScrollStart(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onScrollStop(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
onScrollVisibleContentChange(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollVisibleContentChangeModifier.identity, ListOnScrollVisibleContentChangeModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onItemDelete(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
onItemMove(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemMoveModifier.identity, ListOnItemMoveModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragStart(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragStartModifier.identity, ListOnItemDragStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragEnter(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragEnterModifier.identity, ListOnItemDragEnterModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragMove(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragMoveModifier.identity, ListOnItemDragMoveModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDragLeave(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDragLeaveModifier.identity, ListOnItemDragLeaveModifier, event);
|
||||
return this;
|
||||
}
|
||||
onItemDrop(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnItemDropModifier.identity, ListOnItemDropModifier, event);
|
||||
return this;
|
||||
}
|
||||
onScrollFrameBegin(event) {
|
||||
throw new Error('Method not implemented.');
|
||||
onScrollFrameBegin(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollFrameBeginModifier.identity, ListOnScrollFrameBeginModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onWillScroll(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnWillScrollModifier.identity, ListOnWillScrollModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onDidScroll(callback) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnDidScrollModifier.identity, ListOnDidScrollModifier, callback);
|
||||
return this;
|
||||
}
|
||||
onReachStart(event) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnReachStartModifier.identity, ListOnReachStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
onReachEnd(event) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnReachEndModifier.identity, ListOnReachEndModifier, event);
|
||||
return this;
|
||||
}
|
||||
onScrollStart(event) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollStartModifier.identity, ListOnScrollStartModifier, event);
|
||||
return this;
|
||||
}
|
||||
onScrollStop(event) {
|
||||
modifierWithKey(this._modifiersWithKeys, ListOnScrollStopModifier.identity, ListOnScrollStopModifier, event);
|
||||
return this;
|
||||
}
|
||||
fadingEdge(value, options) {
|
||||
let fadingEdge = new ArkFadingEdge();
|
||||
|
@ -4549,6 +4549,14 @@ void ArkUINativeModule::RegisterScrollableAttributes(Local<panda::ObjectRef> obj
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ScrollableBridge::SetContentClip));
|
||||
scrollable->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetContentClip"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ScrollableBridge::ResetContentClip));
|
||||
scrollable->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnReachStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ScrollableBridge::SetOnReachStart));
|
||||
scrollable->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnReachStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ScrollableBridge::ResetOnReachStart));
|
||||
scrollable->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnReachEnd"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ScrollableBridge::SetOnReachEnd));
|
||||
scrollable->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnReachEnd"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ScrollableBridge::ResetOnReachEnd));
|
||||
object->Set(vm, panda::StringRef::NewFromUtf8(vm, "scrollable"), scrollable);
|
||||
}
|
||||
|
||||
@ -5071,6 +5079,66 @@ void ArkUINativeModule::RegisterListAttributes(Local<panda::ObjectRef> object, E
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetInitialScroller));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetInitialScroller"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetInitialScroller));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnScrollIndex"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnScrollIndex));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnScrollIndex"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnScrollIndex));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnScrollVisibleContentChange"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnScrollVisibleContentChange));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnScrollVisibleContentChange"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnScrollVisibleContentChange));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnItemMove"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnItemMove));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnItemMove"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnItemMove));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnItemDragStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnItemDragStart));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnItemDragStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnItemDragStart));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnItemDragEnter"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnItemDragEnter));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnItemDragEnter"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnItemDragEnter));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnItemDragMove"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnItemDragMove));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnItemDragMove"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnItemDragMove));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnItemDragLeave"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnItemDragLeave));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnItemDragLeave"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnItemDragLeave));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnItemDrop"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnItemDrop));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnItemDrop"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnItemDrop));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnScrollStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListScrollStart));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnScrollStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListScrollStart));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnScrollStop"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListScrollStop));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnScrollStop"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListScrollStop));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnScrollFrameBegin"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListScrollFrameBegin));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnScrollFrameBegin"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListScrollFrameBegin));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnWillScroll"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListWillScroll));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnWillScroll"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListWillScroll));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnDidScroll"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListDidScroll));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnDidScroll"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListDidScroll));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnReachStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListReachStart));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnReachStart"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListReachStart));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "setOnReachEnd"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::SetOnListReachEnd));
|
||||
list->Set(vm, panda::StringRef::NewFromUtf8(vm, "resetOnReachEnd"),
|
||||
panda::FunctionRef::New(const_cast<panda::EcmaVM*>(vm), ListBridge::ResetOnListReachEnd));
|
||||
object->Set(vm, panda::StringRef::NewFromUtf8(vm, "list"), list);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,9 @@
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
|
||||
#include "frameworks/core/components/list/list_theme.h"
|
||||
#include "frameworks/core/components_ng/pattern/list/list_model.h"
|
||||
#include "frameworks/core/components_ng/pattern/list/list_model_ng.h"
|
||||
#include "frameworks/core/components_ng/pattern/scroll_bar/proxy/scroll_bar_proxy.h"
|
||||
#include "frameworks/core/components_ng/base/view_stack_model.h"
|
||||
using namespace OHOS::Ace::Framework;
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
@ -940,4 +942,649 @@ void ListBridge::SetScroller(ArkUIRuntimeCallInfo* runtimeCallInfo, RefPtr<Frame
|
||||
GetArkUINodeModifiers()->getListModifier()->setInitialScroller(nativeNode, controller, proxyPtr);
|
||||
}
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnScrollIndex(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollIndex(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
|
||||
std::function<void(int32_t, int32_t, int32_t )> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](
|
||||
const int32_t start, const int32_t end,
|
||||
const int32_t center) {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
|
||||
panda::Local<panda::NumberRef> startParam = panda::NumberRef::New(vm, start);
|
||||
panda::Local<panda::NumberRef> endParam = panda::NumberRef::New(vm, end);
|
||||
panda::Local<panda::NumberRef> centerParam = panda::NumberRef::New(vm, center);
|
||||
// 3: Array length
|
||||
panda::Local<panda::JSValueRef> params[3] = { startParam, endParam, centerParam };
|
||||
func->Call(vm, func.ToLocal(), params, 3);// 3: Array length
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListScrollIndexCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnScrollVisibleContentChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnScrollVisibleContentChange(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
|
||||
std::function<void(ListItemIndex, ListItemIndex)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](
|
||||
const ListItemIndex start, const ListItemIndex end) {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
|
||||
const char* keys[] = { "index", "itemGroupArea", "itemIndexInGroup" };
|
||||
Local<JSValueRef> startValues[] = { panda::NumberRef::New(vm, static_cast<int32_t>(start.index)),
|
||||
panda::NumberRef::New(vm, static_cast<int32_t>(start.indexInGroup)),
|
||||
panda::NumberRef::New(vm, static_cast<int32_t>(start.area)) };
|
||||
Local<JSValueRef> endValues[] = { panda::NumberRef::New(vm, static_cast<int32_t>(end.index)),
|
||||
panda::NumberRef::New(vm, static_cast<int32_t>(end.indexInGroup)),
|
||||
panda::NumberRef::New(vm, static_cast<int32_t>(end.area)) };
|
||||
auto startParam = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, startValues);
|
||||
auto endParam = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, endValues);
|
||||
startParam->SetNativePointerFieldCount(vm, 1);
|
||||
startParam->SetNativePointerField(vm, 0, static_cast<void*>(&startParam));
|
||||
endParam->SetNativePointerFieldCount(vm, 1);
|
||||
endParam->SetNativePointerField(vm, 0, static_cast<void*>(&endParam));
|
||||
// 2: Array length
|
||||
panda::Local<panda::JSValueRef> params[2] = { startParam, endParam };
|
||||
func->Call(vm, func.ToLocal(), params, 2);// 2: Array length
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnScrollVisibleContentChange(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnItemMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemMove(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
|
||||
std::function<bool(int32_t, int32_t)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](
|
||||
int32_t start, int32_t end) -> bool {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
|
||||
panda::Local<panda::NumberRef> startParam = panda::NumberRef::New(vm, start);
|
||||
panda::Local<panda::NumberRef> endParam = panda::NumberRef::New(vm, end);
|
||||
// 2: Array length
|
||||
panda::Local<panda::JSValueRef> params[2] = { startParam, endParam};
|
||||
auto result = func->Call(vm, func.ToLocal(), params, 2); // 2: Array length
|
||||
if (result->IsBoolean()) {
|
||||
return result->ToBoolean(vm)->Value();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnItemMove(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnItemDragStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
|
||||
Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
|
||||
if (!info[1]->IsFunction()) {
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
RefPtr<JsDragFunction> jsOnDragFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(info[1]));
|
||||
std::function<RefPtr<AceType>(const ItemDragInfo&, int32_t)> callback =
|
||||
[vm, frameNode, func = std::move(jsOnDragFunc), execCtx = info.GetExecutionContext()](
|
||||
const ItemDragInfo& dragInfo, int32_t itemIndex) -> RefPtr<AceType> {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, nullptr);
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
|
||||
auto ret = func->ItemDragStartExecute(dragInfo, itemIndex);
|
||||
if (!ret->IsFunction()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto builderFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSFunc>::Cast(ret));
|
||||
if (!builderFunc) {
|
||||
return nullptr;
|
||||
}
|
||||
// use another VSP instance while executing the builder function
|
||||
ViewStackModel::GetInstance()->NewScope();
|
||||
{
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
builderFunc->Execute();
|
||||
}
|
||||
return ViewStackModel::GetInstance()->Finish();
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnItemDragStart(nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnItemDragEnter(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
|
||||
Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
|
||||
if (!info[1]->IsFunction()) {
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
RefPtr<JsDragFunction> jsOnDragFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(info[1]));
|
||||
|
||||
std::function<void(const ItemDragInfo&)> callback = [vm, frameNode, func = std::move(jsOnDragFunc),
|
||||
execCtx = info.GetExecutionContext()](
|
||||
const ItemDragInfo& dragInfo) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->ItemDragEnterExecute(dragInfo);
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnItemDragEnter(nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnItemDragMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
|
||||
Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
|
||||
if (!info[1]->IsFunction()) {
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
RefPtr<JsDragFunction> jsOnDragFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(info[1]));
|
||||
|
||||
std::function<void(const ItemDragInfo&, int32_t, int32_t)> callback =
|
||||
[vm, frameNode, func = std::move(jsOnDragFunc), execCtx = info.GetExecutionContext()](
|
||||
const ItemDragInfo& dragInfo, int32_t itemIndex, int32_t insertIndex) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->ItemDragMoveExecute(dragInfo, itemIndex, insertIndex);
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnItemDragMove(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnItemDragLeave(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
|
||||
Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
|
||||
if (!info[1]->IsFunction()) {
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
RefPtr<JsDragFunction> jsOnDragFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(info[1]));
|
||||
|
||||
std::function<void(const ItemDragInfo&, int32_t)> callback = [vm, frameNode, func = std::move(jsOnDragFunc)](
|
||||
const ItemDragInfo& dragInfo, int32_t itemIndex) {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->ItemDragLeaveExecute(dragInfo, itemIndex);
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnItemDragLeave(nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnItemDrop(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
|
||||
Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
|
||||
if (!info[1]->IsFunction()) {
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
RefPtr<JsDragFunction> jsOnDragFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(info[1]));
|
||||
|
||||
std::function<void(const ItemDragInfo&, int32_t, int32_t, bool)> callback =
|
||||
[vm, frameNode, func = std::move(jsOnDragFunc)](
|
||||
const ItemDragInfo& dragInfo, int32_t itemIndex, int32_t insertIndex, bool isSuccess) {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->ItemDropExecute(dragInfo, itemIndex, insertIndex, isSuccess);
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnItemDrop(nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListScrollStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollStart(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
|
||||
std::function<void()> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)]() {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->Call(vm, func.ToLocal(), nullptr, 0);
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListScrollStartCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListScrollStop(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM *vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollStop(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)]() {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->Call(vm, func.ToLocal(), nullptr, 0);
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListScrollStopCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListScrollFrameBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollFrameBegin(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<ScrollFrameResult(Dimension, ScrollState)> callback = [vm, frameNode,
|
||||
func = panda::CopyableGlobal(vm, func)](Dimension offset, ScrollState state) -> ScrollFrameResult {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
|
||||
panda::Local<panda::NumberRef> offsetParam = panda::NumberRef::New(
|
||||
vm, static_cast<double>(offset.ConvertToVp()));
|
||||
panda::Local<panda::NumberRef> stateParam = panda::NumberRef::New(vm, static_cast<double>(state));
|
||||
// 2: Array length
|
||||
panda::Local<panda::JSValueRef> params[2] = { offsetParam, stateParam };
|
||||
auto value = func->Call(vm, func.ToLocal(), params, 2); // 2: Array length
|
||||
|
||||
OHOS::Ace::ScrollFrameResult scrollRes { .offset = offset };
|
||||
if (value->IsNumber()) {
|
||||
scrollRes.offset = Dimension(value->ToNumber(vm)->Value(), DimensionUnit::VP);
|
||||
}
|
||||
if (value->IsObject(vm)) {
|
||||
auto resultObj = value->ToObject(vm);
|
||||
panda::Local<panda::JSValueRef> remain = resultObj->Get(vm, panda::StringRef::NewFromUtf8(vm,
|
||||
"offsetRemain"));
|
||||
if (remain->IsNumber()) {
|
||||
scrollRes.offset = Dimension(remain->ToNumber(vm)->Value(), DimensionUnit::VP);
|
||||
}
|
||||
}
|
||||
return scrollRes;
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListScrollFrameBeginCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListWillScroll(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListWillScroll(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<ScrollFrameResult(CalcDimension, ScrollState, ScrollSource)> callback =
|
||||
[vm, frameNode, func = panda::CopyableGlobal(vm, func)](const CalcDimension& scrollOffset, const ScrollState& scrollState,
|
||||
ScrollSource scrollSource) {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
|
||||
panda::Local<panda::NumberRef> offsetParam = panda::NumberRef::New(
|
||||
vm, static_cast<double>(scrollOffset.ConvertToVp()));
|
||||
panda::Local<panda::NumberRef> stateParam = panda::NumberRef::New(vm, static_cast<int32_t>(scrollState));
|
||||
panda::Local<panda::NumberRef> sourceParam = panda::NumberRef::New(vm, static_cast<int32_t>(scrollSource));
|
||||
// 3: Array length
|
||||
panda::Local<panda::JSValueRef> params[3] = { offsetParam, stateParam, sourceParam };
|
||||
auto result = func->Call(vm, func.ToLocal(), params, 3); // 4: Array length
|
||||
ScrollFrameResult scrollRes { .offset = scrollOffset };
|
||||
|
||||
if (result->IsObject(vm)) {
|
||||
auto resultObj = result->ToObject(vm);
|
||||
panda::Local<panda::JSValueRef> dxRemainValue = resultObj->Get(vm, panda::StringRef::NewFromUtf8(vm, "offsetRemain"));
|
||||
if (dxRemainValue->IsNumber()) {
|
||||
scrollRes.offset = Dimension(dxRemainValue->ToNumber(vm)->Value(), DimensionUnit::VP);
|
||||
}
|
||||
}
|
||||
return scrollRes;
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListWillScrollCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListDidScroll(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListDidScroll(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<void(Dimension, ScrollState)> callback = [vm, frameNode,func = panda::CopyableGlobal(vm, func)](
|
||||
const CalcDimension& scrollOffset, const ScrollState& scrollState) {
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
|
||||
panda::Local<panda::NumberRef> offsetParam =
|
||||
panda::NumberRef::New(vm, static_cast<double>(scrollOffset.ConvertToVp()));
|
||||
panda::Local<panda::NumberRef> stateParam = panda::NumberRef::New(vm, static_cast<int32_t>(scrollState));
|
||||
// 2: Array length
|
||||
panda::Local<panda::JSValueRef> params[2] = { offsetParam, stateParam };
|
||||
func->Call(vm, func.ToLocal(), params, 2); // 2: Array length
|
||||
};
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListDidScrollCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListReachStart(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](){
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->Call(vm, func.ToLocal(), nullptr, 0);
|
||||
};
|
||||
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListReachStartCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::SetOnListReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListReachEnd(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](){
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->Call(vm, func.ToLocal(), nullptr, 0);
|
||||
};
|
||||
|
||||
GetArkUINodeModifiers()->getListModifier()->setOnListReachEndCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnScrollIndex(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollIndex(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnScrollVisibleContentChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnScrollVisibleContentChange(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnItemMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemMove(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnItemDragStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemDragStart(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnItemDragEnter(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemDragEnter(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnItemDragMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemDragMove(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnItemDragLeave(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemDragLeave(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnItemDrop(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnItemDrop(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListScrollStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollStart(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListScrollStop(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollStop(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListScrollFrameBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListScrollFrameBegin(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListWillScroll(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListWillScroll(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListDidScroll(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListDidScroll(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListReachStart(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ListBridge::ResetOnListReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getListModifier()->resetOnListReachEnd(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
@ -77,6 +77,38 @@ public:
|
||||
static ArkUINativeModuleValue SetInitialScroller(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetInitialScroller(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
|
||||
static ArkUINativeModuleValue SetOnScrollIndex(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnScrollVisibleContentChange(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnItemMove(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnItemDragStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnItemDragEnter(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnItemDragMove(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnItemDragLeave(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnItemDrop(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListScrollStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListScrollStop(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListScrollFrameBegin(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListWillScroll(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListDidScroll(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnListReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
|
||||
static ArkUINativeModuleValue ResetOnScrollIndex(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnScrollVisibleContentChange(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnItemMove(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnItemDragStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnItemDragEnter(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnItemDragMove(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnItemDragLeave(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnItemDrop(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListScrollStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListScrollStop(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListScrollFrameBegin(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListWillScroll(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListDidScroll(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnListReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
|
||||
private:
|
||||
static void SetScroller(ArkUIRuntimeCallInfo* runtimeCallInfo, RefPtr<Framework::JSScroller> jsScroller);
|
||||
};
|
||||
|
@ -50,4 +50,76 @@ ArkUINativeModuleValue ScrollableBridge::ResetContentClip(ArkUIRuntimeCallInfo*
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->resetContentClip(node);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ScrollableBridge::SetOnReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->resetOnReachStartCallBack(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](){
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->Call(vm, func.ToLocal(), nullptr, 0);
|
||||
};
|
||||
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->setOnReachStartCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ScrollableBridge::ResetOnReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->resetOnReachStartCallBack(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ScrollableBridge::SetOnReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->resetOnReachEndCallBack(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
|
||||
CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
|
||||
panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
|
||||
std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](){
|
||||
panda::LocalScope pandaScope(vm);
|
||||
panda::TryCatch trycatch(vm);
|
||||
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
|
||||
func->Call(vm, func.ToLocal(), nullptr, 0);
|
||||
};
|
||||
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->setOnReachEndCallBack(
|
||||
nativeNode, reinterpret_cast<void*>(&callback));
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
ArkUINativeModuleValue ScrollableBridge::ResetOnReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
GetArkUINodeModifiers()->getScrollableModifier()->resetOnReachEndCallBack(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -26,6 +26,10 @@ class ScrollableBridge {
|
||||
public:
|
||||
static ArkUINativeModuleValue SetContentClip(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetContentClip(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnReachStart(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue SetOnReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
static ArkUINativeModuleValue ResetOnReachEnd(ArkUIRuntimeCallInfo* runtimeCallInfo);
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -835,4 +835,94 @@ void ListModelNG::SetScroller(FrameNode* frameNode, RefPtr<ScrollControllerBase>
|
||||
pattern->SetPositionController(AceType::DynamicCast<ListPositionController>(scroller));
|
||||
pattern->SetScrollBarProxy(AceType::DynamicCast<ScrollBarProxy>(proxy));
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnScrollVisibleContentChange(FrameNode* frameNode, OnScrollVisibleContentChangeEvent&& onScrollVisibleContentChange)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnScrollVisibleContentChange(std::move(onScrollVisibleContentChange));
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnItemMove(FrameNode* frameNode, OnItemMoveEvent&& onItemMove)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnItemMove(std::move(onItemMove));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnItemDragStart(FrameNode* frameNode, OnItemDragStartFunc&& onItemDragStart)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
auto onDragStart =
|
||||
[func = std::move(onItemDragStart)](const ItemDragInfo& dragInfo, int32_t index) -> RefPtr<AceType> {
|
||||
ScopedViewStackProcessor builderViewStackProcessor;
|
||||
{
|
||||
return func(dragInfo, index);
|
||||
}
|
||||
};
|
||||
eventHub->SetOnItemDragStart(onDragStart);
|
||||
|
||||
auto gestureEventHub = eventHub->GetOrCreateGestureEventHub();
|
||||
CHECK_NULL_VOID(gestureEventHub);
|
||||
eventHub->InitItemDragEvent(gestureEventHub);
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnItemDragEnter(FrameNode* frameNode, OnItemDragEnterFunc&& onItemDragEnter)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnItemDragEnter(std::move(onItemDragEnter));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnItemDragLeave(FrameNode* frameNode, OnItemDragLeaveFunc&& onItemDragLeave)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnItemDragLeave(std::move(onItemDragLeave));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnItemDragMove(FrameNode* frameNode, OnItemDragMoveFunc&& onItemDragMove)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnItemDragMove(std::move(onItemDragMove));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ListModelNG::SetOnItemDrop(FrameNode* frameNode, OnItemDropFunc&& onItemDrop)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto eventHub = frameNode->GetEventHub<ListEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
eventHub->SetOnItemDrop(std::move(onItemDrop));
|
||||
|
||||
AddDragFrameNodeToManager(frameNode);
|
||||
}
|
||||
|
||||
void ListModelNG::AddDragFrameNodeToManager(FrameNode* frameNode)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto pipeline = frameNode->GetContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto dragDropManager = pipeline->GetDragDropManager();
|
||||
CHECK_NULL_VOID(dragDropManager);
|
||||
|
||||
dragDropManager->AddListDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -135,8 +135,16 @@ public:
|
||||
static int32_t GetInitialIndex(FrameNode* frameNode);
|
||||
static V2::ItemDivider GetDivider(FrameNode* frameNode);
|
||||
static void SetScroller(FrameNode* frameNode, RefPtr<ScrollControllerBase> scroller, RefPtr<ScrollProxy> proxy);
|
||||
static void SetOnScrollVisibleContentChange(FrameNode* frameNode, OnScrollVisibleContentChangeEvent&& onScrollVisibleContentChange);
|
||||
static void SetOnItemMove(FrameNode* frameNode, OnItemMoveEvent&& onItemMove);
|
||||
static void SetOnItemDragStart(FrameNode* frameNode, OnItemDragStartFunc&& onItemDragStart);
|
||||
static void SetOnItemDragEnter(FrameNode* frameNode, OnItemDragEnterFunc&& onItemDragEnter);
|
||||
static void SetOnItemDragLeave(FrameNode* frameNode, OnItemDragLeaveFunc&& onItemDragLeave);
|
||||
static void SetOnItemDragMove(FrameNode* frameNode, OnItemDragMoveFunc&& onItemDragMove);
|
||||
static void SetOnItemDrop(FrameNode* frameNode, OnItemDropFunc&& onItemDrop);
|
||||
private:
|
||||
void AddDragFrameNodeToManager() const;
|
||||
static void AddDragFrameNodeToManager(FrameNode* frameNode);
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -2474,6 +2474,37 @@ struct ArkUIListModifier {
|
||||
void (*setShowCached)(ArkUINodeHandle node, ArkUI_Bool show);
|
||||
void (*resetShowCached)(ArkUINodeHandle node);
|
||||
ArkUI_Bool (*getShowCached)(ArkUINodeHandle node);
|
||||
void (*setOnListScrollIndexCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnScrollVisibleContentChange)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnItemMove)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnItemDragStart)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnItemDragEnter)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnItemDragMove)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnItemDragLeave)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnItemDrop)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListScrollFrameBeginCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListWillScrollCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListDidScrollCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListReachStartCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListReachEndCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListScrollStartCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*setOnListScrollStopCallBack)(ArkUINodeHandle node, void* callback);
|
||||
|
||||
void (*resetOnListScrollIndex)(ArkUINodeHandle node);
|
||||
void (*resetOnScrollVisibleContentChange)(ArkUINodeHandle node);
|
||||
void (*resetOnItemMove)(ArkUINodeHandle node);
|
||||
void (*resetOnItemDragStart)(ArkUINodeHandle node);
|
||||
void (*resetOnItemDragEnter)(ArkUINodeHandle node);
|
||||
void (*resetOnItemDragMove)(ArkUINodeHandle node);
|
||||
void (*resetOnItemDragLeave)(ArkUINodeHandle node);
|
||||
void (*resetOnItemDrop)(ArkUINodeHandle node);
|
||||
void (*resetOnListScrollStart)(ArkUINodeHandle node);
|
||||
void (*resetOnListScrollStop)(ArkUINodeHandle node);
|
||||
void (*resetOnListScrollFrameBegin)(ArkUINodeHandle node);
|
||||
void (*resetOnListWillScroll)(ArkUINodeHandle node);
|
||||
void (*resetOnListDidScroll)(ArkUINodeHandle node);
|
||||
void (*resetOnListReachStart)(ArkUINodeHandle node);
|
||||
void (*resetOnListReachEnd)(ArkUINodeHandle node);
|
||||
};
|
||||
|
||||
struct ArkUIListItemGroupModifier {
|
||||
@ -2748,6 +2779,10 @@ struct ArkUIScrollableModifier {
|
||||
void (*setContentClip)(ArkUINodeHandle node, ArkUI_Int32 mode);
|
||||
/* setContentClip by custom rect not available */
|
||||
void (*resetContentClip)(ArkUINodeHandle node);
|
||||
void (*setOnReachStartCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*resetOnReachStartCallBack)(ArkUINodeHandle node);
|
||||
void (*setOnReachEndCallBack)(ArkUINodeHandle node, void* callback);
|
||||
void (*resetOnReachEndCallBack)(ArkUINodeHandle node);
|
||||
};
|
||||
|
||||
struct ArkUIScrollModifier {
|
||||
|
@ -709,7 +709,14 @@ const ArkUIListModifier* GetListModifier()
|
||||
SetListFlingSpeedLimit, ResetListFlingSpeedLimit, GetInitialIndex, GetlistDivider,
|
||||
SetInitialScroller, ResetInitialScroller, SetListMaintainVisibleContentPosition,
|
||||
ResetListMaintainVisibleContentPosition, SetListFadingEdge, ResetListFadingEdge,
|
||||
SetShowCached, ResetShowCached, GetShowCached };
|
||||
SetShowCached, ResetShowCached, GetShowCached, SetOnListScrollIndexCallBack,
|
||||
SetOnScrollVisibleContentChange, SetOnItemMove, SetOnItemDragStart, SetOnItemDragEnter, SetOnItemDragMove,
|
||||
SetOnItemDragLeave, SetOnItemDrop, SetOnListScrollFrameBeginCallBack, SetOnListWillScrollCallBack,
|
||||
SetOnListDidScrollCallBack, SetOnListReachStartCallBack, SetOnListReachEndCallBack,
|
||||
SetOnListScrollStartCallBack, SetOnListScrollStopCallBack, ResetOnListScrollIndex, ResetOnListScrollStart,
|
||||
ResetOnListScrollStop, ResetOnListScrollFrameBegin, ResetOnListWillScroll, ResetOnListDidScroll,
|
||||
ResetOnListReachStart, ResetOnListReachEnd, ResetOnScrollVisibleContentChange, ResetOnItemMove,
|
||||
ResetOnItemDragStart, ResetOnItemDragEnter, ResetOnItemDragMove, ResetOnItemDragLeave, ResetOnItemDrop };
|
||||
return &modifier;
|
||||
}
|
||||
|
||||
@ -889,54 +896,291 @@ void SetOnListReachEnd(ArkUINodeHandle node, void* extraParam)
|
||||
ListModelNG::SetOnReachEnd(frameNode, std::move(onReachEnd));
|
||||
}
|
||||
|
||||
void SetOnListScrollIndexCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onScrollIndex = reinterpret_cast<OnScrollIndexEvent*>(extraParam);
|
||||
ListModelNG::SetOnScrollIndex(frameNode, std::move(*onScrollIndex));
|
||||
} else {
|
||||
ListModelNG::SetOnScrollIndex(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnScrollVisibleContentChange(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onScrollVisibleContentChange = reinterpret_cast<OnScrollVisibleContentChangeEvent*>(extraParam);
|
||||
ListModelNG::SetOnScrollVisibleContentChange(frameNode, std::move(*onScrollVisibleContentChange));
|
||||
} else {
|
||||
ListModelNG::SetOnScrollVisibleContentChange(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnItemMove(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onItemMove = reinterpret_cast<OnItemMoveEvent*>(extraParam);
|
||||
ListModelNG::SetOnItemMove(frameNode, std::move(*onItemMove));
|
||||
} else {
|
||||
ListModelNG::SetOnItemMove(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnItemDragStart(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onItemDragStart = reinterpret_cast<OnItemDragStartFunc*>(extraParam);
|
||||
ListModelNG::SetOnItemDragStart(frameNode, std::move(*onItemDragStart));
|
||||
} else {
|
||||
ListModelNG::SetOnItemDragStart(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnItemDragEnter(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onItemDragEnter = reinterpret_cast<OnItemDragEnterFunc*>(extraParam);
|
||||
ListModelNG::SetOnItemDragEnter(frameNode, std::move(*onItemDragEnter));
|
||||
} else {
|
||||
ListModelNG::SetOnItemDragEnter(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnItemDragMove(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onItemDragMove = reinterpret_cast<OnItemDragMoveFunc*>(extraParam);
|
||||
ListModelNG::SetOnItemDragMove(frameNode, std::move(*onItemDragMove));
|
||||
} else {
|
||||
ListModelNG::SetOnItemDragMove(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnItemDragLeave(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onItemDragLeave = reinterpret_cast<OnItemDragLeaveFunc*>(extraParam);
|
||||
ListModelNG::SetOnItemDragLeave(frameNode, std::move(*onItemDragLeave));
|
||||
} else {
|
||||
ListModelNG::SetOnItemDragLeave(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnItemDrop(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onItemDrop = reinterpret_cast<OnItemDropFunc*>(extraParam);
|
||||
ListModelNG::SetOnItemDrop(frameNode, std::move(*onItemDrop));
|
||||
} else {
|
||||
ListModelNG::SetOnItemDrop(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListScrollFrameBeginCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onScrollFrameBegin = reinterpret_cast<OnScrollFrameBeginEvent*>(extraParam);
|
||||
ListModelNG::SetOnScrollFrameBegin(frameNode, std::move(*onScrollFrameBegin));
|
||||
} else {
|
||||
ListModelNG::SetOnScrollFrameBegin(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListWillScrollCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onWillScroll = reinterpret_cast<OnWillScrollEvent*>(extraParam);
|
||||
ScrollableModelNG::SetOnWillScroll(frameNode, std::move(*onWillScroll));
|
||||
} else {
|
||||
ScrollableModelNG::SetOnWillScroll(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListDidScrollCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onDidScroll = reinterpret_cast<OnScrollEvent*>(extraParam);
|
||||
ScrollableModelNG::SetOnDidScroll(frameNode, std::move(*onDidScroll));
|
||||
} else {
|
||||
ScrollableModelNG::SetOnDidScroll(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListReachStartCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onReachStart = reinterpret_cast<OnReachEvent*>(extraParam);
|
||||
ListModelNG::SetOnReachStart(frameNode, std::move(*onReachStart));
|
||||
} else {
|
||||
ListModelNG::SetOnReachStart(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListReachEndCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onReachEnd = reinterpret_cast<OnReachEvent*>(extraParam);
|
||||
ListModelNG::SetOnReachEnd(frameNode, std::move(*onReachEnd));
|
||||
} else {
|
||||
ListModelNG::SetOnReachEnd(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListScrollStartCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onScrollStart = reinterpret_cast<OnScrollStartEvent*>(extraParam);
|
||||
ListModelNG::SetOnScrollStart(frameNode, std::move(*onScrollStart));
|
||||
} else {
|
||||
ListModelNG::SetOnScrollStart(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SetOnListScrollStopCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onScrollStop = reinterpret_cast<OnScrollStopEvent*>(extraParam);
|
||||
ListModelNG::SetOnScrollStop(frameNode, std::move(*onScrollStop));
|
||||
} else {
|
||||
ListModelNG::SetOnScrollStop(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ResetOnListScroll(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnScroll(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListScrollIndex(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnScrollIndex(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnScrollVisibleContentChange(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnScrollVisibleContentChange(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnItemMove(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnItemMove(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnItemDragStart(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnItemDragStart(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnItemDragEnter(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnItemDragEnter(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnItemDragMove(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnItemDragMove(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnItemDragLeave(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnItemDragLeave(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnItemDrop(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnItemDrop(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListScrollStart(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnScrollStart(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListScrollStop(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnScrollStop(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListScrollFrameBegin(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnScrollFrameBegin(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListWillScroll(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ScrollableModelNG::SetOnWillScroll(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListDidScroll(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ScrollableModelNG::SetOnDidScroll(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListReachStart(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ListModelNG::SetOnReachStart(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void ResetOnListReachEnd(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
|
@ -30,6 +30,21 @@ void SetOnListWillScroll(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListDidScroll(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListReachStart(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListReachEnd(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListScrollIndexCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnScrollVisibleContentChange(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnItemMove(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnItemDragStart(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnItemDragEnter(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnItemDragMove(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnItemDragLeave(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnItemDrop(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListScrollFrameBeginCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListWillScrollCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListDidScrollCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListReachStartCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListReachEndCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListScrollStartCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
void SetOnListScrollStopCallBack(ArkUINodeHandle node, void* extraParam);
|
||||
|
||||
void ResetOnListScroll(ArkUINodeHandle node);
|
||||
void ResetOnListScrollIndex(ArkUINodeHandle node);
|
||||
@ -40,6 +55,13 @@ void ResetOnListWillScroll(ArkUINodeHandle node);
|
||||
void ResetOnListDidScroll(ArkUINodeHandle node);
|
||||
void ResetOnListReachStart(ArkUINodeHandle node);
|
||||
void ResetOnListReachEnd(ArkUINodeHandle node);
|
||||
void ResetOnScrollVisibleContentChange(ArkUINodeHandle node);
|
||||
void ResetOnItemMove(ArkUINodeHandle node);
|
||||
void ResetOnItemDragStart(ArkUINodeHandle node);
|
||||
void ResetOnItemDragEnter(ArkUINodeHandle node);
|
||||
void ResetOnItemDragMove(ArkUINodeHandle node);
|
||||
void ResetOnItemDragLeave(ArkUINodeHandle node);
|
||||
void ResetOnItemDrop(ArkUINodeHandle node);
|
||||
} // namespace OHOS::Ace::NG::NodeModifier
|
||||
|
||||
#endif // FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODE_LIST_MODIFIER_H
|
@ -35,10 +35,55 @@ void ResetContentClip(ArkUINodeHandle node)
|
||||
ScrollableModelNG::SetContentClip(frameNode, ContentClipMode::DEFAULT, nullptr);
|
||||
}
|
||||
|
||||
void SetOnReachStartCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onReachStart = reinterpret_cast<OnReachEvent*>(extraParam);
|
||||
ScrollableModelNG::SetOnReachStart(frameNode, std::move(*onReachStart));
|
||||
} else {
|
||||
ScrollableModelNG::SetOnReachStart(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ResetOnReachStartCallBack(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ScrollableModelNG::SetOnReachStart(frameNode, nullptr);
|
||||
}
|
||||
|
||||
void SetOnReachEndCallBack(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (extraParam) {
|
||||
auto onReachEnd = reinterpret_cast<OnReachEvent*>(extraParam);
|
||||
ScrollableModelNG::SetOnReachEnd(frameNode, std::move(*onReachEnd));
|
||||
} else {
|
||||
ScrollableModelNG::SetOnReachEnd(frameNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ResetOnReachEndCallBack(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ScrollableModelNG::SetOnReachEnd(frameNode, nullptr);
|
||||
}
|
||||
|
||||
namespace NodeModifier {
|
||||
const ArkUIScrollableModifier* GetScrollableModifier()
|
||||
{
|
||||
static const ArkUIScrollableModifier modifier = { SetContentClip, ResetContentClip };
|
||||
static const ArkUIScrollableModifier modifier = {
|
||||
SetContentClip,
|
||||
ResetContentClip,
|
||||
SetOnReachStartCallBack,
|
||||
ResetOnReachStartCallBack,
|
||||
SetOnReachEndCallBack,
|
||||
ResetOnReachEndCallBack,
|
||||
};
|
||||
return &modifier;
|
||||
}
|
||||
} // namespace NodeModifier
|
||||
|
Loading…
Reference in New Issue
Block a user