-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathNESNotificationView.swift
More file actions
66 lines (56 loc) · 2.23 KB
/
NESNotificationView.swift
File metadata and controls
66 lines (56 loc) · 2.23 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
import SwiftUI
import ComposableArchitecture
import Logger
struct NESNotificationView: View {
let store: StoreOf<NESSuggestionPanelFeature>
init(store: StoreOf<NESSuggestionPanelFeature>) {
self.store = store
}
var body: some View {
WithPerceptionTracking {
if store.isPanelOutOfFrame,
!store.closeNotificationByUser,
store.nesContent != nil {
let fontSize = store.lineFontSize
let scale = store.fontSizeScale
HStack(spacing: 8) {
Image("EditSparkle")
.resizable()
.scaledToFit()
.font(.system(size: calcImageFontSize(fontSize, scale), weight: .medium))
HStack(spacing: 4 * scale) {
Text("Press")
Text("Tab")
.foregroundStyle(.secondary)
Text("to jump to Next Edit Suggestion")
}
.font(.system(size: fontSize, weight: .medium))
Button(action: {
store.send(.onUserCloseNotification)
}) {
Image(systemName: "xmark")
}
.buttonStyle(.plain)
.font(.system(size: calcImageFontSize(fontSize, scale), weight: .medium))
}
.foregroundStyle(Color(NSColor.controlBackgroundColor))
.padding(8)
.background(
RoundedRectangle(cornerRadius: 4)
.fill(.primary)
)
.shadow(
color: Color("NESShadowColor"),
radius: 12,
x: 0,
y: 3
)
.opacity(store.notificationViewOpacity)
}
}
.frame(maxWidth: .infinity, alignment: .center)
}
func calcImageFontSize(_ baseFontSize: CGFloat, _ scale: Double) -> CGFloat {
return baseFontSize + 2 * scale
}
}