feat:NestedScroller add scrollable

This commit is contained in:
pengfei.zhou 2021-04-23 17:56:51 +08:00 committed by osborn
parent 056f2f041f
commit 5982b15b0d
3 changed files with 24 additions and 1 deletions

View File

@ -15,7 +15,9 @@
*/
package pub.doric.shader.slider;
import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@ -80,9 +82,25 @@ public class NestedSliderNode extends GroupNode<ViewPager> implements ViewPager.
return viewPager;
}
@SuppressLint("ClickableViewAccessibility")
@Override
protected void blend(ViewPager view, String name, JSValue prop) {
switch (name) {
case "scrollable":
if (!prop.isBoolean()) {
return;
}
if (prop.asBoolean().value()) {
this.getView().setOnTouchListener(null);
} else {
this.getView().setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
}
break;
case "onPageSlided":
this.onPageSlidedFuncId = prop.asString().toString();
break;

View File

@ -46,7 +46,9 @@ - (UIScrollView *)build {
}
- (void)blendView:(UIScrollView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"onPageSlided" isEqualToString:name]) {
if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue];
} else if ([@"onPageSlided" isEqualToString:name]) {
self.onPageSelectedFuncId = prop;
} else {
[super blendView:view forPropName:name propValue:prop];

View File

@ -21,6 +21,9 @@ export class NestedSlider extends Group {
@Property
onPageSlided?: (index: number) => void
@Property
scrollable?: boolean
addSlideItem(view: View) {
this.addChild(view)
}