@vnejs/plugins.view.coralina.interface.controls 0.0.1 → 0.1.0
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.
- package/modules/controller.js +31 -11
- package/modules/view.js +4 -4
- package/package.json +5 -6
- package/view/index.jsx +45 -22
- package/view/index.styl +0 -54
package/modules/controller.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { ZINDEX } from "../view";
|
|
4
|
+
|
|
5
|
+
export class InterfaceControlsController extends ModuleController {
|
|
4
6
|
name = "interface.controls.controller";
|
|
5
7
|
|
|
6
8
|
emitGameMenu = () => this.emit(this.EVENTS.INTERFACE.GAMEMENU);
|
|
@@ -17,7 +19,7 @@ export class InterfaceControlsController extends Module.Controller {
|
|
|
17
19
|
[this.CONST.CONTROLS.BUTTONS.ARROW_BOTTOM]: () => this.emit(this.EVENTS.INTERFACE.VISIBLE),
|
|
18
20
|
};
|
|
19
21
|
controlsUnvisible = { [this.CONST.CONTROLS.BUTTONS.ANY]: () => this.emit(this.EVENTS.INTERFACE.VISIBLE) };
|
|
20
|
-
controlsIndex =
|
|
22
|
+
controlsIndex = ZINDEX;
|
|
21
23
|
controlsCheckNext = true;
|
|
22
24
|
|
|
23
25
|
subscribe = () => {
|
|
@@ -25,24 +27,42 @@ export class InterfaceControlsController extends Module.Controller {
|
|
|
25
27
|
this.on(this.EVENTS.INTERFACE_CONTROLS.HIDE, this.onHide);
|
|
26
28
|
|
|
27
29
|
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
28
|
-
this.on(this.EVENTS.INTERFACE.
|
|
30
|
+
this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
|
|
31
|
+
this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
|
|
32
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
onShowChanged = ({
|
|
35
|
+
onShowChanged = ({ isForce = false } = {}) => {
|
|
32
36
|
const { isShow = false } = this.globalState.interface;
|
|
33
37
|
const event = isShow ? this.EVENTS.INTERFACE_CONTROLS.SHOW : this.EVENTS.INTERFACE_CONTROLS.HIDE;
|
|
34
38
|
|
|
35
|
-
if (this.state.isShow !== isShow) return this.emit(event, {
|
|
39
|
+
if (this.state.isShow !== isShow) return this.emit(event, { isForce });
|
|
40
|
+
};
|
|
41
|
+
onViewChanged = ({ isForce = false } = {}) => {
|
|
42
|
+
const { view = "" } = this.globalState.interface;
|
|
43
|
+
|
|
44
|
+
if (this.state.view !== view) return this.updateStateAndView({ view }, isForce, !isForce);
|
|
36
45
|
};
|
|
37
|
-
|
|
46
|
+
onVisibleChanged = async ({ isForce = false } = {}) => {
|
|
38
47
|
const { isVisible = false } = this.globalState.interface;
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
this.toggleUnvisibleControls(isVisible);
|
|
50
|
+
|
|
51
|
+
if (this.state.isVisible !== isVisible) return this.updateStateAndView({ isVisible }, isForce, !isForce);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
onStateChanged = () => {
|
|
55
|
+
const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
|
|
56
|
+
|
|
57
|
+
this.toggleUnvisibleControls(isVisible);
|
|
58
|
+
|
|
59
|
+
return this.updateStateAndViewForce({ isVisible, isShow, view });
|
|
60
|
+
};
|
|
41
61
|
|
|
62
|
+
toggleUnvisibleControls = (isVisible) => {
|
|
42
63
|
const args = { key: `${this.name}-unvisible`, controls: this.controlsUnvisible, index: this.controlsIndex + 500 };
|
|
43
|
-
|
|
44
|
-
await this.updateStateAndView({ isVisible }, force, !force);
|
|
64
|
+
return this.emit(isVisible ? this.EVENTS.CONTROLS.POP : this.EVENTS.CONTROLS.PUSH, args);
|
|
45
65
|
};
|
|
46
66
|
|
|
47
|
-
getDefaultState = () => ({ isShow: false, isVisible: false });
|
|
67
|
+
getDefaultState = () => ({ isShow: false, isVisible: false, view: "" });
|
|
48
68
|
}
|
package/modules/view.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
import { render } from "../view";
|
|
3
|
+
import { render, TRANSITION } from "../view";
|
|
4
4
|
|
|
5
|
-
export class InterfaceControlsView extends
|
|
5
|
+
export class InterfaceControlsView extends ModuleView {
|
|
6
6
|
name = "interface.controls.view";
|
|
7
|
-
animationTime =
|
|
7
|
+
animationTime = TRANSITION;
|
|
8
8
|
renderFunc = render;
|
|
9
9
|
updateEvent = this.EVENTS.INTERFACE_CONTROLS.UPDATE;
|
|
10
10
|
updateHandler = this.onUpdateReactComponent;
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.view.coralina.interface.controls",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
+
"publish:major:plugin": "npm run publish:major",
|
|
8
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
9
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
7
10
|
"publish:major": "npm version major && npm publish --access public",
|
|
8
11
|
"publish:minor": "npm version minor && npm publish --access public",
|
|
9
12
|
"publish:patch": "npm version patch && npm publish --access public"
|
|
10
13
|
},
|
|
11
14
|
"author": "",
|
|
12
15
|
"license": "ISC",
|
|
13
|
-
"description": ""
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
"@vnejs/shared": "*",
|
|
16
|
-
"@vnejs/module": "*"
|
|
17
|
-
}
|
|
16
|
+
"description": ""
|
|
18
17
|
}
|
package/view/index.jsx
CHANGED
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Flex, Icon, View } from "@vnejs/uis.base";
|
|
5
5
|
|
|
6
|
-
import "./
|
|
6
|
+
import settingsSrc from "./images/Settings.png";
|
|
7
|
+
import historySrc from "./images/History.png";
|
|
8
|
+
import hideSrc from "./images/Hide.png";
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
export const TRANSITION = 500;
|
|
11
|
+
export const ZINDEX = 1100;
|
|
12
|
+
|
|
13
|
+
const ICON_COMMON_PROPS = { width: 96, height: 96, isOpacityOnHover: true };
|
|
9
14
|
|
|
10
15
|
class InterfaceControls extends React.Component {
|
|
11
|
-
state = {};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
onHistoryClick = (e) => this.emitEvent(e, this.props.EVENTS.INTERFACE.HISTORY);
|
|
18
|
-
onGameMenuClick = (e) => this.emitEvent(e, this.props.EVENTS.INTERFACE.GAMEMENU);
|
|
19
|
-
onHideClick = (e) => this.emitEvent(e, this.props.EVENTS.INTERFACE.VISIBLE);
|
|
16
|
+
state = { isShow: false, isVisible: false, isForce: false, view: "" };
|
|
17
|
+
|
|
18
|
+
onHistoryClick = () => this.props.emit(this.props.EVENTS.INTERFACE.HISTORY);
|
|
19
|
+
onGameMenuClick = () => this.props.emit(this.props.EVENTS.INTERFACE.GAMEMENU);
|
|
20
|
+
onHideClick = () => this.props.emit(this.props.EVENTS.INTERFACE.VISIBLE);
|
|
20
21
|
render() {
|
|
21
|
-
const { isShow = false, isVisible = false, isForce = false } = this.state;
|
|
22
|
+
const { isShow = false, isVisible = false, isForce = false, view = "" } = this.state;
|
|
23
|
+
|
|
24
|
+
const left = view === "adv" ? 600 : 360;
|
|
22
25
|
|
|
23
26
|
return (
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
<View
|
|
28
|
+
isShow={isShow}
|
|
29
|
+
isForce={isForce}
|
|
30
|
+
isHidden={!isVisible}
|
|
31
|
+
transition={TRANSITION}
|
|
32
|
+
zIndex={ZINDEX}
|
|
33
|
+
left={left}
|
|
34
|
+
bottom={24}
|
|
29
35
|
>
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
<Flex gap={36}>
|
|
37
|
+
<Icon
|
|
38
|
+
{...ICON_COMMON_PROPS}
|
|
39
|
+
transition={isForce ? 0 : TRANSITION}
|
|
40
|
+
src={settingsSrc}
|
|
41
|
+
onClick={this.onGameMenuClick}
|
|
42
|
+
/>
|
|
43
|
+
<Icon
|
|
44
|
+
{...ICON_COMMON_PROPS}
|
|
45
|
+
transition={isForce ? 0 : TRANSITION}
|
|
46
|
+
src={historySrc}
|
|
47
|
+
onClick={this.onHistoryClick}
|
|
48
|
+
/>
|
|
49
|
+
<Icon
|
|
50
|
+
{...ICON_COMMON_PROPS}
|
|
51
|
+
transition={isForce ? 0 : TRANSITION}
|
|
52
|
+
src={hideSrc}
|
|
53
|
+
onClick={this.onHideClick}
|
|
54
|
+
/>
|
|
55
|
+
</Flex>
|
|
56
|
+
</View>
|
|
34
57
|
);
|
|
35
58
|
}
|
|
36
59
|
}
|
package/view/index.styl
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
.InterfaceControls
|
|
2
|
-
position: absolute
|
|
3
|
-
right: 15%
|
|
4
|
-
bottom: 1%
|
|
5
|
-
left: 15%
|
|
6
|
-
font-family: "Montserrat"
|
|
7
|
-
pointer-events: none
|
|
8
|
-
opacity: 0
|
|
9
|
-
z-index: 1100
|
|
10
|
-
|
|
11
|
-
display: flex
|
|
12
|
-
align-items: center
|
|
13
|
-
flex-shrink: 0
|
|
14
|
-
gap: calc(50 / 2688 * 100%);
|
|
15
|
-
|
|
16
|
-
&-control
|
|
17
|
-
width: calc(120 / 2688 * 100%)
|
|
18
|
-
aspect-ratio: 12/10
|
|
19
|
-
transition: box-shadow 300ms, background-image 300ms
|
|
20
|
-
cursor: pointer
|
|
21
|
-
background-position: center
|
|
22
|
-
background-repeat: no-repeat
|
|
23
|
-
background-size: contain
|
|
24
|
-
|
|
25
|
-
&_settings
|
|
26
|
-
background-image: url("./images/Settings.png")
|
|
27
|
-
|
|
28
|
-
&:hover
|
|
29
|
-
background-image: url("./images/Settings_H.png")
|
|
30
|
-
|
|
31
|
-
&_history
|
|
32
|
-
background-image: url("./images/History.png")
|
|
33
|
-
|
|
34
|
-
&:hover
|
|
35
|
-
background-image: url("./images/History_H.png")
|
|
36
|
-
|
|
37
|
-
&_hide
|
|
38
|
-
background-image: url("./images/Hide.png")
|
|
39
|
-
|
|
40
|
-
&:hover
|
|
41
|
-
background-image: url("./images/Hide_H.png")
|
|
42
|
-
|
|
43
|
-
&-control ~ &-control
|
|
44
|
-
margin-left: calc(50 / 2688 * 100%)
|
|
45
|
-
|
|
46
|
-
&_isShow
|
|
47
|
-
pointer-events: all
|
|
48
|
-
opacity: 1
|
|
49
|
-
|
|
50
|
-
&:not(&_isVisible)
|
|
51
|
-
opacity: 0
|
|
52
|
-
|
|
53
|
-
&:not(&_isForce)
|
|
54
|
-
transition: opacity 500ms
|