Remove header and footer support,this is unnecessary

This commit is contained in:
pengfei.zhou 2021-10-11 18:10:59 +08:00 committed by osborn
parent 8fd2477c81
commit 738c072ee4
20 changed files with 270 additions and 471 deletions

View File

@ -40,8 +40,6 @@ import pub.doric.shader.ViewNode;
*/
class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
private static final int TYPE_LOAD_MORE = -1;
private static final int TYPE_HEADER = -2;
private static final int TYPE_FOOTER = -3;
private final FlowLayoutNode flowLayoutNode;
String renderItemFuncId;
int itemCount = 0;
@ -70,10 +68,8 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject());
}
if (holder.flowLayoutItemNode.fullSpan
|| (this.flowLayoutNode.hasHeader() && position == 0)
|| (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1)
|| this.flowLayoutNode.loadMore
&& position == this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
&& position >= this.itemCount) {
StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
holder.itemView.getLayoutParams().height
@ -82,7 +78,7 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
holder.itemView.setLayoutParams(layoutParams);
}
if (this.flowLayoutNode.loadMore
&& position == this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)
&& position >= this.itemCount
&& !TextUtils.isEmpty(this.flowLayoutNode.onLoadMoreFuncId)) {
callLoadMore();
}
@ -90,23 +86,12 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
@Override
public int getItemCount() {
return this.itemCount
+ (this.flowLayoutNode.loadMore ? 1 : 0)
+ (this.flowLayoutNode.hasHeader() ? 1 : 0)
+ (this.flowLayoutNode.hasFooter() ? 1 : 0);
return this.itemCount + (this.flowLayoutNode.loadMore ? 1 : 0);
}
@Override
public int getItemViewType(int position) {
if (this.flowLayoutNode.hasHeader() && position == 0) {
return TYPE_HEADER;
}
if (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1) {
return TYPE_FOOTER;
}
if (position >= this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
if (position >= this.itemCount) {
return TYPE_LOAD_MORE;
}
JSValue value = getItemModel(position);
@ -119,20 +104,9 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
}
private JSValue getItemModel(int position) {
if (this.flowLayoutNode.hasHeader() && position == 0) {
return this.flowLayoutNode.getSubModel(this.flowLayoutNode.headerViewId);
}
if (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1) {
return this.flowLayoutNode.getSubModel(this.flowLayoutNode.footerViewId);
}
if (position >= this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
if (position >= this.itemCount) {
return this.flowLayoutNode.getSubModel(this.flowLayoutNode.loadMoreViewId);
}
if (this.flowLayoutNode.hasHeader()) {
position--;
}
String id = itemValues.get(position);
if (TextUtils.isEmpty(id)) {
AsyncResult<JSDecoder> asyncResult = flowLayoutNode.pureCallJSResponse(

View File

@ -332,21 +332,6 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
}
private int calibratePosition(int position) {
if (hasHeader() && position == 0) {
return -11;
}
if (hasFooter() && position == this.itemCount
+ (this.loadMore ? 1 : 0)
+ (this.hasHeader() ? 1 : 0)
+ (this.hasFooter() ? 1 : 0) - 1) {
return -12;
}
if (position >= this.itemCount + (this.hasHeader() ? 1 : 0)) {
return -10;
}
if (this.hasHeader()) {
return position - 1;
}
return position;
}
@ -377,12 +362,4 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
}
return jsonArray;
}
boolean hasHeader() {
return !TextUtils.isEmpty(this.headerViewId);
}
boolean hasFooter() {
return !TextUtils.isEmpty(this.footerViewId);
}
}

View File

@ -40,8 +40,6 @@ import pub.doric.shader.ViewNode;
*/
class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
private static final int TYPE_LOAD_MORE = -1;
private static final int TYPE_HEADER = -2;
private static final int TYPE_FOOTER = -3;
private final ListNode listNode;
ListAdapter(ListNode listNode) {
@ -68,7 +66,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
}
if (this.listNode.loadMore
&& position == this.itemCount + (this.listNode.hasHeader() ? 1 : 0)
&& position >= this.itemCount
&& !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) {
callLoadMore();
}
@ -76,23 +74,12 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
@Override
public int getItemCount() {
return this.itemCount
+ (this.listNode.loadMore ? 1 : 0)
+ (this.listNode.hasHeader() ? 1 : 0)
+ (this.listNode.hasFooter() ? 1 : 0);
return this.itemCount + (this.listNode.loadMore ? 1 : 0);
}
@Override
public int getItemViewType(int position) {
if (this.listNode.hasHeader() && position == 0) {
return TYPE_HEADER;
}
if (this.listNode.hasFooter() && position == this.getItemCount() - 1) {
return TYPE_FOOTER;
}
if (position >= this.itemCount + (this.listNode.hasHeader() ? 1 : 0)) {
if (position >= this.itemCount) {
return TYPE_LOAD_MORE;
}
@ -106,20 +93,9 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
}
private JSValue getItemModel(int position) {
if (this.listNode.hasHeader() && position == 0) {
return this.listNode.getSubModel(this.listNode.headerViewId);
}
if (this.listNode.hasFooter() && position == this.getItemCount() - 1) {
return this.listNode.getSubModel(this.listNode.footerViewId);
}
if (position >= this.itemCount + (this.listNode.hasHeader() ? 1 : 0)) {
if (position >= this.itemCount) {
return this.listNode.getSubModel(this.listNode.loadMoreViewId);
}
if (this.listNode.hasHeader()) {
position--;
}
String id = listNode.itemValues.get(position);
if (TextUtils.isEmpty(id)) {
int batchCount = listNode.batchCount;

View File

@ -65,8 +65,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
SparseArray<String> itemValues = new SparseArray<>();
boolean loadMore = false;
String loadMoreViewId;
String headerViewId;
String footerViewId;
private final Set<DoricScrollChangeListener> listeners = new HashSet<>();
private String onScrollFuncId;
private String onScrollEndFuncId;
@ -247,12 +245,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
}
});
break;
case "header":
this.headerViewId = prop.asString().value();
break;
case "footer":
this.footerViewId = prop.asString().value();
break;
default:
super.blend(view, name, prop);
break;
@ -304,21 +296,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
}
private int calibratePosition(int position) {
if (hasHeader() && position == 0) {
return -11;
}
if (hasFooter() && position == this.itemCount
+ (this.loadMore ? 1 : 0)
+ (this.hasHeader() ? 1 : 0)
+ (this.hasFooter() ? 1 : 0) - 1) {
return -12;
}
if (position >= this.itemCount + (this.hasHeader() ? 1 : 0)) {
return -10;
}
if (this.hasHeader()) {
return position - 1;
}
return position;
}
@ -370,12 +347,4 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
mView.scrollToPosition(pos);
}
}
boolean hasHeader() {
return !TextUtils.isEmpty(this.headerViewId);
}
boolean hasFooter() {
return !TextUtils.isEmpty(this.footerViewId);
}
}

