Weather app on glanceboard system card and status bar, and has an image

This commit is contained in:
James Babcock committed 2026-10-04 03:08:37 -07:00
1 parent 61ede9b2a0
commit 6db913af48
15 files changed
+762 -33

No files matched your search

+23
View File
@@ -1,6 +1,9 @@
import { ensureLocationPermission, hasLocationPermission } from "../../native/location-permissions";
import { weatherBridge } from "../../native/weather";
import { toggleSettingMenuItem } from "../../ui/dashboard-settings";
import { openSettingsSubMenu } from "../../ui/dashboard/settings-panel";
import { WeatherLayer } from "./weather";
import { weatherShowInStatusBarSetting, weatherShowOnSystemCardSetting } from "./weather-settings";
import {
createInProcessWindow,
YieldAtRootLayer,
@@ -32,6 +35,14 @@ export function createWeatherAppWindow(options: InProcessAppOptions): InProcessW
}).catch((error) => { requestingPermission = false; console.warn(`Weather permission: ${error}`); });
};
// An indicator switched on without location access asks for it here, since
// its background refreshes have no screen of their own to prompt from.
const indicatorSettingOptions = {
onChange: (_ctx: unknown, enabled: boolean) => {
if (enabled && !hasLocationPermission()) requestUpdate();
},
};
const app = createInProcessWindow({
appId: "weather",
windowId: WEATHER_WINDOW_ID,
@@ -47,6 +58,18 @@ export function createWeatherAppWindow(options: InProcessAppOptions): InProcessW
requestUpdate();
},
},
{
label: "Settings",
onSelect: (ctx) => {
// Pop the menu first so closing the settings modal lands back on
// the forecast, not this menu.
ctx.stack.pop();
openSettingsSubMenu(ctx, "Weather settings", [
toggleSettingMenuItem(weatherShowInStatusBarSetting, indicatorSettingOptions),
toggleSettingMenuItem(weatherShowOnSystemCardSetting, indicatorSettingOptions),
]);
},
},
],
actions: options.actions,
baseLayer: new YieldAtRootLayer(new WeatherLayer(() => weatherBridge.snapshot(), requestUpdate)),