2022-03-03 18:19:01 +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
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2022-03-03 18:19:01 +05:30
|
|
|
|
|
|
|
|
import React, { useContext } from 'react';
|
2023-06-05 01:42:39 +02:00
|
|
|
import { LibraryOptions } from '@/typings';
|
2022-03-03 18:19:01 +05:30
|
|
|
|
|
|
|
|
type ContextType = {
|
2022-04-07 12:53:14 +02:00
|
|
|
options: LibraryOptions;
|
|
|
|
|
setOptions: React.Dispatch<React.SetStateAction<LibraryOptions>>;
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-20 07:05:31 +02:00
|
|
|
export enum GridLayout {
|
|
|
|
|
Compact = 0,
|
|
|
|
|
Comfortable = 1,
|
|
|
|
|
List = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-07 12:53:14 +02:00
|
|
|
export const DefaultLibraryOptions: LibraryOptions = {
|
|
|
|
|
showDownloadBadge: false,
|
|
|
|
|
showUnreadBadge: false,
|
2022-12-20 07:05:31 +02:00
|
|
|
gridLayout: GridLayout.Compact,
|
|
|
|
|
SourcegridLayout: GridLayout.Compact,
|
2022-04-07 12:53:14 +02:00
|
|
|
|
|
|
|
|
downloaded: undefined,
|
|
|
|
|
sortDesc: undefined,
|
|
|
|
|
sorts: undefined,
|
|
|
|
|
unread: undefined,
|
2023-04-22 11:39:59 +02:00
|
|
|
|
|
|
|
|
showTabSize: false,
|
2022-03-03 18:19:01 +05:30
|
|
|
};
|
|
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export const LibraryOptionsContext = React.createContext<ContextType>({
|
2022-04-07 12:53:14 +02:00
|
|
|
options: DefaultLibraryOptions,
|
2022-03-03 18:19:01 +05:30
|
|
|
setOptions: () => {},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export function useLibraryOptionsContext() {
|
|
|
|
|
return useContext(LibraryOptionsContext);
|
|
|
|
|
}
|