Expose dark mode flag to plugin authors
Summary: Should be available now with ``` getFlipperLib().settings().isDarkMode ``` Differential Revision: D46685851 fbshipit-source-id: 0777437b7ca06051cc3fd4dc1b794242f453f2b5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bf2f1283d3
commit
84e481e7e9
@@ -264,6 +264,7 @@ test('log listeners are resumed and suspended automatically - 1', async () => {
|
||||
enableMenuEntries: jest.fn(),
|
||||
selectPlugin: jest.fn(),
|
||||
showNotification: jest.fn(),
|
||||
settings: jest.fn(),
|
||||
});
|
||||
|
||||
device.loadDevicePlugins(
|
||||
@@ -352,6 +353,7 @@ test('log listeners are resumed and suspended automatically - 2', async () => {
|
||||
enableMenuEntries: jest.fn(),
|
||||
selectPlugin: jest.fn(),
|
||||
showNotification: jest.fn(),
|
||||
settings: jest.fn(),
|
||||
});
|
||||
|
||||
device.loadDevicePlugins(
|
||||
|
||||
@@ -31,7 +31,10 @@ export function baseFlipperLibImplementation(
|
||||
| 'showNotification'
|
||||
| 'createPaste'
|
||||
| 'intern'
|
||||
> & {intern: Omit<FlipperLib['intern'], 'currentUser' | 'isConnected'>} {
|
||||
| 'settings'
|
||||
> & {
|
||||
intern: Omit<FlipperLib['intern'], 'currentUser' | 'isConnected'>;
|
||||
} {
|
||||
return {
|
||||
isFB: !constants.IS_PUBLIC_BUILD,
|
||||
logger,
|
||||
|
||||
@@ -207,6 +207,9 @@ export interface FlipperLib {
|
||||
};
|
||||
remoteServerContext: RemoteServerContext;
|
||||
intern: InternAPI;
|
||||
settings: () => {
|
||||
isDarkMode: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface InternAPI {
|
||||
|
||||
@@ -106,6 +106,7 @@ export function createMockFlipperLib(options?: StartPluginOptions): FlipperLib {
|
||||
},
|
||||
downloadFile: createStubFunction(),
|
||||
},
|
||||
settings: createStubFunction(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,5 +38,8 @@ export function initializeFlipperLibImplementation(
|
||||
// TODO: Write to stdout/stderr?
|
||||
throw new Error('Not supported in headless context');
|
||||
},
|
||||
settings() {
|
||||
return {isDarkMode: false};
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,5 +59,16 @@ export function initializeFlipperLibImplementation(
|
||||
);
|
||||
},
|
||||
DetailsSidebarImplementation: DetailSidebarImpl,
|
||||
settings() {
|
||||
const darkModeState = store.getState().settingsState.darkMode;
|
||||
let isDarkMode = darkModeState === 'dark';
|
||||
if (
|
||||
darkModeState === 'system' &&
|
||||
window.matchMedia('(prefers-color-scheme:dark)').matches
|
||||
) {
|
||||
isDarkMode = true;
|
||||
}
|
||||
return {isDarkMode};
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user