From 4cf80595ad61107a4edb2041e63983329f23ccb7 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sun, 28 Jul 2024 18:19:55 -0400 Subject: feat(toaster):add support for dismissing toasts and new indicator --- frontend/src/components/Toast.tsx | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'frontend/src/components/Toast.tsx') diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx index e40d1d22..e86e9337 100644 --- a/frontend/src/components/Toast.tsx +++ b/frontend/src/components/Toast.tsx @@ -3,7 +3,6 @@ import { Focusable, Navigation, findClassModule, joinClassNames } from '@decky/u import { FC, memo } from 'react'; import Logger from '../logger'; -import TranslationHelper, { TranslationClass } from '../utils/TranslationHelper'; const logger = new Logger('ToastRenderer'); @@ -17,6 +16,7 @@ export enum ToastLocation { interface ToastProps { toast: ToastData; + newIndicator?: boolean; } interface ToastRendererProps extends ToastProps { @@ -27,7 +27,7 @@ const templateClasses = findClassModule((m) => m.ShortTemplate) || {}; // These are memoized as they like to randomly rerender -const GamepadUIPopupToast: FC = memo(({ toast }) => { +const GamepadUIPopupToast: FC> = memo(({ toast }) => { return (
= memo(({ toast }) => { ); }); -const GamepadUIQAMToast: FC = memo(({ toast }) => { +const GamepadUIQAMToast: FC = memo(({ toast, newIndicator }) => { // The fields aren't mismatched, the logic for these is just a bit weird. return ( { - Navigation.CloseSideMenus(); toast.onClick?.(); + Navigation.CloseSideMenus(); }} className={joinClassNames( templateClasses.StandardTemplateContainer, @@ -65,11 +65,7 @@ const GamepadUIQAMToast: FC = memo(({ toast }) => {
{toast.icon &&
{toast.icon}
} -
- {toast.header || ( - - )} -
+ {toast.title &&
{toast.title}
} {/* timestamp should always be defined by toaster */} {/* TODO check how valve does this */} {toast.timestamp && ( @@ -78,29 +74,30 @@ const GamepadUIQAMToast: FC = memo(({ toast }) => {
)}
-
- {toast.fullTemplateTitle || toast.title} -
-
{toast.body}
+ {toast.body &&
{toast.body}
} + {toast.subtext &&
{toast.subtext}
}
- {/* TODO support NewIndicator */} - {/*
- -
*/} + {newIndicator && ( +
+ + + +
+ )} ); }); -export const ToastRenderer: FC = memo(({ toast, location }) => { +export const ToastRenderer: FC = memo(({ toast, location, newIndicator }) => { switch (location) { default: - logger.warn(`Toast UI not implemented for location ${location}! Falling back to GamepadUIPopupToast.`); + logger.warn(`Toast UI not implemented for location ${location}! Falling back to GamepadUIQAMToast.`); + return ; case ToastLocation.GAMEPADUI_POPUP: return ; case ToastLocation.GAMEPADUI_QAM: - return ; + return ; } }); -- cgit v1.2.3