diff --git a/CodeEdit/Features/ActivityViewer/ActivityViewer.swift b/CodeEdit/Features/ActivityViewer/ActivityViewer.swift index 51cd6650b..705b4c893 100644 --- a/CodeEdit/Features/ActivityViewer/ActivityViewer.swift +++ b/CodeEdit/Features/ActivityViewer/ActivityViewer.swift @@ -13,6 +13,7 @@ struct ActivityViewer: View { var colorScheme @ObservedObject var taskNotificationHandler: TaskNotificationHandler + var body: some View { HStack { HStack(spacing: 0) { @@ -27,13 +28,8 @@ struct ActivityViewer: View { } .padding(.horizontal, 10) .background { - if colorScheme == .dark { - RoundedRectangle(cornerRadius: 5) - .opacity(0.10) - } else { - RoundedRectangle(cornerRadius: 5) - .opacity(0.1) - } + RoundedRectangle(cornerRadius: 5) + .opacity(0.1) } .frame(minWidth: 200, idealWidth: 680) } diff --git a/CodeEdit/Features/ActivityViewer/CustomLoadingRingView.swift b/CodeEdit/Features/ActivityViewer/CustomLoadingRingView.swift index a7d04f087..0a29e5811 100644 --- a/CodeEdit/Features/ActivityViewer/CustomLoadingRingView.swift +++ b/CodeEdit/Features/ActivityViewer/CustomLoadingRingView.swift @@ -10,10 +10,12 @@ import SwiftUI struct CustomLoadingRingView: View { @State private var isAnimating = false @State private var previousValue: Bool = false + var progress: Double? - var currentTaskCount: Int + var currentTaskCount: Int = 1 let lineWidth: CGFloat = 2 + var body: some View { Circle() .stroke(style: StrokeStyle(lineWidth: lineWidth)) @@ -22,12 +24,12 @@ struct CustomLoadingRingView: View { if let progress = progress { Circle() .trim(from: 0, to: progress) - .stroke(Color.blue.gradient, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) + .stroke(Color.accentColor, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) .animation(.easeInOut, value: progress) } else { Circle() .trim(from: 0, to: 0.5) - .stroke(Color.blue.gradient, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) + .stroke(Color.accentColor, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) .rotationEffect( previousValue ? .degrees(isAnimating ? 0 : -360) diff --git a/CodeEdit/Features/ActivityViewer/TaskNotificationView.swift b/CodeEdit/Features/ActivityViewer/TaskNotificationView.swift index cb8b5f892..fafa20034 100644 --- a/CodeEdit/Features/ActivityViewer/TaskNotificationView.swift +++ b/CodeEdit/Features/ActivityViewer/TaskNotificationView.swift @@ -23,8 +23,14 @@ struct TaskNotificationView: View { progress: notification.percentage, currentTaskCount: taskNotificationHandler.notifications.count ) - .padding(.leading, 5) .frame(height: 15) + .popover(isPresented: $isPresented) { + TaskNotificationsDetailView(taskNotificationHandler: taskNotificationHandler) + } + .contentShape(Rectangle()) + .onTapGesture { + self.isPresented.toggle() + } } else { if taskNotificationHandler.notifications.count> 1 { Text("\(taskNotificationHandler.notifications.count)") @@ -37,26 +43,10 @@ struct TaskNotificationView: View { } .animation(.easeInOut, value: notification) .padding(3) - .background { - if hovered { - RoundedRectangle(cornerRadius: 5) - .tint(.gray) - .foregroundStyle(.ultraThickMaterial) - } - } .onHover { isHovered in self.hovered = isHovered } .padding(-3) - .popover(isPresented: $isPresented) { - TaskNotificationsDetailView(taskNotificationHandler: taskNotificationHandler) - }.onTapGesture { - self.isPresented.toggle() - } } } } - -#Preview { - TaskNotificationView(taskNotificationHandler: TaskNotificationHandler()) -} diff --git a/CodeEdit/Features/ActivityViewer/TaskNotificationsDetailView.swift b/CodeEdit/Features/ActivityViewer/TaskNotificationsDetailView.swift index 9f11d20d4..b8c59e816 100644 --- a/CodeEdit/Features/ActivityViewer/TaskNotificationsDetailView.swift +++ b/CodeEdit/Features/ActivityViewer/TaskNotificationsDetailView.swift @@ -9,92 +9,44 @@ import SwiftUI struct TaskNotificationsDetailView: View { @ObservedObject var taskNotificationHandler: TaskNotificationHandler + @State private var selectedTaskNotificationIndex: Int = 0 + var body: some View { ScrollView { VStack(alignment: .leading) { if let selected = taskNotificationHandler .notifications[safe: selectedTaskNotificationIndex] { - Text(selected.title) - .font(.headline) - - Text(selected.id) - .foregroundStyle(.secondary) - .font(.system(size: 8)) - - Divider() - .padding(.vertical, 5) - - if let message = selected.message, !message.isEmpty { - Text(message) - .fixedSize(horizontal: false, vertical: true) - .transition(.identity) - } else { - Text("No Details") - } - - if selected.isLoading { - if let percentage = selected.percentage { - ProgressView(value: percentage) { - // Text("Progress") - } currentValueLabel: { - Text("\(String(format: "%.0f", percentage * 100))%") - }.padding(.top, 5) - } else { - ProgressView() - .progressViewStyle(.linear) - .padding(.top, 5) - } - } - - Spacer() - Divider() HStack { - Button(action: { - withAnimation { - selectedTaskNotificationIndex -= 1 - } - }, label: { - Image(systemName: "chevron.left") - }) - .disabled( - selectedTaskNotificationIndex - 1 < 0 - ) - - Spacer() - - Text("\(selectedTaskNotificationIndex + 1)") - - Spacer() + if selected.isLoading { + CustomLoadingRingView( + progress: selected.percentage, + currentTaskCount: taskNotificationHandler.notifications.count + ) + .frame(height: 16) + } - Button(action: { - withAnimation { - selectedTaskNotificationIndex += 1 + VStack(alignment: .leading) { + Text(selected.title) + if let message = selected.message, !message.isEmpty { + Text(message) + .font(.footnote) + .foregroundStyle(.secondary) + .fixedSize(horizontal: false, vertical: true) + .transition(.identity) } - }, label: { - Image(systemName: "chevron.right") - }) - .disabled( - selectedTaskNotificationIndex + 1 == taskNotificationHandler.notifications.count - ) - }.animation(.spring, value: selected) - } else { - Text("Task done") - .font(.headline) - - Divider() - .padding(.vertical, 5) - - Text("The task has been deleted and is no longer available.") - .fixedSize(horizontal: false, vertical: true) - .transition(.identity) + } + .frame(maxWidth: .infinity, alignment: .leading) + } } } + .padding(.horizontal, 10) + .padding(.vertical, 6) } .padding(5) - .frame(width: 220) + .frame(width: 300) .onChange(of: taskNotificationHandler.notifications) { newValue in if selectedTaskNotificationIndex>= newValue.count { selectedTaskNotificationIndex = 0 @@ -102,7 +54,3 @@ struct TaskNotificationsDetailView: View { } } } - -#Preview { - TaskNotificationsDetailView(taskNotificationHandler: TaskNotificationHandler()) -}

AltStyle によって変換されたページ (->オリジナル) /