feat:Slider add scrollable
This commit is contained in:
parent
c2ca3c0b31
commit
056f2f041f
@ -45,6 +45,7 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
|||||||
private String onPageSlidedFuncId;
|
private String onPageSlidedFuncId;
|
||||||
private int lastPosition = 0;
|
private int lastPosition = 0;
|
||||||
private int itemCount = 0;
|
private int itemCount = 0;
|
||||||
|
private boolean scrollable = true;
|
||||||
|
|
||||||
public SliderNode(DoricContext doricContext) {
|
public SliderNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
@ -55,7 +56,15 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
|||||||
protected RecyclerView build() {
|
protected RecyclerView build() {
|
||||||
RecyclerView recyclerView = new RecyclerView(getContext());
|
RecyclerView recyclerView = new RecyclerView(getContext());
|
||||||
|
|
||||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()) {
|
||||||
|
@Override
|
||||||
|
public boolean canScrollHorizontally() {
|
||||||
|
if (!scrollable) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.canScrollHorizontally();
|
||||||
|
}
|
||||||
|
};
|
||||||
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
final PagerSnapHelper snapHelper = new PagerSnapHelper();
|
final PagerSnapHelper snapHelper = new PagerSnapHelper();
|
||||||
@ -146,6 +155,12 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
|||||||
@Override
|
@Override
|
||||||
protected void blend(RecyclerView view, String name, JSValue prop) {
|
protected void blend(RecyclerView view, String name, JSValue prop) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
case "scrollable":
|
||||||
|
if (!prop.isBoolean()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.scrollable = prop.asBoolean().value();
|
||||||
|
break;
|
||||||
case "itemCount":
|
case "itemCount":
|
||||||
this.itemCount = prop.asNumber().toInt();
|
this.itemCount = prop.asNumber().toInt();
|
||||||
break;
|
break;
|
||||||
|
@ -75,7 +75,9 @@ - (UICollectionView *)build {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValue:(id)prop {
|
- (void)blendView:(UICollectionView *)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.itemCount = [prop unsignedIntegerValue];
|
||||||
[self.view reloadData];
|
[self.view reloadData];
|
||||||
} else if ([@"renderPage" isEqualToString:name]) {
|
} else if ([@"renderPage" isEqualToString:name]) {
|
||||||
|
@ -49,6 +49,9 @@ export class Slider extends Superview {
|
|||||||
@Property
|
@Property
|
||||||
loop?: boolean
|
loop?: boolean
|
||||||
|
|
||||||
|
@Property
|
||||||
|
scrollable?: boolean
|
||||||
|
|
||||||
private getItem(itemIdx: number) {
|
private getItem(itemIdx: number) {
|
||||||
let view = this.renderPage(itemIdx)
|
let view = this.renderPage(itemIdx)
|
||||||
view.superview = this
|
view.superview = this
|
||||||
|
Reference in New Issue
Block a user