mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 10:22:36 +01:00
Add inventory component
This commit is contained in:
parent
9f200a96a4
commit
e07f1d8db6
@ -1 +1,2 @@
|
|||||||
|
export * from './inventory';
|
||||||
export * from './navigator';
|
export * from './navigator';
|
||||||
|
7
src/events/inventory/InventoryEvent.ts
Normal file
7
src/events/inventory/InventoryEvent.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { NitroEvent } from 'nitro-renderer';
|
||||||
|
|
||||||
|
export class InventoryEvent extends NitroEvent
|
||||||
|
{
|
||||||
|
public static SHOW_INVENTORY: string = 'IE_SHOW_INVENTORY';
|
||||||
|
public static TOGGLE_INVENTORY: string = 'IE_TOGGLE_INVENTORY';
|
||||||
|
}
|
1
src/events/inventory/index.ts
Normal file
1
src/events/inventory/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './InventoryEvent';
|
@ -1,5 +1,6 @@
|
|||||||
@import './avatar-image/AvatarImage';
|
@import './avatar-image/AvatarImage';
|
||||||
@import './hotel-view/HotelView';
|
@import './hotel-view/HotelView';
|
||||||
|
@import './inventory/InventoryView';
|
||||||
@import './loading/LoadingView';
|
@import './loading/LoadingView';
|
||||||
@import './main/MainView';
|
@import './main/MainView';
|
||||||
@import './navigator/NavigatorView';
|
@import './navigator/NavigatorView';
|
||||||
|
10
src/views/inventory/InventoryMessageHandler.tsx
Normal file
10
src/views/inventory/InventoryMessageHandler.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { FC } from 'react';
|
||||||
|
import { InventoryMessageHandlerProps } from './InventoryMessageHandler.types';
|
||||||
|
|
||||||
|
export const InventoryMessageHandler: FC<InventoryMessageHandlerProps> = props =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
4
src/views/inventory/InventoryMessageHandler.types.ts
Normal file
4
src/views/inventory/InventoryMessageHandler.types.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface InventoryMessageHandlerProps
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
3
src/views/inventory/InventoryView.scss
Normal file
3
src/views/inventory/InventoryView.scss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.nitro-inventory {
|
||||||
|
width: 450px;
|
||||||
|
}
|
52
src/views/inventory/InventoryView.tsx
Normal file
52
src/views/inventory/InventoryView.tsx
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { FC, useCallback, useState } from 'react';
|
||||||
|
import { InventoryEvent } from '../../events';
|
||||||
|
import { DraggableWindow } from '../../hooks/draggable-window/DraggableWindow';
|
||||||
|
import { useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||||
|
import { LocalizeText } from '../../utils/LocalizeText';
|
||||||
|
import { InventoryMessageHandler } from './InventoryMessageHandler';
|
||||||
|
import { InventoryViewProps } from './InventoryView.types';
|
||||||
|
|
||||||
|
export const InventoryView: FC<InventoryViewProps> = props =>
|
||||||
|
{
|
||||||
|
const [ isVisible, setIsVisible ] = useState(false);
|
||||||
|
|
||||||
|
const onInventoryEvent = useCallback((event: InventoryEvent) =>
|
||||||
|
{
|
||||||
|
switch(event.type)
|
||||||
|
{
|
||||||
|
case InventoryEvent.SHOW_INVENTORY:
|
||||||
|
setIsVisible(true);
|
||||||
|
return;
|
||||||
|
case InventoryEvent.TOGGLE_INVENTORY:
|
||||||
|
setIsVisible(value => !value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useUiEvent(InventoryEvent.SHOW_INVENTORY, onInventoryEvent);
|
||||||
|
useUiEvent(InventoryEvent.TOGGLE_INVENTORY, onInventoryEvent);
|
||||||
|
|
||||||
|
function hideInventory(): void
|
||||||
|
{
|
||||||
|
setIsVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<InventoryMessageHandler />
|
||||||
|
{ isVisible && <DraggableWindow handle=".drag-handler">
|
||||||
|
<div className="nitro-inventory d-flex flex-column bg-primary border border-black shadow rounded">
|
||||||
|
<div className="drag-handler d-flex justify-content-between align-items-center px-3 pt-3">
|
||||||
|
<div className="h6 m-0">{ LocalizeText('inventory.title') }</div>
|
||||||
|
<button type="button" className="close" onClick={ hideInventory }>
|
||||||
|
<i className="fas fa-times"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex p-3">
|
||||||
|
content
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DraggableWindow> }
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
4
src/views/inventory/InventoryView.types.ts
Normal file
4
src/views/inventory/InventoryView.types.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface InventoryViewProps
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -3,6 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|||||||
import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event';
|
import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event';
|
||||||
import { TransitionAnimation } from '../../transitions/TransitionAnimation';
|
import { TransitionAnimation } from '../../transitions/TransitionAnimation';
|
||||||
import { HotelView } from '../hotel-view/HotelView';
|
import { HotelView } from '../hotel-view/HotelView';
|
||||||
|
import { InventoryView } from '../inventory/InventoryView';
|
||||||
import { NavigatorView } from '../navigator/NavigatorView';
|
import { NavigatorView } from '../navigator/NavigatorView';
|
||||||
import { RightSideView } from '../right-side/RightSideView';
|
import { RightSideView } from '../right-side/RightSideView';
|
||||||
import { RoomHostView } from '../room-host/RoomHostView';
|
import { RoomHostView } from '../room-host/RoomHostView';
|
||||||
@ -45,6 +46,7 @@ export function MainView(props: MainViewProps): JSX.Element
|
|||||||
<ToolbarView isInRoom={ !landingViewVisible } />
|
<ToolbarView isInRoom={ !landingViewVisible } />
|
||||||
</TransitionAnimation>
|
</TransitionAnimation>
|
||||||
<NavigatorView />
|
<NavigatorView />
|
||||||
|
<InventoryView />
|
||||||
<RightSideView />
|
<RightSideView />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { UserInfoEvent } from 'nitro-renderer/src/nitro/communication/messages/incoming/user/data/UserInfoEvent';
|
import { UserInfoEvent } from 'nitro-renderer/src/nitro/communication/messages/incoming/user/data/UserInfoEvent';
|
||||||
import { UserInfoDataParser } from 'nitro-renderer/src/nitro/communication/messages/parser/user/data/UserInfoDataParser';
|
import { UserInfoDataParser } from 'nitro-renderer/src/nitro/communication/messages/parser/user/data/UserInfoDataParser';
|
||||||
import { MouseEvent, useCallback, useState } from 'react';
|
import { MouseEvent, useCallback, useState } from 'react';
|
||||||
import { NavigatorEvent } from '../../events';
|
import { InventoryEvent, NavigatorEvent } from '../../events';
|
||||||
import { dispatchUiEvent } from '../../hooks/events/ui/ui-event';
|
import { dispatchUiEvent } from '../../hooks/events/ui/ui-event';
|
||||||
import { CreateMessageHook } from '../../hooks/messages/message-event';
|
import { CreateMessageHook } from '../../hooks/messages/message-event';
|
||||||
import { AvatarImageView } from '../avatar-image/AvatarImageView';
|
import { AvatarImageView } from '../avatar-image/AvatarImageView';
|
||||||
@ -33,6 +33,9 @@ export function ToolbarView(props: ToolbarViewProps): JSX.Element
|
|||||||
case ToolbarViewItems.NAVIGATOR_ITEM:
|
case ToolbarViewItems.NAVIGATOR_ITEM:
|
||||||
dispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_NAVIGATOR));
|
dispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_NAVIGATOR));
|
||||||
return;
|
return;
|
||||||
|
case ToolbarViewItems.INVENTORY_ITEM:
|
||||||
|
dispatchUiEvent(new InventoryEvent(InventoryEvent.TOGGLE_INVENTORY));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +59,7 @@ export function ToolbarView(props: ToolbarViewProps): JSX.Element
|
|||||||
<li className="list-group-item">
|
<li className="list-group-item">
|
||||||
<i className="icon icon-catalog"></i>
|
<i className="icon icon-catalog"></i>
|
||||||
</li>
|
</li>
|
||||||
<li className="list-group-item">
|
<li className="list-group-item" onClick={ event => handleToolbarItemClick(event, ToolbarViewItems.INVENTORY_ITEM) }>
|
||||||
<i className="icon icon-inventory"></i>
|
<i className="icon icon-inventory"></i>
|
||||||
{ (unseenInventoryCount > 0) && (
|
{ (unseenInventoryCount > 0) && (
|
||||||
<div className="position-absolute bg-danger px-1 py-0 rounded shadow count">{ unseenInventoryCount }</div>) }
|
<div className="position-absolute bg-danger px-1 py-0 rounded shadow count">{ unseenInventoryCount }</div>) }
|
||||||
|
@ -6,4 +6,5 @@ export interface ToolbarViewProps
|
|||||||
export class ToolbarViewItems
|
export class ToolbarViewItems
|
||||||
{
|
{
|
||||||
public static NAVIGATOR_ITEM: string = 'TVI_NAVIGATOR_ITEM';
|
public static NAVIGATOR_ITEM: string = 'TVI_NAVIGATOR_ITEM';
|
||||||
|
public static INVENTORY_ITEM: string = 'TVI_INVENTORY_ITEM';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user