import SwiftUI #if os(iOS) import UIKit #else import AppKit #endif @MainActor public struct MeetingShareButton: View { @ObservedObject private var call: Call @State private var showing = false public init(call: Call) { self.call = call } public var body: some View { if call.standing == "member" { Button("Share", glyph: "square.and.arrow.up") { showing = true } .accessibilityLabel("Share meeting link") .sheet(isPresented: $showing) { MeetingInvitationView(call: call, close: { showing = false }) .task { await call.loadInvitation() } } } } } @MainActor public struct MeetingInvitationView: View { @ObservedObject private var call: Call private let close: () -> Void @State private var copied = false public init(call: Call, close: @escaping () -> Void) { self.call = call self.close = close } public var body: some View { VStack(alignment: .leading, spacing: 20) { Text("Share meeting").font(.title2.bold()) Text("Send this invitation to someone you want to join. Guests will wait to be let in.") if call.loadingInvitation { ProgressView("Getting invitation…") } else if let url = call.invitationURL { Text(url.absoluteString).font(.callout).textSelection(.enabled) HStack { ShareLink(item: url) { Text("Share…") } Button(copied ? "Copied" : "Copy link") { #if os(iOS) UIPasteboard.general.url = url copied = true #else NSPasteboard.general.clearContents() copied = NSPasteboard.general.setString(url.absoluteString, forType: .string) #endif } }.buttonStyle(.bordered) } else { Text(call.invitationError).foregroundStyle(.secondary) Button("Try again") { Task { await call.loadInvitation() } } } Button("Done", action: close) }.padding(24).frame(minWidth: 280, idealWidth: 380, maxWidth: 440) } }