-
Notifications
You must be signed in to change notification settings - Fork 43
/
WindowToolbarView.swift
57 lines (52 loc) · 1.01 KB
/
WindowToolbarView.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
56
57
//
// WindowToolbarView.swift
// visionOS
//
// Created by Saagar Jha on 3/2/24.
//
import SwiftUI
struct WindowToolbarView: View {
let title: String
let icon: Data?
@Environment(\.openWindow)
var openWindow
var body: some View {
HStack {
if let icon {
Image(uiImage: UIImage(data: icon)!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxHeight: 64)
.padding()
} else {
Image(systemName: "questionmark.app")
.resizable()
.aspectRatio(contentMode: .fit)
.padding()
}
Text("\(title)")
.font(.title)
.padding(.trailing)
.lineLimit(1)
.fixedSize()
Divider()
.padding(.vertical, 20)
Button(action: {
openWindow(id: "window")
}) {
Image(systemName: "plus")
.padding()
}
.buttonBorderShape(.circle)
.tint(.clear)
.padding()
}
.glassBackgroundEffect(in: .capsule)
}
}
#Preview {
Rectangle()
.ornament(attachmentAnchor: .scene(.bottom)) {
WindowToolbarView(title: "Window Title", icon: nil)
}
}