Skip to content

Commit 22b5b93

Browse files
committed
Adjust Task Notification View
1 parent c7c30af commit 22b5b93

File tree

4 files changed

+58
-42
lines changed

4 files changed

+58
-42
lines changed

CodeEdit/Features/ActivityViewer/ActivityViewer.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ struct ActivityViewer: View {
3737
content
3838
.fixedSize(horizontal: false, vertical: false)
3939
.padding(.horizontal, 4)
40+
// TaskNotificationView doesn't have it's own padding
41+
// Also this padding seems weird. However, we want the spinning circle to be padded with the same
42+
// amount from both the top and bottom, as well as the trailing edge. So despite it not being exactly
43+
// the same it *looks* correctly padded
44+
.padding(.trailing, 8)
45+
.clipShape(Capsule())
4046
} else {
4147
content
4248
.fixedSize(horizontal: false, vertical: false)

CodeEdit/Features/ActivityViewer/Notifications/TaskNotificationView.swift

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,35 @@ struct TaskNotificationView: View {
1717

1818
var body: some View {
1919
ZStack {
20-
if let notification {
21-
HStack {
22-
Text(notification.title)
23-
.font(.subheadline)
24-
.transition(
25-
.asymmetric(insertion: .move(edge: .top), removal: .move(edge: .bottom))
26-
.combined(with: .opacity)
27-
)
28-
.id("NotificationTitle" + notification.title)
29-
30-
if notification.isLoading {
31-
CECircularProgressView(
32-
progress: notification.percentage,
33-
currentTaskCount: taskNotificationHandler.notifications.count
34-
)
35-
.padding(.horizontal, -1)
36-
.frame(height: 16)
37-
} else {
38-
if taskNotificationHandler.notifications.count > 1 {
39-
Text("\(taskNotificationHandler.notifications.count)")
40-
.font(.caption)
41-
.padding(5)
42-
.background(
43-
Circle()
44-
.foregroundStyle(.gray)
45-
.opacity(0.2)
46-
)
47-
.padding(-5)
48-
}
20+
HStack {
21+
if let notification {
22+
HStack {
23+
Text(notification.title)
24+
.font(.subheadline)
25+
.transition(
26+
.asymmetric(insertion: .move(edge: .top), removal: .move(edge: .bottom))
27+
.combined(with: .opacity)
28+
)
29+
.id("NotificationTitle" + notification.title)
4930
}
31+
.transition(.opacity.combined(with: .move(edge: .trailing)))
32+
33+
loaderView(notification: notification)
34+
.transition(.opacity)
35+
.id("Loader")
36+
} else {
37+
Text("")
38+
.id("Loader")
5039
}
51-
.transition(.opacity.combined(with: .move(edge: .trailing)))
52-
.opacity(activeState == .inactive ? 0.4 : 1.0)
53-
.padding(3)
54-
.padding(-3)
55-
.padding(.trailing, 3)
56-
.popover(isPresented: $isPresented, arrowEdge: .bottom) {
57-
TaskNotificationsDetailView(taskNotificationHandler: taskNotificationHandler)
58-
}
59-
.onTapGesture {
60-
self.isPresented.toggle()
61-
}
40+
}
41+
.opacity(activeState == .inactive ? 0.4 : 1.0)
42+
.padding(3)
43+
.padding(-3)
44+
.popover(isPresented: $isPresented, arrowEdge: .bottom) {
45+
TaskNotificationsDetailView(taskNotificationHandler: taskNotificationHandler)
46+
}
47+
.onTapGesture {
48+
self.isPresented.toggle()
6249
}
6350
}
6451
.animation(.easeInOut, value: notification)
@@ -69,6 +56,29 @@ struct TaskNotificationView: View {
6956
}
7057
}
7158

59+
@ViewBuilder
60+
private func loaderView(notification: TaskNotificationModel) -> some View {
61+
if notification.isLoading {
62+
CECircularProgressView(
63+
progress: notification.percentage,
64+
currentTaskCount: taskNotificationHandler.notifications.count
65+
)
66+
.padding(.horizontal, -1)
67+
.frame(height: 16)
68+
} else {
69+
if taskNotificationHandler.notifications.count > 1 {
70+
Text("\(taskNotificationHandler.notifications.count)")
71+
.font(.caption)
72+
.padding(5)
73+
.background(
74+
Circle()
75+
.foregroundStyle(.gray)
76+
.opacity(0.2)
77+
)
78+
.padding(-5)
79+
}
80+
}
81+
}
7282
}
7383

7484
#Preview {

CodeEdit/Features/ActivityViewer/Tasks/SchemeDropDownView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct SchemeDropDownView: View {
8080
.background {
8181
Color(nsColor: colorScheme == .dark ? .white : .black)
8282
.opacity(isHoveringScheme || isSchemePopOverPresented ? 0.05 : 0)
83-
.clipShape(Capsule(style: .continuous))
83+
.clipShape(Capsule())
8484
}
8585
}
8686

CodeEdit/Features/ActivityViewer/Tasks/TaskDropDownView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct TaskDropDownView: View {
5858
.background {
5959
Color(nsColor: colorScheme == .dark ? .white : .black)
6060
.opacity(isHoveringTasks || isTaskPopOverPresented ? 0.05 : 0)
61-
.clipShape(Capsule(style: .continuous))
61+
.clipShape(Capsule())
6262
}
6363
}
6464

0 commit comments

Comments
 (0)