Skip to content

Commit 63754a2

Browse files
File icon improvements (#1645)
* Made file icon improvements. Utilizing new custom symbols. Checking to see if symbols exist and if not falling back to system symbols. * Fixed SwiftLine by disabling rule - long switch statement necessitates a long function. Will look into a better solution for file types later. * Added AppleScript * Added aif, avi, mid, mov, mp3, mp4, pdf, wav * Updated CodeEditSymbols to v0.2.2 * Updated packages and fixed image display issue in the changes tab in the source control navigator
1 parent 7adabea commit 63754a2

File tree

11 files changed

+219
-57
lines changed

11 files changed

+219
-57
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4700,7 +4700,7 @@
47004700
repositoryURL = "https://github.com/CodeEditApp/CodeEditSymbols";
47014701
requirement = {
47024702
kind = exactVersion;
4703-
version = 0.2.1;
4703+
version = 0.2.2;
47044704
};
47054705
};
47064706
287136B1292A407E00E9F5F4 /* XCRemoteSwiftPackageReference "SwiftLintPlugin" */ = {
@@ -4739,8 +4739,8 @@
47394739
isa = XCRemoteSwiftPackageReference;
47404740
repositoryURL = "https://github.com/CodeEditApp/CodeEditKit";
47414741
requirement = {
4742-
kind = upToNextMinorVersion;
4743-
minimumVersion = 0.1.0;
4742+
kind = exactVersion;
4743+
version = 0.1.1;
47444744
};
47454745
};
47464746
6C147C4329A329350089B630 /* XCRemoteSwiftPackageReference "swift-collections" */ = {

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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.176",
9+
"green" : "0.303",
10+
"red" : "0.956"
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.376",
27+
"green" : "0.475",
28+
"red" : "0.960"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
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.522",
9+
"green" : "0.463",
10+
"red" : "0.373"
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.749",
27+
"green" : "0.690",
28+
"red" : "0.585"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}

CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,23 @@ final class CEWorkspaceFile: Codable, Comparable, Hashable, Identifiable, Editor
4848
let url: URL
4949

5050
/// Return the icon of the file as `Image`
51-
var icon: Image { Image(systemName: systemImage) }
51+
var icon: Image {
52+
if let customImage = NSImage.symbol(named: systemImage) {
53+
return Image(nsImage: customImage)
54+
} else {
55+
return Image(systemName: systemImage)
56+
}
57+
}
58+
59+
/// Return the icon of the file as `NSImage`
60+
var nsIcon: NSImage {
61+
if let customImage = NSImage.symbol(named: systemImage) {
62+
return customImage
63+
} else {
64+
return NSImage(systemSymbolName: systemImage, accessibilityDescription: systemImage)
65+
?? NSImage(systemSymbolName: "doc", accessibilityDescription: "doc")!
66+
}
67+
}
5268

5369
/// Returns a parent ``CEWorkspaceFile``.
5470
///

CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFileIcon.swift

