2022-03-03 15:09:18 +05:30
|
|
|
/*
|
|
|
|
|
* 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 React, { useState } from 'react';
|
|
|
|
|
import NavBarContext from 'components/context/NavbarContext';
|
|
|
|
|
|
|
|
|
|
interface IProps{
|
|
|
|
|
children: React.ReactNode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function NavBarProvider({ children }:IProps) {
|
2022-11-21 01:33:45 +01:00
|
|
|
const [defaultBackTo, setDefaultBackTo] = useState<string | undefined>();
|
2022-03-03 15:09:18 +05:30
|
|
|
const [title, setTitle] = useState<string>('Tachidesk');
|
|
|
|
|
const [action, setAction] = useState<any>(<div />);
|
|
|
|
|
const [override, setOverride] = useState<INavbarOverride>({
|
|
|
|
|
status: false,
|
|
|
|
|
value: <div />,
|
|
|
|
|
});
|
|
|
|
|
|
2023-01-07 16:44:00 +01:00
|
|
|
const updateTitle = (newTitle: string) => {
|
|
|
|
|
document.title = `${newTitle} - Tachidesk`;
|
|
|
|
|
setTitle(newTitle);
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-03 15:09:18 +05:30
|
|
|
const value = {
|
2022-11-21 01:33:45 +01:00
|
|
|
defaultBackTo,
|
|
|
|
|
setDefaultBackTo,
|
2022-03-03 15:09:18 +05:30
|
|
|
title,
|
2023-01-07 16:44:00 +01:00
|
|
|
setTitle: updateTitle,
|
2022-03-03 15:09:18 +05:30
|
|
|
action,
|
|
|
|
|
setAction,
|
|
|
|
|
override,
|
|
|
|
|
setOverride,
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<NavBarContext.Provider value={value}>
|
|
|
|
|
{children}
|
|
|
|
|
</NavBarContext.Provider>
|
|
|
|
|
);
|
|
|
|
|
}
|