-
-
Notifications
You must be signed in to change notification settings - Fork 269
Expand file tree
/
Copy pathFullscreenNotification.swift
More file actions
90 lines (79 loc) · 2.69 KB
/
FullscreenNotification.swift
File metadata and controls
90 lines (79 loc) · 2.69 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// FullscreenNotification.swift
// MeetingBar
//
// Created by Andrii Leitsius on 31.07.2023.
// Copyright © 2023 Andrii Leitsius. All rights reserved.
//
import Defaults
import SwiftUI
struct FullscreenNotification: View {
var event: MBEvent
var window: NSWindow?
var body: some View {
ZStack {
Rectangle.semiOpaqueWindow()
VStack {
HStack {
if event.meetingLink != nil {
Image(nsImage: getIconForMeetingService(event.meetingLink?.service))
.resizable().frame(width: 25, height: 25)
}
Text(event.title).font(.title)
}
VStack(spacing: 10) {
Text(getEventDateString(event))
}.padding(15)
// display location of the event, very useful if you
// have a lot of meetings in a building with a lot of meeting rooms
if let location = event.location {
VStack(spacing: 10) {
Text(location)
}.padding(15)
}
HStack(spacing: 30) {
Button(action: dismiss) {
Text("general_close".loco()).padding(.vertical, 5).padding(.horizontal, 20)
}
if event.meetingLink != nil {
Button(action: joinEvent) {
Text("notifications_meetingbar_join_event_action".loco()).padding(.vertical, 5).padding(.horizontal, 25)
}.background(Color.accentColor).cornerRadius(5)
}
}
}
}
.colorScheme(.dark)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
func dismiss() {
window?.close()
}
func joinEvent() {
event.openMeeting()
window?.close()
}
}
public extension View {
static func semiOpaqueWindow() -> some View {
if #available(macOS 11.0, *) {
return VisualEffect().ignoresSafeArea()
} else {
return VisualEffect()
}
}
}
struct VisualEffect: NSViewRepresentable {
func makeNSView(context _: Context) -> NSView {
let view = NSVisualEffectView()
view.material = .underWindowBackground
view.blendingMode = .behindWindow
view.state = .active
return view
}
func updateNSView(_: NSView, context _: Context) {}
}
#Preview {
FullscreenNotification(event: generateFakeEvent(includeMeetingLink: true), window: nil)
FullscreenNotification(event: generateFakeEvent(includeMeetingLink: false), window: nil)
}