feat: add preloadItemCount for List, incase we need preload more items before scroll to end
This commit is contained in:
parent
4103704162
commit
0774df96e1
@ -68,7 +68,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
|||||||
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
|
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
|
||||||
}
|
}
|
||||||
if (this.loadMore
|
if (this.loadMore
|
||||||
&& position >= this.itemCount
|
&& position >= this.itemCount - this.listNode.preloadItemCount
|
||||||
&& !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) {
|
&& !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) {
|
||||||
callLoadMore();
|
callLoadMore();
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,8 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
|||||||
private String onScrollEndFuncId;
|
private String onScrollEndFuncId;
|
||||||
private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
|
private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
|
||||||
|
|
||||||
|
int preloadItemCount = 0;
|
||||||
|
|
||||||
public ListNode(DoricContext doricContext) {
|
public ListNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
this.listAdapter = new ListAdapter(this);
|
this.listAdapter = new ListAdapter(this);
|
||||||
@ -377,6 +379,12 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
|||||||
}
|
}
|
||||||
this.onDraggedFuncId = prop.asString().value();
|
this.onDraggedFuncId = prop.asString().value();
|
||||||
break;
|
break;
|
||||||
|
case "preloadItemCount":
|
||||||
|
if (!prop.isNumber()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.preloadItemCount = prop.asNumber().toInt();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
super.blend(view, name, prop);
|
super.blend(view, name, prop);
|
||||||
break;
|
break;
|
||||||
|
@ -20,8 +20,8 @@ async function loadData(offset: number): Promise<{
|
|||||||
}>(resolve => {
|
}>(resolve => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve({
|
resolve({
|
||||||
isEnd: offset > 100,
|
isEnd: offset > 1000,
|
||||||
data: new Array(5).fill(offset).map((e, idx) => {
|
data: new Array(15).fill(offset).map((e, idx) => {
|
||||||
return { text: `Item: ${e + idx}` }
|
return { text: `Item: ${e + idx}` }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -65,6 +65,7 @@ class ListVH extends ViewHolder {
|
|||||||
class ListVM extends ViewModel<ListModel, ListVH> {
|
class ListVM extends ViewModel<ListModel, ListVH> {
|
||||||
onAttached(state: ListModel, vh: ListVH) {
|
onAttached(state: ListModel, vh: ListVH) {
|
||||||
vh.list.apply({
|
vh.list.apply({
|
||||||
|
preloadItemCount: 5,
|
||||||
canDrag: true,
|
canDrag: true,
|
||||||
onDragging: (from, to) => {
|
onDragging: (from, to) => {
|
||||||
log(`onDragging, from: ${from}, to: ${to}`)
|
log(`onDragging, from: ${from}, to: ${to}`)
|
||||||
@ -127,7 +128,14 @@ class ListVM extends ViewModel<ListModel, ListVH> {
|
|||||||
loge('completelyVisible Items is:', ret)
|
loge('completelyVisible Items is:', ret)
|
||||||
const ret2 = await vh.list.findVisibleItems(context)
|
const ret2 = await vh.list.findVisibleItems(context)
|
||||||
loge('visible Items is:', ret2)
|
loge('visible Items is:', ret2)
|
||||||
}
|
},
|
||||||
|
loadMoreView: listItem(text({
|
||||||
|
text: "LoadMore",
|
||||||
|
}), {
|
||||||
|
layoutConfig: layoutConfig().mostWidth().justHeight(),
|
||||||
|
height: 30,
|
||||||
|
backgroundColor: Color.YELLOW,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
loadData(state.offset).then(ret => {
|
loadData(state.offset).then(ret => {
|
||||||
this.updateState(state => {
|
this.updateState(state => {
|
||||||
|
@ -75,6 +75,7 @@ @interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
|
|||||||
|
|
||||||
@property(nonatomic, assign) NSUInteger rowCount;
|
@property(nonatomic, assign) NSUInteger rowCount;
|
||||||
@property(nonatomic, assign) BOOL needReload;
|
@property(nonatomic, assign) BOOL needReload;
|
||||||
|
@property(nonatomic, assign) NSUInteger preloadItemCount;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricListNode
|
@implementation DoricListNode
|
||||||
@ -85,6 +86,7 @@ - (instancetype)initWithContext:(DoricContext *)doricContext {
|
|||||||
_itemActions = [NSMutableDictionary new];
|
_itemActions = [NSMutableDictionary new];
|
||||||
_batchCount = 15;
|
_batchCount = 15;
|
||||||
_loadAnchor = -1;
|
_loadAnchor = -1;
|
||||||
|
_preloadItemCount = 0;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -206,6 +208,8 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
self.onDraggingFuncId = prop;
|
self.onDraggingFuncId = prop;
|
||||||
} else if ([@"onDragged" isEqualToString:name]) {
|
} else if ([@"onDragged" isEqualToString:name]) {
|
||||||
self.onDraggedFuncId = prop;
|
self.onDraggedFuncId = prop;
|
||||||
|
} else if ([@"preloadItemCount" isEqualToString:name]) {
|
||||||
|
self.preloadItemCount = [prop unsignedIntegerValue];
|
||||||
} else {
|
} else {
|
||||||
[super blendView:view forPropName:name propValue:prop];
|
[super blendView:view forPropName:name propValue:prop];
|
||||||
}
|
}
|
||||||
@ -249,7 +253,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
|
|||||||
NSString *reuseId = props[@"identifier"];
|
NSString *reuseId = props[@"identifier"];
|
||||||
self.itemActions[@(position)] = props[@"actions"];
|
self.itemActions[@(position)] = props[@"actions"];
|
||||||
if (self.loadMore
|
if (self.loadMore
|
||||||
&& position >= self.rowCount - 1
|
&& position >= self.rowCount - 1 - self.preloadItemCount
|
||||||
&& self.onLoadMoreFuncId) {
|
&& self.onLoadMoreFuncId) {
|
||||||
reuseId = @"doricLoadMoreCell";
|
reuseId = @"doricLoadMoreCell";
|
||||||
[self callLoadMore];
|
[self callLoadMore];
|
||||||
|
@ -2645,6 +2645,10 @@ var List = /** @class */ (function (_super) {
|
|||||||
Property,
|
Property,
|
||||||
__metadata$b("design:type", Function)
|
__metadata$b("design:type", Function)
|
||||||
], List.prototype, "onDragged", void 0);
|
], List.prototype, "onDragged", void 0);
|
||||||
|
__decorate$b([
|
||||||
|
Property,
|
||||||
|
__metadata$b("design:type", Number)
|
||||||
|
], List.prototype, "preloadItemCount", void 0);
|
||||||
return List;
|
return List;
|
||||||
}(Superview));
|
}(Superview));
|
||||||
function list(config) {
|
function list(config) {
|
||||||
@ -4402,7 +4406,7 @@ var __generator$1 = (undefined && undefined.__generator) || function (thisArg, b
|
|||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
function step(op) {
|
function step(op) {
|
||||||
if (f) { throw new TypeError("Generator is already executing."); }
|
if (f) { throw new TypeError("Generator is already executing."); }
|
||||||
while (_) { try {
|
while (g && (g = 0, op[0] && (_ = 0)), _) { try {
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
|
||||||
if (y = 0, t) { op = [op[0] & 2, t.value]; }
|
if (y = 0, t) { op = [op[0] & 2, t.value]; }
|
||||||
switch (op[0]) {
|
switch (op[0]) {
|
||||||
@ -4631,7 +4635,7 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
function step(op) {
|
function step(op) {
|
||||||
if (f) { throw new TypeError("Generator is already executing."); }
|
if (f) { throw new TypeError("Generator is already executing."); }
|
||||||
while (_) { try {
|
while (g && (g = 0, op[0] && (_ = 0)), _) { try {
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
|
||||||
if (y = 0, t) { op = [op[0] & 2, t.value]; }
|
if (y = 0, t) { op = [op[0] & 2, t.value]; }
|
||||||
switch (op[0]) {
|
switch (op[0]) {
|
||||||
|
@ -161,6 +161,24 @@ function createRef() {
|
|||||||
return new Ref;
|
return new Ref;
|
||||||
}
|
}
|
||||||
class View {
|
class View {
|
||||||
|
callback2Id(f) {
|
||||||
|
const id = uniqueId('Function');
|
||||||
|
this.callbacks.set(id, f);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
id2Callback(id) {
|
||||||
|
let f = this.callbacks.get(id);
|
||||||
|
if (f === undefined) {
|
||||||
|
f = Reflect.get(this, id);
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
findViewByTag(tag) {
|
||||||
|
if (tag === this.tag) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
constructor() {
|
constructor() {
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
@ -192,24 +210,6 @@ class View {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
callback2Id(f) {
|
|
||||||
const id = uniqueId('Function');
|
|
||||||
this.callbacks.set(id, f);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
id2Callback(id) {
|
|
||||||
let f = this.callbacks.get(id);
|
|
||||||
if (f === undefined) {
|
|
||||||
f = Reflect.get(this, id);
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
findViewByTag(tag) {
|
|
||||||
if (tag === this.tag) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
/** Anchor start*/
|
/** Anchor start*/
|
||||||
get left() {
|
get left() {
|
||||||
return this.x;
|
return this.x;
|
||||||
@ -2010,6 +2010,10 @@ __decorate$b([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$b("design:type", Function)
|
__metadata$b("design:type", Function)
|
||||||
], List.prototype, "onDragged", void 0);
|
], List.prototype, "onDragged", void 0);
|
||||||
|
__decorate$b([
|
||||||
|
Property,
|
||||||
|
__metadata$b("design:type", Number)
|
||||||
|
], List.prototype, "preloadItemCount", void 0);
|
||||||
function list(config) {
|
function list(config) {
|
||||||
const ret = new List;
|
const ret = new List;
|
||||||
ret.apply(config);
|
ret.apply(config);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1273,6 +1273,16 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Context {
|
class Context {
|
||||||
|
hookBeforeNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hookAfterNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
this.callbacks = new Map;
|
this.callbacks = new Map;
|
||||||
this.classes = new Map;
|
this.classes = new Map;
|
||||||
@ -1307,16 +1317,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hookBeforeNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hookAfterNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callNative(namespace, method, args) {
|
callNative(namespace, method, args) {
|
||||||
const callbackId = uniqueId('callback');
|
const callbackId = uniqueId('callback');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -1284,6 +1284,16 @@ function jsCallReject(contextId, callbackId, args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Context {
|
class Context {
|
||||||
|
hookBeforeNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hookAfterNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
this.callbacks = new Map;
|
this.callbacks = new Map;
|
||||||
this.classes = new Map;
|
this.classes = new Map;
|
||||||
@ -1318,16 +1328,6 @@ class Context {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hookBeforeNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hookAfterNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callNative(namespace, method, args) {
|
callNative(namespace, method, args) {
|
||||||
const callbackId = uniqueId('callback');
|
const callbackId = uniqueId('callback');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -1701,6 +1701,24 @@ function createRef() {
|
|||||||
return new Ref;
|
return new Ref;
|
||||||
}
|
}
|
||||||
class View {
|
class View {
|
||||||
|
callback2Id(f) {
|
||||||
|
const id = uniqueId('Function');
|
||||||
|
this.callbacks.set(id, f);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
id2Callback(id) {
|
||||||
|
let f = this.callbacks.get(id);
|
||||||
|
if (f === undefined) {
|
||||||
|
f = Reflect.get(this, id);
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
findViewByTag(tag) {
|
||||||
|
if (tag === this.tag) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
constructor() {
|
constructor() {
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
@ -1732,24 +1750,6 @@ class View {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
callback2Id(f) {
|
|
||||||
const id = uniqueId('Function');
|
|
||||||
this.callbacks.set(id, f);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
id2Callback(id) {
|
|
||||||
let f = this.callbacks.get(id);
|
|
||||||
if (f === undefined) {
|
|
||||||
f = Reflect.get(this, id);
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
findViewByTag(tag) {
|
|
||||||
if (tag === this.tag) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
/** Anchor start*/
|
/** Anchor start*/
|
||||||
get left() {
|
get left() {
|
||||||
return this.x;
|
return this.x;
|
||||||
@ -3550,6 +3550,10 @@ __decorate$b([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$b("design:type", Function)
|
__metadata$b("design:type", Function)
|
||||||
], List.prototype, "onDragged", void 0);
|
], List.prototype, "onDragged", void 0);
|
||||||
|
__decorate$b([
|
||||||
|
Property,
|
||||||
|
__metadata$b("design:type", Number)
|
||||||
|
], List.prototype, "preloadItemCount", void 0);
|
||||||
function list(config) {
|
function list(config) {
|
||||||
const ret = new List;
|
const ret = new List;
|
||||||
ret.apply(config);
|
ret.apply(config);
|
||||||
|
3
doric-js/index.d.ts
vendored
3
doric-js/index.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
declare module "doric" {
|
declare module "doric" {
|
||||||
// Generated by dts-bundle-generator v6.12.0
|
// Generated by dts-bundle-generator v6.13.0
|
||||||
|
|
||||||
export interface Modeling {
|
export interface Modeling {
|
||||||
toModel(): Model;
|
toModel(): Model;
|
||||||
@ -1043,6 +1043,7 @@ declare module "doric" {
|
|||||||
beforeDragging?: (from: number) => (Array<number> | void);
|
beforeDragging?: (from: number) => (Array<number> | void);
|
||||||
onDragging?: (from: number, to: number) => void;
|
onDragging?: (from: number, to: number) => void;
|
||||||
onDragged?: (from: number, to: number) => void;
|
onDragged?: (from: number, to: number) => void;
|
||||||
|
preloadItemCount?: number;
|
||||||
scrollToItem(context: BridgeContext, index: number, config?: {
|
scrollToItem(context: BridgeContext, index: number, config?: {
|
||||||
animated?: boolean;
|
animated?: boolean;
|
||||||
}): Promise<any>;
|
}): Promise<any>;
|
||||||
|
4
doric-js/lib/index.web.d.ts
vendored
4
doric-js/lib/index.web.d.ts
vendored
@ -4,8 +4,8 @@ declare module NativeClient {
|
|||||||
function callNative(name: string, args: string): string;
|
function callNative(name: string, args: string): string;
|
||||||
function fetchArrayBuffer(id: string): string;
|
function fetchArrayBuffer(id: string): string;
|
||||||
}
|
}
|
||||||
declare type RawValue = number | string | boolean | object | undefined | ArrayBuffer;
|
type RawValue = number | string | boolean | object | undefined | ArrayBuffer;
|
||||||
declare type WrappedValue = {
|
type WrappedValue = {
|
||||||
type: "number" | "string" | "boolean" | "object" | "array" | "null" | "arrayBuffer";
|
type: "number" | "string" | "boolean" | "object" | "array" | "null" | "arrayBuffer";
|
||||||
value: RawValue;
|
value: RawValue;
|
||||||
};
|
};
|
||||||
|
2
doric-js/lib/src/pattern/mvvm.d.ts
vendored
2
doric-js/lib/src/pattern/mvvm.d.ts
vendored
@ -5,7 +5,7 @@ import { ClassType } from "../util/types";
|
|||||||
export declare abstract class ViewHolder {
|
export declare abstract class ViewHolder {
|
||||||
abstract build(root: Group): void;
|
abstract build(root: Group): void;
|
||||||
}
|
}
|
||||||
export declare type Setter<M> = (state: M) => void;
|
export type Setter<M> = (state: M) => void;
|
||||||
export declare abstract class ViewModel<M extends Object, V extends ViewHolder> {
|
export declare abstract class ViewModel<M extends Object, V extends ViewHolder> {
|
||||||
context: BridgeContext;
|
context: BridgeContext;
|
||||||
private state;
|
private state;
|
||||||
|
4
doric-js/lib/src/pattern/provider.d.ts
vendored
4
doric-js/lib/src/pattern/provider.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
export declare type Observer<T> = (v: T) => void;
|
export type Observer<T> = (v: T) => void;
|
||||||
export declare type Updater<T> = (v: T) => T;
|
export type Updater<T> = (v: T) => T;
|
||||||
export interface IObservable<T> {
|
export interface IObservable<T> {
|
||||||
addObserver(observer: Observer<T | undefined>): void;
|
addObserver(observer: Observer<T | undefined>): void;
|
||||||
removeObserver(observer: Observer<T | undefined>): void;
|
removeObserver(observer: Observer<T | undefined>): void;
|
||||||
|
2
doric-js/lib/src/runtime/global.d.ts
vendored
2
doric-js/lib/src/runtime/global.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
import { Panel } from "../ui/panel";
|
import { Panel } from "../ui/panel";
|
||||||
import { ClassType } from "../util/types";
|
import { ClassType } from "../util/types";
|
||||||
export declare type BridgeContext = {
|
export type BridgeContext = {
|
||||||
/**
|
/**
|
||||||
* The identify of current context
|
* The identify of current context
|
||||||
*/
|
*/
|
||||||
|
6
doric-js/lib/src/runtime/sandbox.d.ts
vendored
6
doric-js/lib/src/runtime/sandbox.d.ts
vendored
@ -23,9 +23,9 @@ export declare function jsObtainContext(id: string): Context | undefined;
|
|||||||
export declare function jsReleaseContext(id: string): void;
|
export declare function jsReleaseContext(id: string): void;
|
||||||
export declare function __require__(name: string): any;
|
export declare function __require__(name: string): any;
|
||||||
export declare function jsRegisterModule(name: string, moduleObject: any): void;
|
export declare function jsRegisterModule(name: string, moduleObject: any): void;
|
||||||
export declare function jsCallEntityMethod(contextId: string, methodName: string, args?: any): any;
|
export declare function jsCallEntityMethod(contextId: string, methodName: string, args?: any): unknown;
|
||||||
export declare function pureCallEntityMethod(contextId: string, methodName: string, args?: any): any;
|
export declare function pureCallEntityMethod(contextId: string, methodName: string, args?: any): unknown;
|
||||||
declare type ClassType<T> = new (...args: any) => T;
|
type ClassType<T> = new (...args: any) => T;
|
||||||
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
|
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
|
||||||
export declare function jsCallbackTimer(timerId: number): void;
|
export declare function jsCallbackTimer(timerId: number): void;
|
||||||
export declare function jsHookAfterNativeCall(): void;
|
export declare function jsHookAfterNativeCall(): void;
|
||||||
|
@ -71,6 +71,16 @@ export function jsCallReject(contextId, callbackId, args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class Context {
|
export class Context {
|
||||||
|
hookBeforeNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hookAfterNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
this.callbacks = new Map;
|
this.callbacks = new Map;
|
||||||
this.classes = new Map;
|
this.classes = new Map;
|
||||||
@ -105,16 +115,6 @@ export class Context {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hookBeforeNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hookAfterNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callNative(namespace, method, args) {
|
callNative(namespace, method, args) {
|
||||||
const callbackId = uniqueId('callback');
|
const callbackId = uniqueId('callback');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
2
doric-js/lib/src/ui/animation.d.ts
vendored
2
doric-js/lib/src/ui/animation.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
import { Color } from "../util/color";
|
import { Color } from "../util/color";
|
||||||
import { Modeling, Model } from "../util/types";
|
import { Modeling, Model } from "../util/types";
|
||||||
export declare type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY" | "rotationX" | "rotationY" | "backgroundColor" | "alpha";
|
export type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY" | "rotationX" | "rotationY" | "backgroundColor" | "alpha";
|
||||||
export declare enum RepeatMode {
|
export declare enum RepeatMode {
|
||||||
RESTART = 1,
|
RESTART = 1,
|
||||||
REVERSE = 2
|
REVERSE = 2
|
||||||
|
8
doric-js/lib/src/ui/view.d.ts
vendored
8
doric-js/lib/src/ui/view.d.ts
vendored
@ -7,14 +7,14 @@ import { FlexConfig } from "../util/flexbox";
|
|||||||
export declare function Property(target: Object, propKey: string): void;
|
export declare function Property(target: Object, propKey: string): void;
|
||||||
export declare function InconsistProperty(target: Object, propKey: string): void;
|
export declare function InconsistProperty(target: Object, propKey: string): void;
|
||||||
export declare function ViewComponent(constructor: ClassType<any>): void;
|
export declare function ViewComponent(constructor: ClassType<any>): void;
|
||||||
export declare type NativeViewModel = {
|
export type NativeViewModel = {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
props: {
|
props: {
|
||||||
[index: string]: Model;
|
[index: string]: Model;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
declare type RefType<T> = T extends Ref<infer R> ? R : never;
|
type RefType<T> = T extends Ref<infer R> ? R : never;
|
||||||
export declare class Ref<T extends View> {
|
export declare class Ref<T extends View> {
|
||||||
private view?;
|
private view?;
|
||||||
set current(v: T);
|
set current(v: T);
|
||||||
@ -151,8 +151,8 @@ export declare abstract class Superview extends View {
|
|||||||
clean(): void;
|
clean(): void;
|
||||||
toModel(): NativeViewModel;
|
toModel(): NativeViewModel;
|
||||||
}
|
}
|
||||||
export declare type ViewArray = View[];
|
export type ViewArray = View[];
|
||||||
export declare type ViewFragment = View | ViewArray | undefined | null;
|
export type ViewFragment = View | ViewArray | undefined | null;
|
||||||
export declare abstract class Group extends Superview implements JSX.ElementChildrenAttribute {
|
export declare abstract class Group extends Superview implements JSX.ElementChildrenAttribute {
|
||||||
padding?: {
|
padding?: {
|
||||||
left?: number;
|
left?: number;
|
||||||
|
@ -43,6 +43,24 @@ export function createRef() {
|
|||||||
return new Ref;
|
return new Ref;
|
||||||
}
|
}
|
||||||
export class View {
|
export class View {
|
||||||
|
callback2Id(f) {
|
||||||
|
const id = uniqueId('Function');
|
||||||
|
this.callbacks.set(id, f);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
id2Callback(id) {
|
||||||
|
let f = this.callbacks.get(id);
|
||||||
|
if (f === undefined) {
|
||||||
|
f = Reflect.get(this, id);
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
findViewByTag(tag) {
|
||||||
|
if (tag === this.tag) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
constructor() {
|
constructor() {
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
@ -74,24 +92,6 @@ export class View {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
callback2Id(f) {
|
|
||||||
const id = uniqueId('Function');
|
|
||||||
this.callbacks.set(id, f);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
id2Callback(id) {
|
|
||||||
let f = this.callbacks.get(id);
|
|
||||||
if (f === undefined) {
|
|
||||||
f = Reflect.get(this, id);
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
findViewByTag(tag) {
|
|
||||||
if (tag === this.tag) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
/** Anchor start*/
|
/** Anchor start*/
|
||||||
get left() {
|
get left() {
|
||||||
return this.x;
|
return this.x;
|
||||||
|
2
doric-js/lib/src/util/flexbox.d.ts
vendored
2
doric-js/lib/src/util/flexbox.d.ts
vendored
@ -64,7 +64,7 @@ export declare enum Display {
|
|||||||
FLEX = 0,
|
FLEX = 0,
|
||||||
NONE = 1
|
NONE = 1
|
||||||
}
|
}
|
||||||
export declare type FlexValue = FlexTypedValue | number;
|
export type FlexValue = FlexTypedValue | number;
|
||||||
export interface FlexConfig {
|
export interface FlexConfig {
|
||||||
direction?: Direction;
|
direction?: Direction;
|
||||||
flexDirection?: FlexDirection;
|
flexDirection?: FlexDirection;
|
||||||
|
8
doric-js/lib/src/util/types.d.ts
vendored
8
doric-js/lib/src/util/types.d.ts
vendored
@ -2,11 +2,11 @@ export interface Modeling {
|
|||||||
toModel(): Model;
|
toModel(): Model;
|
||||||
}
|
}
|
||||||
export declare function obj2Model(obj: Model, convertor: (v: Function) => string): Model;
|
export declare function obj2Model(obj: Model, convertor: (v: Function) => string): Model;
|
||||||
declare type _M = string | number | boolean | Modeling | {
|
type _M = string | number | boolean | Modeling | {
|
||||||
[index: string]: Model;
|
[index: string]: Model;
|
||||||
} | undefined;
|
} | undefined;
|
||||||
export declare type Model = _M | Array<_M>;
|
export type Model = _M | Array<_M>;
|
||||||
export declare type Binder<T> = (v: T) => void;
|
export type Binder<T> = (v: T) => void;
|
||||||
export declare class Mutable<T> {
|
export declare class Mutable<T> {
|
||||||
private val;
|
private val;
|
||||||
private binders;
|
private binders;
|
||||||
@ -16,5 +16,5 @@ export declare class Mutable<T> {
|
|||||||
bind(binder: Binder<T>): void;
|
bind(binder: Binder<T>): void;
|
||||||
static of<E>(v: E): Mutable<E>;
|
static of<E>(v: E): Mutable<E>;
|
||||||
}
|
}
|
||||||
export declare type ClassType<T> = new (...args: any) => T;
|
export type ClassType<T> = new (...args: any) => T;
|
||||||
export {};
|
export {};
|
||||||
|
1
doric-js/lib/src/widget/list.d.ts
vendored
1
doric-js/lib/src/widget/list.d.ts
vendored
@ -49,6 +49,7 @@ export declare class List extends Superview {
|
|||||||
beforeDragging?: (from: number) => (Array<number> | void);
|
beforeDragging?: (from: number) => (Array<number> | void);
|
||||||
onDragging?: (from: number, to: number) => void;
|
onDragging?: (from: number, to: number) => void;
|
||||||
onDragged?: (from: number, to: number) => void;
|
onDragged?: (from: number, to: number) => void;
|
||||||
|
preloadItemCount?: number;
|
||||||
scrollToItem(context: BridgeContext, index: number, config?: {
|
scrollToItem(context: BridgeContext, index: number, config?: {
|
||||||
animated?: boolean;
|
animated?: boolean;
|
||||||
}): Promise<any>;
|
}): Promise<any>;
|
||||||
|
@ -162,6 +162,10 @@ __decorate([
|
|||||||
Property,
|
Property,
|
||||||
__metadata("design:type", Function)
|
__metadata("design:type", Function)
|
||||||
], List.prototype, "onDragged", void 0);
|
], List.prototype, "onDragged", void 0);
|
||||||
|
__decorate([
|
||||||
|
Property,
|
||||||
|
__metadata("design:type", Number)
|
||||||
|
], List.prototype, "preloadItemCount", void 0);
|
||||||
export function list(config) {
|
export function list(config) {
|
||||||
const ret = new List;
|
const ret = new List;
|
||||||
ret.apply(config);
|
ret.apply(config);
|
||||||
|
@ -88,8 +88,8 @@ export class List extends Superview {
|
|||||||
* @param from
|
* @param from
|
||||||
* @returns Returns the item of index which can dragged or not.
|
* @returns Returns the item of index which can dragged or not.
|
||||||
*/
|
*/
|
||||||
@Property
|
@Property
|
||||||
itemCanDrag?: (from: number) => boolean
|
itemCanDrag?: (from: number) => boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param from
|
* @param from
|
||||||
@ -104,6 +104,9 @@ export class List extends Superview {
|
|||||||
@Property
|
@Property
|
||||||
onDragged?: (from: number, to: number) => void
|
onDragged?: (from: number, to: number) => void
|
||||||
|
|
||||||
|
@Property
|
||||||
|
preloadItemCount?: number
|
||||||
|
|
||||||
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>
|
||||||
|
60
doric-web/dist/index.js
vendored
60
doric-web/dist/index.js
vendored
@ -1278,6 +1278,16 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Context {
|
class Context {
|
||||||
|
hookBeforeNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hookAfterNativeCall() {
|
||||||
|
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
||||||
|
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
this.callbacks = new Map;
|
this.callbacks = new Map;
|
||||||
this.classes = new Map;
|
this.classes = new Map;
|
||||||
@ -1312,16 +1322,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hookBeforeNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookBeforeNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookBeforeNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hookAfterNativeCall() {
|
|
||||||
if (this.entity && Reflect.has(this.entity, 'hookAfterNativeCall')) {
|
|
||||||
Reflect.apply(Reflect.get(this.entity, 'hookAfterNativeCall'), this.entity, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callNative(namespace, method, args) {
|
callNative(namespace, method, args) {
|
||||||
const callbackId = uniqueId('callback');
|
const callbackId = uniqueId('callback');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -1776,6 +1776,24 @@ function createRef() {
|
|||||||
return new Ref;
|
return new Ref;
|
||||||
}
|
}
|
||||||
class View {
|
class View {
|
||||||
|
callback2Id(f) {
|
||||||
|
const id = uniqueId('Function');
|
||||||
|
this.callbacks.set(id, f);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
id2Callback(id) {
|
||||||
|
let f = this.callbacks.get(id);
|
||||||
|
if (f === undefined) {
|
||||||
|
f = Reflect.get(this, id);
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
findViewByTag(tag) {
|
||||||
|
if (tag === this.tag) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
constructor() {
|
constructor() {
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
@ -1807,24 +1825,6 @@ class View {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
callback2Id(f) {
|
|
||||||
const id = uniqueId('Function');
|
|
||||||
this.callbacks.set(id, f);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
id2Callback(id) {
|
|
||||||
let f = this.callbacks.get(id);
|
|
||||||
if (f === undefined) {
|
|
||||||
f = Reflect.get(this, id);
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
findViewByTag(tag) {
|
|
||||||
if (tag === this.tag) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
/** Anchor start*/
|
/** Anchor start*/
|
||||||
get left() {
|
get left() {
|
||||||
return this.x;
|
return this.x;
|
||||||
@ -3625,6 +3625,10 @@ __decorate$b([
|
|||||||
Property,
|
Property,
|
||||||
__metadata$b("design:type", Function)
|
__metadata$b("design:type", Function)
|
||||||
], List.prototype, "onDragged", void 0);
|
], List.prototype, "onDragged", void 0);
|
||||||
|
__decorate$b([
|
||||||
|
Property,
|
||||||
|
__metadata$b("design:type", Number)
|
||||||
|
], List.prototype, "preloadItemCount", void 0);
|
||||||
function list(config) {
|
function list(config) {
|
||||||
const ret = new List;
|
const ret = new List;
|
||||||
ret.apply(config);
|
ret.apply(config);
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user