浏览代码

Show widget actions without login and refresh on auth changes.

Made-with: Cursor
huzaifahayat12 1 月之前
父节点
当前提交
7ca2e1a822
共有 2 个文件被更改,包括 32 次插入32 次删除
  1. 2 0
      meetings_app/ViewController.swift
  2. 30 32
      meetings_app/Widgets/DesktopWidgetView.swift

+ 2 - 0
meetings_app/ViewController.swift

@@ -6924,6 +6924,8 @@ private extension ViewController {
6924 6924
                     self.pageCache[.settings] = nil
6925 6925
                     self.showSidebarPage(self.selectedSidebarPage)
6926 6926
                 }
6927
+                // Ensure desktop widgets refresh immediately with the newly available meetings.
6928
+                await self.loadSchedule()
6927 6929
             } catch {
6928 6930
                 self.showSimpleError("Couldn’t connect Google account.", error: error)
6929 6931
             }

+ 30 - 32
meetings_app/Widgets/DesktopWidgetView.swift

@@ -48,35 +48,31 @@ struct DesktopWidgetView: View {
48 48
 
49 49
     @ViewBuilder
50 50
     private var contentBody: some View {
51
-        if !isSignedIn {
52
-            loggedOutContent
53
-        } else {
54
-            switch variant.size {
55
-            case .small:
56
-                VStack(alignment: .leading, spacing: 10) {
57
-                    Text("Quick actions")
58
-                        .font(.system(size: 11.5, weight: .semibold))
59
-                        .foregroundStyle(.white.opacity(0.78))
60
-                    compactActionButton(title: "Open Meet", icon: "video.fill", destination: .openMeetWeb)
61
-                    HStack(spacing: 8) {
62
-                        compactActionButton(title: "Schedule", icon: "clock.badge.checkmark", destination: .schedule)
63
-                        compactActionButton(title: "Settings", icon: "gearshape.fill", destination: .settings)
64
-                    }
51
+        switch variant.size {
52
+        case .small:
53
+            VStack(alignment: .leading, spacing: 10) {
54
+                Text("Quick actions")
55
+                    .font(.system(size: 11.5, weight: .semibold))
56
+                    .foregroundStyle(.white.opacity(0.78))
57
+                compactActionButton(title: "Open Meet", icon: "video.fill", destination: .openMeetWeb)
58
+                HStack(spacing: 8) {
59
+                    compactActionButton(title: "Schedule", icon: "clock.badge.checkmark", destination: .schedule)
60
+                    compactActionButton(title: "Settings", icon: "gearshape.fill", destination: .settings)
65 61
                 }
66
-            case .medium:
67
-                meetingBlock(maxRows: 2)
68
-                LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
69
-                    ForEach(variant.quickActions.prefix(4)) { action in
70
-                        actionTile(action)
71
-                    }
62
+            }
63
+        case .medium:
64
+            meetingBlock(maxRows: 2)
65
+            LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
66
+                ForEach(variant.quickActions.prefix(4)) { action in
67
+                    actionTile(action)
72 68
                 }
73
-            case .large:
74
-                meetingBlock(maxRows: 3)
75
-                Divider().overlay(Color.white.opacity(0.18))
76
-                LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
77
-                    ForEach(variant.quickActions.prefix(6)) { action in
78
-                        actionTile(action)
79
-                    }
69
+            }
70
+        case .large:
71
+            meetingBlock(maxRows: 3)
72
+            Divider().overlay(Color.white.opacity(0.18))
73
+            LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
74
+                ForEach(variant.quickActions.prefix(6)) { action in
75
+                    actionTile(action)
80 76
                 }
81 77
             }
82 78
         }
@@ -106,7 +102,9 @@ struct DesktopWidgetView: View {
106 102
             Text("Upcoming meetings")
107 103
                 .font(.system(size: 11.5, weight: .semibold))
108 104
                 .foregroundStyle(.white.opacity(0.80))
109
-            if topMeetings.isEmpty {
105
+            if !isSignedIn {
106
+                signInCTA
107
+            } else if topMeetings.isEmpty {
110 108
                 Text("No upcoming meetings")
111 109
                     .font(.system(size: 12, weight: .medium))
112 110
                     .foregroundStyle(.white.opacity(0.82))
@@ -120,13 +118,13 @@ struct DesktopWidgetView: View {
120 118
         }
121 119
     }
122 120
 
123
-    @ViewBuilder
124
-    private var loggedOutContent: some View {
121
+    private var signInCTA: some View {
125 122
         VStack(alignment: .leading, spacing: 10) {
126
-            Text("Connect Google to use widget actions.")
123
+            Text("Sign in to see upcoming meetings")
127 124
                 .font(.system(size: 12, weight: .medium))
128 125
                 .foregroundStyle(.white.opacity(0.86))
129
-            Button(action: { open(action: WidgetQuickAction(id: "login", title: "Login", systemImage: "person.crop.circle.badge.checkmark", destination: .signIn)) }) {
126
+
127
+            Button(action: { WidgetAppNavigator.open(target: .signIn) }) {
130 128
                 HStack(spacing: 8) {
131 129
                     Image(systemName: "person.crop.circle.badge.checkmark")
132 130
                         .font(.system(size: 12, weight: .semibold))