1 |
|
2 |
|
3 |
|
4 | 'use strict';
|
5 |
|
6 | const Base = require('../base/Component');
|
7 |
|
8 | module.exports = class View extends Base {
|
9 |
|
10 | constructor (config) {
|
11 | super({
|
12 |
|
13 |
|
14 | theme: config.parent && config.parent.theme,
|
15 | ThemeSet: require('./ThemeSet'),
|
16 | ...config
|
17 | });
|
18 | }
|
19 |
|
20 | async init () {
|
21 | if (this.original) {
|
22 | this.original.createThemeMap();
|
23 | this.parent = this.original.isEmpty() ? this.parent : this.original;
|
24 | }
|
25 | this.createThemeMap();
|
26 | }
|
27 |
|
28 | createThemeMap () {
|
29 | this.themeSet = ClassHelper.spawn(this.ThemeSet, {
|
30 | theme: this.theme,
|
31 | parent: this.parent && this.parent.themeSet,
|
32 | directory: this.module.getPath(),
|
33 | isOrigin: this.parent && this.parent === this.original
|
34 | });
|
35 | }
|
36 |
|
37 | getTheme (name) {
|
38 | return this.themeSet.get(name);
|
39 | }
|
40 |
|
41 | isEmpty () {
|
42 | return this.themeSet.isEmpty();
|
43 | }
|
44 | };
|
45 |
|
46 | const ClassHelper = require('../helper/ClassHelper'); |
\ | No newline at end of file |