diff --git a/YAPS/YAPS/Assets.xcassets/folder.symbolset/Contents.json b/YAPS/YAPS/Assets.xcassets/folder.symbolset/Contents.json deleted file mode 100644 index 3038316..0000000 --- a/YAPS/YAPS/Assets.xcassets/folder.symbolset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - }, - "symbols" : [ - { - "filename" : "folder.svg", - "idiom" : "universal" - } - ] -} diff --git a/YAPS/YAPS/Assets.xcassets/folder.symbolset/folder.svg b/YAPS/YAPS/Assets.xcassets/folder.symbolset/folder.svg deleted file mode 100644 index 17e0ca7..0000000 --- a/YAPS/YAPS/Assets.xcassets/folder.symbolset/folder.svg +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - Weight/Scale Variations - Ultralight - Thin - Light - Regular - Medium - Semibold - Bold - Heavy - Black - - - - - - - - - - - Design Variations - Symbols are supported in up to nine weights and three scales. - For optimal layout with text and other symbols, vertically align - symbols with the adjacent text. - - - - - - Margins - Leading and trailing margins on the left and right side of each symbol - can be adjusted by modifying the x-location of the margin guidelines. - Modifications are automatically applied proportionally to all - scales and weights. - - - - Exporting - Symbols should be outlined when exporting to ensure the - design is preserved when submitting to Xcode. - Template v.2.0 - Requires Xcode 12 or greater - Generated from folder - Typeset at 100 points - Small - Medium - Large - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/YAPS/YAPS/ContentView.swift b/YAPS/YAPS/ContentView.swift index 5cc3afc..3e42673 100644 --- a/YAPS/YAPS/ContentView.swift +++ b/YAPS/YAPS/ContentView.swift @@ -13,77 +13,97 @@ struct ContentView: View { @State var previewImg = Image("placeholder-image") var body: some View { - HStack { - VStack(alignment: .leading) { - /* - HStack { - Image.init("folder") - - Button(action: { - let files = FinderHelper.shared.askForFolderAndGetFiles() + VStack { + HStack(spacing: 0.0) { + VStack(alignment: .leading) { + /* + HStack { + Image.init("folder") - if files.count > 0 { - self.fileList.removeAll() - self.fileList.append(contentsOf: files) + Button(action: { + let files = FinderHelper.shared.askForFolderAndGetFiles() - self.resetCurrentFile() - } - }) { - Text("􀈕 Select Folder") - } - } - */ - - List() { - ForEach(self.observedFileList.array, id: \.self) { yapsFile in - YapsFileCell(focused: self.checkCurrentFile(yapsFile: yapsFile), yapsFile: yapsFile) - .onTapGesture(perform: { - print("pressed \(yapsFile.name)") + if files.count > 0 { + self.fileList.removeAll() + self.fileList.append(contentsOf: files) - self.setCurrentFile(newCurrent: yapsFile, at: yapsFile.index) - }) + self.resetCurrentFile() + } + }) { + Text("􀈕 Select Folder") + } + } + */ + + List() { + ForEach(self.observedFileList.array, id: \.self) { yapsFile in + YapsFileCell(focused: self.checkCurrentFile(yapsFile: yapsFile), yapsFile: yapsFile) + .onTapGesture(perform: { + print("pressed \(yapsFile.name)") + + self.setCurrentFile(newCurrent: yapsFile, at: yapsFile.index) + }) + } + } + .listStyle(SidebarListStyle()) + .focusable() + .onMoveCommand { (direction) in + if Shared.shared.fileList.array.count > 0 { + var newIndex = Shared.shared.currentFile.index + + print("\(direction)") + + switch direction { + case MoveCommandDirection.down: + let max = self.observedFileList.array.count + if (newIndex + 1) < max { + newIndex += 1 + } + case MoveCommandDirection.up: + if (newIndex - 1) >= 0 { + newIndex -= 1 + } + default: + newIndex += 0 + } + + self.setCurrentFile(newCurrent: self.observedFileList.array[newIndex], at: newIndex) + } } } - .listStyle(SidebarListStyle()) - .focusable() - .onMoveCommand { (direction) in - var newIndex = Shared.shared.currentFile.index - - print("\(direction)") - - switch direction { - case MoveCommandDirection.down: - let max = self.observedFileList.array.count - if (newIndex + 1) < max { - newIndex += 1 - } - case MoveCommandDirection.up: - if (newIndex - 1) >= 0 { - newIndex -= 1 - } - default: - newIndex += 0 + .frame(width: 260.0) + + + GeometryReader { geo in + VStack(alignment: .center) { + self.previewImg.self + .resizable() + .aspectRatio(contentMode: .fit) } - - self.setCurrentFile(newCurrent: self.observedFileList.array[newIndex], at: newIndex) + .aspectRatio(contentMode: .fit) + .frame(width: geo.size.width, height: geo.size.height) } } - .frame(width: 260.0) + Divider() - GeometryReader { geo in - VStack(alignment: .center) { - self.previewImg.self - .resizable() - .aspectRatio(contentMode: .fit) - + // Statusleiste + Group { + HStack { Text("\(Shared.shared.currentFile.file.path)") .multilineTextAlignment(.leading) .lineLimit(1) + .padding(.leading, 6.0) + + Spacer() + + Text("\(Shared.shared.destination.path)") + .multilineTextAlignment(.leading) + .lineLimit(1) + .padding(.trailing, 6.0) } - .aspectRatio(contentMode: .fit) - .frame(width: geo.size.width, height: geo.size.height) } + .padding(.bottom, 6.0) } } diff --git a/YAPS/YAPS/Model/ObservableArray.swift b/YAPS/YAPS/Model/ObservableArray.swift index febb70d..35f8eaf 100644 --- a/YAPS/YAPS/Model/ObservableArray.swift +++ b/YAPS/YAPS/Model/ObservableArray.swift @@ -5,6 +5,8 @@ // Created by Gerrit Linnemann on 20.09.20. // Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved. // +// Infos: https://www.thetopsites.net/article/58523692.shtml +// import Foundation import Combine diff --git a/YAPS/YAPS/Shared.swift b/YAPS/YAPS/Shared.swift index 22cf4b4..d6c0f4b 100644 --- a/YAPS/YAPS/Shared.swift +++ b/YAPS/YAPS/Shared.swift @@ -14,8 +14,8 @@ class Shared: ObservableObject { var fileList: ObservableArray var currentFile: YapsFile - var destination: URL - var destinationDefined: Bool + @Published var destination: URL + @Published var destinationDefined: Bool init() { self.fileList = ObservableArray(array: []) diff --git a/YAPS/YAPS/Toolbar.swift b/YAPS/YAPS/Toolbar.swift index 3ffcf64..0768382 100644 --- a/YAPS/YAPS/Toolbar.swift +++ b/YAPS/YAPS/Toolbar.swift @@ -13,8 +13,7 @@ extension NSImage.Name { } extension NSToolbarItem.Identifier { - static let calendar = NSToolbarItem.Identifier(rawValue: "ShowCalendar") - static let today = NSToolbarItem.Identifier(rawValue: "GoToToday") + static let sourceFolder = NSToolbarItem.Identifier(rawValue: "SourceFolder") } extension NSToolbar { @@ -28,11 +27,15 @@ extension NSToolbar { extension AppDelegate: NSToolbarDelegate { func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - [.today, .calendar] + [ + .sourceFolder + ] } func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - [.today, .calendar] + [ + .sourceFolder + ] } @objc @@ -43,10 +46,10 @@ extension AppDelegate: NSToolbarDelegate { func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { switch itemIdentifier { - case NSToolbarItem.Identifier.calendar: + case NSToolbarItem.Identifier.sourceFolder: let button = NSButton(image: NSImage(named: .folder)!, target: nil, action: #selector(toolbarOpenSourceAction)) button.bezelStyle = .texturedRounded - return customToolbarItem(itemIdentifier: .calendar, label: "Open", paletteLabel: "Open", toolTip: "Open source folder", itemContent: button) + return customToolbarItem(itemIdentifier: .sourceFolder, label: "Open", paletteLabel: "Open", toolTip: "Open source folder", itemContent: button) default: return nil }