@vnejs/plugins.views.screens.gallery.full 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.
@@ -0,0 +1,5 @@
1
+ export const SUBSCRIBE_EVENTS = {
2
+ SHOW: "vne:gallery_full:show",
3
+ HIDE: "vne:gallery_full:hide",
4
+ UPDATE: "vne:gallery_full:update",
5
+ };
@@ -0,0 +1,7 @@
1
+ export const TRANSITION = 500;
2
+ export const ZINDEX = 9000;
3
+
4
+ export const VIEW_PROPS = {
5
+ screen: { isIgnoreOnScreenshot: true, zIndex: ZINDEX, transition: TRANSITION },
6
+ close: { position: { right: 120, top: 90 }, props: { size: 60 } },
7
+ };
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { regPlugin } from "@vnejs/shared";
2
+
3
+ import { SUBSCRIBE_EVENTS } from "./const/events";
4
+ import * as params from "./const/params";
5
+
6
+ import { GalleryFullController } from "./modules/controller";
7
+ import { GalleryFullView } from "./modules/view";
8
+
9
+ regPlugin("GALLERY_FULL_VIEW", { events: SUBSCRIBE_EVENTS, params }, [GalleryFullController, GalleryFullView]);
@@ -0,0 +1,32 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+
3
+ export class GalleryFullController extends ModuleController {
4
+ name = "gallery.full.controller";
5
+
6
+ updateEvent = this.EVENTS.GALLERY_FULL_VIEW.UPDATE;
7
+
8
+ emitHide = () => this.emit(this.EVENTS.GALLERY_FULL_VIEW.HIDE);
9
+
10
+ controls = {
11
+ [this.CONST.CONTROLS.BUTTONS.BACK]: this.emitHide,
12
+ [this.CONST.CONTROLS.BUTTONS.MENU]: this.emitHide,
13
+ [this.CONST.CONTROLS.BUTTONS.GAMEMENU]: this.emitHide,
14
+ };
15
+ controlsIndex = this.PARAMS.GALLERY_FULL_VIEW.ZINDEX;
16
+
17
+ subscribe = () => {
18
+ this.on(this.EVENTS.GALLERY_FULL_VIEW.SHOW, this.onShow);
19
+ this.on(this.EVENTS.GALLERY_FULL_VIEW.HIDE, this.onHide);
20
+
21
+ this.on(this.EVENTS.GALLERY.CHOOSE, this.onGalleryViewChoose);
22
+ };
23
+
24
+ beforeShow = async ({ index } = {}) => {
25
+ const { fullName, mediaType } = this.globalState?.["gallery.controller"].currentItems[index];
26
+
27
+ return this.updateState({ bgSrc: (await this.loadImageMedia(fullName, mediaType, this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src });
28
+ };
29
+ afterHide = () => this.setDefaultState();
30
+
31
+ onGalleryViewChoose = ({ index } = {}) => this.emit(this.EVENTS.GALLERY_FULL_VIEW.SHOW, { index });
32
+ }
@@ -0,0 +1,13 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+
3
+ import { render } from "../view";
4
+
5
+ export class GalleryFullView extends ModuleView {
6
+ name = "gallery.full.view";
7
+
8
+ animationTime = this.PARAMS.GALLERY_FULL_VIEW.TRANSITION;
9
+ updateEvent = this.EVENTS.GALLERY_FULL_VIEW.UPDATE;
10
+
11
+ renderFunc = render;
12
+ updateHandler = this.onUpdateStoreComponent;
13
+ }
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@vnejs/plugins.views.screens.gallery.full",
3
+ "version": "0.1.2",
4
+ "main": "index.js",
5
+ "scripts": {
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",
10
+ "publish:major": "npm version major && npm publish --access public",
11
+ "publish:minor": "npm version minor && npm publish --access public",
12
+ "publish:patch": "npm version patch && npm publish --access public"
13
+ },
14
+ "author": "",
15
+ "license": "ISC",
16
+ "description": ""
17
+ }
package/view/index.jsx ADDED
@@ -0,0 +1,26 @@
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+
4
+ import { PositionBox, Screen, Svg } from "@vnejs/uis.react";
5
+
6
+ const GalleryFull = ({ store, onMount, ...props } = {}) => {
7
+ const [{ isShow = false, isForce = false, bgSrc = "" }, setState] = useState({});
8
+
9
+ useEffect(() => store.subscribe(setState), []);
10
+ useEffect(() => void onMount(), []);
11
+
12
+ const propsView = props.PARAMS.GALLERY_FULL_VIEW.VIEW_PROPS;
13
+
14
+ const propsScreen = useMemo(() => ({ ...propsView.screen, isShow, isForce, isDisableAutoread: isShow, bgSrc }), [isShow, isForce, bgSrc]);
15
+ const propsClose = useMemo(() => ({ ...propsView.close.props, onClick: () => props.emit(props.EVENTS.GALLERY_FULL_VIEW.HIDE) }), []);
16
+
17
+ return (
18
+ <Screen {...propsScreen}>
19
+ <PositionBox {...propsView.close.position}>
20
+ <Svg.Cross {...propsClose} />
21
+ </PositionBox>
22
+ </Screen>
23
+ );
24
+ };
25
+
26
+ export const render = (props, root) => createRoot(root).render(<GalleryFull {...props} />);