forked from Blendman974/faceclaw
Add a consolidated single export to each app
This commit is contained in:
1 parent
9b3832d7a7
commit
f38366df6e
23 files changed
+597
-337
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { shell } from "../../ui/shell/shell";
|
||||
import { type AppDefinition } from "../app-definition";
|
||||
import {
|
||||
createSettingsAppWindow,
|
||||
SETTINGS_SURFACE_ID,
|
||||
SETTINGS_WINDOW_ID,
|
||||
type SettingsAppWindow,
|
||||
} from "./settings-app";
|
||||
|
||||
// The Settings app is a singleton; tracked so a relaunch with a section
|
||||
// deep-link can focus that section in the open window.
|
||||
let activeSettingsApp: SettingsAppWindow | null = null;
|
||||
|
||||
const settingsApp: AppDefinition = {
|
||||
appId: "settings",
|
||||
title: "Settings",
|
||||
icon: "settings",
|
||||
launch: async (ctx, params) => {
|
||||
if (activeSettingsApp) {
|
||||
if (params?.section) activeSettingsApp.focusSection(params.section);
|
||||
shell.focusWindow(SETTINGS_WINDOW_ID);
|
||||
ctx.requestShellRender();
|
||||
return;
|
||||
}
|
||||
await ctx.launchInProcessApp(SETTINGS_WINDOW_ID, SETTINGS_SURFACE_ID, (options) => {
|
||||
const app = createSettingsAppWindow({
|
||||
...options,
|
||||
onClosed: () => {
|
||||
// Closing mid-edit must not leave the phone-side editor dangling.
|
||||
void options.actions.endTextSettingEdit();
|
||||
ctx.setTextEditorHost(null);
|
||||
activeSettingsApp = null;
|
||||
options.onClosed();
|
||||
},
|
||||
});
|
||||
activeSettingsApp = app;
|
||||
// The controller echoes phone-side edits into the glasses editor.
|
||||
ctx.setTextEditorHost(app);
|
||||
return app.inProcess;
|
||||
});
|
||||
if (params?.section) activeSettingsApp?.focusSection(params.section);
|
||||
},
|
||||
};
|
||||
|
||||
export default settingsApp;
|
||||
@@ -2,7 +2,7 @@ import { GrayImage } from "../../graphics/image";
|
||||
import { LayerActions } from "../../ui/layers";
|
||||
import { EditTextSettingLayer } from "../../ui/dashboard-settings";
|
||||
import { createSettingsPanelLayer } from "../../ui/dashboard/settings-menus";
|
||||
import { createInProcessWindow } from "../../ui/shell/in-process-window";
|
||||
import { createInProcessWindow, type InProcessWindow } from "../../ui/shell/in-process-window";
|
||||
import { type ShellWindow } from "../../ui/shell/shell";
|
||||
|
||||
export const SETTINGS_WINDOW_ID = "settings";
|
||||
@@ -18,6 +18,8 @@ export type SettingsAppOptions = {
|
||||
|
||||
export type SettingsAppWindow = {
|
||||
window: ShellWindow;
|
||||
/** The full in-process window record, for hosts that manage window lifecycle. */
|
||||
inProcess: InProcessWindow;
|
||||
requestRender: () => void;
|
||||
/** Select a section in the left column by label (e.g. "Terminal"). */
|
||||
focusSection: (label: string) => void;
|
||||
@@ -35,7 +37,7 @@ export type SettingsAppWindow = {
|
||||
*/
|
||||
export function createSettingsAppWindow(options: SettingsAppOptions): SettingsAppWindow {
|
||||
const panel = createSettingsPanelLayer();
|
||||
const { window, stack, requestRender } = createInProcessWindow({
|
||||
const inProcess = createInProcessWindow({
|
||||
appId: "settings",
|
||||
windowId: SETTINGS_WINDOW_ID,
|
||||
title: "Settings",
|
||||
@@ -51,8 +53,10 @@ export function createSettingsAppWindow(options: SettingsAppOptions): SettingsAp
|
||||
removeSurface: options.removeSurface,
|
||||
onClosed: options.onClosed,
|
||||
});
|
||||
const { window, stack, requestRender } = inProcess;
|
||||
return {
|
||||
window,
|
||||
inProcess,
|
||||
requestRender,
|
||||
focusSection: (label) => {
|
||||
panel.focusSection(label);
|
||||
|
||||
Reference in new issue
Block a user