diff --git a/src/events/avatar-editor/AvatarEditorEvent.ts b/src/events/avatar-editor/AvatarEditorEvent.ts new file mode 100644 index 00000000..cd123b52 --- /dev/null +++ b/src/events/avatar-editor/AvatarEditorEvent.ts @@ -0,0 +1,8 @@ +import { NitroEvent } from 'nitro-renderer'; + +export class AvatarEditorEvent extends NitroEvent +{ + public static SHOW_EDITOR: string = 'AEE_SHOW_EDITOR'; + public static HIDE_EDITOR: string = 'AEE_HIDE_EDITOR'; + public static TOGGLE_EDITOR: string = 'AEE_TOGGLE_EDITOR'; +} diff --git a/src/events/avatar-editor/index.ts b/src/events/avatar-editor/index.ts new file mode 100644 index 00000000..79313d2b --- /dev/null +++ b/src/events/avatar-editor/index.ts @@ -0,0 +1 @@ +export * from './AvatarEditorEvent'; diff --git a/src/events/index.ts b/src/events/index.ts index 9f56656b..81a2cdd4 100644 --- a/src/events/index.ts +++ b/src/events/index.ts @@ -1,3 +1,4 @@ +export * from './avatar-editor'; export * from './catalog'; export * from './friend-list'; export * from './inventory'; diff --git a/src/views/Styles.scss b/src/views/Styles.scss index 54cbbd9a..6d270b8f 100644 --- a/src/views/Styles.scss +++ b/src/views/Styles.scss @@ -1,3 +1,4 @@ +@import './avatar-editor/AvatarEditorView'; @import './avatar-image/AvatarImage'; @import './badge-image/BadgeImage'; @import './catalog/CatalogView'; diff --git a/src/views/avatar-editor/AvatarEditorView.scss b/src/views/avatar-editor/AvatarEditorView.scss new file mode 100644 index 00000000..ecc8cf0c --- /dev/null +++ b/src/views/avatar-editor/AvatarEditorView.scss @@ -0,0 +1,8 @@ +.nitro-avatar-editor { + width: 550px; + + .content-area { + height: 300px; + max-height: 300px; + } +} diff --git a/src/views/avatar-editor/AvatarEditorView.tsx b/src/views/avatar-editor/AvatarEditorView.tsx new file mode 100644 index 00000000..fff21b3d --- /dev/null +++ b/src/views/avatar-editor/AvatarEditorView.tsx @@ -0,0 +1,59 @@ +import { FC, useCallback, useEffect, useReducer, useState } from 'react'; +import { AvatarEditorEvent } from '../../events/avatar-editor'; +import { useUiEvent } from '../../hooks/events/ui/ui-event'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsView, NitroCardView } from '../../layout'; +import { LocalizeText } from '../../utils/LocalizeText'; +import { AvatarEditorViewProps } from './AvatarEditorView.types'; +import { AvatarEditorContextProvider } from './context/AvatarEditorContext'; +import { AvatarEditorReducer, initialAvatarEditor } from './reducers/AvatarEditorReducer'; + +export const AvatarEditorView: FC = props => +{ + const [ isVisible, setIsVisible ] = useState(false); + const [ avatarEditorState, dispatchAvatarEditorState ] = useReducer(AvatarEditorReducer, initialAvatarEditor); + const { } = avatarEditorState; + + const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) => + { + switch(event.type) + { + case AvatarEditorEvent.SHOW_EDITOR: + setIsVisible(true); + return; + case AvatarEditorEvent.HIDE_EDITOR: + setIsVisible(false); + return; + case AvatarEditorEvent.TOGGLE_EDITOR: + setIsVisible(value => !value); + return; + } + }, []); + + useUiEvent(AvatarEditorEvent.SHOW_EDITOR, onAvatarEditorEvent); + useUiEvent(AvatarEditorEvent.HIDE_EDITOR, onAvatarEditorEvent); + useUiEvent(AvatarEditorEvent.TOGGLE_EDITOR, onAvatarEditorEvent); + + useEffect(() => + { + if(!isVisible) return; + }, [ isVisible ]); + + return ( + + { isVisible && + + setIsVisible(false) } /> + + + +
+
+
+
+
+
+
+
} +
+ ); +} diff --git a/src/views/avatar-editor/AvatarEditorView.types.ts b/src/views/avatar-editor/AvatarEditorView.types.ts new file mode 100644 index 00000000..faab915a --- /dev/null +++ b/src/views/avatar-editor/AvatarEditorView.types.ts @@ -0,0 +1,4 @@ +export interface AvatarEditorViewProps +{ + +} diff --git a/src/views/avatar-editor/context/AvatarEditorContext.tsx b/src/views/avatar-editor/context/AvatarEditorContext.tsx new file mode 100644 index 00000000..95087f57 --- /dev/null +++ b/src/views/avatar-editor/context/AvatarEditorContext.tsx @@ -0,0 +1,14 @@ +import { createContext, FC, useContext } from 'react'; +import { AvatarEditorContextProps, IAvatarEditorContext } from './AvatarEditorContext.types'; + +const AvatarEditorContext = createContext({ + avatarEditorState: null, + dispatchAvatarEditorState: null +}); + +export const AvatarEditorContextProvider: FC = props => +{ + return { props.children } +} + +export const useAvatarEditorContext = () => useContext(AvatarEditorContext); diff --git a/src/views/avatar-editor/context/AvatarEditorContext.types.ts b/src/views/avatar-editor/context/AvatarEditorContext.types.ts new file mode 100644 index 00000000..0df02ff4 --- /dev/null +++ b/src/views/avatar-editor/context/AvatarEditorContext.types.ts @@ -0,0 +1,13 @@ +import { Dispatch, ProviderProps } from 'react'; +import { IAvatarEditorAction, IAvatarEditorState } from '../reducers/AvatarEditorReducer'; + +export interface IAvatarEditorContext +{ + avatarEditorState: IAvatarEditorState; + dispatchAvatarEditorState: Dispatch; +} + +export interface AvatarEditorContextProps extends ProviderProps +{ + +} diff --git a/src/views/avatar-editor/reducers/AvatarEditorReducer.tsx b/src/views/avatar-editor/reducers/AvatarEditorReducer.tsx new file mode 100644 index 00000000..3fe6ee7f --- /dev/null +++ b/src/views/avatar-editor/reducers/AvatarEditorReducer.tsx @@ -0,0 +1,30 @@ +import { Reducer } from 'react'; + +export interface IAvatarEditorState +{ + +} + +export interface IAvatarEditorAction +{ + type: string; + payload: { + } +} + +export class AvatarEditorActions +{ + +} + +export const initialAvatarEditor: IAvatarEditorState = { +} + +export const AvatarEditorReducer: Reducer = (state, action) => +{ + switch(action.type) + { + default: + return state; + } +} diff --git a/src/views/main/MainView.tsx b/src/views/main/MainView.tsx index 416e72c0..a9e603cb 100644 --- a/src/views/main/MainView.tsx +++ b/src/views/main/MainView.tsx @@ -3,6 +3,7 @@ import { useCallback, useEffect, useState } from 'react'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; import { TransitionAnimation } from '../../transitions/TransitionAnimation'; import { TransitionAnimationTypes } from '../../transitions/TransitionAnimation.types'; +import { AvatarEditorView } from '../avatar-editor/AvatarEditorView'; import { CatalogView } from '../catalog/CatalogView'; import { FriendListView } from '../friend-list/FriendListView'; import { HotelView } from '../hotel-view/HotelView'; @@ -48,6 +49,7 @@ export function MainView(props: MainViewProps): JSX.Element + diff --git a/src/views/toolbar/ToolbarView.tsx b/src/views/toolbar/ToolbarView.tsx index 492fb207..49e85ce4 100644 --- a/src/views/toolbar/ToolbarView.tsx +++ b/src/views/toolbar/ToolbarView.tsx @@ -1,7 +1,7 @@ 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 { MouseEvent, useCallback, useState } from 'react'; -import { CatalogEvent, FriendListEvent, InventoryEvent, NavigatorEvent } from '../../events'; +import { useCallback, useState } from 'react'; +import { AvatarEditorEvent, CatalogEvent, FriendListEvent, InventoryEvent, NavigatorEvent } from '../../events'; import { dispatchUiEvent } from '../../hooks/events/ui/ui-event'; import { CreateMessageHook } from '../../hooks/messages/message-event'; import { TransitionAnimation } from '../../transitions/TransitionAnimation'; @@ -28,7 +28,7 @@ export function ToolbarView(props: ToolbarViewProps): JSX.Element setUserInfo(parser.userInfo); }, []); - function handleToolbarItemClick(event: MouseEvent, item: string): void + const handleToolbarItemClick = useCallback((item: string) => { switch(item) { @@ -44,8 +44,11 @@ export function ToolbarView(props: ToolbarViewProps): JSX.Element case ToolbarViewItems.FRIEND_LIST_ITEM: dispatchUiEvent(new CatalogEvent(FriendListEvent.TOGGLE_FRIEND_LIST)); return; + case ToolbarViewItems.CLOTHING_ITEM: + dispatchUiEvent(new AvatarEditorEvent(AvatarEditorEvent.TOGGLE_EDITOR)); + return; } - } + }, []); function toggleMeToolbar(): void { @@ -60,7 +63,7 @@ export function ToolbarView(props: ToolbarViewProps): JSX.Element return ( <> - +
@@ -81,18 +84,18 @@ export function ToolbarView(props: ToolbarViewProps): JSX.Element
) } -
handleToolbarItemClick(event, ToolbarViewItems.NAVIGATOR_ITEM) }> +
handleToolbarItemClick(ToolbarViewItems.NAVIGATOR_ITEM) }>
-
handleToolbarItemClick(event, ToolbarViewItems.CATALOG_ITEM) }> +
handleToolbarItemClick(ToolbarViewItems.CATALOG_ITEM) }>
-
handleToolbarItemClick(event, ToolbarViewItems.INVENTORY_ITEM) }> +
handleToolbarItemClick(ToolbarViewItems.INVENTORY_ITEM) }> { (unseenInventoryCount > 0) && (
{ unseenInventoryCount }
) }
-
handleToolbarItemClick(event, ToolbarViewItems.FRIEND_LIST_ITEM) }> +
handleToolbarItemClick(ToolbarViewItems.FRIEND_LIST_ITEM) }> { (unseenFriendListCount > 0) && (
{ unseenFriendListCount }
) } diff --git a/src/views/toolbar/ToolbarView.types.ts b/src/views/toolbar/ToolbarView.types.ts index 4670449e..b0b97068 100644 --- a/src/views/toolbar/ToolbarView.types.ts +++ b/src/views/toolbar/ToolbarView.types.ts @@ -9,4 +9,5 @@ export class ToolbarViewItems public static INVENTORY_ITEM: string = 'TVI_INVENTORY_ITEM'; public static CATALOG_ITEM: string = 'TVI_CATALOG_ITEM'; public static FRIEND_LIST_ITEM: string = 'TVI_FRIEND_LIST_ITEM'; + public static CLOTHING_ITEM: string = 'TVI_CLOTHING_ITEM'; } diff --git a/src/views/toolbar/me/ToolbarMeView.tsx b/src/views/toolbar/me/ToolbarMeView.tsx index 7ce487a6..48564dfd 100644 --- a/src/views/toolbar/me/ToolbarMeView.tsx +++ b/src/views/toolbar/me/ToolbarMeView.tsx @@ -1,10 +1,11 @@ import { MouseEventType } from 'nitro-renderer'; import { useEffect, useRef } from 'react'; +import { ToolbarViewItems } from '../ToolbarView.types'; import { ToolbarMeViewProps } from './ToolbarMeView.types'; export function ToolbarMeView(props: ToolbarMeViewProps): JSX.Element { - const { setMeExpanded = null } = props; + const { setMeExpanded = null, handleToolbarItemClick = null } = props; const elementRef = useRef(); @@ -46,7 +47,7 @@ export function ToolbarMeView(props: ToolbarMeViewProps): JSX.Element
-
+
handleToolbarItemClick(ToolbarViewItems.CLOTHING_ITEM) }>
diff --git a/src/views/toolbar/me/ToolbarMeView.types.ts b/src/views/toolbar/me/ToolbarMeView.types.ts index 6a3a9076..ecc0b113 100644 --- a/src/views/toolbar/me/ToolbarMeView.types.ts +++ b/src/views/toolbar/me/ToolbarMeView.types.ts @@ -3,4 +3,5 @@ import { Dispatch, SetStateAction } from 'react'; export interface ToolbarMeViewProps { setMeExpanded: Dispatch>; + handleToolbarItemClick: (item: string) => void; }