1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. import type {ReactContext} from 'shared/ReactTypes';
    
  11. 
    
  12. import * as React from 'react';
    
  13. import {createContext, useMemo, useState} from 'react';
    
  14. 
    
  15. export type DisplayDensity = 'comfortable' | 'compact';
    
  16. export type Theme = 'auto' | 'light' | 'dark';
    
  17. 
    
  18. type Context = {
    
  19.   isModalShowing: boolean,
    
  20.   setIsModalShowing: (value: boolean) => void,
    
  21.   ...
    
  22. };
    
  23. 
    
  24. const SettingsModalContext: ReactContext<Context> = createContext<Context>(
    
  25.   ((null: any): Context),
    
  26. );
    
  27. SettingsModalContext.displayName = 'SettingsModalContext';
    
  28. 
    
  29. function SettingsModalContextController({
    
  30.   children,
    
  31. }: {
    
  32.   children: React$Node,
    
  33. }): React.Node {
    
  34.   const [isModalShowing, setIsModalShowing] = useState<boolean>(false);
    
  35. 
    
  36.   const value = useMemo(
    
  37.     () => ({isModalShowing, setIsModalShowing}),
    
  38.     [isModalShowing, setIsModalShowing],
    
  39.   );
    
  40. 
    
  41.   return (
    
  42.     <SettingsModalContext.Provider value={value}>
    
  43.       {children}
    
  44.     </SettingsModalContext.Provider>
    
  45.   );
    
  46. }
    
  47. 
    
  48. export {SettingsModalContext, SettingsModalContextController};