@vnejs/plugins.view.coralina.settings.defaults 0.1.3 → 0.1.5

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.
@@ -1,12 +1,5 @@
1
1
  import { ModuleController } from "@vnejs/module.components";
2
2
 
3
- const mapField = (field) => ({ ...field, isNotRender: typeof field.isNotShowFunc === "function" ? field.isNotShowFunc() : false });
4
- const mapTabInfo = ({ ...tabInfo }) => {
5
- if (tabInfo.options) tabInfo.options = [...tabInfo.options.map(mapField)];
6
-
7
- return tabInfo;
8
- };
9
-
10
3
  export class SettingsDefaultsController extends ModuleController {
11
4
  name = "settings.defaults.controller";
12
5
 
@@ -15,14 +8,19 @@ export class SettingsDefaultsController extends ModuleController {
15
8
 
16
9
  subscribe = () => {
17
10
  this.on(this.EVENTS.SETTINGS_DEFAULTS.SHOW, this.onShow);
11
+ this.on(this.EVENTS.SETTINGS_DEFAULTS.HIDE, this.onHide);
18
12
 
19
13
  this.on(this.EVENTS.LOCS.LANG_CHANGED, this.onSettingChange);
20
14
  this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
15
+
16
+ this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
21
17
  };
22
18
 
23
- beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src, tab: mapTabInfo(this.PARAMS.SETTINGS_VIEW.TABS.DEFAULT), currentTab: 0 });
19
+ beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src, tab: this.PARAMS.SETTINGS_VIEW.TABS.DEFAULT, currentTab: 0 });
24
20
 
25
21
  emitFunc = (func) => func({ SETTINGS: this.SETTINGS, CONST: this.CONST, platform: window.VneCore.getPlatform() });
26
22
 
27
23
  onSettingChange = () => this.state.isShow && this.updateViewFast();
24
+
25
+ onMemoryCleared = async () => this.updateStateAndViewFast({ bgSrc: (await this.loadBgMedia()).src });
28
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.view.coralina.settings.defaults",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/view/index.jsx CHANGED
@@ -9,41 +9,37 @@ const SettingsDefaults = ({ store, onMount, ...props } = {}) => {
9
9
  useEffect(() => store.subscribe(setState), []);
10
10
  useEffect(() => void onMount(), []);
11
11
 
12
+ console.log(11111, props);
13
+
12
14
  const mapFields = useCallback(
13
- ({ locKey = "", type = "", settingKey = "", options = [], titleToggledLocKey = "", titleUntoggledLocKey = "", ...fieldProps } = {}) => {
15
+ ({ locKey = "", type = "", settingKey = "", options = [], titleToggledLocKey = "", titleUntoggledLocKey = "", valueMap = "", ...props2 } = {}) => {
14
16
  const onChange = (value) => props.emit(props.EVENTS.SETTINGS.SET, { name: settingKey, value });
15
17
 
16
18
  const titles = { title: locs[locKey], titleToggled: locs[titleToggledLocKey], titleUntoggled: locs[titleUntoggledLocKey] };
17
19
 
18
- return { ...titles, value: props.shared.settings[settingKey], type, onChange, props: fieldProps, options };
20
+ const valueMapReal = valueMap ? props.PARAMS.SETTINGS_VIEW.VALUE_MAPS[valueMap] : null;
21
+
22
+ return { ...titles, value: props.shared.settings[settingKey], type, onChange, props: props2, options, valueMap: valueMapReal };
19
23
  },
20
24
  [locs],
21
25
  );
22
26
  const onAccept = useCallback(() => props.emit(props.EVENTS.SETTINGS_DEFAULTS.CONFIRM), []);
23
27
 
24
- const settings = useMemo(() => (tab.fields ? tab.fields.map(mapFields) : []), [tab, mapFields]);
28
+ const settings = tab.fields ? tab.fields.map(mapFields) : [];
25
29
 
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
- );
30
+ const propsByView = props.PARAMS.SETTINGS_DEFAULTS_VIEW.VIEW_PROPS;
31
+
32
+ const propsScreen = useMemo(() => ({ ...propsByView.screen, isShow, bgSrc }), [isShow, bgSrc]);
33
+ const propsTitle = useMemo(() => ({ ...propsByView.title, text: locs[tab.titleLocKey] }), [locs, tab]);
34
+ const propsSettings = useMemo(() => ({ ...propsByView.settings, settings, selectedIndex: 0, selectedIndexInner: 0 }), [settings]);
35
+ const propsAccept = useMemo(() => ({ ...propsByView.accept, text: locs[tab.acceptLocKey], onClick: onAccept }), [locs, tab]);
32
36
 
33
37
  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}>
38
+ <Screen {...propsScreen}>
39
+ <PositionBox {...propsByView.position}>
40
+ <Flex {...propsByView.flex}>
41
41
  <Text {...propsTitle} />
42
- <Settings
43
- {...propsSettings}
44
- selectedIndex={0}
45
- selectedIndexInner={0}
46
- />
42
+ <Settings {...propsSettings} />
47
43
  <Text {...propsAccept} />
48
44
  </Flex>
49
45
  </PositionBox>