Skip to content

Commit c292c7d

Browse files
committed
Fixed animation glitch when taking action on a notification while notification panel is presented. Removed notification tests and made the notification test in the dev inspector more configurable.
1 parent b839c1a commit c292c7d

File tree

7 files changed

+229
-260
lines changed

7 files changed

+229
-260
lines changed

โ€ŽCodeEdit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@
529529
B616EA882D651ADA00DF9029 /* ScrollOffsetPreferenceKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = B616EA872D651ADA00DF9029 /* ScrollOffsetPreferenceKey.swift */; };
530530
B616EA892D651ADA00DF9029 /* OverlayButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B616EA862D651ADA00DF9029 /* OverlayButtonStyle.swift */; };
531531
B616EA8D2D65238900DF9029 /* InternalDevelopmentInspectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B616EA8B2D65238900DF9029 /* InternalDevelopmentInspectorView.swift */; };
532+
B616EA8F2D662E9800DF9029 /* InternalDevelopmentNotificationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B616EA8E2D662E9800DF9029 /* InternalDevelopmentNotificationsView.swift */; };
532533
B61A606129F188AB009B43F9 /* ExternalLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = B61A606029F188AB009B43F9 /* ExternalLink.swift */; };
533534
B61A606929F4481A009B43F9 /* MonospacedFontPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = B61A606829F4481A009B43F9 /* MonospacedFontPicker.swift */; };
534535
B61DA9DF29D929E100BF4A43 /* GeneralSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B61DA9DE29D929E100BF4A43 /* GeneralSettingsView.swift */; };
@@ -1224,6 +1225,7 @@
12241225
B616EA862D651ADA00DF9029 /* OverlayButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverlayButtonStyle.swift; sourceTree = "<group>"; };
12251226
B616EA872D651ADA00DF9029 /* ScrollOffsetPreferenceKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollOffsetPreferenceKey.swift; sourceTree = "<group>"; };
12261227
B616EA8B2D65238900DF9029 /* InternalDevelopmentInspectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternalDevelopmentInspectorView.swift; sourceTree = "<group>"; };
1228+
B616EA8E2D662E9800DF9029 /* InternalDevelopmentNotificationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternalDevelopmentNotificationsView.swift; sourceTree = "<group>"; };
12271229
B61A606029F188AB009B43F9 /* ExternalLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLink.swift; sourceTree = "<group>"; };
12281230
B61A606829F4481A009B43F9 /* MonospacedFontPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonospacedFontPicker.swift; sourceTree = "<group>"; };
12291231
B61DA9DE29D929E100BF4A43 /* GeneralSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralSettingsView.swift; sourceTree = "<group>"; };
@@ -3288,6 +3290,7 @@
32883290
isa = PBXGroup;
32893291
children = (
32903292
B616EA8B2D65238900DF9029 /* InternalDevelopmentInspectorView.swift */,
3293+
B616EA8E2D662E9800DF9029 /* InternalDevelopmentNotificationsView.swift */,
32913294
);
32923295
path = InternalDevelopmentInspector;
32933296
sourceTree = "<group>";
@@ -4472,6 +4475,7 @@
44724475
587B9E7929301D8F00AC7927 /* GitHubIssueRouter.swift in Sources */,
44734476
B67700F92D2A2662004FD61F /* WorkspacePanelView.swift in Sources */,
44744477
587B9E8029301D8F00AC7927 /* GitHubConfiguration.swift in Sources */,
4478+
B616EA8F2D662E9800DF9029 /* InternalDevelopmentNotificationsView.swift in Sources */,
44754479
58822524292C280D00E83CDE /* StatusBarView.swift in Sources */,
44764480
581550D429FBD37D00684881 /* ProjectNavigatorToolbarBottom.swift in Sources */,
44774481
66AF6CE72BF17FFB00D83C9D /* UpdateStatusBarInfo.swift in Sources */,

โ€ŽCodeEdit/AppDelegate.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
2626

2727
NSApp.closeWindow(.welcome, .about)
2828

