Skip to content

Commit 07ebe63

Browse files
icon list view now shows sorted results
1 parent d79a2ef commit 07ebe63

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

IconChanger/IconList.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ struct IconList: View {
2929
ForEach(iconManager.apps, id: \.url) { app in
3030
IconView(app: app, setPath: $setPath, searchText: $searchText, setAlias: $setAlias)
3131
}
32+
.onAppear {
33+
print(iconManager.apps.map(\.name))
34+
}
3235
}
3336
}
3437
}
@@ -89,12 +92,17 @@ struct IconView: View {
8992
.onDrop(of: [.fileURL], delegate: MyDropDelegate(app: app))
9093
.contextMenu {
9194
Menu("Path") {
95+
Button("Copy the Name") {
96+
NSPasteboard.general.clearContents()
97+
NSPasteboard.general.setString(app.name, forType: .string)
98+
}
99+
92100
Button("Copy") {
93101
NSPasteboard.general.clearContents()
94102
NSPasteboard.general.setString(app.url.universalPath(), forType: .string)
95103
}
96104

97-
Button("Copy Path Name") {
105+
Button("Copy the Path Name") {
98106
NSPasteboard.general.clearContents()
99107
NSPasteboard.general.setString(app.url.deletingPathExtension().lastPathComponent, forType: .string)
100108
}
@@ -104,7 +112,7 @@ struct IconView: View {
104112
}
105113
}
106114

107-
Button("Set Alias") {
115+
Button("Set the Alias") {
108116
setAlias = app.url.deletingPathExtension().lastPathComponent
109117
}
110118

IconChanger/IconManager.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class IconManager: ObservableObject {
2525
do {
2626
let helper = try LaunchPadManagerDBHelper()
2727

28-
apps = try helper.getAllAppInfos()
28+
apps = try helper.getAllAppInfos().sorted(by: { info1, info2 in
29+
info1.name.compare(info2.name) == .orderedAscending
30+
})
2931

3032
load = false
3133
} catch {
@@ -41,7 +43,9 @@ class IconManager: ObservableObject {
4143
do {
4244
let helper = try LaunchPadManagerDBHelper()
4345

44-
apps = try helper.getAllAppInfos()
46+
apps = try helper.getAllAppInfos().sorted(by: { info1, info2 in
47+
info1.name.compare(info2.name) == .orderedAscending
48+
})
4549

4650
load = false
4751
} catch {

IconChanger/Request.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class MyQueryRequestController {
101101
}
102102

103103
let json = try JSON(data: data)
104+
print(json)
104105
let hits = json["hits"].arrayValue
105106

106107
return hits.map { json in

0 commit comments

Comments
 (0)