View File

@ -21,14 +21,6 @@ class FlowDemo extends Panel {
columnCount: 3,
columnSpace: 10,
rowSpace: 10,
header: flowItem(image({
layoutConfig: layoutConfig().mostWidth().fitHeight(),
imageUrl: imageUrls[0]
})),
footer: flowItem(image({
layoutConfig: layoutConfig().mostWidth().fitHeight(),
imageUrl: imageUrls[1]
})),
renderItem: (idx) => {
return flowItem(
text({

View File

@ -47,12 +47,6 @@ class ListVH extends ViewHolder {
height: 50,
}),
this.list = list({
header: listItem(text({
text: "This is header",
})),
footer: listItem(text({
text: "This is footer",
})),
itemCount: 0,
layoutConfig: {
widthSpec: LayoutSpec.MOST,

View File

@ -167,8 +167,6 @@ @interface DoricFlowLayoutNode () <UICollectionViewDataSource, UICollectionViewD
@property(nonatomic, copy) NSString *onLoadMoreFuncId;
@property(nonatomic, copy) NSString *loadMoreViewId;
@property(nonatomic, copy) NSString *headerViewId;
@property(nonatomic, copy) NSString *footerViewId;
@property(nonatomic, assign) BOOL loadMore;
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
@property(nonatomic, copy) NSString *onScrollFuncId;
@ -207,14 +205,6 @@ - (UICollectionView *)build {
}];
}
- (BOOL)hasHeader {
return self.headerViewId && self.headerViewId.length > 0;
}
- (BOOL)hasFooter {
return self.footerViewId && self.footerViewId.length > 0;
}
- (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue];
@ -254,36 +244,19 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
self.onScrollFuncId = prop;
} else if ([@"onScrollEnd" isEqualToString:name]) {
self.onScrollEndFuncId = prop;
} else if ([@"header" isEqualToString:name]) {
self.headerViewId = prop;
} else if ([@"footer" isEqualToString:name]) {
self.footerViewId = prop;
} else {
[super blendView:view forPropName:name propValue:prop];
}
}
- (NSDictionary *)itemModelAt:(NSUInteger)position {
if (self.hasHeader && position == 0) {
return [self subModelOf:self.headerViewId];
}
if (self.hasFooter && position == self.itemCount
+ (self.loadMore ? 1 : 0)
+ (self.hasHeader ? 1 : 0)
+ (self.hasFooter ? 1 : 0)
- 1) {
return [self subModelOf:self.footerViewId];
}
if (self.loadMore && position >= self.itemCount + (self.hasHeader ? 1 : 0)) {
if (self.loadMore && position >= self.itemCount) {
if (self.loadMoreViewId && self.loadMoreViewId.length > 0) {
return [self subModelOf:self.loadMoreViewId];
} else {
return nil;
}
}
if (self.hasHeader) {
position--;
}
NSString *viewId = self.itemViewIds[@(position)];
if (viewId && viewId.length > 0) {
return [self subModelOf:viewId];
@ -366,7 +339,7 @@ - (void)callLoadMore {
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.itemCount + (self.loadMore ? 1 : 0) + (self.hasHeader ? 1 : 0) + (self.hasFooter ? 1 : 0);
return self.itemCount + (self.loadMore ? 1 : 0);
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
@ -374,17 +347,8 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
NSDictionary *model = [self itemModelAt:position];
NSDictionary *props = model[@"props"];
NSString *identifier = props[@"identifier"] ?: @"doricCell";
if (self.hasHeader && position == 0) {
identifier = @"doricHeaderCell";
} else if (self.hasFooter
&& position == self.itemCount
+ (self.loadMore ? 1 : 0)
+ (self.hasHeader ? 1 : 0)
+ (self.hasFooter ? 1 : 0)
- 1) {
identifier = @"doricFooterCell";
} else if (self.loadMore
&& position == self.itemCount + (self.hasHeader ? 1 : 0)
if (self.loadMore
&& position >= self.itemCount
&& self.onLoadMoreFuncId) {
identifier = @"doricLoadMoreCell";
[self callLoadMore];
@ -402,15 +366,7 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
node.viewId = model[@"id"];
[node blend:props];
BOOL fillWidth = [props[@"fullSpan"] boolValue]
|| (self.hasHeader && position == 0)
|| (self.hasFooter
&& position == self.itemCount
+ (self.loadMore ? 1 : 0)
+ (self.hasHeader ? 1 : 0)
+ (self.hasFooter ? 1 : 0)
- 1)
|| (self.loadMore
&& position == self.itemCount + (self.hasHeader ? 1 : 0));
|| (self.loadMore && position >= self.itemCount);
if (fillWidth) {
node.view.width = collectionView.width;
} else {
@ -457,15 +413,7 @@ - (NSInteger)doricFlowLayoutColumnCount {
- (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath {
NSUInteger position = (NSUInteger) indexPath.row;
if ((self.hasHeader && position == 0)
|| (self.hasFooter
&& position == self.itemCount
+ (self.loadMore ? 1 : 0)
+ (self.hasHeader ? 1 : 0)
+ (self.hasFooter ? 1 : 0)
- 1)
|| (self.loadMore
&& position == self.itemCount + (self.hasHeader ? 1 : 0))) {
if (self.loadMore && position >= self.itemCount) {
return YES;
} else {
NSDictionary *model = [self itemModelAt:position];

View File

@ -53,8 +53,6 @@ @interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, copy) NSString *onLoadMoreFuncId;
@property(nonatomic, copy) NSString *renderItemFuncId;
@property(nonatomic, copy) NSString *loadMoreViewId;
@property(nonatomic, copy) NSString *headerViewId;
@property(nonatomic, copy) NSString *footerViewId;
@property(nonatomic, assign) BOOL loadMore;
@property(nonatomic, assign) NSUInteger loadAnchor;
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
@ -95,14 +93,6 @@ - (UITableView *)build {
}];
}
- (BOOL)hasHeader {
return self.headerViewId && self.headerViewId.length > 0;
}
- (BOOL)hasFooter {
return self.footerViewId && self.footerViewId.length > 0;
}
- (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"scrollable" isEqualToString:name]) {
self.view.scrollEnabled = [prop boolValue];
@ -136,17 +126,13 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
dispatch_async(dispatch_get_main_queue(), ^{
[view scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[prop unsignedIntegerValue] inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
});
} else if ([@"header" isEqualToString:name]) {
self.headerViewId = prop;
} else if ([@"footer" isEqualToString:name]) {
self.footerViewId = prop;
} else {
[super blendView:view forPropName:name propValue:prop];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.itemCount + (self.loadMore ? 1 : 0) + (self.hasHeader ? 1 : 0) + (self.hasFooter ? 1 : 0);
return self.itemCount + (self.loadMore ? 1 : 0);
}
- (void)callLoadMore {
@ -162,17 +148,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSDictionary *props = model[@"props"];
NSString *reuseId = props[@"identifier"];
self.itemActions[@(position)] = props[@"actions"];
if (self.hasHeader && position == 0) {
reuseId = @"doricHeaderCell";
} else if (self.hasFooter
&& position == self.itemCount
+ (self.loadMore ? 1 : 0)
+ (self.hasHeader ? 1 : 0)
+ (self.hasFooter ? 1 : 0)
- 1) {
reuseId = @"doricFooterCell";
} else if (self.loadMore
&& position == self.itemCount + (self.hasHeader ? 1 : 0)
if (self.loadMore
&& position >= self.itemCount
&& self.onLoadMoreFuncId) {
reuseId = @"doricLoadMoreCell";
[self callLoadMore];
@ -260,26 +237,13 @@ - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView tra
}
- (NSDictionary *)itemModelAt:(NSUInteger)position {
if (self.hasHeader && position == 0) {
return [self subModelOf:self.headerViewId];
}
if (self.hasFooter && position == self.itemCount
+ (self.loadMore ? 1 : 0)
+ (self.hasHeader ? 1 : 0)
+ (self.hasFooter ? 1 : 0)
- 1) {
return [self subModelOf:self.footerViewId];
}
if (self.loadMore && position >= self.itemCount + (self.hasHeader ? 1 : 0)) {
if (self.loadMore && position >= self.itemCount) {
if (self.loadMoreViewId && self.loadMoreViewId.length > 0) {
return [self subModelOf:self.loadMoreViewId];
} else {
return nil;
}
}
if (self.hasHeader) {
position--;
}
NSString *viewId = self.itemViewIds[@(position)];
if (viewId && viewId.length > 0) {
return [self subModelOf:viewId];

View File

@ -2316,6 +2316,12 @@ var ListItem = /** @class */ (function (_super) {
], ListItem.prototype, "actions", void 0);
return ListItem;
}(Stack));
exports.OtherItems = void 0;
(function (OtherItems) {
OtherItems[OtherItems["LoadMore"] = -10] = "LoadMore";
OtherItems[OtherItems["Header"] = -11] = "Header";
OtherItems[OtherItems["Footer"] = -12] = "Footer";
})(exports.OtherItems || (exports.OtherItems = {}));
var List = /** @class */ (function (_super) {
__extends$c(List, _super);
function List() {
@ -2330,18 +2336,26 @@ var List = /** @class */ (function (_super) {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
};
List.prototype.scrollToItem = function (context, index, config) {
var animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, });
};
/**
* @param context
* @returns Returns the range of the visible views.
*/
List.prototype.findVisibleItems = function (context) {
return this.nativeChannel(context, 'findVisibleItems')();
};
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
List.prototype.findCompletelyVisibleItems = function (context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
};
List.prototype.reset = function () {
this.cachedViews.clear();
this.itemCount = 0;
@ -2363,12 +2377,6 @@ var List = /** @class */ (function (_super) {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return _super.prototype.toModel.call(this);
};
__decorate$9([
@ -2415,14 +2423,6 @@ var List = /** @class */ (function (_super) {
Property,
__metadata$9("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "header", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "footer", void 0);
return List;
}(Superview));
function list(config) {
@ -2952,14 +2952,22 @@ var FlowLayout = /** @class */ (function (_super) {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
};
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
FlowLayout.prototype.findVisibleItems = function (context) {
return this.nativeChannel(context, 'findVisibleItems')();
};
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
FlowLayout.prototype.findCompletelyVisibleItems = function (context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
};
FlowLayout.prototype.reset = function () {
this.cachedViews.clear();
this.itemCount = 0;
@ -2981,12 +2989,6 @@ var FlowLayout = /** @class */ (function (_super) {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return _super.prototype.toModel.call(this);
};
__decorate$5([
@ -3041,14 +3043,6 @@ var FlowLayout = /** @class */ (function (_super) {
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
return FlowLayout;
}(Superview));
function flowlayout(config) {

View File

@ -1739,6 +1739,12 @@ __decorate$9([
Property,
__metadata$9("design:type", Array)
], ListItem.prototype, "actions", void 0);
exports.OtherItems = void 0;
(function (OtherItems) {
OtherItems[OtherItems["LoadMore"] = -10] = "LoadMore";
OtherItems[OtherItems["Header"] = -11] = "Header";
OtherItems[OtherItems["Footer"] = -12] = "Footer";
})(exports.OtherItems || (exports.OtherItems = {}));
class List extends Superview {
constructor() {
super(...arguments);
@ -1751,18 +1757,26 @@ class List extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
}
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -1783,12 +1797,6 @@ class List extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -1836,14 +1844,6 @@ __decorate$9([
Property,
__metadata$9("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "header", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "footer", void 0);
function list(config) {
const ret = new List;
ret.apply(config);
@ -2228,14 +2228,22 @@ class FlowLayout extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -2256,12 +2264,6 @@ class FlowLayout extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -2317,14 +2319,6 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

View File

@ -3260,6 +3260,12 @@ __decorate$9([
Property,
__metadata$9("design:type", Array)
], ListItem.prototype, "actions", void 0);
exports.OtherItems = void 0;
(function (OtherItems) {
OtherItems[OtherItems["LoadMore"] = -10] = "LoadMore";
OtherItems[OtherItems["Header"] = -11] = "Header";
OtherItems[OtherItems["Footer"] = -12] = "Footer";
})(exports.OtherItems || (exports.OtherItems = {}));
class List extends Superview {
constructor() {
super(...arguments);
@ -3272,18 +3278,26 @@ class List extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
}
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -3304,12 +3318,6 @@ class List extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -3357,14 +3365,6 @@ __decorate$9([
Property,
__metadata$9("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "header", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "footer", void 0);
function list(config) {
const ret = new List;
ret.apply(config);
@ -3749,14 +3749,22 @@ class FlowLayout extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -3777,12 +3785,6 @@ class FlowLayout extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -3838,14 +3840,6 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

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

@ -703,6 +703,11 @@ declare module 'doric/lib/src/widget/list' {
callback: () => void;
}[];
}
export enum OtherItems {
LoadMore = -10,
Header = -11,
Footer = -12
}
export class List extends Superview {
allSubviews(): ListItem[];
itemCount: number;
@ -725,11 +730,25 @@ declare module 'doric/lib/src/widget/list' {
* Take effect only on iOS
*/
bounces?: boolean;
header?: ListItem;
footer?: ListItem;
scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean;
}): Promise<any>;
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}>;
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}>;
reset(): void;
toModel(): NativeViewModel;
}
@ -830,6 +849,7 @@ declare module 'doric/lib/src/widget/refreshable' {
declare module 'doric/lib/src/widget/flowlayout' {
import { Stack } from 'doric/lib/src/widget/layouts';
import { Superview, View, NativeViewModel } from 'doric/lib/src/ui/view';
import { BridgeContext } from "doric/lib/src/runtime/global";
export class FlowLayoutItem extends Stack {
/**
* Set to reuse native view
@ -837,6 +857,7 @@ declare module 'doric/lib/src/widget/flowlayout' {
identifier?: string;
/**
* When set to true, the item will layout using all span area.
* HeaderView, footerView or loadMoreView is always true by default.
*/
fullSpan?: boolean;
}
@ -864,8 +885,22 @@ declare module 'doric/lib/src/widget/flowlayout' {
* Take effect only on iOS
*/
bounces?: boolean;
header?: FlowLayoutItem;
footer?: FlowLayoutItem;
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}[]>;
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}[]>;
reset(): void;
toModel(): NativeViewModel;
}

View File

@ -1,5 +1,6 @@
import { Stack } from './layouts';
import { Superview, View, NativeViewModel } from '../ui/view';
import { BridgeContext } from "../runtime/global";
export declare class FlowLayoutItem extends Stack {
/**
* Set to reuse native view
@ -7,6 +8,7 @@ export declare class FlowLayoutItem extends Stack {
identifier?: string;
/**
* When set to true, the item will layout using all span area.
* HeaderView, footerView or loadMoreView is always true by default.
*/
fullSpan?: boolean;
}
@ -35,8 +37,22 @@ export declare class FlowLayout extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
header?: FlowLayoutItem;
footer?: FlowLayoutItem;
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}[]>;
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}[]>;
reset(): void;
private getItem;
private renderBunchedItems;

View File

@ -48,14 +48,22 @@ export class FlowLayout extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -76,12 +84,6 @@ export class FlowLayout extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -137,14 +139,6 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate([
Property,
__metadata("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
export function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

View File

@ -13,6 +13,11 @@ export declare class ListItem extends Stack {
callback: () => void;
}[];
}
export declare enum OtherItems {
LoadMore = -10,
Header = -11,
Footer = -12
}
export declare class List extends Superview {
private cachedViews;
allSubviews(): ListItem[];
@ -36,11 +41,25 @@ export declare class List extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
header?: ListItem;
footer?: ListItem;
scrollToItem(context: BridgeContext, index: number, config?: {
animated?: boolean;
}): Promise<any>;
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}>;
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context: BridgeContext): Promise<{
first: number;
last: number;
}>;
reset(): void;
private getItem;
private renderBunchedItems;

View File

@ -35,6 +35,12 @@ __decorate([
Property,
__metadata("design:type", Array)
], ListItem.prototype, "actions", void 0);
export var OtherItems;
(function (OtherItems) {
OtherItems[OtherItems["LoadMore"] = -10] = "LoadMore";
OtherItems[OtherItems["Header"] = -11] = "Header";
OtherItems[OtherItems["Footer"] = -12] = "Footer";
})(OtherItems || (OtherItems = {}));
export class List extends Superview {
constructor() {
super(...arguments);
@ -47,18 +53,26 @@ export class List extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
}
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -79,12 +93,6 @@ export class List extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -132,14 +140,6 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", ListItem)
], List.prototype, "header", void 0);
__decorate([
Property,
__metadata("design:type", ListItem)
], List.prototype, "footer", void 0);
export function list(config) {
const ret = new List;
ret.apply(config);

View File

@ -16,7 +16,7 @@
import { Stack } from './layouts'
import { Property, Superview, View, NativeViewModel } from '../ui/view'
import { layoutConfig } from '../util/index.util'
import { BridgeContext } from '../..'
import { BridgeContext } from "../runtime/global";
export class FlowLayoutItem extends Stack {
/**
@ -26,7 +26,7 @@ export class FlowLayoutItem extends Stack {
identifier?: string
/**
* When set to true, the item will layout using all span area.
* HeaderView, footerView or loadMoreView is always true by default.
* LoadMoreView is default to true.
*/
@Property
fullSpan?: boolean
@ -40,12 +40,6 @@ export class FlowLayout extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView)
}
if (this.header) {
ret.push(this.header)
}
if (this.footer) {
ret.push(this.footer)
}
return ret
}
@ -90,11 +84,6 @@ export class FlowLayout extends Superview {
@Property
bounces?: boolean
@Property
header?: FlowLayoutItem
@Property
footer?: FlowLayoutItem
/**
* @param context
* @returns Returns the range of the visible views for each column.
@ -132,12 +121,6 @@ export class FlowLayout extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId
}
return super.toModel()
}
}

View File

@ -49,12 +49,6 @@ export class List extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView)
}
if (this.header) {
ret.push(this.header)
}
if (this.footer) {
ret.push(this.footer)
}
return ret
}
@ -93,12 +87,6 @@ export class List extends Superview {
@Property
bounces?: boolean
@Property
header?: ListItem
@Property
footer?: ListItem
scrollToItem(context: BridgeContext, index: number, config?: { animated?: boolean, }) {
const animated = config?.animated
return this.nativeChannel(context, 'scrollToItem')({ index, animated, }) as Promise<any>
@ -140,12 +128,6 @@ export class List extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId
}
return super.toModel()
}
}

View File

@ -3314,6 +3314,12 @@ __decorate$9([
Property,
__metadata$9("design:type", Array)
], ListItem.prototype, "actions", void 0);
exports.OtherItems = void 0;
(function (OtherItems) {
OtherItems[OtherItems["LoadMore"] = -10] = "LoadMore";
OtherItems[OtherItems["Header"] = -11] = "Header";
OtherItems[OtherItems["Footer"] = -12] = "Footer";
})(exports.OtherItems || (exports.OtherItems = {}));
class List extends Superview {
constructor() {
super(...arguments);
@ -3326,18 +3332,26 @@ class List extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
}
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -3358,12 +3372,6 @@ class List extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -3411,14 +3419,6 @@ __decorate$9([
Property,
__metadata$9("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "header", void 0);
__decorate$9([
Property,
__metadata$9("design:type", ListItem)
], List.prototype, "footer", void 0);
function list(config) {
const ret = new List;
ret.apply(config);
@ -3803,14 +3803,22 @@ class FlowLayout extends Superview {
if (this.loadMoreView) {
ret.push(this.loadMoreView);
}
if (this.header) {
ret.push(this.header);
}
if (this.footer) {
ret.push(this.footer);
}
return ret;
}
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context) {
return this.nativeChannel(context, 'findVisibleItems')();
}
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')();
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
@ -3831,12 +3839,6 @@ class FlowLayout extends Superview {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
if (this.header) {
this.dirtyProps['header'] = this.header.viewId;
}
if (this.footer) {
this.dirtyProps['footer'] = this.footer.viewId;
}
return super.toModel();
}
}
@ -3892,14 +3894,6 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "header", void 0);
__decorate$5([
Property,
__metadata$5("design:type", FlowLayoutItem)
], FlowLayout.prototype, "footer", void 0);
function flowlayout(config) {
const ret = new FlowLayout;
for (let key in config) {

File diff suppressed because one or more lines are too long