29-
// Add test notification
30-
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
31-
NotificationManager.shared.post(
32-
iconText: "๐Ÿ‘‹",
33-
iconTextColor: .white,
34-
iconColor: .indigo,
35-
title: "Welcome to CodeEdit",
36-
description: "This is a test notification to demonstrate the notification system.",
37-
actionButtonTitle: "Learn More...",
38-
action: {
39-
print("Action button clicked!")
40-
}
41-
)
42-
}
43-
4429
DispatchQueue.main.async {
4530
var needToHandleOpen = true
4631

โ€ŽCodeEdit/Features/InspectorArea/FileInspector/FileInspectorView.swift

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -59,71 +59,6 @@ struct FileInspectorView: View {
5959
widthOptions
6060
wrapLinesToggle
6161
}
62-
Section("Test Notifications") {
63-
Button("Add Notification") {
64-
let (iconSymbol, iconColor) = randomSymbolAndColor()
65-
NotificationManager.shared.post(
66-
iconSymbol: iconSymbol,
67-
iconColor: iconColor,
68-
title: "Test Notification",
69-
description: "This is a test notification.",
70-
actionButtonTitle: "Action",
71-
action: {
72-
print("Test notification action triggered")
73-
}
74-
)
75-
}
76-
Button("Add Sticky Notification") {
77-
NotificationManager.shared.post(
78-
iconSymbol: "pin.fill",
79-
iconColor: .orange,
80-
title: "Sticky Notification",
81-
description: "This notification will stay until dismissed.",
82-
actionButtonTitle: "Acknowledge",
83-
action: {
84-
print("Sticky notification acknowledged")
85-
},
86-
isSticky: true
87-
)
88-
}
89-
Button("Add Image Notification") {
90-
NotificationManager.shared.post(
91-
iconImage: randomImage(),
92-
title: "Test Notification with Image",
93-
description: "This is a test notification with a custom image.",
94-
actionButtonTitle: "Action",
95-
action: {
96-
print("Test notification action triggered")
97-
}
98-
)
99-
}
100-
Button("Add Text Notification") {
101-
NotificationManager.shared.post(
102-
iconText: randomLetter(),
103-
iconTextColor: .white,
104-
iconColor: randomColor(),
105-
title: "Text Notification",
106-
description: "This is a test notification with text.",
107-
actionButtonTitle: "Acknowledge",
108-
action: {
109-
print("Test notification action triggered")
110-
}
111-
)
112-
}
113-
Button("Add Emoji Notification") {
114-
NotificationManager.shared.post(
115-
iconText: randomEmoji(),
116-
iconTextColor: .white,
117-
iconColor: randomColor(),
118-
title: "Emoji Notification",
119-
description: "This is a test notification with an emoji.",
120-
actionButtonTitle: "Acknowledge",
121-
action: {
122-
print("Test notification action triggered")
123-
}
124-
)
125-
}
126-
}
12762
}
12863
} else {
12964
NoSelectionInspectorView()
@@ -146,62 +81,6 @@ struct FileInspectorView: View {
14681
}
14782
}
14883

