Introduce "useAppTitleAndAction" hook
This commit is contained in:
@@ -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;
|
||||
|
||||
20
src/modules/navigation-bar/hooks/useAppTitleAndAction.ts
Normal file
20
src/modules/navigation-bar/hooks/useAppTitleAndAction.ts
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user