2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-01-26 23:32:12 +03:30
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2021-01-26 23:32:12 +03:30
|
|
|
|
2024-06-14 13:43:15 +02:00
|
|
|
import React, { useContext } from 'react';
|
2023-06-05 01:42:39 +02:00
|
|
|
import { INavbarOverride } from '@/typings';
|
2021-01-22 17:00:33 +03:30
|
|
|
|
|
|
|
|
type ContextType = {
|
2024-06-14 13:32:54 +02:00
|
|
|
history: string[];
|
|
|
|
|
|
2021-10-30 16:10:34 +03:30
|
|
|
// AppBar title
|
2023-04-22 11:39:59 +02:00
|
|
|
title: string | React.ReactNode;
|
|
|
|
|
setTitle: (title: ContextType['title'], browserTitle?: string) => void;
|
2021-10-30 16:10:34 +03:30
|
|
|
|
|
|
|
|
// AppBar action buttons
|
2023-02-06 10:06:33 +01:00
|
|
|
action: any;
|
|
|
|
|
setAction: React.Dispatch<React.SetStateAction<any>>;
|
2021-10-30 16:10:34 +03:30
|
|
|
|
|
|
|
|
// Allow default navbar to be overrided
|
2023-02-06 10:06:33 +01:00
|
|
|
override: INavbarOverride;
|
|
|
|
|
setOverride: React.Dispatch<React.SetStateAction<INavbarOverride>>;
|
2021-01-22 17:00:33 +03:30
|
|
|
};
|
|
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export const NavBarContext = React.createContext<ContextType>({
|
2024-06-14 13:32:54 +02:00
|
|
|
history: [],
|
2024-01-05 20:11:29 +01:00
|
|
|
title: 'Suwayomi',
|
2023-02-06 10:06:33 +01:00
|
|
|
setTitle: (): void => {},
|
2021-03-08 21:04:42 +03:30
|
|
|
action: <div />,
|
2023-02-06 10:06:33 +01:00
|
|
|
setAction: (): void => {},
|
2021-03-18 21:46:24 +03:30
|
|
|
override: { status: false, value: <div /> },
|
2023-02-06 10:06:33 +01:00
|
|
|
setOverride: (): void => {},
|
2021-01-22 17:00:33 +03:30
|
|
|
});
|
|
|
|
|
|
2022-11-21 01:33:45 +01:00
|
|
|
export const useNavBarContext = () => useContext(NavBarContext);
|