oficina / meet Public

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

Plain git — no account needed to clone.

Download

Download this file

1#if DEBUG
2 @_spi(Fixtures) import CallsKit
3 import SwiftUI
4
5 /// The call screen with no server behind it, for the UI test of its
6 /// controls and the snapshots taken there. Debug builds only; launched
7 /// with `-CallsCallFixture focus` (or grid, screen, notices), and
8 /// optionally `-CallsFixtureControls shown|hidden` to pin the controls,
9 /// `-CallsFixtureMore YES` to open the controls menu, `-CallsFixtureDark
10 /// YES`, `-CallsFixtureClassic YES`, `-CallsFixtureBackdrop black|white|busy`
11 /// for a frame in place of the stage, `-CallsFixtureStagePicture
12 /// black|white|busy` for a frame as the picture on the stage's tile (the
13 /// filmstrip and labels over it), `-CallsFixtureSelf
14 /// muted|cameraOff|sharing` for your own state, `-CallsFixtureSpeaking
15 /// silent|low|mid|high` for everyone's speaking glow, and
16 /// `-CallsFixtureNoGlass YES` for the material older systems draw in
17 /// place of Liquid Glass. For Speaker view (0.4.0): `-CallsFixtureLayout
18 /// speaker|grid` (the grid fixture is Grid unless it says), and
19 /// `-CallsFixtureSpeaker tom`, `-CallsFixturePinned li`, `-CallsFixtureLift
20 /// li` (a tile half way through a drag) and `-CallsFixtureOrder
21 /// li,tom,me,ana`. `-CallsFixtureRimGallery silent|low|mid|high` shows,
22 /// in place of any call, the warm rim on a name at that level over the
23 /// pictures it has to read on (`WarmRimGallery`, 0.4.3).
24 /// `-CallsFixtureFeeds ana=720x1280,li=1280x720` draws each peer's
25 /// picture at that size on every tile it has (portrait video,
26 /// 2026-10-21), and `-CallsFixtureFillEveryCamera YES` places them as
27 /// 0.4.10 did, every camera filling, for the before pictures.
28 struct PhoneCallFixture: View {
29 static var requested: CallFixture? {
30 UserDefaults.standard.string(forKey: "CallsCallFixture").flatMap(CallFixture.init(rawValue:))
31 }
32 static var rimGallery: FixtureSpeaking? {
33 UserDefaults.standard.string(forKey: "CallsFixtureRimGallery").flatMap(FixtureSpeaking.init(rawValue:))
34 }
35
36 let fixture: CallFixture
37 @StateObject private var call = Call(playAudio: false)
38 @State private var applied = false
39
40 var body: some View {
41 let defaults = UserDefaults.standard
42 let pinned = defaults.string(forKey: "CallsFixtureControls").map { $0 == "shown" }
43 NavigationStack {
44 PhoneCall(
45 call: call, leave: {},
46 style: defaults.bool(forKey: "CallsFixtureClassic") ? .classic : .fullWindow,
47 controlsShown: pinned, showingMore: defaults.bool(forKey: "CallsFixtureMore"),
48 grid: defaults.string(forKey: "CallsFixtureLayout").map { $0 == "grid" } ?? (fixture == .grid))
49 }
50 .tint(CallsAppearance.accent)
51 .environment(
52 \.fixtureBackdrop,
53 defaults.string(forKey: "CallsFixtureBackdrop").flatMap(FixtureBackdrop.init(rawValue:)))
54 .environment(
55 \.fixtureStagePicture,
56 defaults.string(forKey: "CallsFixtureStagePicture").flatMap(FixtureBackdrop.init(rawValue:)))
57 .environment(\.fixtureFeeds, FixtureFeeds.parse(defaults.string(forKey: "CallsFixtureFeeds") ?? ""))
58 .environment(\.callOverlayGlass, !defaults.bool(forKey: "CallsFixtureNoGlass"))
59 .preferredColorScheme(defaults.bool(forKey: "CallsFixtureDark") ? .dark : .light)
60 .onAppear {
61 guard !applied else { return }
62 applied = true
63 FixtureVideo.fillsEveryCamera = defaults.bool(forKey: "CallsFixtureFillEveryCamera")
64 fixture.apply(to: call)
65 UserDefaults.standard.string(forKey: "CallsFixtureSelf")
66 .flatMap(FixtureSelf.init(rawValue:))?.apply(to: call)
67 UserDefaults.standard.string(forKey: "CallsFixtureSpeaking")
68 .flatMap(FixtureSpeaking.init(rawValue:))?.apply(to: call)
69 call.levels.speaker.showFixture(defaults.string(forKey: "CallsFixtureSpeaker"))
70 call.arrangement.showPinned(defaults.string(forKey: "CallsFixturePinned").map(StageItem.camera))
71 call.arrangement.showLift(defaults.string(forKey: "CallsFixtureLift"))
72 call.arrangement.showOrder(
73 (defaults.string(forKey: "CallsFixtureOrder") ?? "").split(separator: ",").map(String.init))
74 }
75 }
76 }
77#endif
78