jsbox-cview 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,6 +14,11 @@ interface TabBarControllerProps extends BaseControllerProps {
|
|
|
14
14
|
index?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
interface TabBarControllerEvents extends BaseControllerEvents {
|
|
18
|
+
changed?: (controller: TabBarController, index: number) => void;
|
|
19
|
+
doubleTapped?: (controller: TabBarController, index: number) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* # CView TabBar Controller
|
|
19
24
|
*
|
|
@@ -31,6 +36,7 @@ interface TabBarControllerProps extends BaseControllerProps {
|
|
|
31
36
|
*/
|
|
32
37
|
export class TabBarController extends BaseController {
|
|
33
38
|
_props: TabBarControllerProps;
|
|
39
|
+
_events: TabBarControllerEvents;
|
|
34
40
|
cviews: {
|
|
35
41
|
tabbar: TabBar;
|
|
36
42
|
pageContentView: ContentView;
|
|
@@ -39,18 +45,27 @@ export class TabBarController extends BaseController {
|
|
|
39
45
|
constructor({ props, layout, events = {} }: {
|
|
40
46
|
props: TabBarControllerProps;
|
|
41
47
|
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
42
|
-
events?:
|
|
48
|
+
events?: TabBarControllerEvents;
|
|
43
49
|
}) {
|
|
44
50
|
super({
|
|
45
51
|
props: {
|
|
46
52
|
id: props.id,
|
|
47
53
|
bgcolor: props.bgcolor
|
|
48
|
-
},
|
|
54
|
+
},
|
|
55
|
+
layout,
|
|
56
|
+
events: {
|
|
57
|
+
...events,
|
|
58
|
+
didAppear: () => {
|
|
59
|
+
this._props.items[this.index].controller.appear();
|
|
60
|
+
this._events.didAppear?.(this);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
49
63
|
});
|
|
50
64
|
this._props = {
|
|
51
65
|
items: props.items,
|
|
52
66
|
index: props.index || 0
|
|
53
67
|
};
|
|
68
|
+
this._events = events;
|
|
54
69
|
this.cviews = {} as {
|
|
55
70
|
tabbar: TabBar;
|
|
56
71
|
pageContentView: ContentView;
|
|
@@ -61,7 +76,15 @@ export class TabBarController extends BaseController {
|
|
|
61
76
|
index: this._props.index
|
|
62
77
|
},
|
|
63
78
|
events: {
|
|
64
|
-
changed: (cview, index) =>
|
|
79
|
+
changed: (cview, index) => {
|
|
80
|
+
this.index = index;
|
|
81
|
+
this._props.items.find(item=>item.controller.status === 2)?.controller.disappear();
|
|
82
|
+
this._props.items[index].controller.appear();
|
|
83
|
+
this._events.changed?.(this, index);
|
|
84
|
+
},
|
|
85
|
+
doubleTapped: (cview, index) => {
|
|
86
|
+
this._events.doubleTapped?.(this, index);
|
|
87
|
+
}
|
|
65
88
|
}
|
|
66
89
|
});
|
|
67
90
|
|
|
@@ -25,12 +25,19 @@ class TabBarController extends base_controller_1.BaseController {
|
|
|
25
25
|
props: {
|
|
26
26
|
id: props.id,
|
|
27
27
|
bgcolor: props.bgcolor
|
|
28
|
-
},
|
|
28
|
+
},
|
|
29
|
+
layout,
|
|
30
|
+
events: Object.assign(Object.assign({}, events), { didAppear: () => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
this._props.items[this.index].controller.appear();
|
|
33
|
+
(_b = (_a = this._events).didAppear) === null || _b === void 0 ? void 0 : _b.call(_a, this);
|
|
34
|
+
} })
|
|
29
35
|
});
|
|
30
36
|
this._props = {
|
|
31
37
|
items: props.items,
|
|
32
38
|
index: props.index || 0
|
|
33
39
|
};
|
|
40
|
+
this._events = events;
|
|
34
41
|
this.cviews = {};
|
|
35
42
|
this.cviews.tabbar = new tabbar_1.TabBar({
|
|
36
43
|
props: {
|
|
@@ -38,7 +45,17 @@ class TabBarController extends base_controller_1.BaseController {
|
|
|
38
45
|
index: this._props.index
|
|
39
46
|
},
|
|
40
47
|
events: {
|
|
41
|
-
changed: (cview, index) =>
|
|
48
|
+
changed: (cview, index) => {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
this.index = index;
|
|
51
|
+
(_a = this._props.items.find(item => item.controller.status === 2)) === null || _a === void 0 ? void 0 : _a.controller.disappear();
|
|
52
|
+
this._props.items[index].controller.appear();
|
|
53
|
+
(_c = (_b = this._events).changed) === null || _c === void 0 ? void 0 : _c.call(_b, this, index);
|
|
54
|
+
},
|
|
55
|
+
doubleTapped: (cview, index) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
(_b = (_a = this._events).doubleTapped) === null || _b === void 0 ? void 0 : _b.call(_a, this, index);
|
|
58
|
+
}
|
|
42
59
|
}
|
|
43
60
|
});
|
|
44
61
|
this.pages = this._props.items.map((n, i) => {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tabbar_controller_1 = require("../controller/tabbar-controller");
|
|
4
|
+
const base_controller_1 = require("../controller/base-controller");
|
|
5
|
+
const items = [{
|
|
6
|
+
controller: new base_controller_1.BaseController({
|
|
7
|
+
props: { bgcolor: $color("red") },
|
|
8
|
+
events: {
|
|
9
|
+
didAppear: () => {
|
|
10
|
+
console.log("Page 1 did appear");
|
|
11
|
+
},
|
|
12
|
+
didDisappear: () => {
|
|
13
|
+
console.log("Page 1 did disappear");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
title: "Page 1"
|
|
18
|
+
}, {
|
|
19
|
+
controller: new base_controller_1.BaseController({
|
|
20
|
+
props: { bgcolor: $color("yellow") },
|
|
21
|
+
events: {
|
|
22
|
+
didAppear: () => {
|
|
23
|
+
console.log("Page 2 did appear");
|
|
24
|
+
},
|
|
25
|
+
didDisappear: () => {
|
|
26
|
+
console.log("Page 2 did disappear");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
title: "Page 2"
|
|
31
|
+
}];
|
|
32
|
+
const pageViewerController = new tabbar_controller_1.TabBarController({
|
|
33
|
+
props: {
|
|
34
|
+
items
|
|
35
|
+
},
|
|
36
|
+
events: {
|
|
37
|
+
changed: (sender, index) => {
|
|
38
|
+
console.log(`Index changed to ${index}`);
|
|
39
|
+
},
|
|
40
|
+
doubleTapped: (sender, index) => {
|
|
41
|
+
console.log(`Double tapped on index ${index}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
pageViewerController.uirender({});
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TabBarController } from "../controller/tabbar-controller";
|
|
2
|
+
import { BaseController } from "../controller/base-controller";
|
|
3
|
+
import { PageViewer } from "../components/pageviewer";
|
|
4
|
+
|
|
5
|
+
const items = [{
|
|
6
|
+
controller: new BaseController({
|
|
7
|
+
props: { bgcolor: $color("red") },
|
|
8
|
+
events: {
|
|
9
|
+
didAppear: () => {
|
|
10
|
+
console.log("Page 1 did appear");
|
|
11
|
+
},
|
|
12
|
+
didDisappear: () => {
|
|
13
|
+
console.log("Page 1 did disappear");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
title: "Page 1"
|
|
18
|
+
}, {
|
|
19
|
+
controller: new BaseController({
|
|
20
|
+
props: { bgcolor: $color("yellow") },
|
|
21
|
+
events: {
|
|
22
|
+
didAppear: () => {
|
|
23
|
+
console.log("Page 2 did appear");
|
|
24
|
+
},
|
|
25
|
+
didDisappear: () => {
|
|
26
|
+
console.log("Page 2 did disappear");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
title: "Page 2"
|
|
31
|
+
}]
|
|
32
|
+
|
|
33
|
+
const pageViewerController = new TabBarController({
|
|
34
|
+
props: {
|
|
35
|
+
items
|
|
36
|
+
},
|
|
37
|
+
events: {
|
|
38
|
+
changed: (sender, index) => {
|
|
39
|
+
console.log(`Index changed to ${index}`);
|
|
40
|
+
},
|
|
41
|
+
doubleTapped: (sender, index) => {
|
|
42
|
+
console.log(`Double tapped on index ${index}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
pageViewerController.uirender({});
|