feat: modular add test case

This commit is contained in:
pengfei.zhou
2021-05-13 16:26:48 +08:00
committed by osborn
parent c27a9bd672
commit 546af79534
14 changed files with 358 additions and 57 deletions

View File

@@ -1,3 +1,4 @@
export * from './candies';
export * from './provider';
export * from './mvvm';
export * from './modular';

View File

@@ -16,3 +16,4 @@
export * from './candies';
export * from './provider';
export * from './mvvm';
export * from './modular';

View File

@@ -1,9 +1,10 @@
import { Panel } from "../ui/panel";
import { Group } from "../ui/view";
import { ClassType } from "../util/types";
export declare abstract class ModularPanel extends Panel {
private modules;
constructor(modules: Panel[]);
abstract setupModules(): Panel[];
constructor();
abstract setupModules(): ClassType<Panel>[];
abstract setupShelf(root: Group): Group;
build(root: Group): void;
onCreate(): void;

View File

@@ -1,9 +1,8 @@
import { Panel } from "../ui/panel";
export class ModularPanel extends Panel {
constructor(modules) {
constructor() {
super();
this.modules = [];
this.modules = modules;
this.modules = this.setupModules().map(e => new e);
}
build(root) {
const groupView = this.setupShelf(root);
@@ -15,6 +14,7 @@ export class ModularPanel extends Panel {
onCreate() {
super.onCreate();
this.modules.forEach(e => {
e.context = this.context;
e.onCreate();
});
}