feat: add bounces for list,scroller,nestedSlider,flowlayout

This commit is contained in:
pengfei.zhou 2021-04-30 14:32:53 +08:00 committed by osborn
parent e621db48b9
commit 6da8d5658b
22 changed files with 109 additions and 1 deletions

View File

@ -192,6 +192,8 @@ - (UICollectionView *)build {
- (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"columnSpace" isEqualToString:name]) {
self.columnSpace = [prop floatValue];
[self.view.collectionViewLayout invalidateLayout];

View File

@ -96,6 +96,8 @@ - (UITableView *)build {
- (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"itemCount" isEqualToString:name]) {
self.itemCount = [prop unsignedIntegerValue];
[self.view reloadData];

View File

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

View File

@ -129,6 +129,8 @@ - (void)requestLayout {
- (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"content" isEqualToString:name]) {
self.childViewId = prop;
} else if ([@"onScroll" isEqualToString:name]) {

View File

@ -2142,6 +2142,10 @@ var List = /** @class */ (function (_super) {
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "scrollable", void 0);
__decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "bounces", void 0);
return List;
}(Superview));
function list(config) {
@ -2362,6 +2366,10 @@ var Scroller = /** @class */ (function (_super) {
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0);
__decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
return Scroller;
}(Superview));
@ -2671,6 +2679,10 @@ var FlowLayout = /** @class */ (function (_super) {
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
return FlowLayout;
}(Superview));
function flowlayout(config) {
@ -2858,6 +2870,10 @@ var NestedSlider = /** @class */ (function (_super) {
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0);
__decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
return NestedSlider;
}(Group));

View File

@ -1637,6 +1637,10 @@ __decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "scrollable", void 0);
__decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "bounces", void 0);
function list(config) {
const ret = new List;
for (let key in config) {
@ -1812,6 +1816,10 @@ __decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0);
__decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -2055,6 +2063,10 @@ __decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {
@ -2200,6 +2212,10 @@ __decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0);
__decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

View File

@ -3158,6 +3158,10 @@ __decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "scrollable", void 0);
__decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "bounces", void 0);
function list(config) {
const ret = new List;
for (let key in config) {
@ -3333,6 +3337,10 @@ __decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0);
__decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -3576,6 +3584,10 @@ __decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {
@ -3721,6 +3733,10 @@ __decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0);
__decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

4
doric-js/index.d.ts vendored
View File

@ -617,6 +617,7 @@ declare module 'doric/lib/src/widget/list' {
}) => void;
scrolledPosition?: number;
scrollable?: boolean;
bounces?: boolean;
scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean;
}): Promise<any>;
@ -672,6 +673,7 @@ declare module 'doric/lib/src/widget/scroller' {
y: number;
}) => void;
scrollable?: boolean;
bounces?: boolean;
allSubviews(): View[];
toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: {
@ -737,6 +739,7 @@ declare module 'doric/lib/src/widget/flowlayout' {
y: number;
}) => void;
scrollable?: boolean;
bounces?: boolean;
reset(): void;
toModel(): NativeViewModel;
}
@ -783,6 +786,7 @@ declare module 'doric/lib/src/widget/nestedSlider' {
export class NestedSlider extends Group {
onPageSlided?: (index: number) => void;
scrollable?: boolean;
bounces?: boolean;
addSlideItem(view: View): void;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>;

View File

@ -27,6 +27,7 @@ export declare class FlowLayout extends Superview {
y: number;
}) => void;
scrollable?: boolean;
bounces?: boolean;
reset(): void;
private getItem;
private renderBunchedItems;

View File

@ -118,6 +118,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
export function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

View File

@ -32,6 +32,7 @@ export declare class List extends Superview {
}) => void;
scrolledPosition?: number;
scrollable?: boolean;
bounces?: boolean;
scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean;
}): Promise<any>;

View File

@ -117,6 +117,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], List.prototype, "scrollable", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], List.prototype, "bounces", void 0);
export function list(config) {
const ret = new List;
for (let key in config) {

View File

@ -3,6 +3,7 @@ import { BridgeContext } from '../runtime/global';
export declare class NestedSlider extends Group {
onPageSlided?: (index: number) => void;
scrollable?: boolean;
bounces?: boolean;
addSlideItem(view: View): void;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>;

View File

@ -42,3 +42,7 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);

View File

@ -16,6 +16,7 @@ export declare class Scroller extends Superview {
y: number;
}) => void;
scrollable?: boolean;
bounces?: boolean;
allSubviews(): View[];
toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: {

View File

@ -66,3 +66,7 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);

View File

@ -72,6 +72,9 @@ export class FlowLayout extends Superview {
@Property
scrollable?: boolean
@Property
bounces?: boolean
reset() {
this.cachedViews.clear()
this.itemCount = 0

View File

@ -76,6 +76,9 @@ export class List extends Superview {
@Property
scrollable?: boolean
@Property
bounces?: boolean
scrollToItem(context: BridgeContext, index: number, config?: { animated?: boolean, }) {
const animated = config?.animated
return this.nativeChannel(context, 'scrollToItem')({ index, animated, }) as Promise<any>

View File

@ -24,6 +24,9 @@ export class NestedSlider extends Group {
@Property
scrollable?: boolean
@Property
bounces?: boolean
addSlideItem(view: View) {
this.addChild(view)
}

View File

@ -45,6 +45,9 @@ export class Scroller extends Superview {
@Property
scrollable?: boolean
@Property
bounces?: boolean
allSubviews() {
return [this.content]
}

View File

@ -3212,6 +3212,10 @@ __decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "scrollable", void 0);
__decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "bounces", void 0);
function list(config) {
const ret = new List;
for (let key in config) {
@ -3387,6 +3391,10 @@ __decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0);
__decorate$6([
Property,
__metadata$6("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -3630,6 +3638,10 @@ __decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {
@ -3775,6 +3787,10 @@ __decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0);
__decorate$2([
Property,
__metadata$2("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

File diff suppressed because one or more lines are too long