#if os(macOS) import SwiftUI /// Calls → Settings…. Sections rather than tabs: there are a few things /// worth choosing, and the next preference belongs beside them. public struct CallsSettingsView: View { @ObservedObject private var model: CallsModel @AppStorage(MiniWindowPreferences.enabledKey) private var miniWindow = MiniWindowPreferences.defaultEnabled @AppStorage(MiniWindowPreferences.cornerKey) private var corner = MiniWindowPreferences.defaultCorner @AppStorage(MiniWindowPreferences.placementKey) private var placement = MiniWindowPreferences.defaultPlacement @AppStorage(MiniWindowPreferences.positionsKey) private var positions: String? @AppStorage(CallLayoutStyle.key) private var callLayout = CallLayoutStyle.defaultStyle public init(model: CallsModel) { self.model = model } public var body: some View { Form { Section { Picker(selection: $callLayout) { ForEach(CallLayoutStyle.allCases) { style in Text(style.title).tag(style) } } label: { Text("Call layout") Text( callLayout == .fullWindow ? "The call fills the window. Move the pointer over it to show the controls." : "The call sits above a row of controls that are always showing." ) } .accessibilityIdentifier("callLayout") Toggle(isOn: $miniWindow) { Text("Show a mini window when you switch to another app") Text( "During a call, a small window of the call stays on top of other apps. The full call returns when you come back to Calls." ) } Picker(selection: $placement) { ForEach(MiniWindowPlacement.allCases) { placement in Text(placement.title).tag(placement) } } label: { Text("Mini window placement") Text(placementNote) } .disabled(!miniWindow) Picker(selection: $corner) { ForEach(MiniWindowCorner.allCases) { corner in Text(corner.title).tag(corner) } } label: { Text("Mini window position") Text( placement == .corners ? "You can also drag the mini window to another corner, and resize it from its edges." : "Where it starts. Choosing a corner here moves it back into that corner." ) } .disabled(!miniWindow) .onChange(of: corner) { // A corner chosen here is asked for: whatever position the // window was left at, on any display, gives way to it. positions = nil } } header: { Text("During a call") } ServerSettingsSection(model: model) QualityReportsSection() if let automaticUpdates { Section { Toggle(isOn: automaticUpdates) { Text("Update Calls automatically") Text( "Updates download in the background and install when you quit Calls, never during a call." ) } .accessibilityIdentifier("automaticUpdates") } header: { Text("Updates") } } } .formStyle(.grouped) .frame(width: 480) .fixedSize(horizontal: false, vertical: true) .tint(CallsAppearance.accent) } /// Nil where the build cannot update itself: development builds, and iPhone. private var automaticUpdates: Binding? /// Adds the automatic-update switch, from the Mac app that owns the updater. public init(model: CallsModel, automaticUpdates: Binding?) { self.model = model self.automaticUpdates = automaticUpdates } private var placementNote: String { switch placement { case .corners: "A dragged mini window settles in the nearest corner. Hold ⌥ Option while dragging to leave it exactly where you drop it, for this call." case .anywhere: "The mini window stays exactly where you leave it, remembered for each display." } } } #endif