feat: add ModularPanel
This commit is contained in:
2
doric-js/lib/src/native/navigator.d.ts
vendored
2
doric-js/lib/src/native/navigator.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { ClassType } from "../pattern/mvvm";
|
||||
import { Panel } from "../ui/panel";
|
||||
import { ClassType } from "../util/types";
|
||||
export declare function internalScheme(context: BridgeContext, panelClass: ClassType<Panel>): string;
|
||||
export declare function navigator(context: BridgeContext): {
|
||||
push: (source: string | ClassType<Panel>, config?: {
|
||||
|
14
doric-js/lib/src/pattern/modular.d.ts
vendored
Normal file
14
doric-js/lib/src/pattern/modular.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Panel } from "../ui/panel";
|
||||
import { Group } from "../ui/view";
|
||||
export declare abstract class ModularPanel extends Panel {
|
||||
private modules;
|
||||
constructor(modules: Panel[]);
|
||||
abstract setupModules(): Panel[];
|
||||
abstract setupShelf(root: Group): Group;
|
||||
build(root: Group): void;
|
||||
onCreate(): void;
|
||||
onDestroy(): void;
|
||||
onShow(): void;
|
||||
onHidden(): void;
|
||||
onRenderFinished(): void;
|
||||
}
|
45
doric-js/lib/src/pattern/modular.js
Normal file
45
doric-js/lib/src/pattern/modular.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Panel } from "../ui/panel";
|
||||
export class ModularPanel extends Panel {
|
||||
constructor(modules) {
|
||||
super();
|
||||
this.modules = [];
|
||||
this.modules = modules;
|
||||
}
|
||||
build(root) {
|
||||
const groupView = this.setupShelf(root);
|
||||
this.modules.forEach(e => {
|
||||
Reflect.set(e, "__root__", groupView);
|
||||
e.build(groupView);
|
||||
});
|
||||
}
|
||||
onCreate() {
|
||||
super.onCreate();
|
||||
this.modules.forEach(e => {
|
||||
e.onCreate();
|
||||
});
|
||||
}
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
this.modules.forEach(e => {
|
||||
e.onDestroy();
|
||||
});
|
||||
}
|
||||
onShow() {
|
||||
super.onShow();
|
||||
this.modules.forEach(e => {
|
||||
e.onShow();
|
||||
});
|
||||
}
|
||||
onHidden() {
|
||||
super.onHidden();
|
||||
this.modules.forEach(e => {
|
||||
e.onHidden();
|
||||
});
|
||||
}
|
||||
onRenderFinished() {
|
||||
super.onRenderFinished();
|
||||
this.modules.forEach(e => {
|
||||
e.onRenderFinished();
|
||||
});
|
||||
}
|
||||
}
|
2
doric-js/lib/src/pattern/mvvm.d.ts
vendored
2
doric-js/lib/src/pattern/mvvm.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
import { Group } from "../ui/view";
|
||||
import { Panel } from "../ui/panel";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { ClassType } from "../util/types";
|
||||
export declare abstract class ViewHolder {
|
||||
abstract build(root: Group): void;
|
||||
}
|
||||
@@ -17,7 +18,6 @@ export declare abstract class ViewModel<M extends Object, V extends ViewHolder>
|
||||
abstract onAttached(state: M, vh: V): void;
|
||||
abstract onBind(state: M, vh: V): void;
|
||||
}
|
||||
export declare type ClassType<T> = new (...args: any) => T;
|
||||
export declare abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
||||
private vm?;
|
||||
private vh?;
|
||||
|
2
doric-js/lib/src/runtime/global.d.ts
vendored
2
doric-js/lib/src/runtime/global.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { Panel } from "../ui/panel";
|
||||
import { ClassType } from "../pattern/mvvm";
|
||||
import { ClassType } from "../util/types";
|
||||
export declare type BridgeContext = {
|
||||
/**
|
||||
* The identify of current context
|
||||
|
2
doric-js/lib/src/ui/panel.d.ts
vendored
2
doric-js/lib/src/ui/panel.d.ts
vendored
@@ -32,6 +32,6 @@ export declare abstract class Panel {
|
||||
private nativeRender;
|
||||
private hookBeforeNativeCall;
|
||||
private hookAfterNativeCall;
|
||||
private onRenderFinished;
|
||||
onRenderFinished(): void;
|
||||
addOnRenderFinishedCallback(cb: () => void): void;
|
||||
}
|
||||
|
1
doric-js/lib/src/util/types.d.ts
vendored
1
doric-js/lib/src/util/types.d.ts
vendored
@@ -16,4 +16,5 @@ export declare class Mutable<T> {
|
||||
bind(binder: Binder<T>): void;
|
||||
static of<E>(v: E): Mutable<E>;
|
||||
}
|
||||
export declare type ClassType<T> = new (...args: any) => T;
|
||||
export {};
|
||||
|
Reference in New Issue
Block a user