Cotton code
33 lines · 1.1 KB · SwiftRaw
// Cotton Calling round the app's root: the deck's handset and camera place// calls through the engine, a `cottoncalling://call?…` link places one, and// the core's words for a refused call are said.#if os(iOS)import CottonKitimport CottonUIimport SwiftUIpublic struct CallingShell: ViewModifier {    @State private var engine = CallingEngine.shared    public init() {}    public func body(content: Content) -> some View {        let center = engine.center        content            .environment(\.placesCall) { person, video, refused in center.start(person: person, video: video, refused: refused) }            .environment(\.opensCallLink) { url in                guard url.host() == "call" else { return false }                center.open(link: url)                return true            }            .overlay { CallScreen(center: center, video: engine.peer.video) }            .task { center.refresh() }    }}extension View {    /// Cotton Calling's engine round this view.    public func callingShell() -> some View { modifier(CallingShell()) }}#endif