oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2 import SwiftUI
3
4 /// Calls → Settings…. Sections rather than tabs: there are a few things
5 /// worth choosing, and the next preference belongs beside them.
6 public struct CallsSettingsView: View {
7 @ObservedObject private var model: CallsModel
8 @AppStorage(MiniWindowPreferences.enabledKey) private var miniWindow =
9 MiniWindowPreferences.defaultEnabled
10 @AppStorage(MiniWindowPreferences.cornerKey) private var corner =
11 MiniWindowPreferences.defaultCorner
12 @AppStorage(MiniWindowPreferences.moveFreelyKey) private var moveFreely =
13 MiniWindowPreferences.defaultMoveFreely
14 @AppStorage(MiniWindowPreferences.snapToCornersKey) private var snapToCorners =
15 MiniWindowPreferences.defaultSnapToCorners
16 @AppStorage(MiniWindowPreferences.positionsKey) private var positions: String?
17 @AppStorage(CallLayoutStyle.key) private var callLayout = CallLayoutStyle.defaultStyle
18
19 public init(model: CallsModel) {
20 self.model = model
21 MiniWindowPreferences.migrate(.standard)
22 }
23
24 public var body: some View {
25 Form {
26 Section {
27 Picker(selection: $callLayout) {
28 ForEach(CallLayoutStyle.allCases) { style in
29 Text(style.title).tag(style)
30 }
31 } label: {
32 Text("Call layout")
33 Text(
34 callLayout == .fullWindow
35 ? "The call fills the window. Move the pointer over it to show the controls."
36 : "The call sits above a row of controls that are always showing."
37 )
38 }
39 .accessibilityIdentifier("callLayout")
40 Toggle(isOn: $miniWindow) {
41 Text("Show a mini window when you switch to another app")
42 Text(
43 "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."
44 )
45 }
46 // Two switches, never both off (MiniWindowPreferences): the one
47 // still on cannot be turned off until the other is back on.
48 LabeledContent {
49 VStack(alignment: .leading, spacing: 6) {
50 Toggle("Move freely", isOn: $moveFreely)
51 .disabled(moveFreely && !snapToCorners)
52 .accessibilityIdentifier("miniWindowMoveFreely")
53 Toggle("Snap to corners", isOn: $snapToCorners)
54 .disabled(snapToCorners && !moveFreely)
55 .accessibilityIdentifier("miniWindowSnapToCorners")
56 }
57 .toggleStyle(.checkbox)
58 } label: {
59 Text("Mini window placement")
60 Text(placementNote)
61 }
62 .disabled(!miniWindow)
63 Picker(selection: $corner) {
64 ForEach(MiniWindowCorner.allCases) { corner in
65 Text(corner.title).tag(corner)
66 }
67 } label: {
68 Text("Mini window position")
69 Text(
70 moveFreely
71 ? "Where it starts. Choosing a corner here moves it back into that corner."
72 : "You can also drag the mini window to another corner, and resize it from its edges."
73 )
74 }
75 .disabled(!miniWindow)
76 .onChange(of: corner) {
77 // A corner chosen here is asked for: whatever position the
78 // window was left at, on any display, gives way to it.
79 positions = nil
80 }
81 } header: {
82 Text("During a call")
83 }
84 ServerSettingsSection(model: model)
85 QualityReportsSection()
86 if let automaticUpdates {
87 Section {
88 Toggle(isOn: automaticUpdates) {
89 Text("Update Calls automatically")
90 Text(
91 "Updates download in the background and install when you quit Calls, never during a call."
92 )
93 }
94 .accessibilityIdentifier("automaticUpdates")
95 } header: {
96 Text("Updates")
97 }
98 }
99 }
100 .formStyle(.grouped)
101 .frame(width: 480)
102 .fixedSize(horizontal: false, vertical: true)
103 .tint(CallsAppearance.accent)
104 }
105
106 /// Nil where the build cannot update itself: development builds, and iPhone.
107 private var automaticUpdates: Binding<Bool>?
108
109 /// Adds the automatic-update switch, from the Mac app that owns the updater.
110 public init(model: CallsModel, automaticUpdates: Binding<Bool>?) {
111 self.model = model
112 self.automaticUpdates = automaticUpdates
113 }
114
115 private var placementNote: String {
116 switch (moveFreely, snapToCorners) {
117 case (true, true):
118 "The mini window stays where you leave it, and snaps into a corner when you let go near one. Hold ⌥ Option while dragging to place it exactly, without snapping."
119 case (false, _):
120 "A dragged mini window settles in the nearest corner. Hold ⌥ Option while dragging to leave it exactly where you drop it, for this call."
121 case (true, false):
122 "The mini window stays exactly where you leave it, remembered for each display."
123 }
124 }
125 }
126#endif
127