Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
}
},
"dependencies": {
"lucide-react": "^0.546.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
Expand Down
10 changes: 10 additions & 0 deletions apps/browser/src/main/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class IPCHandlers {
this.registerWebContentsHandlers();
this.registerThemeHandlers();
this.registerOrientationHandlers();
this.registerAppHandlers();
}

/**
Expand Down Expand Up @@ -349,4 +350,13 @@ export class IPCHandlers {
return this.windowManager.toggleOrientation();
});
}

/**
* Register app-related handlers
*/
private registerAppHandlers(): void {
ipcMain.handle("get-app-version", () => {
return app.getVersion();
});
}
}
9 changes: 9 additions & 0 deletions apps/browser/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ contextBridge.exposeInMainWorld("electronAPI", {
return () => ipcRenderer.removeAllListeners("fullscreen-mode-changed");
},

// Settings listener
onOpenSettings: (callback: () => void) => {
ipcRenderer.on("open-settings", callback);
return () => ipcRenderer.removeListener("open-settings", callback);
},

// App version
getAppVersion: () => ipcRenderer.invoke("get-app-version"),

// Tab management APIs
tabs: {
getAll: () => ipcRenderer.invoke("tabs-get-all"),
Expand Down
64 changes: 58 additions & 6 deletions apps/browser/src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useState, useEffect, useRef } from "react";
import TopBar from "./components/top-bar";
import PhoneFrame from "./components/phone-frame";
import TabOverview from "./components/tab-overview";
import Settings from "./components/settings";

function App() {
const [_time, setTime] = useState("9:41");
Expand All @@ -16,6 +17,7 @@ function App() {
"portrait"
);
const [showTabOverview, setShowTabOverview] = useState(false);
const [showSettings, setShowSettings] = useState(false);
const [tabCount, setTabCount] = useState(1);
const [isFullscreen, setIsFullscreen] = useState(false);
const webContainerRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -73,6 +75,19 @@ function App() {
};
}, []);

// Listen for settings open request
useEffect(() => {
const cleanup = window.electronAPI?.onOpenSettings(() => {
setShowSettings(true);
// Hide WebContentsView when showing settings
window.electronAPI?.webContents.setVisible(false);
});

return () => {
if (cleanup) cleanup();
};
}, []);

// Track tab count
useEffect(() => {
// Get initial tab count
Expand Down Expand Up @@ -515,6 +530,35 @@ function App() {
window.electronAPI?.webContents.reload();
};

const handleCloseSettings = () => {
setShowSettings(false);

// Set bounds before showing view
if (webContainerRef.current) {
const rect = webContainerRef.current.getBoundingClientRect();
const statusBarHeight = 58;
const statusBarWidth = 58;

window.electronAPI?.webContents.setBounds({
x: Math.round(
rect.x + (orientation === "landscape" ? statusBarWidth : 0)
),
y: Math.round(
rect.y + (orientation === "landscape" ? 0 : statusBarHeight)
),
width: Math.round(
rect.width - (orientation === "landscape" ? statusBarWidth : 0)
),
height: Math.round(
rect.height - (orientation === "landscape" ? 0 : statusBarHeight)
),
});
}

// Show WebContentsView when closing settings
window.electronAPI?.webContents.setVisible(true);
};

return (
<div className="w-screen h-screen rounded-xl overflow-hidden bg-transparent">
<TopBar
Expand All @@ -533,14 +577,22 @@ function App() {
orientation={orientation}
themeColor={themeColor}
textColor={textColor}
showTabOverview={showTabOverview}
showTabOverview={showTabOverview || showSettings}
isFullscreen={isFullscreen}
tabOverviewContent={
<TabOverview
theme={systemTheme}
orientation={orientation}
onClose={handleCloseTabOverview}
/>
showSettings ? (
<Settings
theme={systemTheme}
orientation={orientation}
onClose={handleCloseSettings}
/>
) : (
<TabOverview
theme={systemTheme}
orientation={orientation}
onClose={handleCloseTabOverview}
/>
)
}
/>
</div>
Expand Down
Loading