forked from Blendman974/faceclaw
Add Timer, Weather apps; build out UI of music app; add wakeword action setting
This commit is contained in:
1 parent
008f2277ca
commit
5c73ba2a4d
27 files changed
+2181
-312
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import { ensureLocationPermission, hasLocationPermission } from "../../g2/android-permissions";
|
||||
import { weatherBridge } from "../../native/weather";
|
||||
import { WeatherLayer } from "../apps/weather";
|
||||
import {
|
||||
createInProcessWindow,
|
||||
YieldAtRootLayer,
|
||||
type InProcessAppOptions,
|
||||
type InProcessWindow,
|
||||
} from "./in-process-window";
|
||||
|
||||
export const WEATHER_WINDOW_ID = "weather";
|
||||
export const WEATHER_SURFACE_ID = "window:weather";
|
||||
|
||||
/** Local current conditions and forecast from the National Weather Service. */
|
||||
export function createWeatherAppWindow(options: InProcessAppOptions): InProcessWindow {
|
||||
let requestingPermission = false;
|
||||
let unsubscribe: (() => void) | null = null;
|
||||
let app: InProcessWindow;
|
||||
|
||||
const requestUpdate = () => {
|
||||
if (requestingPermission) return;
|
||||
if (hasLocationPermission()) {
|
||||
weatherBridge.start();
|
||||
return;
|
||||
}
|
||||
requestingPermission = true;
|
||||
void ensureLocationPermission().then((granted) => {
|
||||
requestingPermission = false;
|
||||
if (granted) weatherBridge.start();
|
||||
app.requestRender();
|
||||
});
|
||||
};
|
||||
|
||||
app = createInProcessWindow({
|
||||
appId: "weather",
|
||||
windowId: WEATHER_WINDOW_ID,
|
||||
title: "Weather",
|
||||
iconLetter: "W",
|
||||
icon: "cloud-sun",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(new WeatherLayer(() => weatherBridge.snapshot(), requestUpdate)),
|
||||
submitFrame: options.submitFrame,
|
||||
setSurfaceVisible: options.setSurfaceVisible,
|
||||
removeSurface: options.removeSurface,
|
||||
onClosed: () => {
|
||||
unsubscribe?.();
|
||||
unsubscribe = null;
|
||||
weatherBridge.stop();
|
||||
options.onClosed();
|
||||
},
|
||||
});
|
||||
unsubscribe = weatherBridge.onStateChange(() => app.requestRender());
|
||||
requestUpdate();
|
||||
return app;
|
||||
}
|
||||
Reference in new issue
Block a user