Skip to content

Commit 749c716

Browse files
committed
Moved CloseButtonStyle into CodeEditUI and renamed it OverlayButtonStyle
1 parent 4815194 commit 749c716

File tree

4 files changed

+20
-47
lines changed

4 files changed

+20
-47
lines changed

CodeEdit/Features/ActivityViewer/Notifications/TaskNotificationHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import Combine
7676
/// "id": "uniqueTaskID",
7777
/// "action": "update",
7878
/// "title": "Updated Task Title",
79-
/// "message": "Updated Task Message"
79+
/// "message": "Updated Task Message",
8080
/// "percentage": 0.5,
8181
/// "isLoading": true
8282
/// ]

CodeEdit/Features/CodeEditUI/Styles/OverlayButtonStyle.swift

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ import SwiftUI
22

33
/// A button style for overlay buttons (like close, action buttons in notifications)
44
struct OverlayButtonStyle: ButtonStyle {
5-
@Environment(\.isEnabled)
6-
private var isEnabled
7-
8-
@Environment(\.controlActiveState)
9-
private var controlActive
5+
@Environment(\.colorScheme)
6+
private var colorScheme
107

118
func makeBody(configuration: Configuration) -> some View {
129
configuration.label
13-
.foregroundColor(
14-
isEnabled
15-
? (configuration.isPressed
16-
? .primary.opacity(0.3)
17-
: (controlActive == .inactive
18-
? .primary.opacity(0.5)
19-
: .primary.opacity(0.7)))
20-
: .primary.opacity(0.3)
10+
.font(.system(size: 10))
11+
.foregroundColor(.secondary)
12+
.frame(width: 20, height: 20, alignment: .center)
13+
.background(Color.primary.opacity(configuration.isPressed ? colorScheme == .dark ? 0.10 : 0.05 : 0.00))
14+
.background(.regularMaterial)
15+
.overlay(
16+
RoundedRectangle(cornerRadius: 10)
17+
.stroke(Color(nsColor: .separatorColor), lineWidth: 2)
18+
)
19+
.cornerRadius(10)
20+
.shadow(
21+
color: Color(.black.withAlphaComponent(colorScheme == .dark ? 0.2 : 0.1)),
22+
radius: 5,
23+
x: 0,
24+
y: 2
2125
)
22-
.padding(4)
23-
.contentShape(Rectangle())
2426
}
2527
}
2628

CodeEdit/Features/InspectorArea/FileInspector/FileInspectorView.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,16 @@ struct FileInspectorView: View {
8282
}
8383

8484
@ViewBuilder private var fileNameField: some View {
85-
@State var isValid: Bool = true
86-
8785
if let file {
8886
TextField("Name", text: $fileName)
8987
.background(
90-
isValid ? Color.clear : Color(errorRed)
88+
fileName != file.fileName() && !file.validateFileName(for: fileName) ? Color(errorRed) : Color.clear
9189
)
9290
.onSubmit {
9391
if file.validateFileName(for: fileName) {
9492
let destinationURL = file.url
9593
.deletingLastPathComponent()
9694
.appendingPathComponent(fileName)
97-
isValid = true
9895
DispatchQueue.main.async { [weak workspace] in
9996
do {
10097
if let newItem = try workspace?.workspaceFileManager?.move(
@@ -112,7 +109,6 @@ struct FileInspectorView: View {
112109
}
113110
}
114111
} else {
115-
isValid = false
116112
fileName = file.labelFileName()
117113
}
118114
}

CodeEdit/Features/Notifications/Views/NotificationBannerView.swift

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,6 @@
77

88
import SwiftUI
99

10-
struct CloseButtonStyle: ButtonStyle {
11-
@Environment(\.colorScheme)
12-
private var colorScheme
13-
14-
func makeBody(configuration: Configuration) -> some View {
15-
configuration.label
16-
.font(.system(size: 10))
17-
.foregroundColor(.secondary)
18-
.frame(width: 20, height: 20, alignment: .center)
19-
.background(Color.primary.opacity(configuration.isPressed ? colorScheme == .dark ? 0.10 : 0.05 : 0.00))
20-
.background(.regularMaterial)
21-
.overlay(
22-
RoundedRectangle(cornerRadius: 10)
23-
.stroke(Color(nsColor: .separatorColor), lineWidth: 2)
24-
)
25-
.cornerRadius(10)
26-
.shadow(
27-
color: Color(.black.withAlphaComponent(colorScheme == .dark ? 0.2 : 0.1)),
28-
radius: 5,
29-
x: 0,
30-
y: 2
31-
)
32-
}
33-
}
34-
3510
struct NotificationBannerView: View {
3611
@Environment(\.colorScheme)
3712
private var colorScheme
@@ -149,7 +124,7 @@ struct NotificationBannerView: View {
149124
Button(action: onDismiss) {
150125
Image(systemName: "xmark")
151126
}
152-
.buttonStyle(CloseButtonStyle())
127+
.buttonStyle(.overlay)
153128
.padding(.top, -5)
154129
.padding(.leading, -5)
155130
.transition(.opacity)

0 commit comments

Comments
 (0)