Skip to content

Commit cd1bf2d

Browse files
committed
Changed variable name isManuallyShown to isPresented, and notificationOverlay to notificationPanel. Fixed SwiftLint errors.
1 parent c292c7d commit cd1bf2d

File tree

10 files changed

+73
-75
lines changed

10 files changed

+73
-75
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@
589589
B68DE5E02D5A61E5009A43EF /* NotificationBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68DE5D92D5A61E5009A43EF /* NotificationBannerView.swift */; };
590590
B68DE5E22D5A61E5009A43EF /* NotificationToolbarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68DE5DB2D5A61E5009A43EF /* NotificationToolbarItem.swift */; };
591591
B68DE5E32D5A61E5009A43EF /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68DE5DD2D5A61E5009A43EF /* NotificationManager.swift */; };
592-
B68DE5E52D5A7988009A43EF /* NotificationOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68DE5E42D5A7988009A43EF /* NotificationOverlayView.swift */; };
592+
B68DE5E52D5A7988009A43EF /* NotificationPanelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68DE5E42D5A7988009A43EF /* NotificationPanelView.swift */; };
593593
B6966A282C2F683300259C2D /* SourceControlPullView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A272C2F683300259C2D /* SourceControlPullView.swift */; };
594594
B6966A2A2C2F687A00259C2D /* SourceControlFetchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A292C2F687A00259C2D /* SourceControlFetchView.swift */; };
595595
B6966A2E2C3056AD00259C2D /* SourceControlCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A2D2C3056AD00259C2D /* SourceControlCommands.swift */; };
@@ -598,7 +598,7 @@
598598
B6966A342C34996B00259C2D /* SourceControlManager+GitClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A332C34996B00259C2D /* SourceControlManager+GitClient.swift */; };
599599
B696A7E62CFE20C40048CFE1 /* FeatureIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = B696A7E52CFE20C40048CFE1 /* FeatureIcon.swift */; };
600600
B697937A29FF5668002027EC /* AccountsSettingsAccountLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = B697937929FF5668002027EC /* AccountsSettingsAccountLink.swift */; };
601-
B69970322D63E5C700BB132D /* NotificationOverlayViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69970302D63E5C700BB132D /* NotificationOverlayViewModel.swift */; };
601+
B69970322D63E5C700BB132D /* NotificationPanelViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69970302D63E5C700BB132D /* NotificationPanelViewModel.swift */; };
602602
B69BFDC72B0686910050D9A6 /* GitClient+Initiate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69BFDC62B0686910050D9A6 /* GitClient+Initiate.swift */; };
603603
B69D3EDE2C5E85A2005CF43A /* StopTaskToolbarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69D3EDD2C5E85A2005CF43A /* StopTaskToolbarButton.swift */; };
604604
B69D3EE12C5F5357005CF43A /* TaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69D3EE02C5F5357005CF43A /* TaskView.swift */; };
@@ -1290,7 +1290,7 @@
12901290
B68DE5D92D5A61E5009A43EF /* NotificationBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationBannerView.swift; sourceTree = "<group>"; };
12911291
B68DE5DB2D5A61E5009A43EF /* NotificationToolbarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationToolbarItem.swift; sourceTree = "<group>"; };
12921292
B68DE5DD2D5A61E5009A43EF /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; };
1293-
B68DE5E42D5A7988009A43EF /* NotificationOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationOverlayView.swift; sourceTree = "<group>"; };
1293+
B68DE5E42D5A7988009A43EF /* NotificationPanelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationPanelView.swift; sourceTree = "<group>"; };
12941294
B6966A272C2F683300259C2D /* SourceControlPullView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlPullView.swift; sourceTree = "<group>"; };
12951295
B6966A292C2F687A00259C2D /* SourceControlFetchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlFetchView.swift; sourceTree = "<group>"; };
12961296
B6966A2D2C3056AD00259C2D /* SourceControlCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlCommands.swift; sourceTree = "<group>"; };
@@ -1299,7 +1299,7 @@
12991299
B6966A332C34996B00259C2D /* SourceControlManager+GitClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceControlManager+GitClient.swift"; sourceTree = "<group>"; };
13001300
B696A7E52CFE20C40048CFE1 /* FeatureIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureIcon.swift; sourceTree = "<group>"; };
13011301
B697937929FF5668002027EC /* AccountsSettingsAccountLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsSettingsAccountLink.swift; sourceTree = "<group>"; };
1302-
B69970302D63E5C700BB132D /* NotificationOverlayViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationOverlayViewModel.swift; sourceTree = "<group>"; };
1302+
B69970302D63E5C700BB132D /* NotificationPanelViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationPanelViewModel.swift; sourceTree = "<group>"; };
13031303
B69BFDC62B0686910050D9A6 /* GitClient+Initiate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GitClient+Initiate.swift"; sourceTree = "<group>"; };
13041304
B69D3EDD2C5E85A2005CF43A /* StopTaskToolbarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopTaskToolbarButton.swift; sourceTree = "<group>"; };
13051305
B69D3EE02C5F5357005CF43A /* TaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskView.swift; sourceTree = "<group>"; };
@@ -3601,8 +3601,8 @@
36013601
isa = PBXGroup;
36023602
children = (
36033603
B68DE5D92D5A61E5009A43EF /* NotificationBannerView.swift */,
3604+
B68DE5E42D5A7988009A43EF /* NotificationPanelView.swift */,
36043605
B68DE5DB2D5A61E5009A43EF /* NotificationToolbarItem.swift */,
3605-
B68DE5E42D5A7988009A43EF /* NotificationOverlayView.swift */,
36063606
);
36073607
path = Views;
36083608
sourceTree = "<group>";
@@ -3639,7 +3639,7 @@
36393639
B69970312D63E5C700BB132D /* ViewModels */ = {
36403640
isa = PBXGroup;
36413641
children = (
3642-
B69970302D63E5C700BB132D /* NotificationOverlayViewModel.swift */,
3642+
B69970302D63E5C700BB132D /* NotificationPanelViewModel.swift */,
36433643
);
36443644
path = ViewModels;
36453645
sourceTree = "<group>";
@@ -4269,8 +4269,8 @@
42694269
B6B2D7A12CE8797B00379967 /* GitConfigExtensions.swift in Sources */,
42704270
587B9E7329301D8F00AC7927 /* GitRouter.swift in Sources */,
42714271
6C2C156129B4F52F00EA60A5 /* SplitViewModifiers.swift in Sources */,
4272-
B69970322D63E5C700BB132D /* NotificationOverlayViewModel.swift in Sources */,
4273-
B68DE5E52D5A7988009A43EF /* NotificationOverlayView.swift in Sources */,
4272+
B69970322D63E5C700BB132D /* NotificationPanelViewModel.swift in Sources */,
4273+
B68DE5E52D5A7988009A43EF /* NotificationPanelView.swift in Sources */,
42744274
61A53A812B4449F00093BF8A /* WorkspaceDocument+Index.swift in Sources */,
42754275
66AF6CE22BF17CC300D83C9D /* StatusBarViewModel.swift in Sources */,
42764276
30CB648D2C12680F00CC8A9E /* LSPService+Events.swift in Sources */,

CodeEdit/Features/CodeEditUI/Styles/OverlayButtonStyle.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import SwiftUI
22

33
/// A button style for overlay buttons (like close, action buttons in notifications)
44
struct OverlayButtonStyle: ButtonStyle {
5-
@Environment(\.isEnabled) private var isEnabled
6-
@Environment(\.controlActiveState) private var controlActive
7-
5+
@Environment(\.isEnabled)
6+
private var isEnabled
7+
8+
@Environment(\.controlActiveState)
9+
private var controlActive
10+
811
func makeBody(configuration: Configuration) -> some View {
912
configuration.label
1013
.foregroundColor(

CodeEdit/Features/Documents/WorkspaceDocument/WorkspaceDocument.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {
4343
var workspaceSettingsManager: CEWorkspaceSettings?
4444
var taskNotificationHandler: TaskNotificationHandler = TaskNotificationHandler()
4545

46-
@Published var notificationOverlay = NotificationOverlayViewModel()
47-
private var notificationOverlaySubscription: AnyCancellable?
46+
@Published var notificationPanel = NotificationPanelViewModel()
47+
private var notificationPanelSubscription: AnyCancellable?
4848

4949
private var cancellables = Set<AnyCancellable>()
5050

5151
override init() {
5252
super.init()
5353

54-
// Observe changes to notification overlay
55-
notificationOverlaySubscription = notificationOverlay.objectWillChange
54+
// Observe changes to notification panel
55+
notificationPanelSubscription = notificationPanel.objectWillChange
5656
.receive(on: DispatchQueue.main)
5757
.sink { [weak self] _ in
5858
self?.objectWillChange.send()
@@ -62,7 +62,7 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {
6262
deinit {
6363
cancellables.forEach { $0.cancel() }
6464
NotificationCenter.default.removeObserver(self)
65-
notificationOverlaySubscription?.cancel()
65+
notificationPanelSubscription?.cancel()
6666
}
6767

6868
func getFromWorkspaceState(_ key: WorkspaceStateKey) -> Any? {

CodeEdit/Features/InspectorArea/Views/InspectorAreaView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ struct InspectorAreaView: View {
2626

2727
private func updateTabs() {
2828
var tabs: [InspectorTab] = [.file, .gitHistory]
29-
29+
3030
if showInternalDevelopmentInspector {
3131
tabs.append(.internalDevelopment)
3232
}
33-
33+
3434
viewModel.tabItems = tabs + extensionManager
3535
.extensions
3636
.map { ext in

CodeEdit/Features/Notifications/NotificationManager.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ final class NotificationManager: NSObject, ObservableObject {
2828
notifications.filter { !$0.isRead }.count
2929
}
3030

31-
/// Whether there are currently notifications being displayed in the overlay
32-
var hasActiveNotification: Bool {
33-
!notifications.isEmpty
34-
}
35-
3631
/// Posts a new notification
3732
/// - Parameters:
3833
/// - iconSymbol: SF Symbol or CodeEditSymbol name for the notification icon

CodeEdit/Features/Notifications/ViewModels/NotificationOverlayViewModel.swift renamed to CodeEdit/Features/Notifications/ViewModels/NotificationPanelViewModel.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
//
2-
// NotificationOverlayViewModel.swift
2+
// NotificationPanelViewModel.swift
33
// CodeEdit
44
//
55
// Created by Austin Condiff on 2/14/24.
66
//
77

88
import SwiftUI
99

10-
final class NotificationOverlayViewModel: ObservableObject {
11-
/// Currently displayed notifications in the overlay
10+
final class NotificationPanelViewModel: ObservableObject {
11+
/// Currently displayed notifications in the panel
1212
@Published private(set) var activeNotifications: [CENotification] = []
1313

14-
/// Whether notifications were manually shown via toolbar
15-
@Published private(set) var isManuallyShown: Bool = false
14+
/// Whether notifications panel was manually shown via toolbar
15+
@Published private(set) var isPresented: Bool = false
1616

1717
/// Set of hidden notification IDs
1818
@Published private(set) var hiddenNotificationIds: Set<UUID> = []
@@ -30,37 +30,37 @@ final class NotificationOverlayViewModel: ObservableObject {
3030

3131
@Published var scrolledToTop: Bool = true
3232

33-
/// Whether a notification should be visible in the overlay
33+
/// Whether a notification should be visible in the panel
3434
func isNotificationVisible(_ notification: CENotification) -> Bool {
3535
if notification.isBeingDismissed {
3636
return true // Always show notifications being dismissed
3737
}
3838
if notification.isSticky {
3939
return true // Always show sticky notifications
4040
}
41-
if isManuallyShown {
41+
if isPresented {
4242
return true // Show all notifications when manually shown
4343
}
4444
return !hiddenNotificationIds.contains(notification.id)
4545
}
4646

47-
/// Handles focus changes for the notification overlay
47+
/// Handles focus changes for the notification panel
4848
func handleFocusChange(isFocused: Bool) {
4949
if !isFocused {
5050
// Only hide if manually shown and focus is completely lost
51-
if isManuallyShown {
51+
if isPresented {
5252
toggleNotificationsVisibility()
5353
}
5454
}
5555
}
5656

57-
/// Toggles visibility of notifications in the overlay
57+
/// Toggles visibility of notifications in the panel
5858
func toggleNotificationsVisibility() {
59-
if isManuallyShown {
59+
if isPresented {
6060
if !scrolledToTop {
61-
// Just set isManuallyShown to false to trigger the offset animation
61+
// Just set isPresented to false to trigger the offset animation
6262
withAnimation(.easeInOut(duration: 0.3)) {
63-
isManuallyShown = false
63+
isPresented = false
6464
}
6565

6666
// After the slide-out animation, hide notifications
@@ -82,7 +82,7 @@ final class NotificationOverlayViewModel: ObservableObject {
8282
}
8383
} else {
8484
withAnimation(.easeInOut(duration: 0.3)) {
85-
isManuallyShown = true
85+
isPresented = true
8686
hiddenNotificationIds.removeAll()
8787
objectWillChange.send()
8888
}
@@ -91,7 +91,7 @@ final class NotificationOverlayViewModel: ObservableObject {
9191

9292
private func hideNotifications() {
9393
withAnimation(.easeInOut(duration: 0.3)) {
94-
self.isManuallyShown = false
94+
self.isPresented = false
9595
self.activeNotifications
9696
.filter { !$0.isSticky }
9797
.forEach { self.hiddenNotificationIds.insert($0.id) }
@@ -101,7 +101,7 @@ final class NotificationOverlayViewModel: ObservableObject {
101101

102102
/// Starts the timer to automatically hide a notification
103103
func startHideTimer(for notification: CENotification) {
104-
guard !notification.isSticky && !isManuallyShown else { return }
104+
guard !notification.isSticky && !isPresented else { return }
105105

106106
timers[notification.id]?.invalidate()
107107
timers[notification.id] = nil
@@ -174,7 +174,7 @@ final class NotificationOverlayViewModel: ObservableObject {
174174
withAnimation(.easeInOut(duration: 0.3)) {
175175
insertNotification(notification)
176176
hiddenNotificationIds.remove(notification.id)
177-
if !isManuallyShown && !notification.isSticky {
177+
if !isPresented && !notification.isSticky {
178178
startHideTimer(for: notification)
179179
}
180180
}
@@ -204,8 +204,8 @@ final class NotificationOverlayViewModel: ObservableObject {
204204
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
205205
withAnimation(.easeOut(duration: 0.2)) {
206206
self.activeNotifications.removeAll(where: { $0.id == notification.id })
207-
if self.activeNotifications.isEmpty && self.isManuallyShown {
208-
self.isManuallyShown = false
207+
if self.activeNotifications.isEmpty && self.isPresented {
208+
self.isPresented = false
209209
}
210210
}
211211

@@ -257,8 +257,8 @@ final class NotificationOverlayViewModel: ObservableObject {
257257
activeNotifications.removeAll(where: { $0.id == ceNotification.id })
258258

259259
// If this was the last notification and they were manually shown, hide the panel
260-
if activeNotifications.isEmpty && isManuallyShown {
261-
isManuallyShown = false
260+
if activeNotifications.isEmpty && isPresented {
261+
isPresented = false
262262
}
263263
}
264264
}

CodeEdit/Features/Notifications/Views/NotificationBannerView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ struct NotificationBannerView: View {
175175
}
176176

177177
if hovering {
178-
workspace.notificationOverlay.pauseTimer()
178+
workspace.notificationPanel.pauseTimer()
179179
} else {
180-
workspace.notificationOverlay.resumeTimer()
180+
workspace.notificationPanel.resumeTimer()
181181
}
182182
}
183183
}

0 commit comments

Comments
 (0)