Skip to content

Commit 3b04601

Browse files
committed
added itemImage function.
Should probably add a type property enum to FSItem instead of comparin extensions though
1 parent 3913fd4 commit 3b04601

File tree

3 files changed

+60
-42
lines changed

3 files changed

+60
-42
lines changed

FilippoBrowser.xcodeproj/xcshareddata/xcschemes/FilippoBrowser WatchKit App (Complication).xcscheme

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES"
5757
launchAutomaticallySubstyle = "32">
58-
<BuildableProductRunnable
59-
runnableDebuggingMode = "0">
58+
<RemoteRunnable
59+
runnableDebuggingMode = "2"
60+
BundleIdentifier = "com.apple.Carousel"
61+
RemotePath = "/FilippoBrowser WatchKit App">
6062
<BuildableReference
6163
BuildableIdentifier = "primary"
6264
BlueprintIdentifier = "0B4BED82233531D9005E5BB1"
6365
BuildableName = "FilippoBrowser WatchKit App.app"
6466
BlueprintName = "FilippoBrowser WatchKit App"
6567
ReferencedContainer = "container:FilippoBrowser.xcodeproj">
6668
</BuildableReference>
67-
</BuildableProductRunnable>
69+
</RemoteRunnable>
6870
</LaunchAction>
6971
<ProfileAction
7072
buildConfiguration = "Release"
@@ -73,16 +75,27 @@
7375
useCustomWorkingDirectory = "NO"
7476
debugDocumentVersioning = "YES"
7577
launchAutomaticallySubstyle = "32">
76-
<BuildableProductRunnable
77-
runnableDebuggingMode = "0">
78+
<RemoteRunnable
79+
runnableDebuggingMode = "2"
80+
BundleIdentifier = "com.apple.Carousel"
81+
RemotePath = "/FilippoBrowser WatchKit App">
7882
<BuildableReference
7983
BuildableIdentifier = "primary"
8084
BlueprintIdentifier = "0B4BED82233531D9005E5BB1"
8185
BuildableName = "FilippoBrowser WatchKit App.app"
8286
BlueprintName = "FilippoBrowser WatchKit App"
8387
ReferencedContainer = "container:FilippoBrowser.xcodeproj">
8488
</BuildableReference>
85-
</BuildableProductRunnable>
89+
</RemoteRunnable>
90+
<MacroExpansion>
91+
<BuildableReference
92+
BuildableIdentifier = "primary"
93+
BlueprintIdentifier = "0B4BED82233531D9005E5BB1"
94+
BuildableName = "FilippoBrowser WatchKit App.app"
95+
BlueprintName = "FilippoBrowser WatchKit App"
96+
ReferencedContainer = "container:FilippoBrowser.xcodeproj">
97+
</BuildableReference>
98+
</MacroExpansion>
8699
</ProfileAction>
87100
<AnalyzeAction
88101
buildConfiguration = "Debug">

FilippoBrowser.xcodeproj/xcshareddata/xcschemes/FilippoBrowser WatchKit App.xcscheme

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,46 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<BuildableProductRunnable
58-
runnableDebuggingMode = "0">
57+
<RemoteRunnable
58+
runnableDebuggingMode = "2"
59+
BundleIdentifier = "com.apple.Carousel"
60+
RemotePath = "/FilippoBrowser WatchKit App">
5961
<BuildableReference
6062
BuildableIdentifier = "primary"
6163
BlueprintIdentifier = "0B4BED82233531D9005E5BB1"
6264
BuildableName = "FilippoBrowser WatchKit App.app"
6365
BlueprintName = "FilippoBrowser WatchKit App"
6466
ReferencedContainer = "container:FilippoBrowser.xcodeproj">
6567
</BuildableReference>
66-
</BuildableProductRunnable>
68+
</RemoteRunnable>
6769
</LaunchAction>
6870
<ProfileAction
6971
buildConfiguration = "Release"
7072
shouldUseLaunchSchemeArgsEnv = "YES"
7173
savedToolIdentifier = ""
7274
useCustomWorkingDirectory = "NO"
7375
debugDocumentVersioning = "YES">
74-
<BuildableProductRunnable
75-
runnableDebuggingMode = "0">
76+
<RemoteRunnable
77+
runnableDebuggingMode = "2"
78+
BundleIdentifier = "com.apple.Carousel"
79+
RemotePath = "/FilippoBrowser WatchKit App">
7680
<BuildableReference
7781
BuildableIdentifier = "primary"
7882
BlueprintIdentifier = "0B4BED82233531D9005E5BB1"
7983
BuildableName = "FilippoBrowser WatchKit App.app"
8084
BlueprintName = "FilippoBrowser WatchKit App"
8185
ReferencedContainer = "container:FilippoBrowser.xcodeproj">
8286
</BuildableReference>
83-
</BuildableProductRunnable>
87+
</RemoteRunnable>
88+
<MacroExpansion>
89+
<BuildableReference
90+
BuildableIdentifier = "primary"
91+
BlueprintIdentifier = "0B4BED82233531D9005E5BB1"
92+
BuildableName = "FilippoBrowser WatchKit App.app"
93+
BlueprintName = "FilippoBrowser WatchKit App"
94+
ReferencedContainer = "container:FilippoBrowser.xcodeproj">
95+
</BuildableReference>
96+
</MacroExpansion>
8497
</ProfileAction>
8598
<AnalyzeAction
8699
buildConfiguration = "Debug">

