Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8f6d360

Browse files
Update design of activity viewer
1 parent e8b1bf5 commit 8f6d360

File tree

4 files changed

+38
-102
lines changed

4 files changed

+38
-102
lines changed

β€ŽCodeEdit/Features/ActivityViewer/ActivityViewer.swiftβ€Ž

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct ActivityViewer: View {
1313
var colorScheme
1414

1515
@ObservedObject var taskNotificationHandler: TaskNotificationHandler
16+
1617
var body: some View {
1718
HStack {
1819
HStack(spacing: 0) {
@@ -27,13 +28,8 @@ struct ActivityViewer: View {
2728
}
2829
.padding(.horizontal, 10)
2930
.background {
30-
if colorScheme == .dark {
31-
RoundedRectangle(cornerRadius: 5)
32-
.opacity(0.10)
33-
} else {
34-
RoundedRectangle(cornerRadius: 5)
35-
.opacity(0.1)
36-
}
31+
RoundedRectangle(cornerRadius: 5)
32+
.opacity(0.1)
3733
}
3834
.frame(minWidth: 200, idealWidth: 680)
3935
}

β€ŽCodeEdit/Features/ActivityViewer/CustomLoadingRingView.swiftβ€Ž

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import SwiftUI
1010
struct CustomLoadingRingView: View {
1111
@State private var isAnimating = false
1212
@State private var previousValue: Bool = false
13+
1314
var progress: Double?
14-
var currentTaskCount: Int
15+
var currentTaskCount: Int=1
1516

1617
let lineWidth: CGFloat = 2
18+
1719
var body: some View {
1820
Circle()
1921
.stroke(style: StrokeStyle(lineWidth: lineWidth))
@@ -22,12 +24,12 @@ struct CustomLoadingRingView: View {
2224
if let progress = progress {
2325
Circle()
2426
.trim(from: 0, to: progress)
25-
.stroke(Color.blue.gradient, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round))
27+
.stroke(Color.accentColor, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round))
2628
.animation(.easeInOut, value: progress)
2729
} else {
2830
Circle()
2931
.trim(from: 0, to: 0.5)
30-
.stroke(Color.blue.gradient, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round))
32+
.stroke(Color.accentColor, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round))
3133
.rotationEffect(
3234
previousValue ?
3335
.degrees(isAnimating ? 0 : -360)

β€ŽCodeEdit/Features/ActivityViewer/TaskNotificationView.swiftβ€Ž

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ struct TaskNotificationView: View {
2323
progress: notification.percentage,
2424
currentTaskCount: taskNotificationHandler.notifications.count
2525
)
26-
.padding(.leading, 5)
2726
.frame(height: 15)
27+
.popover(isPresented: $isPresented) {
28+
TaskNotificationsDetailView(taskNotificationHandler: taskNotificationHandler)
29+
}
30+
.contentShape(Rectangle())
31+
.onTapGesture {
32+
self.isPresented.toggle()
33+
}
2834
} else {
2935
if taskNotificationHandler.notifications.count > 1 {
3036
Text("\(taskNotificationHandler.notifications.count)")
@@ -37,26 +43,10 @@ struct TaskNotificationView: View {
3743
}
3844
.animation(.easeInOut, value: notification)
3945
.padding(3)
40-
.background {
41-
if hovered {
42-
RoundedRectangle(cornerRadius: 5)
43-
.tint(.gray)
44-
.foregroundStyle(.ultraThickMaterial)
45-
}
46-
}
4746
.onHover { isHovered in
4847
self.hovered = isHovered
4948
}
5049
.padding(-3)
51-
.popover(isPresented: $isPresented) {
52-
TaskNotificationsDetailView(taskNotificationHandler: taskNotificationHandler)
53-
}.onTapGesture {
54-
self.isPresented.toggle()
55-
}
5650
}
5751
}
5852
}
59-
60-
#Preview {
61-
TaskNotificationView(taskNotificationHandler: TaskNotificationHandler())
62-
}

β€ŽCodeEdit/Features/ActivityViewer/TaskNotificationsDetailView.swiftβ€Ž

Lines changed: 23 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -9,100 +9,48 @@ import SwiftUI
99

1010
struct TaskNotificationsDetailView: View {
1111
@ObservedObject var taskNotificationHandler: TaskNotificationHandler
12+
1213
@State private var selectedTaskNotificationIndex: Int = 0
14+
1315
var body: some View {
1416
ScrollView {
1517
VStack(alignment: .leading) {
1618
if let selected =
1719
taskNotificationHandler
1820
.notifications[safe: selectedTaskNotificationIndex] {
19-
Text(selected.title)
20-
.font(.headline)
21-
22-
Text(selected.id)
23-
.foregroundStyle(.secondary)
24-
.font(.system(size: 8))
25-
26-
Divider()
27-
.padding(.vertical, 5)
28-
29-
if let message = selected.message, !message.isEmpty {
30-
Text(message)
31-
.fixedSize(horizontal: false, vertical: true)
32-
.transition(.identity)
33-
} else {
34-
Text("No Details")
35-
}
36-
37-
if selected.isLoading {
38-
if let percentage = selected.percentage {
39-
ProgressView(value: percentage) {
40-
// Text("Progress")
41-
} currentValueLabel: {
42-
Text("\(String(format: "%.0f", percentage * 100))%")
43-
}.padding(.top, 5)
44-
} else {
45-
ProgressView()
46-
.progressViewStyle(.linear)
47-
.padding(.top, 5)
48-
}
49-
}
50-
51-
Spacer()
52-
Divider()
5321

5422
HStack {
55-
Button(action: {
56-
withAnimation {
57-
selectedTaskNotificationIndex -= 1
58-
}
59-
}, label: {
60-
Image(systemName: "chevron.left")
61-
})
62-
.disabled(
63-
selectedTaskNotificationIndex - 1 < 0
64-
)
65-
66-
Spacer()
67-
68-
Text("\(selectedTaskNotificationIndex + 1)")
69-
70-
Spacer()
23+
if selected.isLoading {
24+
CustomLoadingRingView(
25+
progress: selected.percentage,
26+
currentTaskCount: taskNotificationHandler.notifications.count
27+
)
28+
.frame(height: 16)
29+
}
7130

72-
Button(action: {
73-
withAnimation {
74-
selectedTaskNotificationIndex += 1
31+
VStack(alignment: .leading) {
32+
Text(selected.title)
33+
if let message = selected.message, !message.isEmpty {
34+
Text(message)
35+
.font(.footnote)
36+
.foregroundStyle(.secondary)
37+
.fixedSize(horizontal: false, vertical: true)
38+
.transition(.identity)
7539
}
76-
}, label: {
77-
Image(systemName: "chevron.right")
78-
})
79-
.disabled(
80-
selectedTaskNotificationIndex + 1 == taskNotificationHandler.notifications.count
81-
)
82-
}.animation(.spring, value: selected)
83-
} else {
84-
Text("Task done")
85-
.font(.headline)
86-
87-
Divider()
88-
.padding(.vertical, 5)
89-
90-
Text("The task has been deleted and is no longer available.")
91-
.fixedSize(horizontal: false, vertical: true)
92-
.transition(.identity)
40+
}
41+
.frame(maxWidth: .infinity, alignment: .leading)
42+
}
9343
}
9444
}
45+
.padding(.horizontal, 10)
46+
.padding(.vertical, 6)
9547
}
9648
.padding(5)
97-
.frame(width: 220)
49+
.frame(width: 300)
9850
.onChange(of: taskNotificationHandler.notifications) { newValue in
9951
if selectedTaskNotificationIndex >= newValue.count {
10052
selectedTaskNotificationIndex = 0
10153
}
10254
}
10355
}
10456
}
105-
106-
#Preview {
107-
TaskNotificationsDetailView(taskNotificationHandler: TaskNotificationHandler())
108-
}

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /