Init
This commit is contained in:
parent
2aa40e0742
commit
893829d0e5
@ -1,136 +0,0 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 21.07.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import SwiftUI
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
var window: NSWindow!
|
||||
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Create the SwiftUI view and set the context as the value for the managedObjectContext environment keyPath.
|
||||
// Add `@Environment(\.managedObjectContext)` in the views that will need the context.
|
||||
let contentView = ContentView().environment(\.managedObjectContext, persistentContainer.viewContext)
|
||||
|
||||
// Create the window and set the content view.
|
||||
window = NSWindow(
|
||||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
||||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||
backing: .buffered, defer: false)
|
||||
window.center()
|
||||
window.setFrameAutosaveName("Main Window")
|
||||
window.contentView = NSHostingView(rootView: contentView)
|
||||
window.makeKeyAndOrderFront(nil)
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
// Insert code here to tear down your application
|
||||
}
|
||||
|
||||
// MARK: - Core Data stack
|
||||
|
||||
lazy var persistentContainer: NSPersistentContainer = {
|
||||
/*
|
||||
The persistent container for the application. This implementation
|
||||
creates and returns a container, having loaded the store for the
|
||||
application to it. This property is optional since there are legitimate
|
||||
error conditions that could cause the creation of the store to fail.
|
||||
*/
|
||||
let container = NSPersistentContainer(name: "YAPS")
|
||||
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
|
||||
if let error = error {
|
||||
// Replace this implementation with code to handle the error appropriately.
|
||||
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||
|
||||
/*
|
||||
Typical reasons for an error here include:
|
||||
* The parent directory does not exist, cannot be created, or disallows writing.
|
||||
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
|
||||
* The device is out of space.
|
||||
* The store could not be migrated to the current model version.
|
||||
Check the error message to determine what the actual problem was.
|
||||
*/
|
||||
fatalError("Unresolved error \(error)")
|
||||
}
|
||||
})
|
||||
return container
|
||||
}()
|
||||
|
||||
// MARK: - Core Data Saving and Undo support
|
||||
|
||||
@IBAction func saveAction(_ sender: AnyObject?) {
|
||||
// Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user.
|
||||
let context = persistentContainer.viewContext
|
||||
|
||||
if !context.commitEditing() {
|
||||
NSLog("\(NSStringFromClass(type(of: self))) unable to commit editing before saving")
|
||||
}
|
||||
if context.hasChanges {
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
// Customize this code block to include application-specific recovery steps.
|
||||
let nserror = error as NSError
|
||||
NSApplication.shared.presentError(nserror)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func windowWillReturnUndoManager(window: NSWindow) -> UndoManager? {
|
||||
// Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application.
|
||||
return persistentContainer.viewContext.undoManager
|
||||
}
|
||||
|
||||
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
||||
// Save changes in the application's managed object context before the application terminates.
|
||||
let context = persistentContainer.viewContext
|
||||
|
||||
if !context.commitEditing() {
|
||||
NSLog("\(NSStringFromClass(type(of: self))) unable to commit editing to terminate")
|
||||
return .terminateCancel
|
||||
}
|
||||
|
||||
if !context.hasChanges {
|
||||
return .terminateNow
|
||||
}
|
||||
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
let nserror = error as NSError
|
||||
|
||||
// Customize this code block to include application-specific recovery steps.
|
||||
let result = sender.presentError(nserror)
|
||||
if (result) {
|
||||
return .terminateCancel
|
||||
}
|
||||
|
||||
let question = NSLocalizedString("Could not save changes while quitting. Quit anyway?", comment: "Quit without saves error question message")
|
||||
let info = NSLocalizedString("Quitting now will lose any changes you have made since the last successful save", comment: "Quit without saves error question info");
|
||||
let quitButton = NSLocalizedString("Quit anyway", comment: "Quit anyway button title")
|
||||
let cancelButton = NSLocalizedString("Cancel", comment: "Cancel button title")
|
||||
let alert = NSAlert()
|
||||
alert.messageText = question
|
||||
alert.informativeText = info
|
||||
alert.addButton(withTitle: quitButton)
|
||||
alert.addButton(withTitle: cancelButton)
|
||||
|
||||
let answer = alert.runModal()
|
||||
if answer == .alertSecondButtonReturn {
|
||||
return .terminateCancel
|
||||
}
|
||||
}
|
||||
// If we got here, it is time to quit.
|
||||
return .terminateNow
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 21.07.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
Text("Hello, World!")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>_XCCurrentVersionName</key>
|
||||
<string>YAPS.xcdatamodel</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
|
||||
<elements/>
|
||||
</model>
|
||||
@ -7,28 +7,30 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
EC2C21D524C769EB009E7ED1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2C21D424C769EB009E7ED1 /* AppDelegate.swift */; };
|
||||
EC2C21D724C769EB009E7ED1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2C21D624C769EB009E7ED1 /* ContentView.swift */; };
|
||||
EC2C21DA24C769EB009E7ED1 /* YAPS.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = EC2C21D824C769EB009E7ED1 /* YAPS.xcdatamodeld */; };
|
||||
EC2C21DC24C769EF009E7ED1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EC2C21DB24C769EF009E7ED1 /* Assets.xcassets */; };
|
||||
EC2C21DF24C769EF009E7ED1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EC2C21DE24C769EF009E7ED1 /* Preview Assets.xcassets */; };
|
||||
EC2C21E224C769EF009E7ED1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EC2C21E024C769EF009E7ED1 /* Main.storyboard */; };
|
||||
EC13305B24DAE92D008063CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13305A24DAE92D008063CF /* AppDelegate.swift */; };
|
||||
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13305C24DAE92D008063CF /* ContentView.swift */; };
|
||||
EC13305F24DAE92E008063CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EC13305E24DAE92E008063CF /* Assets.xcassets */; };
|
||||
EC13306224DAE92E008063CF /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EC13306124DAE92E008063CF /* Preview Assets.xcassets */; };
|
||||
EC13306524DAE92E008063CF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EC13306324DAE92E008063CF /* Main.storyboard */; };
|
||||
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13306E24DD687F008063CF /* YapsFile.swift */; };
|
||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307024DDB3F4008063CF /* FinderHelper.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
EC2C21D124C769EB009E7ED1 /* YAPS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YAPS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EC2C21D424C769EB009E7ED1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
EC2C21D624C769EB009E7ED1 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
EC2C21D924C769EB009E7ED1 /* YAPS.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = YAPS.xcdatamodel; sourceTree = "<group>"; };
|
||||
EC2C21DB24C769EF009E7ED1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EC2C21DE24C769EF009E7ED1 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
EC2C21E124C769EF009E7ED1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
EC2C21E324C769EF009E7ED1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
EC2C21E424C769EF009E7ED1 /* YAPS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = YAPS.entitlements; sourceTree = "<group>"; };
|
||||
EC13305724DAE92D008063CF /* YAPS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YAPS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EC13305A24DAE92D008063CF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
EC13305C24DAE92D008063CF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
EC13305E24DAE92E008063CF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EC13306124DAE92E008063CF /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
EC13306424DAE92E008063CF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
EC13306624DAE92E008063CF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
EC13306724DAE92E008063CF /* YAPS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = YAPS.entitlements; sourceTree = "<group>"; };
|
||||
EC13306E24DD687F008063CF /* YapsFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFile.swift; sourceTree = "<group>"; };
|
||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderHelper.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
EC2C21CE24C769EB009E7ED1 /* Frameworks */ = {
|
||||
EC13305424DAE92D008063CF /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
@ -38,55 +40,64 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
EC2C21C824C769EB009E7ED1 = {
|
||||
EC13304E24DAE92D008063CF = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC2C21D324C769EB009E7ED1 /* YAPS */,
|
||||
EC2C21D224C769EB009E7ED1 /* Products */,
|
||||
EC13305924DAE92D008063CF /* YAPS */,
|
||||
EC13305824DAE92D008063CF /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC2C21D224C769EB009E7ED1 /* Products */ = {
|
||||
EC13305824DAE92D008063CF /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC2C21D124C769EB009E7ED1 /* YAPS.app */,
|
||||
EC13305724DAE92D008063CF /* YAPS.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC2C21D324C769EB009E7ED1 /* YAPS */ = {
|
||||
EC13305924DAE92D008063CF /* YAPS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC2C21D424C769EB009E7ED1 /* AppDelegate.swift */,
|
||||
EC2C21D624C769EB009E7ED1 /* ContentView.swift */,
|
||||
EC2C21DB24C769EF009E7ED1 /* Assets.xcassets */,
|
||||
EC2C21E024C769EF009E7ED1 /* Main.storyboard */,
|
||||
EC2C21E324C769EF009E7ED1 /* Info.plist */,
|
||||
EC2C21E424C769EF009E7ED1 /* YAPS.entitlements */,
|
||||
EC2C21D824C769EB009E7ED1 /* YAPS.xcdatamodeld */,
|
||||
EC2C21DD24C769EF009E7ED1 /* Preview Content */,
|
||||
EC13306D24DD685F008063CF /* Model */,
|
||||
EC13305A24DAE92D008063CF /* AppDelegate.swift */,
|
||||
EC13305C24DAE92D008063CF /* ContentView.swift */,
|
||||
EC13305E24DAE92E008063CF /* Assets.xcassets */,
|
||||
EC13306324DAE92E008063CF /* Main.storyboard */,
|
||||
EC13306624DAE92E008063CF /* Info.plist */,
|
||||
EC13306724DAE92E008063CF /* YAPS.entitlements */,
|
||||
EC13306024DAE92E008063CF /* Preview Content */,
|
||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */,
|
||||
);
|
||||
path = YAPS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC2C21DD24C769EF009E7ED1 /* Preview Content */ = {
|
||||
EC13306024DAE92E008063CF /* Preview Content */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC2C21DE24C769EF009E7ED1 /* Preview Assets.xcassets */,
|
||||
EC13306124DAE92E008063CF /* Preview Assets.xcassets */,
|
||||
);
|
||||
path = "Preview Content";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC13306D24DD685F008063CF /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC13306E24DD687F008063CF /* YapsFile.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
EC2C21D024C769EB009E7ED1 /* YAPS */ = {
|
||||
EC13305624DAE92D008063CF /* YAPS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = EC2C21E724C769EF009E7ED1 /* Build configuration list for PBXNativeTarget "YAPS" */;
|
||||
buildConfigurationList = EC13306A24DAE92E008063CF /* Build configuration list for PBXNativeTarget "YAPS" */;
|
||||
buildPhases = (
|
||||
EC2C21CD24C769EB009E7ED1 /* Sources */,
|
||||
EC2C21CE24C769EB009E7ED1 /* Frameworks */,
|
||||
EC2C21CF24C769EB009E7ED1 /* Resources */,
|
||||
EC13305324DAE92D008063CF /* Sources */,
|
||||
EC13305424DAE92D008063CF /* Frameworks */,
|
||||
EC13305524DAE92D008063CF /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -94,25 +105,25 @@
|
||||
);
|
||||
name = YAPS;
|
||||
productName = YAPS;
|
||||
productReference = EC2C21D124C769EB009E7ED1 /* YAPS.app */;
|
||||
productReference = EC13305724DAE92D008063CF /* YAPS.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
EC2C21C924C769EB009E7ED1 /* Project object */ = {
|
||||
EC13304F24DAE92D008063CF /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1140;
|
||||
LastUpgradeCheck = 1140;
|
||||
ORGANIZATIONNAME = "Adawim UG (haftungsbeschränkt)";
|
||||
TargetAttributes = {
|
||||
EC2C21D024C769EB009E7ED1 = {
|
||||
EC13305624DAE92D008063CF = {
|
||||
CreatedOnToolsVersion = 11.4.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = EC2C21CC24C769EB009E7ED1 /* Build configuration list for PBXProject "YAPS" */;
|
||||
buildConfigurationList = EC13305224DAE92D008063CF /* Build configuration list for PBXProject "YAPS" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
@ -120,47 +131,48 @@
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = EC2C21C824C769EB009E7ED1;
|
||||
productRefGroup = EC2C21D224C769EB009E7ED1 /* Products */;
|
||||
mainGroup = EC13304E24DAE92D008063CF;
|
||||
productRefGroup = EC13305824DAE92D008063CF /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
EC2C21D024C769EB009E7ED1 /* YAPS */,
|
||||
EC13305624DAE92D008063CF /* YAPS */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
EC2C21CF24C769EB009E7ED1 /* Resources */ = {
|
||||
EC13305524DAE92D008063CF /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EC2C21E224C769EF009E7ED1 /* Main.storyboard in Resources */,
|
||||
EC2C21DF24C769EF009E7ED1 /* Preview Assets.xcassets in Resources */,
|
||||
EC2C21DC24C769EF009E7ED1 /* Assets.xcassets in Resources */,
|
||||
EC13306524DAE92E008063CF /* Main.storyboard in Resources */,
|
||||
EC13306224DAE92E008063CF /* Preview Assets.xcassets in Resources */,
|
||||
EC13305F24DAE92E008063CF /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
EC2C21CD24C769EB009E7ED1 /* Sources */ = {
|
||||
EC13305324DAE92D008063CF /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EC2C21D724C769EB009E7ED1 /* ContentView.swift in Sources */,
|
||||
EC2C21D524C769EB009E7ED1 /* AppDelegate.swift in Sources */,
|
||||
EC2C21DA24C769EB009E7ED1 /* YAPS.xcdatamodeld in Sources */,
|
||||
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */,
|
||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */,
|
||||
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */,
|
||||
EC13305B24DAE92D008063CF /* AppDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
EC2C21E024C769EF009E7ED1 /* Main.storyboard */ = {
|
||||
EC13306324DAE92E008063CF /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
EC2C21E124C769EF009E7ED1 /* Base */,
|
||||
EC13306424DAE92E008063CF /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
@ -168,7 +180,7 @@
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
EC2C21E524C769EF009E7ED1 /* Debug */ = {
|
||||
EC13306824DAE92E008063CF /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
@ -228,7 +240,7 @@
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EC2C21E624C769EF009E7ED1 /* Release */ = {
|
||||
EC13306924DAE92E008063CF /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
@ -281,7 +293,7 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
EC2C21E824C769EF009E7ED1 /* Debug */ = {
|
||||
EC13306B24DAE92E008063CF /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
@ -296,13 +308,13 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.adawim.yaps.YAPS;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.adawim.macos.YAPS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EC2C21E924C769EF009E7ED1 /* Release */ = {
|
||||
EC13306C24DAE92E008063CF /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
@ -317,7 +329,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.adawim.yaps.YAPS;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.adawim.macos.YAPS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
@ -326,38 +338,25 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
EC2C21CC24C769EB009E7ED1 /* Build configuration list for PBXProject "YAPS" */ = {
|
||||
EC13305224DAE92D008063CF /* Build configuration list for PBXProject "YAPS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EC2C21E524C769EF009E7ED1 /* Debug */,
|
||||
EC2C21E624C769EF009E7ED1 /* Release */,
|
||||
EC13306824DAE92E008063CF /* Debug */,
|
||||
EC13306924DAE92E008063CF /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
EC2C21E724C769EF009E7ED1 /* Build configuration list for PBXNativeTarget "YAPS" */ = {
|
||||
EC13306A24DAE92E008063CF /* Build configuration list for PBXNativeTarget "YAPS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EC2C21E824C769EF009E7ED1 /* Debug */,
|
||||
EC2C21E924C769EF009E7ED1 /* Release */,
|
||||
EC13306B24DAE92E008063CF /* Debug */,
|
||||
EC13306C24DAE92E008063CF /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCVersionGroup section */
|
||||
EC2C21D824C769EB009E7ED1 /* YAPS.xcdatamodeld */ = {
|
||||
isa = XCVersionGroup;
|
||||
children = (
|
||||
EC2C21D924C769EB009E7ED1 /* YAPS.xcdatamodel */,
|
||||
);
|
||||
currentVersion = EC2C21D924C769EB009E7ED1 /* YAPS.xcdatamodel */;
|
||||
path = YAPS.xcdatamodeld;
|
||||
sourceTree = "<group>";
|
||||
versionGroupType = wrapper.xcdatamodel;
|
||||
};
|
||||
/* End XCVersionGroup section */
|
||||
};
|
||||
rootObject = EC2C21C924C769EB009E7ED1 /* Project object */;
|
||||
rootObject = EC13304F24DAE92D008063CF /* Project object */;
|
||||
}
|
||||
39
YAPS/YAPS/AppDelegate.swift
Normal file
39
YAPS/YAPS/AppDelegate.swift
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 05.08.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import SwiftUI
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
var window: NSWindow!
|
||||
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Create the SwiftUI view that provides the window contents.
|
||||
let contentView = ContentView(finderHelper: FinderHelper())
|
||||
|
||||
// Create the window and set the content view.
|
||||
window = NSWindow(
|
||||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
||||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||
backing: .buffered, defer: false)
|
||||
window.center()
|
||||
window.setFrameAutosaveName("Main Window")
|
||||
window.contentView = NSHostingView(rootView: contentView)
|
||||
window.makeKeyAndOrderFront(nil)
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
// Insert code here to tear down your application
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
21
YAPS/YAPS/Assets.xcassets/file_raw.imageset/Contents.json
vendored
Normal file
21
YAPS/YAPS/Assets.xcassets/file_raw.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "file_raw.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
YAPS/YAPS/Assets.xcassets/file_raw.imageset/file_raw.png
vendored
Normal file
BIN
YAPS/YAPS/Assets.xcassets/file_raw.imageset/file_raw.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
54
YAPS/YAPS/ContentView.swift
Normal file
54
YAPS/YAPS/ContentView.swift
Normal file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 05.08.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
|
||||
@State var fileList = [YapsFile]()
|
||||
|
||||
var finderHelper: FinderHelper
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
VStack {
|
||||
HStack {
|
||||
Button(action: {
|
||||
self.fileList.append(contentsOf: self.finderHelper.selectFolder())
|
||||
}) {
|
||||
Text("Select Folder")
|
||||
}
|
||||
}
|
||||
|
||||
List {
|
||||
ForEach(self.fileList, id: \.self) { yapsFile in
|
||||
HStack {
|
||||
Image("file_raw").resizable().frame(width: 20, height: 20)
|
||||
Text(yapsFile.name)
|
||||
}
|
||||
.onTapGesture(perform: {
|
||||
print("pressed \(yapsFile.name)")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Text("THUMBNAIL")
|
||||
}
|
||||
|
||||
Text("Hello, World!")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView(finderHelper: FinderHelper())
|
||||
}
|
||||
}
|
||||
57
YAPS/YAPS/FinderHelper.swift
Normal file
57
YAPS/YAPS/FinderHelper.swift
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// FinderHelper.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 07.08.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
class FinderHelper {
|
||||
|
||||
func selectFolder() -> [YapsFile] {
|
||||
let dialog = NSOpenPanel();
|
||||
var fileList = [YapsFile]()
|
||||
|
||||
dialog.title = "Select folder of images"
|
||||
dialog.showsResizeIndicator = true
|
||||
dialog.showsHiddenFiles = false
|
||||
dialog.allowsMultipleSelection = false
|
||||
dialog.canChooseFiles = false
|
||||
dialog.canChooseDirectories = true
|
||||
|
||||
if(dialog.runModal() == NSApplication.ModalResponse.OK) {
|
||||
let result = dialog.url
|
||||
|
||||
if(result != nil) {
|
||||
let path: String = result!.path
|
||||
print("Use \(path)")
|
||||
fileList.append(contentsOf: getFilesList(path: result!))
|
||||
}
|
||||
} else {
|
||||
// User clicked on "Cancel"
|
||||
}
|
||||
|
||||
return fileList
|
||||
}
|
||||
|
||||
func getFilesList(path: URL) -> [YapsFile] {
|
||||
let fm = FileManager.default
|
||||
var fileList = [YapsFile]()
|
||||
|
||||
do {
|
||||
let items = try fm.contentsOfDirectory(at: path, includingPropertiesForKeys: nil, options: .skipsHiddenFiles)
|
||||
|
||||
for item in items {
|
||||
let yapsFile: YapsFile = YapsFile(name: item.lastPathComponent, file: item)
|
||||
fileList.append(yapsFile)
|
||||
}
|
||||
} catch {
|
||||
// failed to read directory – bad permissions, perhaps?
|
||||
}
|
||||
|
||||
return fileList
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,8 @@
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.photography</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
16
YAPS/YAPS/Model/YapsFile.swift
Normal file
16
YAPS/YAPS/Model/YapsFile.swift
Normal file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// File.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 07.08.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct YapsFile: Identifiable, Hashable {
|
||||
let id = UUID()
|
||||
|
||||
var name: String
|
||||
var file: URL
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user