@vnejs/plugins.view.coralina.settings.defaults 0.1.0 → 0.1.2
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/const/params.js +16 -0
- package/index.js +3 -1
- package/modules/controller.js +2 -7
- package/modules/view.js +3 -3
- package/package.json +1 -1
- package/view/index.jsx +51 -71
package/const/params.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const BACKGROUND = "Menu/save";
|
|
2
|
+
|
|
3
|
+
export const TRANSITION = 500;
|
|
4
|
+
export const ZINDEX = 4000;
|
|
5
|
+
export const LOC_LABEL = "settings";
|
|
6
|
+
|
|
7
|
+
const TEXT_PROPS = { align: "center", width: 3120 };
|
|
8
|
+
|
|
9
|
+
export const VIEW_PROPS = {
|
|
10
|
+
screen: { withBackgroundDark: true, withBackgroundBlur: false, transition: TRANSITION, zIndex: ZINDEX },
|
|
11
|
+
position: { isCentered: true },
|
|
12
|
+
flex: { direction: "column", gap: 120 },
|
|
13
|
+
title: TEXT_PROPS,
|
|
14
|
+
settings: { transition: TRANSITION },
|
|
15
|
+
accept: TEXT_PROPS,
|
|
16
|
+
};
|
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { regPlugin } from "@vnejs/shared";
|
|
2
2
|
|
|
3
|
+
import * as params from "./const/params";
|
|
4
|
+
|
|
3
5
|
import { SettingsDefaultsController } from "./modules/controller";
|
|
4
6
|
import { SettingsDefaultsView } from "./modules/view";
|
|
5
7
|
|
|
6
|
-
regPlugin("SETTINGS_DEFAULTS_VIEW", {}, [SettingsDefaultsController, SettingsDefaultsView]);
|
|
8
|
+
regPlugin("SETTINGS_DEFAULTS_VIEW", { params }, [SettingsDefaultsController, SettingsDefaultsView]);
|
package/modules/controller.js
CHANGED
|
@@ -10,8 +10,7 @@ const mapTabInfo = ({ ...tabInfo }) => {
|
|
|
10
10
|
export class SettingsDefaultsController extends ModuleController {
|
|
11
11
|
name = "settings.defaults.controller";
|
|
12
12
|
|
|
13
|
-
bgName =
|
|
14
|
-
|
|
13
|
+
bgName = this.PARAMS.SETTINGS_DEFAULTS_VIEW.BACKGROUND;
|
|
15
14
|
updateEvent = this.EVENTS.SETTINGS_DEFAULTS.UPDATE;
|
|
16
15
|
|
|
17
16
|
subscribe = () => {
|
|
@@ -21,11 +20,7 @@ export class SettingsDefaultsController extends ModuleController {
|
|
|
21
20
|
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
this.tab = mapTabInfo(this.PARAMS.SETTINGS_VIEW.TABS.DEFAULT);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src, tab: this.tab, currentTab: 0 });
|
|
23
|
+
beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src, tab: mapTabInfo(this.PARAMS.SETTINGS_VIEW.TABS.DEFAULT), currentTab: 0 });
|
|
29
24
|
|
|
30
25
|
emitFunc = (func) => func({ SETTINGS: this.SETTINGS, CONST: this.CONST, platform: window.VneCore.getPlatform() });
|
|
31
26
|
|
package/modules/view.js
CHANGED
|
@@ -5,10 +5,10 @@ import { render } from "../view";
|
|
|
5
5
|
export class SettingsDefaultsView extends ModuleView {
|
|
6
6
|
name = "settings.defaults.view";
|
|
7
7
|
|
|
8
|
-
locLabel =
|
|
9
|
-
animationTime =
|
|
8
|
+
locLabel = this.PARAMS.SETTINGS_DEFAULTS_VIEW.LOC_LABEL;
|
|
9
|
+
animationTime = this.PARAMS.SETTINGS_DEFAULTS_VIEW.TRANSITION;
|
|
10
10
|
updateEvent = this.EVENTS.SETTINGS_DEFAULTS.UPDATE;
|
|
11
11
|
|
|
12
12
|
renderFunc = render;
|
|
13
|
-
updateHandler = this.
|
|
13
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
14
14
|
}
|
package/package.json
CHANGED
package/view/index.jsx
CHANGED
|
@@ -1,74 +1,54 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
3
|
|
|
4
4
|
import { Flex, Text, Screen, Settings, PositionBox } from "@vnejs/uis.base";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
selectedIndex={0}
|
|
56
|
-
selectedIndexInner={0}
|
|
57
|
-
transition={TRANSITION}
|
|
58
|
-
settings={tab.fields.map(this.mapFields)}
|
|
59
|
-
/>
|
|
60
|
-
|
|
61
|
-
<Text
|
|
62
|
-
align={Text.ALIGNS.CENTER}
|
|
63
|
-
width={3120}
|
|
64
|
-
text={locs[tab.acceptLocKey]}
|
|
65
|
-
onClick={this.onClickConfirm}
|
|
66
|
-
/>
|
|
67
|
-
</Flex>
|
|
68
|
-
</PositionBox>
|
|
69
|
-
</Screen>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export const render = (props, root, resolve) => ReactDOM.render(<SettingsDefaults {...props} />, root, resolve);
|
|
6
|
+
const SettingsDefaults = ({ store, onMount, ...props } = {}) => {
|
|
7
|
+
const [{ isShow = false, locs = {}, tab = {}, bgSrc = "" }, setState] = useState({});
|
|
8
|
+
|
|
9
|
+
useEffect(() => store.subscribe(setState), []);
|
|
10
|
+
useEffect(() => void onMount(), []);
|
|
11
|
+
|
|
12
|
+
const mapFields = useCallback(
|
|
13
|
+
({ locKey = "", type = "", settingKey = "", options = [], titleToggledLocKey = "", titleUntoggledLocKey = "", ...fieldProps } = {}) => {
|
|
14
|
+
const onChange = (value) => props.emit(props.EVENTS.SETTINGS.SET, { name: settingKey, value });
|
|
15
|
+
|
|
16
|
+
const titles = { title: locs[locKey], titleToggled: locs[titleToggledLocKey], titleUntoggled: locs[titleUntoggledLocKey] };
|
|
17
|
+
|
|
18
|
+
return { ...titles, value: props.shared.settings[settingKey], type, onChange, props: fieldProps, options };
|
|
19
|
+
},
|
|
20
|
+
[locs],
|
|
21
|
+
);
|
|
22
|
+
const onAccept = useCallback(() => props.emit(props.EVENTS.SETTINGS_DEFAULTS.CONFIRM), []);
|
|
23
|
+
|
|
24
|
+
const settings = useMemo(() => (tab.fields ? tab.fields.map(mapFields) : []), [tab, mapFields]);
|
|
25
|
+
|
|
26
|
+
const propsTitle = useMemo(() => ({ ...props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS.title, text: locs[tab.titleLocKey] }), [locs, tab]);
|
|
27
|
+
const propsSettings = useMemo(() => ({ ...props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS.settings, settings }), [settings]);
|
|
28
|
+
const propsAccept = useMemo(
|
|
29
|
+
() => ({ ...props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS.accept, text: locs[tab.acceptLocKey], onClick: onAccept }),
|
|
30
|
+
[locs, tab],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Screen
|
|
35
|
+
{...props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS.screen}
|
|
36
|
+
isShow={isShow}
|
|
37
|
+
bgSrc={bgSrc}
|
|
38
|
+
>
|
|
39
|
+
<PositionBox {...props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS.position}>
|
|
40
|
+
<Flex {...props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS.flex}>
|
|
41
|
+
<Text {...propsTitle} />
|
|
42
|
+
<Settings
|
|
43
|
+
{...propsSettings}
|
|
44
|
+
selectedIndex={0}
|
|
45
|
+
selectedIndexInner={0}
|
|
46
|
+
/>
|
|
47
|
+
<Text {...propsAccept} />
|
|
48
|
+
</Flex>
|
|
49
|
+
</PositionBox>
|
|
50
|
+
</Screen>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const render = (props, root) => createRoot(root).render(<SettingsDefaults {...props} />);
|