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 { - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"scrollable" isEqualToString:name]) { if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue]; self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"columnSpace" isEqualToString:name]) { } else if ([@"columnSpace" isEqualToString:name]) {
self.columnSpace = [prop floatValue]; self.columnSpace = [prop floatValue];
[self.view.collectionViewLayout invalidateLayout]; [self.view.collectionViewLayout invalidateLayout];

View File

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

View File

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

View File

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

View File

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

View File

@ -1637,6 +1637,10 @@ __decorate$8([
Property, Property,
__metadata$8("design:type", Boolean) __metadata$8("design:type", Boolean)
], List.prototype, "scrollable", void 0); ], List.prototype, "scrollable", void 0);
__decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "bounces", void 0);
function list(config) { function list(config) {
const ret = new List; const ret = new List;
for (let key in config) { for (let key in config) {
@ -1812,6 +1816,10 @@ __decorate$6([
Property, Property,
__metadata$6("design:type", Boolean) __metadata$6("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0); ], 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 __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; var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -2055,6 +2063,10 @@ __decorate$4([
Property, Property,
__metadata$4("design:type", Boolean) __metadata$4("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0); ], FlowLayout.prototype, "scrollable", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
function flowlayout(config) { function flowlayout(config) {
const ret = new FlowLayout; const ret = new FlowLayout;
for (let key in config) { for (let key in config) {
@ -2200,6 +2212,10 @@ __decorate$2([
Property, Property,
__metadata$2("design:type", Boolean) __metadata$2("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0); ], 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 __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; 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, Property,
__metadata$8("design:type", Boolean) __metadata$8("design:type", Boolean)
], List.prototype, "scrollable", void 0); ], List.prototype, "scrollable", void 0);
__decorate$8([
Property,
__metadata$8("design:type", Boolean)
], List.prototype, "bounces", void 0);
function list(config) { function list(config) {
const ret = new List; const ret = new List;
for (let key in config) { for (let key in config) {
@ -3333,6 +3337,10 @@ __decorate$6([
Property, Property,
__metadata$6("design:type", Boolean) __metadata$6("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0); ], 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 __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; var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -3576,6 +3584,10 @@ __decorate$4([
Property, Property,
__metadata$4("design:type", Boolean) __metadata$4("design:type", Boolean)
], FlowLayout.prototype, "scrollable", void 0); ], FlowLayout.prototype, "scrollable", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
function flowlayout(config) { function flowlayout(config) {
const ret = new FlowLayout; const ret = new FlowLayout;
for (let key in config) { for (let key in config) {
@ -3721,6 +3733,10 @@ __decorate$2([
Property, Property,
__metadata$2("design:type", Boolean) __metadata$2("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0); ], 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 __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; 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; }) => void;
scrolledPosition?: number; scrolledPosition?: number;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
scrollToItem(context: BridgeContext, index: number, config?: { scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean; animated?: boolean;
}): Promise<any>; }): Promise<any>;
@ -672,6 +673,7 @@ declare module 'doric/lib/src/widget/scroller' {
y: number; y: number;
}) => void; }) => void;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
allSubviews(): View[]; allSubviews(): View[];
toModel(): NativeViewModel; toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: { scrollTo(context: BridgeContext, offset: {
@ -737,6 +739,7 @@ declare module 'doric/lib/src/widget/flowlayout' {
y: number; y: number;
}) => void; }) => void;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
reset(): void; reset(): void;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }
@ -783,6 +786,7 @@ declare module 'doric/lib/src/widget/nestedSlider' {
export class NestedSlider extends Group { export class NestedSlider extends Group {
onPageSlided?: (index: number) => void; onPageSlided?: (index: number) => void;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
addSlideItem(view: View): void; addSlideItem(view: View): void;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>; slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>; getSlidedPage(context: BridgeContext): Promise<number>;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,3 +42,7 @@ __decorate([
Property, Property,
__metadata("design:type", Boolean) __metadata("design:type", Boolean)
], NestedSlider.prototype, "scrollable", void 0); ], 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; y: number;
}) => void; }) => void;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
allSubviews(): View[]; allSubviews(): View[];
toModel(): NativeViewModel; toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: { scrollTo(context: BridgeContext, offset: {

View File

@ -66,3 +66,7 @@ __decorate([
Property, Property,
__metadata("design:type", Boolean) __metadata("design:type", Boolean)
], Scroller.prototype, "scrollable", void 0); ], 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 @Property
scrollable?: boolean scrollable?: boolean
@Property
bounces?: boolean
reset() { reset() {
this.cachedViews.clear() this.cachedViews.clear()
this.itemCount = 0 this.itemCount = 0

View File

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

View File

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

View File

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

View File

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