diff --git a/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java b/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java index bfc27857..3ad4f96b 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java @@ -62,11 +62,14 @@ public class ListNode extends SuperNode implements IDoricScrollabl private String onScrollFuncId; private String onScrollEndFuncId; private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher(); + public ListNode(DoricContext doricContext) { super(doricContext); this.listAdapter = new ListAdapter(this); } + private boolean scrollable = true; + @Override protected void blendSubNode(JSObject subProperties) { String viewId = subProperties.getProperty("id").asString().value(); @@ -85,7 +88,15 @@ public class ListNode extends SuperNode implements IDoricScrollabl @Override protected RecyclerView build() { RecyclerView recyclerView = new RecyclerView(getContext()); - recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + public boolean canScrollVertically() { + if (!scrollable) { + return false; + } + return super.canScrollVertically(); + } + }); recyclerView.setAdapter(this.listAdapter); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override @@ -145,6 +156,12 @@ public class ListNode extends SuperNode implements IDoricScrollabl @Override protected void blend(RecyclerView view, String name, final JSValue prop) { switch (name) { + case "scrollable": + if (!prop.isBoolean()) { + return; + } + this.scrollable = prop.asBoolean().value(); + break; case "itemCount": if (!prop.isNumber()) { return; diff --git a/doric-iOS/Pod/Classes/Shader/DoricListNode.m b/doric-iOS/Pod/Classes/Shader/DoricListNode.m index 4669322c..729d915d 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricListNode.m @@ -89,7 +89,9 @@ - (UITableView *)build { } - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id)prop { - if ([@"itemCount" isEqualToString:name]) { + if ([@"scrollable" isEqualToString:name]) { + self.view.scrollEnabled = [prop boolValue]; + } else if ([@"itemCount" isEqualToString:name]) { self.itemCount = [prop unsignedIntegerValue]; [self.view reloadData]; } else if ([@"renderItem" isEqualToString:name]) { diff --git a/doric-js/src/widget/list.ts b/doric-js/src/widget/list.ts index aed86554..a3306e7c 100644 --- a/doric-js/src/widget/list.ts +++ b/doric-js/src/widget/list.ts @@ -66,6 +66,9 @@ export class List extends Superview { @Property scrolledPosition?: number + @Property + scrollable?: boolean + scrollToItem(context: BridgeContext, index: number, config?: { animated?: boolean, }) { const animated = config?.animated return this.nativeChannel(context, 'scrollToItem')({ index, animated, }) as Promise