Lines changed: 114 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,73 +12,129 @@ enum FileIcon {
1212

1313
// swiftlint:disable identifier_name
1414
enum FileType: String {
15-
case json
16-
case js
15+
case adb
16+
case aif
17+
case avi
18+
case bash
19+
case c
20+
case cetheme
21+
case clj
22+
case cls
23+
case cs
1724
case css
18-
case jsx
19-
case swift
25+
case d
26+
case dart
27+
case elm
28+
case entitlements
2029
case env
30+
case ex
2131
case example
32+
case f95
33+
case fs
2234
case gitignore
23-
case png
24-
case jpg
25-
case jpeg
35+
case go
36+
case gs
37+
case h
38+
case hs
39+
case html
2640
case ico
27-
case svg
28-
case entitlements
29-
case plist
41+
case java
42+
case jl
43+
case jpeg
44+
case jpg
45+
case js
46+
case json
47+
case jsx
48+
case kt
49+
case l
50+
case LICENSE
51+
case lock
52+
case lsp
53+
case lua
54+
case m
55+
case Makefile
3056
case md
31-
case txt = "text"
32-
case rtf
33-
case html
57+
case mid
58+
case mjs
59+
case mk
60+
case mod
61+
case mov
62+
case mp3
63+
case mp4
64+
case pas
65+
case pdf
66+
case pl
67+
case plist
68+
case png
3469
case py
70+
case resolved
71+
case rb
72+
case rs
73+
case rtf
74+
case scm
75+
case scpt
3576
case sh
36-
case LICENSE
37-
case java
38-
case h
39-
case m
40-
case vue
41-
case go
77+
case ss
78+
case strings
4279
case sum
43-
case mod
44-
case Makefile
80+
case svg
81+
case swift
4582
case ts
46-
case rs
83+
case tsx
84+
case txt = "text"
85+
case vue
86+
case wav
87+
case xcconfig
88+
case yml
89+
case zsh
4790
}
91+
4892
// swiftlint:enable identifier_name
4993

5094
/// Returns a string describing a SFSymbol for files
5195
/// If not specified otherwise this will return `"doc"`
52-
static func fileIcon(fileType: FileType) -> String { // swiftlint:disable:this cyclomatic_complexity
96+
static func fileIcon(fileType: FileType) -> String { // swiftlint:disable:this cyclomatic_complexity function_body_length line_length
5397
switch fileType {
54-
case .json, .js:
55-
return "curlybraces"
98+
case .json, .yml, .resolved:
99+
return "doc.json"
100+
case .lock:
101+
return "lock.doc"
56102
case .css:
57-
return "number"
58-
case .jsx:
103+
return "curlybraces"
104+
case .js, .mjs:
105+
return "doc.javascript"
106+
case .jsx, .tsx:
59107
return "atom"
60108
case .swift:
61109
return "swift"
62110
case .env, .example:
63111
return "gearshape.fill"
64112
case .gitignore:
65113
return "arrow.triangle.branch"
66-
case .png, .jpg, .jpeg, .ico:
114+
case .pdf, .png, .jpg, .jpeg, .ico:
67115
return "photo"
68116
case .svg:
69117
return "square.fill.on.circle.fill"
70118
case .entitlements:
71119
return "checkmark.seal"
72120
case .plist:
73121
return "tablecells"
74-
case .md, .txt, .rtf:
122+
case .md, .txt:
75123
return "doc.plaintext"
76-
case .html, .py, .sh:
124+
case .rtf:
125+
return "doc.richtext"
126+
case .html:
77127
return "chevron.left.forwardslash.chevron.right"
78128
case .LICENSE:
79129
return "key.fill"
80130
case .java:
81131
return "cup.and.saucer"
132+
case .py:
133+
return "doc.python"
134+
case .rb:
135+
return "doc.ruby"
136+
case .strings:
137+
return "text.quote"
82138
case .h:
83139
return "h.square"
84140
case .m:
@@ -91,10 +147,23 @@ enum FileIcon {
91147
return "s.square"
92148
case .mod:
93149
return "m.square"
94-
case .Makefile:
150+
case .bash, .sh, .Makefile, .zsh:
95151
return "terminal"
96152
case .rs:
97153
return "r.square"
154+
case .wav, .mp3, .aif, .mid:
155+
return "speaker.wave.2"
156+
case .avi, .mp4, .mov:
157+
return "film"
158+
case .scpt:
159+
return "applescript"
160+
case .xcconfig:
161+
return "gearshape.2"
162+
case .cetheme:
163+
return "paintbrush"
164+
case .adb, .clj, .cls, .cs, .d, .dart, .elm, .ex, .f95, .fs, .gs, .hs,
165+
.jl, .kt, .l, .lsp, .lua, .mk, .pas, .pl, .scm, .ss:
166+
return "doc.plaintext"
98167
default:
99168
return "doc"
100169
}
@@ -106,14 +175,20 @@ enum FileIcon {
106175
switch fileType {
107176
case .swift, .html:
108177
return .orange
109-
case .java:
110-
return .red
111-
case .js, .entitlements, .json, .LICENSE:
112-
return Color("SidebarYellow")
113-
case .css, .ts, .jsx, .md, .py:
178+
case .java, .jpg, .png, .svg, .ts:
114179
return .blue
115-
case .sh:
116-
return .green
180+
case .css:
181+
return .teal
182+
case .js, .mjs, .py, .entitlements, .LICENSE:
183+
return Color("Amber")
184+
case .json, .resolved, .rb, .strings, .yml:
185+
return Color("Scarlet")
186+
case .jsx, .tsx:
187+
return .cyan
188+
case .plist, .xcconfig, .sh:
189+
return Color("Steel")
190+
case .c, .cetheme:
191+
return .purple
117192
case .vue:
118193
return Color(red: 0.255, green: 0.722, blue: 0.514, opacity: 1.0)
119194
case .h:
@@ -129,7 +204,7 @@ enum FileIcon {
129204
case .rs:
130205
return .orange
131206
default:
132-
return .accentColor
207+
return Color("Steel")
133208
}
134209
}
135210
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ final class PathBarMenuItem: NSMenuItem {
7979
submenu = subMenu
8080
color = NSColor(named: "FolderBlue") ?? NSColor(.secondary)
8181
}
82-
let image = NSImage(
83-
systemSymbolName: icon,
84-
accessibilityDescription: icon
85-
)?.withSymbolConfiguration(.init(paletteColors: [color]))
82+
let image = fileItem.nsIcon.withSymbolConfiguration(.init(paletteColors: [color]))
8683
self.image = image
8784
representedObject = fileItem
8885
if fileItem.isFolder {

0 commit comments

Comments
 (0)