Skip to content

Commit 919f419

Browse files
Using the correct color when File Icon Type is set to Monochrome (#1766)
Added CoolGray color and applied to icons when file icon type setting is set to monochrome.
1 parent af8c7e1 commit 919f419

File tree

8 files changed

+82
-21
lines changed

8 files changed

+82
-21
lines changed

CodeEdit/Assets.xcassets/Custom Colors/Amber.colorset/Contents.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"colors" : [
33
{
44
"color" : {
5-
"color-space" : "srgb",
5+
"color-space" : "display-p3",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "0.000",
9-
"green" : "0.689",
10-
"red" : "0.931"
8+
"blue" : "0.133",
9+
"green" : "0.635",
10+
"red" : "0.784"
1111
}
1212
},
1313
"idiom" : "universal"
@@ -20,8 +20,13 @@
2020
}
2121
],
2222
"color" : {
23-
"platform" : "universal",
24-
"reference" : "systemYellowColor"
23+
"color-space" : "display-p3",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0.302",
27+
"green" : "0.812",
28+
"red" : "0.961"
29+
}
2530
},
2631
"idiom" : "universal"
2732
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "display-p3",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0.553",
9+
"green" : "0.541",
10+
"red" : "0.518"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "display-p3",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0.549",
27+
"green" : "0.537",
28+
"red" : "0.525"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}

CodeEdit/Assets.xcassets/Custom Colors/FolderBlue.colorset/Contents.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"colors" : [
33
{
44
"color" : {
5-
"color-space" : "srgb",
5+
"color-space" : "display-p3",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "0.945",
9-
"green" : "0.671",
10-
"red" : "0.075"
8+
"blue" : "0.973",
9+
"green" : "0.698",
10+
"red" : "0.125"
1111
}
1212
},
1313
"idiom" : "universal"
@@ -20,12 +20,12 @@
2020
}
2121
],
2222
"color" : {
23-
"color-space" : "srgb",
23+
"color-space" : "display-p3",
2424
"components" : {
2525
"alpha" : "1.000",
26-
"blue" : "0.871",
27-
"green" : "0.702",
28-
"red" : "0.322"
26+
"blue" : "0.859",
27+
"green" : "0.698",
28+
"red" : "0.365"
2929
}
3030
},
3131
"idiom" : "universal"

CodeEdit/Features/Editor/PathBar/Views/EditorPathBarMenu.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ final class EditorPathBarMenu: NSMenu, NSMenuDelegate {
6161
final class PathBarMenuItem: NSMenuItem {
6262
private let fileItem: CEWorkspaceFile
6363
private let tappedOpenFile: (CEWorkspaceFile) -> Void
64+
private let generalSettings = Settings.shared.preferences.general
6465

6566
init(
6667
fileItem: CEWorkspaceFile,
@@ -77,6 +78,9 @@ final class PathBarMenuItem: NSMenuItem {
7778
submenu = subMenu
7879
color = NSColor(named: "FolderBlue") ?? NSColor(.secondary)
7980
}
81+
if generalSettings.fileIconStyle == .monochrome {
82+
color = NSColor(named: "CoolGray") ?? NSColor(.gray)
83+
}
8084
let image = fileItem.nsIcon.withSymbolConfiguration(.init(paletteColors: [color]))
8185
self.image = image
8286
representedObject = fileItem

CodeEdit/Features/NavigatorArea/OutlineView/FileSystemTableViewCell.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ class FileSystemTableViewCell: StandardTableViewCell {
8080
/// - Parameter item: The `FileItem` to get the color for
8181
/// - Returns: A `NSColor` for the given `FileItem`.
8282
func color(for item: CEWorkspaceFile) -> NSColor {
83-
if !item.isFolder && prefs.fileIconStyle == .color {
84-
return NSColor(item.iconColor)
83+
if prefs.fileIconStyle == .color {
84+
if !item.isFolder {
85+
return NSColor(item.iconColor)
86+
} else {
87+
return NSColor(named: "FolderBlue") ?? NSColor(.cyan)
88+
}
8589
} else {
86-
return NSColor(named: "FolderBlue")!
90+
return NSColor(named: "CoolGray") ?? NSColor(.gray)
8791
}
8892
}
8993
}

CodeEdit/Features/NavigatorArea/SourceControlNavigator/Changes/Views/SourceControlNavigatorChangedFileView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import SwiftUI
99

1010
struct SourceControlNavigatorChangedFileView: View {
11+
@AppSettings(\.general.fileIconStyle)
12+
var fileIconStyle
13+
1114
@EnvironmentObject var sourceControlManager: SourceControlManager
1215
@Binding var changedFile: CEWorkspaceFile
1316
@State var staged: Bool
@@ -53,7 +56,7 @@ struct SourceControlNavigatorChangedFileView: View {
5356
.truncationMode(.middle)
5457
}, icon: {
5558
Image(nsImage: changedFile.nsIcon)
56-
.foregroundStyle(changedFile.iconColor)
59+
.foregroundStyle(fileIconStyle == .color ? changedFile.iconColor : Color("CoolGray"))
5760
})
5861

5962
Spacer()

CodeEdit/Features/NavigatorArea/SourceControlNavigator/History/Views/CommitChangedFileListItemView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import SwiftUI
99

1010
struct CommitChangedFileListItemView: View {
11+
@AppSettings(\.general.fileIconStyle)
12+
var fileIconStyle
13+
1114
@EnvironmentObject var sourceControlManager: SourceControlManager
15+
1216
@Binding var changedFile: CEWorkspaceFile
1317

1418
var folder: String? {
@@ -34,7 +38,7 @@ struct CommitChangedFileListItemView: View {
3438
.truncationMode(.middle)
3539
}, icon: {
3640
Image(nsImage: changedFile.nsIcon)
37-
.foregroundStyle(changedFile.iconColor)
41+
.foregroundStyle(fileIconStyle == .color ? changedFile.iconColor : Color("CoolGray"))
3842
})
3943

4044
Spacer()

CodeEdit/Features/NavigatorArea/SourceControlNavigator/Repository/Views/SourceControlNavigatorRepositoryItem.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import SwiftUI
99

1010
struct SourceControlNavigatorRepositoryItem: View {
11+
@AppSettings(\.general.fileIconStyle)
12+
var fileIconStyle
13+
1114
let item: RepoOutlineGroupItem
1215

1316
@Environment(\.controlActiveState)
@@ -49,11 +52,11 @@ struct SourceControlNavigatorRepositoryItem: View {
4952
if item.symbolImage != nil {
5053
Image(symbol: item.symbolImage ?? "")
5154
.opacity(controlActiveState == .inactive ? 0.5 : 1)
52-
.foregroundStyle(item.imageColor ?? .accentColor)
55+
.foregroundStyle(fileIconStyle == .color ? item.imageColor ?? .accentColor : Color("CoolGray"))
5356
} else {
5457
Image(systemName: item.systemImage ?? "")
5558
.opacity(controlActiveState == .inactive ? 0.5 : 1)
56-
.foregroundStyle(item.imageColor ?? .accentColor)
59+
.foregroundStyle(fileIconStyle == .color ? item.imageColor ?? .accentColor : Color("CoolGray"))
5760
}
5861
})
5962
.padding(.leading, 1)

0 commit comments

Comments
 (0)