FilippoBrowser/ContentView.swift

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct FileViewer : View {
8282

8383
var body: some View {
8484
VStack {
85+
#warning("Forse dovrei creare una enum per stabilire di partenza il tipo di file, invece di fare controlli con le estensioni")
8586
if (imageExtensions.contains(getExtension(self.file.path))){
8687
Image(uiImage: UIImage(contentsOfFile: self.file.path)!)
8788
.resizable()
@@ -103,6 +104,21 @@ struct FileViewer : View {
103104
}
104105
}
105106

107+
func itemImage(for item: FSItem) -> String {
108+
109+
if item.isFolder {
110+
return "folder.fill"
111+
} else if imageExtensions.contains(getExtension(item.lastComponent)) {
112+
return "photo.fill"
113+
} else if listExtensions.contains(getExtension(item.lastComponent)){
114+
return "list.bullet.indent"
115+
} else if textExtensions.contains(getExtension(item.lastComponent)) {
116+
return "doc.text.fill"
117+
} else {
118+
return "doc.fill"
119+
}
120+
}
121+
106122
// MARK: Directory List Viewer
107123
// This is the directory browser, it shows files and subdirectories of a folder in list style
108124
struct DirectoryListBrowser : View {
@@ -131,20 +147,8 @@ struct DirectoryListBrowser : View {
131147
}) { subItem in
132148
HStack{
133149
// Test for various file types and assign icons (SFSymbols, which are GREAT <3)
134-
Group{
135-
if subItem.isFolder {
136-
Image(systemName: "folder.fill")
137-
} else if imageExtensions.contains(getExtension(subItem.lastComponent)) {
138-
Image(systemName: "photo.fill")
139-
} else if listExtensions.contains(getExtension(subItem.lastComponent)){
140-
Image(systemName: "list.bullet.indent")
141-
} else if textExtensions.contains(getExtension(subItem.lastComponent)) {
142-
Image(systemName: "doc.text.fill")
143-
} else {
144-
Image(systemName: "doc.fill")
145-
}
146-
}
147-
.foregroundColor((subItem.rootProtected) ? .orange : .green)
150+
Image(systemName: itemImage(for: subItem))
151+
.foregroundColor((subItem.rootProtected) ? .orange : .green)
148152

149153

150154

@@ -243,21 +247,9 @@ struct DirectoryGridBrowser : View {
243247
}) { subItem in
244248
VStack{
245249
// Test for various file types and assign icons (SFSymbols, which are GREAT <3)
246-
Group{
247-
if subItem.isFolder {
248-
Image(systemName: "folder.fill")
249-
} else if imageExtensions.contains(getExtension(subItem.lastComponent)) {
250-
Image(systemName: "photo.fill")
251-
} else if listExtensions.contains(getExtension(subItem.lastComponent)){
252-
Image(systemName: "list.bullet.indent")
253-
} else if textExtensions.contains(getExtension(subItem.lastComponent)) {
254-
Image(systemName: "doc.text.fill")
255-
} else {
256-
Image(systemName: "doc.fill")
257-
}
258-
}
259-
.foregroundColor((subItem.rootProtected) ? .orange : .green)
260-
.padding(.vertical, 5)
250+
Image(systemName: itemImage(for: subItem))
251+
.foregroundColor((subItem.rootProtected) ? .orange : .green)
252+
.padding(.vertical, 5)
261253

262254

263255

@@ -287,7 +279,7 @@ struct DirectoryGridBrowser : View {
287279
Text(subItem.lastComponent)
288280
Button(action: {
289281
setFavorite(name: subItem.lastComponent, path: subItem.path)
290-
let newFavorite = UIMutableApplicationShortcutItem(type: "FB_\(subItem.lastComponent)", localizedTitle: subItem.lastComponent, localizedSubtitle: subItem.path, icon: UIApplicationShortcutIcon(systemImageName: subItem.isFolder ? "folder.fill" : "square.and.arrow.down.fill"))
282+
let newFavorite = UIMutableApplicationShortcutItem(type: "FB_\(subItem.lastComponent)", localizedTitle: subItem.lastComponent, localizedSubtitle: subItem.path, icon: UIApplicationShortcutIcon(systemImageName: itemImage(for: subItem))) //subItem.isFolder ? "folder.fill" : "square.and.arrow.down.fill"))
291283
UIApplication.shared.shortcutItems?.append(newFavorite)
292284
NSLog("Added to Favorites.")
293285
}){

0 commit comments

Comments
 (0)