Преглед изворни кода

Show widget actions without login and refresh on auth changes.

Made-with: Cursor
huzaifahayat12 пре 3 месеци
родитељ
комит
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 {
                     self.pageCache[.settings] = nil
                     self.showSidebarPage(self.selectedSidebarPage)
                 }
+                // Ensure desktop widgets refresh immediately with the newly available meetings.
+                await self.loadSchedule()
             } catch {
                 self.showSimpleError("Couldn’t connect Google account.", error: error)
             }

+ 30 - 32
meetings_app/Widgets/DesktopWidgetView.swift

@@ -48,35 +48,31 @@ struct DesktopWidgetView: View {
 
     @ViewBuilder
     private var contentBody: some View {
-        if !isSignedIn {
-            loggedOutContent
-        } else {
-            switch variant.size {
-            case .small:
-                VStack(alignment: .leading, spacing: 10) {
-                    Text("Quick actions")
-                        .font(.system(size: 11.5, weight: .semibold))
-                        .foregroundStyle(.white.opacity(0.78))
-                    compactActionButton(title: "Open Meet", icon: "video.fill", destination: .openMeetWeb)
-                    HStack(spacing: 8) {
-                        compactActionButton(title: "Schedule", icon: "clock.badge.checkmark", destination: .schedule)
-                        compactActionButton(title: "Settings", icon: "gearshape.fill", destination: .settings)
-                    }
+        switch variant.size {
+        case .small:
+            VStack(alignment: .leading, spacing: 10) {
+                Text("Quick actions")
+                    .font(.system(size: 11.5, weight: .semibold))
+                    .foregroundStyle(.white.opacity(0.78))
+                compactActionButton(title: "Open Meet", icon: "video.fill", destination: .openMeetWeb)
+                HStack(spacing: 8) {
+                    compactActionButton(title: "Schedule", icon: "clock.badge.checkmark", destination: .schedule)
+                    compactActionButton(title: "Settings", icon: "gearshape.fill", destination: .settings)
                 }
-            case .medium:
-                meetingBlock(maxRows: 2)
-                LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
-                    ForEach(variant.quickActions.prefix(4)) { action in
-                        actionTile(action)
-                    }
+            }
+        case .medium:
+            meetingBlock(maxRows: 2)
+            LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
+                ForEach(variant.quickActions.prefix(4)) { action in
+                    actionTile(action)
                 }
-            case .large:
-                meetingBlock(maxRows: 3)
-                Divider().overlay(Color.white.opacity(0.18))
-                LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
-                    ForEach(variant.quickActions.prefix(6)) { action in
-                        actionTile(action)
-                    }
+            }
+        case .large:
+            meetingBlock(maxRows: 3)
+            Divider().overlay(Color.white.opacity(0.18))
+            LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 0), spacing: 8), count: 2), spacing: 8) {
+                ForEach(variant.quickActions.prefix(6)) { action in
+                    actionTile(action)
                 }
             }
         }
@@ -106,7 +102,9 @@ struct DesktopWidgetView: View {
             Text("Upcoming meetings")
                 .font(.system(size: 11.5, weight: .semibold))
                 .foregroundStyle(.white.opacity(0.80))
-            if topMeetings.isEmpty {
+            if !isSignedIn {
+                signInCTA
+            } else if topMeetings.isEmpty {
                 Text("No upcoming meetings")
                     .font(.system(size: 12, weight: .medium))
                     .foregroundStyle(.white.opacity(0.82))
@@ -120,13 +118,13 @@ struct DesktopWidgetView: View {
         }
     }
 
-    @ViewBuilder
-    private var loggedOutContent: some View {
+    private var signInCTA: some View {
         VStack(alignment: .leading, spacing: 10) {
-            Text("Connect Google to use widget actions.")
+            Text("Sign in to see upcoming meetings")
                 .font(.system(size: 12, weight: .medium))
                 .foregroundStyle(.white.opacity(0.86))
-            Button(action: { open(action: WidgetQuickAction(id: "login", title: "Login", systemImage: "person.crop.circle.badge.checkmark", destination: .signIn)) }) {
+
+            Button(action: { WidgetAppNavigator.open(target: .signIn) }) {
                 HStack(spacing: 8) {
                     Image(systemName: "person.crop.circle.badge.checkmark")
                         .font(.system(size: 12, weight: .semibold))