Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Activity Viewer #1769

Merged
merged 7 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@
61538B902B111FE800A88846 /* String+AppearancesOfSubstring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61538B8F2B111FE800A88846 /* String+AppearancesOfSubstring.swift */; };
61538B932B11201900A88846 /* String+Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61538B922B11201900A88846 /* String+Character.swift */; };
615AA21A2B0CFD480013FCCC /* LazyStringLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 615AA2192B0CFD480013FCCC /* LazyStringLoader.swift */; };
617DB3D02C25AFAE00B58BFE /* TaskNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3CF2C25AFAE00B58BFE /* TaskNotificationHandler.swift */; };
617DB3D32C25AFEA00B58BFE /* TaskNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3D22C25AFEA00B58BFE /* TaskNotificationModel.swift */; };
617DB3D62C25B02D00B58BFE /* TaskNotificationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3D52C25B02D00B58BFE /* TaskNotificationView.swift */; };
617DB3D82C25B04D00B58BFE /* CustomLoadingRingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3D72C25B04D00B58BFE /* CustomLoadingRingView.swift */; };
617DB3DA2C25B07F00B58BFE /* TaskNotificationsDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3D92C25B07F00B58BFE /* TaskNotificationsDetailView.swift */; };
617DB3DC2C25B14A00B58BFE /* ActivityViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3DB2C25B14A00B58BFE /* ActivityViewer.swift */; };
617DB3DF2C25E13800B58BFE /* TaskNotificationHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3DE2C25E13800B58BFE /* TaskNotificationHandlerTests.swift */; };
6195E30D2B64044F007261CA /* WorkspaceDocument+SearchState+FindTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6195E30C2B64044F007261CA /* WorkspaceDocument+SearchState+FindTests.swift */; };
6195E30F2B640474007261CA /* WorkspaceDocument+SearchState+FindAndReplaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6195E30E2B640474007261CA /* WorkspaceDocument+SearchState+FindAndReplaceTests.swift */; };
6195E3112B640485007261CA /* WorkspaceDocument+SearchState+IndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6195E3102B640485007261CA /* WorkspaceDocument+SearchState+IndexTests.swift */; };
Expand Down Expand Up @@ -863,6 +870,13 @@
61538B8F2B111FE800A88846 /* String+AppearancesOfSubstring.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+AppearancesOfSubstring.swift"; sourceTree = "<group>"; };
61538B922B11201900A88846 /* String+Character.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Character.swift"; sourceTree = "<group>"; };
615AA2192B0CFD480013FCCC /* LazyStringLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyStringLoader.swift; sourceTree = "<group>"; };
617DB3CF2C25AFAE00B58BFE /* TaskNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationHandler.swift; sourceTree = "<group>"; };
617DB3D22C25AFEA00B58BFE /* TaskNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationModel.swift; sourceTree = "<group>"; };
617DB3D52C25B02D00B58BFE /* TaskNotificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationView.swift; sourceTree = "<group>"; };
617DB3D72C25B04D00B58BFE /* CustomLoadingRingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLoadingRingView.swift; sourceTree = "<group>"; };
617DB3D92C25B07F00B58BFE /* TaskNotificationsDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationsDetailView.swift; sourceTree = "<group>"; };
617DB3DB2C25B14A00B58BFE /* ActivityViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityViewer.swift; sourceTree = "<group>"; };
617DB3DE2C25E13800B58BFE /* TaskNotificationHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationHandlerTests.swift; sourceTree = "<group>"; };
6195E30C2B64044F007261CA /* WorkspaceDocument+SearchState+FindTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+SearchState+FindTests.swift"; sourceTree = "<group>"; };
6195E30E2B640474007261CA /* WorkspaceDocument+SearchState+FindAndReplaceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+SearchState+FindAndReplaceTests.swift"; sourceTree = "<group>"; };
6195E3102B640485007261CA /* WorkspaceDocument+SearchState+IndexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+SearchState+IndexTests.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1461,6 +1475,7 @@
children = (
582213EE2918345500EFE361 /* About */,
588847642992A30900996D95 /* CEWorkspace */,
617DB3CE2C25AF5B00B58BFE /* ActivityViewer */,
587B9D7529300ABD00AC7927 /* CodeEditUI */,
58FD7603291EA1CB0051D6E4 /* Commands */,
043C321227E31FE8006AE443 /* Documents */,
Expand Down Expand Up @@ -1787,6 +1802,7 @@
children = (
283BDCC22972F211002AFF81 /* Acknowledgements */,
4EE96EC82960562000FFBEA8 /* Documents */,
617DB3DD2C25E11500B58BFE /* ActivityViewer */,
583E527429361B39001AB554 /* CodeEditUI */,
587B612C2934199800D5CD8F /* CodeFile */,
613899BD2B6E70E200A5CAF6 /* Search */,
Expand Down Expand Up @@ -2382,6 +2398,35 @@
path = FuzzySearch;
sourceTree = "<group>";
};
617DB3CE2C25AF5B00B58BFE /* ActivityViewer */ = {
isa = PBXGroup;
children = (
617DB3DB2C25B14A00B58BFE /* ActivityViewer.swift */,
617DB3D52C25B02D00B58BFE /* TaskNotificationView.swift */,
617DB3D92C25B07F00B58BFE /* TaskNotificationsDetailView.swift */,
617DB3D72C25B04D00B58BFE /* CustomLoadingRingView.swift */,
617DB3CF2C25AFAE00B58BFE /* TaskNotificationHandler.swift */,
617DB3D12C25AFD300B58BFE /* Models */,
);
path = ActivityViewer;
sourceTree = "<group>";
};
617DB3D12C25AFD300B58BFE /* Models */ = {
isa = PBXGroup;
children = (
617DB3D22C25AFEA00B58BFE /* TaskNotificationModel.swift */,
);
path = Models;
sourceTree = "<group>";
};
617DB3DD2C25E11500B58BFE /* ActivityViewer */ = {
isa = PBXGroup;
children = (
617DB3DE2C25E13800B58BFE /* TaskNotificationHandlerTests.swift */,
);
path = ActivityViewer;
sourceTree = "<group>";
};
66AF6CE02BF17CB100D83C9D /* ViewModels */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3403,6 +3448,7 @@
04BA7C142AE2AA7300584E1C /* GitCloneViewModel.swift in Sources */,
B61A606129F188AB009B43F9 /* ExternalLink.swift in Sources */,
587B9E9729301D8F00AC7927 /* BitBucketAccount+Token.swift in Sources */,
617DB3D62C25B02D00B58BFE /* TaskNotificationView.swift in Sources */,
587B9E7729301D8F00AC7927 /* String+PercentEncoding.swift in Sources */,
587B9E5B29301D8F00AC7927 /* GitCheckoutBranchView.swift in Sources */,
2813F93827ECC4AA00E305E4 /* FindNavigatorResultList.swift in Sources */,
Expand Down Expand Up @@ -3484,6 +3530,7 @@
58798284292ED0FB0085B254 /* TerminalEmulatorView.swift in Sources */,
B6C4F2AC2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift in Sources */,
6C82D6B329BFD88700495C54 /* NavigateCommands.swift in Sources */,
617DB3D82C25B04D00B58BFE /* CustomLoadingRingView.swift in Sources */,
B6CFD8112C20A8EE00E63F1A /* NSFont+WithWeight.swift in Sources */,
B66A4E4C29C9179B004573B4 /* CodeEditApp.swift in Sources */,
661EF7B82BEE215300C3E577 /* ImageFileView.swift in Sources */,
Expand Down Expand Up @@ -3605,6 +3652,7 @@
581550D029FBD30400684881 /* FileSystemTableViewCell.swift in Sources */,
B607183F2B17DB07009CDAB4 /* SourceControlNavigatorRepositoryView+contextMenu.swift in Sources */,
B62AEDD42A27B29F009A9F52 /* PaneToolbar.swift in Sources */,
617DB3D32C25AFEA00B58BFE /* TaskNotificationModel.swift in Sources */,
D7E201B227E8D50000CB86D0 /* FindNavigatorForm.swift in Sources */,
287776E927E34BC700D46668 /* EditorTabBarView.swift in Sources */,
B60BE8BD297A167600841125 /* AcknowledgementRowView.swift in Sources */,
Expand Down Expand Up @@ -3634,6 +3682,7 @@
613899B52B6E700300A5CAF6 /* FuzzySearchModels.swift in Sources */,
58D01C94293167DC00C5B6B4 /* Color+HEX.swift in Sources */,
6C578D8729CD345900DC73B2 /* ExtensionSceneView.swift in Sources */,
617DB3D02C25AFAE00B58BFE /* TaskNotificationHandler.swift in Sources */,
B640A9A129E2188F00715F20 /* View+NavigationBarBackButtonVisible.swift in Sources */,
587B9E7929301D8F00AC7927 /* GitHubIssueRouter.swift in Sources */,
587B9E8029301D8F00AC7927 /* GitHubConfiguration.swift in Sources */,
Expand Down Expand Up @@ -3700,6 +3749,7 @@
58798218292D92370085B254 /* String+SafeOffset.swift in Sources */,
6C6BD70429CD17B600235D17 /* ExtensionsManager.swift in Sources */,
587B9E6129301D8F00AC7927 /* GitLabOAuthConfiguration.swift in Sources */,
617DB3DC2C25B14A00B58BFE /* ActivityViewer.swift in Sources */,
587B9E6229301D8F00AC7927 /* GitLabConfiguration.swift in Sources */,
61A53A7E2B4449870093BF8A /* WorkspaceDocument+Find.swift in Sources */,
6CABB19E29C5591D00340467 /* NSTableViewWrapper.swift in Sources */,
Expand Down Expand Up @@ -3810,6 +3860,7 @@
04C3255B2801F86400C8DA2D /* ProjectNavigatorViewController.swift in Sources */,
587B9E6029301D8F00AC7927 /* GitLabOAuthRouter.swift in Sources */,
B6AB09B32AB919CF0003A3A6 /* View+actionBar.swift in Sources */,
617DB3DA2C25B07F00B58BFE /* TaskNotificationsDetailView.swift in Sources */,
6C05A8AF284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift in Sources */,
588847632992A2A200996D95 /* CEWorkspaceFile.swift in Sources */,
6C2C155D29B4F4E500EA60A5 /* SplitViewReader.swift in Sources */,
Expand All @@ -3825,6 +3876,7 @@
files = (
583E528C29361B39001AB554 /* CodeEditUITests.swift in Sources */,
613053652B23A49300D767E3 /* TemporaryFile.swift in Sources */,
617DB3DF2C25E13800B58BFE /* TaskNotificationHandlerTests.swift in Sources */,
587B60F82934124200D5CD8F /* CEWorkspaceFileManagerTests.swift in Sources */,
6130535F2B23A31300D767E3 /* MemorySearchTests.swift in Sources */,
587B61012934170A00D5CD8F /* UnitTests_Extensions.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

final class AcknowledgementsViewModel: ObservableObject {

@Published private (set) var acknowledgements: [AcknowledgementDependency]
@Published private(set) var acknowledgements: [AcknowledgementDependency]

var indexedAcknowledgements: [(index: Int, acknowledgement: AcknowledgementDependency)] {
return Array(zip(acknowledgements.indices, acknowledgements))
Expand Down
42 changes: 42 additions & 0 deletions CodeEdit/Features/ActivityViewer/ActivityViewer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// ActivityViewer.swift
// CodeEdit
//
// Created by Tommy Ludwig on 21.06.24.
//

import SwiftUI

/// A view that shows the activity bar and the current status of any executed task
struct ActivityViewer: View {
@Environment(\.colorScheme)
var colorScheme

@ObservedObject var taskNotificationHandler: TaskNotificationHandler
var body: some View {
HStack {
HStack(spacing: 0) {
// This is only a placeholder for the task popover(coming in the next pr)
Rectangle()
.frame(height: 22)
.hidden()

Spacer()

TaskNotificationView(taskNotificationHandler: taskNotificationHandler)
}
.padding(.horizontal, 10)
.background {
if colorScheme == .dark {
RoundedRectangle(cornerRadius: 5)
.opacity(0.10)
} else {
RoundedRectangle(cornerRadius: 5)
.opacity(0.1)
}
}
.frame(minWidth: 200, idealWidth: 680)
}
.frame(height: 22)
}
}
62 changes: 62 additions & 0 deletions CodeEdit/Features/ActivityViewer/CustomLoadingRingView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// CustomLoadingRingView.swift
// CodeEdit
//
// Created by Tommy Ludwig on 21.06.24.
//

import SwiftUI

struct CustomLoadingRingView: View {
@State private var isAnimating = false
@State private var previousValue: Bool = false
var progress: Double?
var currentTaskCount: Int

let lineWidth: CGFloat = 2
var body: some View {
Circle()
.stroke(style: StrokeStyle(lineWidth: lineWidth))
.foregroundStyle(.tertiary)
.overlay {
if let progress = progress {
Circle()
.trim(from: 0, to: progress)
.stroke(Color.blue.gradient, 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))
.rotationEffect(
previousValue ?
.degrees(isAnimating ? 0 : -360)
: .degrees(isAnimating ? 360 : 0)
)
.animation(Animation.linear(duration: 1).repeatForever(autoreverses: false), value: isAnimating)
.onAppear {
self.previousValue = isAnimating
self.isAnimating.toggle()
}
}
}
.rotationEffect(.degrees(-90))
.overlay {
if currentTaskCount > 1 {
Text("\(currentTaskCount)")
.font(.caption)
}
}
}
}

#Preview {
Group {
CustomLoadingRingView(currentTaskCount: 1)
.frame(width: 22, height: 22)

CustomLoadingRingView(progress: 0.65, currentTaskCount: 1)
.frame(width: 22, height: 22)
}
.padding()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// TaskNotificationModel.swift
// CodeEdit
//
// Created by Tommy Ludwig on 21.06.24.
//

import Foundation

/// Represents a notifications or tasks, that are displayed in the activity viewer
struct TaskNotificationModel: Equatable {
var id: String
var title: String
var message: String?
var percentage: Double?
var isLoading: Bool = false
}
Loading
Loading