-
Notifications
You must be signed in to change notification settings - Fork 43
/
WindowPreviewView.swift
55 lines (50 loc) · 1009 Bytes
/
WindowPreviewView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// WindowPreviewView.swift
// visionOS
//
// Created by Saagar Jha on 10/10/23.
//
import SwiftUI
struct WindowPreviewView: View {
let remote: Remote
let window: Window
@Binding
var selectedWindow: Window?
@State
var preview: Frame?
var body: some View {
Button(action: {
selectedWindow = window
}) {
VStack(alignment: .leading) {
let size = macOSInterface.M.WindowPreview.previewSize
Group {
if let preview {
FrameView(frame: preview)
} else {
ProgressView {
Text("Loading Preview…")
}
}
}.frame(width: size.width, height: size.height)
Text(window.app)
.font(.title)
.lineLimit(1)
Text(window.title!)
.lineLimit(1)
}
}
.buttonBorderShape(.roundedRectangle)
.task {
do {
// while true {
guard let preview = try await remote.windowPreview(for: window.id) else {
return
}
self.preview = preview
// try await Task.sleep(for: .seconds(1))
// }
} catch {}
}
}
}