Açıklama Yok

WidgetTemplates.swift 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import Foundation
  2. import CoreGraphics
  3. struct WidgetQuickAction: Identifiable, Hashable {
  4. enum Destination: String, Hashable {
  5. case joinMeetings
  6. case schedule
  7. case calendar
  8. case settings
  9. case signIn
  10. case openMeetWeb
  11. case refreshMeetings
  12. }
  13. let id: String
  14. let title: String
  15. let systemImage: String
  16. let destination: Destination
  17. }
  18. struct WidgetVariant: Identifiable, Hashable {
  19. let id: String
  20. let title: String
  21. let subtitle: String
  22. let size: WidgetSize
  23. let quickActions: [WidgetQuickAction]
  24. }
  25. enum WidgetTemplates {
  26. static let meetVariants: [WidgetVariant] = [
  27. WidgetVariant(
  28. id: "meet_small",
  29. title: "Google Meet",
  30. subtitle: "Open and join quickly",
  31. size: .small,
  32. quickActions: [
  33. WidgetQuickAction(id: "open", title: "Open Meet", systemImage: "video.fill", destination: .openMeetWeb),
  34. WidgetQuickAction(id: "join", title: "Join Meetings", systemImage: "arrow.up.forward.app.fill", destination: .joinMeetings)
  35. ]
  36. ),
  37. WidgetVariant(
  38. id: "meet_medium",
  39. title: "Google Meet",
  40. subtitle: "Upcoming meetings",
  41. size: .medium,
  42. quickActions: [
  43. WidgetQuickAction(id: "schedule", title: "Schedule", systemImage: "clock.badge.checkmark", destination: .schedule),
  44. WidgetQuickAction(id: "calendar", title: "Calendar", systemImage: "calendar", destination: .calendar),
  45. WidgetQuickAction(id: "settings", title: "Settings", systemImage: "gearshape.fill", destination: .settings),
  46. WidgetQuickAction(id: "refresh", title: "Refresh", systemImage: "arrow.clockwise", destination: .refreshMeetings)
  47. ]
  48. )
  49. ]
  50. static func variant(for variantID: String) -> WidgetVariant {
  51. meetVariants.first(where: { $0.id == variantID }) ?? meetVariants[0]
  52. }
  53. }
  54. extension WidgetVariant {
  55. var previewCardSize: CGSize {
  56. switch size {
  57. case .small:
  58. return CGSize(width: 196, height: 196)
  59. case .medium:
  60. // Match the medium desktop widget’s tallest expected layout (e.g. 2 meetings + actions)
  61. // so the preview doesn’t clip inside the “Add Widget to Desktop” screen.
  62. return CGSize(width: 340, height: 288)
  63. }
  64. }
  65. }