Introduce "useAppTitleAndAction" hook

This commit is contained in:
schroda
2025-05-03 13:37:20 +02:00
parent aacdbaaeef
commit 04768d5210
8 changed files with 55 additions and 40 deletions

View File

@@ -8,6 +8,7 @@
import { OverridableComponent } from '@mui/material/OverridableComponent';
import { SvgIconTypeMap } from '@mui/material/SvgIcon';
import { ReactNode } from 'react';
import { TranslationKey } from '@/Base.types.ts';
import { StaticAppRoute } from '@/modules/core/AppRoute.constants.ts';
@@ -40,8 +41,8 @@ export type NavbarContextType = {
setAppBarHeight: React.Dispatch<React.SetStateAction<number>>;
// AppBar action buttons
action: any;
setAction: React.Dispatch<React.SetStateAction<any>>;
action: ReactNode;
setAction: React.Dispatch<React.SetStateAction<ReactNode>>;
// Allow default navbar to be overrided
override: INavbarOverride;

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { NavbarContextType } from '@/modules/navigation-bar/NavigationBar.types.ts';
import { useAppTitle } from '@/modules/navigation-bar/hooks/useAppTitle.ts';
import { useAppAction } from '@/modules/navigation-bar/hooks/useAppAction.ts';
export const useAppTitleAndAction = (
title: NavbarContextType['title'],
action: NavbarContextType['action'],
actionDependencies?: any[],
) => {
useAppTitle(title);
useAppAction(action, actionDependencies);
};