1import { ColorValue, Platform, processColor } from 'react-native';
2
3import ExpoSystemUI from './ExpoSystemUI';
4
5/**
6 * Changes the root view background color.
7 * Call this function in the root file outside of you component.
8 *
9 * @example
10 * ```ts
11 * SystemUI.setBackgroundColorAsync("black");
12 * ```
13 * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).
14 */
15export async function setBackgroundColorAsync(color: ColorValue | null): Promise<void> {
16  if (color == null) {
17    return await ExpoSystemUI.setBackgroundColorAsync(null);
18  } else {
19    const colorNumber = Platform.OS === 'web' ? color : processColor(color);
20    return await ExpoSystemUI.setBackgroundColorAsync(colorNumber);
21  }
22}
23
24/**
25 * Gets the root view background color.
26 *
27 * @example
28 * ```ts
29 * const color = await SystemUI.getBackgroundColorAsync();
30 * ```
31 * @returns Current root view background color in hex format. Returns `null` if the background color is not set.
32 */
33export async function getBackgroundColorAsync(): Promise<ColorValue | null> {
34  return await ExpoSystemUI.getBackgroundColorAsync();
35}
36