浏览代码

Open widgets for selected app in panel view

Made-with: Cursor
huzaifahayat12 3 月之前
父节点
当前提交
36ad5405e5
共有 1 个文件被更改,包括 21 次插入1 次删除
  1. 21 1
      google_apps/LauncherRootView.swift

+ 21 - 1
google_apps/LauncherRootView.swift

@@ -246,7 +246,7 @@ struct LauncherRootView: View {
                 IconPanelView(
                     apps: filteredApps,
                     onAppTap: { app in
-                        handleAppTap(app)
+                        handlePanelAppTap(app)
                     },
                     draggedAppID: $draggedAppID,
                     lastDropDestinationAppID: $lastDropDestinationAppID,
@@ -300,6 +300,26 @@ struct LauncherRootView: View {
         selectedApp = app
     }
 
+    /// Second (panel) view: tapping a row opens the Widgets window for that app.
+    private func handlePanelAppTap(_ app: LauncherApp) {
+        if app.isCreateNew {
+            showingCreateAppSheet = true
+            return
+        }
+        openWidgetsPage(for: app)
+    }
+
+    private func openWidgetsPage(for app: LauncherApp) {
+        var updated = decodeUUIDSetGlobal(from: widgetAppIDsData)
+        updated.insert(app.id)
+        widgetAppIDsData = encodeUUIDSetGlobal(updated)
+        NotificationCenter.default.post(
+            name: .openWidgetsPage,
+            object: nil,
+            userInfo: ["appID": app.id]
+        )
+    }
+
     private func addCustomApp(name: String, url: URL) {
         let newApp = LauncherApp(
             name: name,