149-
func randomColor() -> Color {
150-
let colors: [Color] = [
151-
.red, .orange, .yellow, .green, .mint, .cyan,
152-
.teal, .blue, .indigo, .purple, .pink, .gray
153-
]
154-
return colors.randomElement() ?? .black
155-
}
156-
157-
func randomSymbolAndColor() -> (String, Color) {
158-
let symbols: [(String, Color)] = [
159-
("bell.fill", .red),
160-
("bell.badge.fill", .red),
161-
("exclamationmark.triangle.fill", .orange),
162-
("info.circle.fill", .blue),
163-
("checkmark.seal.fill", .green),
164-
("xmark.octagon.fill", .red),
165-
("bubble.left.fill", .teal),
166-
("envelope.fill", .blue),
167-
("phone.fill", .green),
168-
("megaphone.fill", .pink),
169-
("clock.fill", .gray),
170-
("calendar", .red),
171-
("flag.fill", .green),
172-
("bookmark.fill", .orange),
173-
("bolt.fill", .indigo),
174-
("shield.lefthalf.fill", .red),
175-
("gift.fill", .purple),
176-
("heart.fill", .pink),
177-
("star.fill", .orange),
178-
("curlybraces", .cyan),
179-
]
180-
return symbols.randomElement() ?? ("bell.fill", .red)
181-
}
182-
183-
func randomEmoji() -> String {
184-
let emoji: [String] = [
185-
"๐Ÿ””", "๐Ÿšจ", "โš ๏ธ", "๐Ÿ‘‹", "๐Ÿ˜", "๐Ÿ˜Ž", "๐Ÿ˜˜", "๐Ÿ˜œ", "๐Ÿ˜", "๐Ÿ˜€", "๐Ÿ˜",
186-
"๐Ÿ˜‚", "๐Ÿคฃ", "๐Ÿ˜ƒ", "๐Ÿ˜„", "๐Ÿ˜…", "๐Ÿ˜†", "๐Ÿ˜‡", "๐Ÿ˜‰", "๐Ÿ˜Š", "๐Ÿ˜‹", "๐Ÿ˜Œ"
187-
]
188-
return emoji.randomElement() ?? "๐Ÿ””"
189-
}
190-
191-
func randomImage() -> Image {
192-
let images: [Image] = [
193-
Image("GitHubIcon"),
194-
Image("BitBucketIcon"),
195-
Image("GitLabIcon")
196-
]
197-
return images.randomElement() ?? Image("GitHubIcon")
198-
}
199-
200-
func randomLetter() -> String {
201-
let letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".map { String($0) }
202-
return letters.randomElement() ?? "A"
203-
}
204-
20584
@ViewBuilder private var fileNameField: some View {
20685
@State var isValid: Bool = true
20786

Lines changed: 8 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,16 @@
1+
//
2+
// InternalDevelopmentInspectorView.swift
3+
// CodeEdit
4+
//
5+
// Created by Austin Condiff on 2/19/24.
6+
//
7+
18
import SwiftUI
29

310
struct InternalDevelopmentInspectorView: View {
411
var body: some View {
512
Form {
6-
Section("Test Notifications") {
7-
Button("Add Notification") {
8-
let (iconSymbol, iconColor) = randomSymbolAndColor()
9-
NotificationManager.shared.post(
10-
iconSymbol: iconSymbol,
11-
iconColor: iconColor,
12-
title: "Test Notification",
13-
description: "This is a test notification.",
14-
actionButtonTitle: "Action",
15-
action: {
16-
print("Test notification action triggered")
17-
}
18-
)
19-
}
20-
Button("Add Sticky Notification") {
21-
NotificationManager.shared.post(
22-
iconSymbol: "pin.fill",
23-
iconColor: .orange,
24-
title: "Sticky Notification",
25-
description: "This notification will stay until dismissed.",
26-
actionButtonTitle: "Acknowledge",
27-
action: {
28-
print("Sticky notification acknowledged")
29-
},
30-
isSticky: true
31-
)
32-
}
33-
Button("Add Image Notification") {
34-
NotificationManager.shared.post(
35-
iconImage: randomImage(),
36-
title: "Test Notification with Image",
37-
description: "This is a test notification with a custom image.",
38-
actionButtonTitle: "Action",
39-
action: {
40-
print("Test notification action triggered")
41-
}
42-
)
43-
}
44-
Button("Add Text Notification") {
45-
NotificationManager.shared.post(
46-
iconText: randomLetter(),
47-
iconTextColor: .white,
48-
iconColor: randomColor(),
49-
title: "Text Notification",
50-
description: "This is a test notification with text.",
51-
actionButtonTitle: "Acknowledge",
52-
action: {
53-
print("Test notification action triggered")
54-
}
55-
)
56-
}
57-
Button("Add Emoji Notification") {
58-
NotificationManager.shared.post(
59-
iconText: randomEmoji(),
60-
iconTextColor: .white,
61-
iconColor: randomColor(),
62-
title: "Emoji Notification",
63-
description: "This is a test notification with an emoji.",
64-
actionButtonTitle: "Acknowledge",
65-
action: {
66-
print("Test notification action triggered")
67-
}
68-
)
69-
}
70-
}
13+
InternalDevelopmentNotificationsView()
7114
}
7215
}
73-
74-
// Helper functions moved from FileInspectorView
75-
private func randomColor() -> Color {
76-
let colors: [Color] = [
77-
.red, .orange, .yellow, .green, .mint, .cyan,
78-
.teal, .blue, .indigo, .purple, .pink, .gray
79-
]
80-
return colors.randomElement() ?? .black
81-
}
82-
83-
private func randomSymbolAndColor() -> (String, Color) {
84-
let symbols: [(String, Color)] = [
85-
("bell.fill", .red),
86-
("bell.badge.fill", .red),
87-
("exclamationmark.triangle.fill", .orange),
88-
("info.circle.fill", .blue),
89-
("checkmark.seal.fill", .green),
90-
("xmark.octagon.fill", .red),
91-
("bubble.left.fill", .teal),
92-
("envelope.fill", .blue),
93-
("phone.fill", .green),
94-
("megaphone.fill", .pink),
95-
("clock.fill", .gray),
96-
("calendar", .red),
97-
("flag.fill", .green),
98-
("bookmark.fill", .orange),
99-
("bolt.fill", .indigo),
100-
("shield.lefthalf.fill", .red),
101-
("gift.fill", .purple),
102-
("heart.fill", .pink),
103-
("star.fill", .orange),
104-
("curlybraces", .cyan),
105-
]
106-
return symbols.randomElement() ?? ("bell.fill", .red)
107-
}
108-
109-
private func randomEmoji() -> String {
110-
let emoji: [String] = [
111-
"๐Ÿ””", "๐Ÿšจ", "โš ๏ธ", "๐Ÿ‘‹", "๐Ÿ˜", "๐Ÿ˜Ž", "๐Ÿ˜˜", "๐Ÿ˜œ", "๐Ÿ˜", "๐Ÿ˜€", "๐Ÿ˜",
112-
"๐Ÿ˜‚", "๐Ÿคฃ", "๐Ÿ˜ƒ", "๐Ÿ˜„", "๐Ÿ˜…", "๐Ÿ˜†", "๐Ÿ˜‡", "๐Ÿ˜‰", "๐Ÿ˜Š", "๐Ÿ˜‹", "๐Ÿ˜Œ"
113-
]
114-
return emoji.randomElement() ?? "๐Ÿ””"
115-
}
116-
117-
private func randomImage() -> Image {
118-
let images: [Image] = [
119-
Image("GitHubIcon"),
120-
Image("BitBucketIcon"),
121-
Image("GitLabIcon")
122-
]
123-
return images.randomElement() ?? Image("GitHubIcon")
124-
}
125-
126-
private func randomLetter() -> String {
127-
let letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".map { String($0) }
128-
return letters.randomElement() ?? "A"
129-
}
13016
}

0 commit comments

Comments
ย (0)