import { StatusBar, Style } from "@capacitor/status-bar";
import { platformRuntime } from "./runtime.js";

const STATUS_BAR_COLORS = Object.freeze({ dark: "#15171b", light: "#f7f7f8" });

export async function syncSystemBars(theme, runtime = platformRuntime, statusBar = StatusBar) {
  if (!runtime.isAndroid) return;

  await Promise.allSettled([
    statusBar.setStyle({ style: theme === "dark" ? Style.Dark : Style.Light }),
    statusBar.setBackgroundColor({ color: STATUS_BAR_COLORS[theme] ?? STATUS_BAR_COLORS.dark })
  ]);
}
