From 1284de33cf095ecb8d6a7da9c7c22de44dfa0607 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Sun, 4 Oct 2020 16:08:58 -0400 Subject: [PATCH 01/14] fixed beta updates --- Speculid.xcodeproj/project.pbxproj | 8 +++--- Speculid/ClassicDocument.swift | 43 ++++++++++++++++++++++-------- Speculid/ClassicView.swift | 38 ++++++++++++++------------ packages/SpeculidKit | 2 +- scripts/github-markdown-toc | 2 +- 5 files changed, 59 insertions(+), 34 deletions(-) diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 88123fe8..712ba318 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -250,7 +250,7 @@ }; }; buildConfigurationList = B3DB4800243162DA00B1DA4F /* Build configuration list for PBXProject "Speculid" */; - compatibilityVersion = "Xcode 9.3"; + compatibilityVersion = "Xcode 12.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -357,7 +357,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.16; + MACOSX_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = YES; }; name = Debug; @@ -391,7 +391,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.16; + MACOSX_DEPLOYMENT_TARGET = 11.0; }; name = Release; }; diff --git a/Speculid/ClassicDocument.swift b/Speculid/ClassicDocument.swift index c8151311..e4badb8a 100644 --- a/Speculid/ClassicDocument.swift +++ b/Speculid/ClassicDocument.swift @@ -10,6 +10,8 @@ extension UTType { } struct ClassicDocument: FileDocument { + + var document: SpeculidMutableSpecificationsFile init(document: SpeculidSpecificationsFile = SpeculidSpecificationsFile()) { @@ -17,22 +19,41 @@ struct ClassicDocument: FileDocument { } static var readableContentTypes: [UTType] { [.speculidImageDocument] } - - init(fileWrapper: FileWrapper, contentType _: UTType) throws { - let decoder = JSONDecoder() - guard let data = fileWrapper.regularFileContents - else { - throw CocoaError(.fileReadCorruptFile) - } - let document = try decoder.decode(SpeculidSpecificationsFile.self, from: data) - self.document = SpeculidMutableSpecificationsFile(source: document) +// +// init(fileWrapper: FileWrapper, contentType _: UTType) throws { +// let decoder = JSONDecoder() +// guard let data = fileWrapper.regularFileContents +// else { +// throw CocoaError(.fileReadCorruptFile) +// } +// let document = try decoder.decode(SpeculidSpecificationsFile.self, from: data) +// self.document = SpeculidMutableSpecificationsFile(source: document) +// } +// + + init(configuration: ReadConfiguration) throws { + + let decoder = JSONDecoder() + guard let data = configuration.file.regularFileContents + else { + throw CocoaError(.fileReadCorruptFile) + } + let document = try decoder.decode(SpeculidSpecificationsFile.self, from: data) + self.document = SpeculidMutableSpecificationsFile(source: document) } - func write(to fileWrapper: inout FileWrapper, contentType _: UTType) throws { +// func write(to fileWrapper: inout FileWrapper, contentType _: UTType) throws { +// let document = SpeculidSpecificationsFile(source: self.document) +// let encoder = JSONEncoder() +// let data = try encoder.encode(document) +// fileWrapper = FileWrapper(regularFileWithContents: data) +// } + + func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { let document = SpeculidSpecificationsFile(source: self.document) let encoder = JSONEncoder() let data = try encoder.encode(document) - fileWrapper = FileWrapper(regularFileWithContents: data) + return FileWrapper(regularFileWithContents: data) } func build(fromURL url: URL, inSandbox sandbox: Sandbox) { diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 1bca41a3..baf10e09 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -5,7 +5,8 @@ import SwiftUI struct ClassicView: View { @StateObject var object: ClassicObject @EnvironmentObject var bookmarkCollection: BookmarkURLCollectionObject - @Environment(\.importFiles) var importFiles + @State private var isImporting: Bool = false + init(url: URL?, document: ClassicDocument, documentBinding _: Binding) { _object = StateObject(wrappedValue: ClassicObject(url: url, document: document)) @@ -27,14 +28,16 @@ struct ClassicView: View { Text("File Path:").frame(width: 75, alignment: .trailing) TextField("SVG of PNG File", text: self.$object.sourceImageRelativePath) .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) - .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250).onTapGesture { - self.importFiles(singleOfType: [.svg, .png]) { result in - guard case let .success(url) = result else { - return - } - bookmarkCollection.saveBookmark(url) - } - } + .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) + +// .onTapGesture { +// self.importFiles(singleOfType: [.svg, .png]) { result in +// guard case let .success(url) = result else { +// return +// } +// bookmarkCollection.saveBookmark(url) +// } +// } Image(systemName: "lock.fill").foregroundColor(.yellow).opacity(self.bookmarkCollection.isAvailable(basedOn: self.object.url, relativePath: self.object.sourceImageRelativePath) ? 0.0 : 1.0) Spacer() } @@ -46,14 +49,15 @@ struct ClassicView: View { Text("Folder:").frame(width: 75, alignment: .trailing) TextField(".appiconset or .imageset", text: self.$object.assetDirectoryRelativePath) .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) - .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250).onTapGesture { - self.importFiles(singleOfType: [.directory]) { result in - guard case let .success(url) = result else { - return - } - bookmarkCollection.saveBookmark(url) - } - } + .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) +// .onTapGesture { +// self.importFiles(singleOfType: [.directory]) { result in +// guard case let .success(url) = result else { +// return +// } +// bookmarkCollection.saveBookmark(url) +// } +// } Image(systemName: "lock.fill").foregroundColor(.yellow).opacity(self.bookmarkCollection.isAvailable(basedOn: self.object.url, relativePath: self.object.assetDirectoryRelativePath) ? 0.0 : 1.0) Spacer() } diff --git a/packages/SpeculidKit b/packages/SpeculidKit index 4dde8dc3..393f300f 160000 --- a/packages/SpeculidKit +++ b/packages/SpeculidKit @@ -1 +1 @@ -Subproject commit 4dde8dc3ad6addcc4a9ea6a56011f074859bf085 +Subproject commit 393f300fb891d029890fbf003314fac3dc2b2ea2 diff --git a/scripts/github-markdown-toc b/scripts/github-markdown-toc index 83fadb60..488f3100 160000 --- a/scripts/github-markdown-toc +++ b/scripts/github-markdown-toc @@ -1 +1 @@ -Subproject commit 83fadb60a7f1607c1c46e868ed2a866bb70b4c76 +Subproject commit 488f310064b16c1eb9c17862cc5844189ee65955 From 9b3e438145fb48c81249a2473529714d73ebf2e3 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Sun, 4 Oct 2020 18:41:52 -0400 Subject: [PATCH 02/14] working with updates --- Speculid/ClassicDocument.swift | 6 +++--- packages/SpeculidKit | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Speculid/ClassicDocument.swift b/Speculid/ClassicDocument.swift index e4badb8a..223577aa 100644 --- a/Speculid/ClassicDocument.swift +++ b/Speculid/ClassicDocument.swift @@ -82,9 +82,9 @@ struct ClassicDocument: FileDocument { let assetDirectoryURL = url.deletingLastPathComponent().appendingPathComponent(self.document.assetDirectoryRelativePath) let imageSpecificationBuilder = SpeculidImageSpecificationBuilder() - let imageSpecifications: [ImageSpecification] + let imageSpecifications: [ImageSpecificationObject] do { - imageSpecifications = try sandboxMap.map { (asset, _, url) -> ImageSpecification in + imageSpecifications = try sandboxMap.map { (asset, _, url) -> ImageSpecificationObject in try imageSpecificationBuilder.imageSpecification(forURL: url, withSpecifications: document.specificationsFile, andAsset: asset) } } catch { @@ -92,7 +92,7 @@ struct ClassicDocument: FileDocument { return // callback(error) } - let service = Service() + let service = ServiceObject() let sourceURL: URL do { sourceURL = try management.bookmarkURL(fromURL: document.sourceImageURL) diff --git a/packages/SpeculidKit b/packages/SpeculidKit index 393f300f..a3d1f769 160000 --- a/packages/SpeculidKit +++ b/packages/SpeculidKit @@ -1 +1 @@ -Subproject commit 393f300fb891d029890fbf003314fac3dc2b2ea2 +Subproject commit a3d1f769c43837544ddac9792638a8cb73fbdbd7 From ea2970eafacecabb0eea51757e7936a2a978a2f8 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Sun, 4 Oct 2020 21:03:27 -0400 Subject: [PATCH 03/14] removing SwiftDraw --- Speculid/ClassicView.swift | 36 ++++++++++++++++++------------------ packages/SpeculidKit | 2 +- scripts/github-markdown-toc | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index baf10e09..c1d41e96 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -5,7 +5,8 @@ import SwiftUI struct ClassicView: View { @StateObject var object: ClassicObject @EnvironmentObject var bookmarkCollection: BookmarkURLCollectionObject - @State private var isImporting: Bool = false + @State private var isACImporting: Bool = false + @State private var isSourceImporting : Bool = false init(url: URL?, document: ClassicDocument, documentBinding _: Binding) { @@ -29,15 +30,14 @@ struct ClassicView: View { TextField("SVG of PNG File", text: self.$object.sourceImageRelativePath) .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) - -// .onTapGesture { -// self.importFiles(singleOfType: [.svg, .png]) { result in -// guard case let .success(url) = result else { -// return -// } -// bookmarkCollection.saveBookmark(url) -// } -// } + .fileImporter(isPresented: self.$isSourceImporting, allowedContentTypes: [.svg, .png]) { result in + guard case let .success(url) = result else { + return + } + bookmarkCollection.saveBookmark(url) + }.onTapGesture { + self.isSourceImporting = true + } Image(systemName: "lock.fill").foregroundColor(.yellow).opacity(self.bookmarkCollection.isAvailable(basedOn: self.object.url, relativePath: self.object.sourceImageRelativePath) ? 0.0 : 1.0) Spacer() } @@ -50,14 +50,14 @@ struct ClassicView: View { TextField(".appiconset or .imageset", text: self.$object.assetDirectoryRelativePath) .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) -// .onTapGesture { -// self.importFiles(singleOfType: [.directory]) { result in -// guard case let .success(url) = result else { -// return -// } -// bookmarkCollection.saveBookmark(url) -// } -// } + .fileImporter(isPresented: self.$isACImporting, allowedContentTypes: [.directory]) { result in + guard case let .success(url) = result else { + return + } + bookmarkCollection.saveBookmark(url) + }.onTapGesture { + self.isACImporting = true + } Image(systemName: "lock.fill").foregroundColor(.yellow).opacity(self.bookmarkCollection.isAvailable(basedOn: self.object.url, relativePath: self.object.assetDirectoryRelativePath) ? 0.0 : 1.0) Spacer() } diff --git a/packages/SpeculidKit b/packages/SpeculidKit index a3d1f769..7ad35613 160000 --- a/packages/SpeculidKit +++ b/packages/SpeculidKit @@ -1 +1 @@ -Subproject commit a3d1f769c43837544ddac9792638a8cb73fbdbd7 +Subproject commit 7ad356136d6d1c03b70b94f8967781add411ead4 diff --git a/scripts/github-markdown-toc b/scripts/github-markdown-toc index 488f3100..83fadb60 160000 --- a/scripts/github-markdown-toc +++ b/scripts/github-markdown-toc @@ -1 +1 @@ -Subproject commit 488f310064b16c1eb9c17862cc5844189ee65955 +Subproject commit 83fadb60a7f1607c1c46e868ed2a866bb70b4c76 From 75f0b6e33faba2604269fb978796a3c2a8d50f64 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Tue, 6 Oct 2020 20:40:08 -0400 Subject: [PATCH 04/14] fixing schemes --- Speculid.xcodeproj/project.pbxproj | 217 ------------------ .../xcshareddata/xcschemes/Speculid.xcscheme | 78 ------- packages/SpeculidKit | 2 +- 3 files changed, 1 insertion(+), 296 deletions(-) delete mode 100644 Speculid.xcodeproj/xcshareddata/xcschemes/Speculid.xcscheme diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 712ba318..95828df8 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ B347128924B64968001CCCFD /* ClassicDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = B347128824B64968001CCCFD /* ClassicDocument.swift */; }; B347128B24B668DE001CCCFD /* ClassicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B347128A24B668DE001CCCFD /* ClassicView.swift */; }; B34B6BC224BE354D00F4EE6B /* BookmarkURLCollectionObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34B6BC124BE354D00F4EE6B /* BookmarkURLCollectionObject.swift */; }; - B3796B7C2432C50100E5F5F9 /* speculid in CopyFiles */ = {isa = PBXBuildFile; fileRef = B3DB4824243166FC00B1DA4F /* speculid */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; B3B6A4D124B15292009C6E32 /* doc_appApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B364623E24B14DBB0089382E /* doc_appApp.swift */; }; B3DB48142431642600B1DA4F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B3DB48132431642600B1DA4F /* Assets.xcassets */; }; B3DB48172431642600B1DA4F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B3DB48162431642600B1DA4F /* Preview Assets.xcassets */; }; @@ -22,19 +21,8 @@ B3E1707C24C1DBF700784D20 /* LabeledOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E1707B24C1DBF700784D20 /* LabeledOption.swift */; }; B3E1707E24C1DC1100784D20 /* ResizeOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E1707D24C1DC1100784D20 /* ResizeOption.swift */; }; B3E1708024C1DC6C00784D20 /* ClassicObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E1707F24C1DC6C00784D20 /* ClassicObject.swift */; }; - B3E8D6B22434D71000B34464 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3DB4826243166FC00B1DA4F /* main.swift */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - B3796B7D2432C87600E5F5F9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = B3DB47FD243162DA00B1DA4F /* Project object */; - proxyType = 1; - remoteGlobalIDString = B3DB4823243166FC00B1DA4F; - remoteInfo = speculid; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXCopyFilesBuildPhase section */ B324D41624C49F500047ED11 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; @@ -52,16 +40,6 @@ buildActionMask = 8; dstPath = Contents/Helpers; dstSubfolderSpec = 1; - files = ( - B3796B7C2432C50100E5F5F9 /* speculid in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 1; - }; - B3DB4822243166FC00B1DA4F /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; files = ( ); runOnlyForDeploymentPostprocessing = 1; @@ -86,7 +64,6 @@ B3DB48192431642600B1DA4F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; B3DB481B2431642600B1DA4F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B3DB481C2431642600B1DA4F /* Speculid.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Speculid.entitlements; sourceTree = ""; }; - B3DB4824243166FC00B1DA4F /* speculid */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = speculid; sourceTree = BUILT_PRODUCTS_DIR; }; B3DB4826243166FC00B1DA4F /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B3E1707B24C1DBF700784D20 /* LabeledOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabeledOption.swift; sourceTree = ""; }; B3E1707D24C1DC1100784D20 /* ResizeOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResizeOption.swift; sourceTree = ""; }; @@ -103,13 +80,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B3DB4821243166FC00B1DA4F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -155,7 +125,6 @@ isa = PBXGroup; children = ( B3DB48072431642100B1DA4F /* Speculid.app */, - B3DB4824243166FC00B1DA4F /* speculid */, ); name = Products; sourceTree = ""; @@ -205,7 +174,6 @@ buildRules = ( ); dependencies = ( - B3796B7E2432C87600E5F5F9 /* PBXTargetDependency */, ); name = Speculid; packageProductDependencies = ( @@ -215,23 +183,6 @@ productReference = B3DB48072431642100B1DA4F /* Speculid.app */; productType = "com.apple.product-type.application"; }; - B3DB4823243166FC00B1DA4F /* speculid */ = { - isa = PBXNativeTarget; - buildConfigurationList = B3DB4828243166FC00B1DA4F /* Build configuration list for PBXNativeTarget "speculid" */; - buildPhases = ( - B3DB4820243166FC00B1DA4F /* Sources */, - B3DB4821243166FC00B1DA4F /* Frameworks */, - B3DB4822243166FC00B1DA4F /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = speculid; - productName = speculid; - productReference = B3DB4824243166FC00B1DA4F /* speculid */; - productType = "com.apple.product-type.tool"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -244,9 +195,6 @@ B3DB48062431642100B1DA4F = { CreatedOnToolsVersion = 11.4; }; - B3DB4823243166FC00B1DA4F = { - CreatedOnToolsVersion = 11.4; - }; }; }; buildConfigurationList = B3DB4800243162DA00B1DA4F /* Build configuration list for PBXProject "Speculid" */; @@ -263,7 +211,6 @@ projectRoot = ""; targets = ( B3DB48062431642100B1DA4F /* Speculid */, - B3DB4823243166FC00B1DA4F /* speculid */, ); }; /* End PBXProject section */ @@ -297,24 +244,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - B3DB4820243166FC00B1DA4F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - B3E8D6B22434D71000B34464 /* main.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - B3796B7E2432C87600E5F5F9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B3DB4823243166FC00B1DA4F /* speculid */; - targetProxy = B3796B7D2432C87600E5F5F9 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ B3DB48182431642600B1DA4F /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -588,145 +519,6 @@ }; name = Release; }; - B3DB4829243166FC00B1DA4F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_ENTITLEMENTS = command/Command.entitlements; - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - CREATE_INFOPLIST_SECTION_IN_BINARY = YES; - CURRENT_PROJECT_VERSION = 12; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = MLT7M394S7; - ENABLE_HARDENED_RUNTIME = YES; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = "$(SRCROOT)/command/Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 3.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-macOS-Cmd"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - B3DB482A243166FC00B1DA4F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_ENTITLEMENTS = command/Command.entitlements; - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - CREATE_INFOPLIST_SECTION_IN_BINARY = YES; - CURRENT_PROJECT_VERSION = 12; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = MLT7M394S7; - ENABLE_HARDENED_RUNTIME = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = "$(SRCROOT)/command/Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 3.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-macOS-Cmd"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - SKIP_INSTALL = YES; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -748,15 +540,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - B3DB4828243166FC00B1DA4F /* Build configuration list for PBXNativeTarget "speculid" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B3DB4829243166FC00B1DA4F /* Debug */, - B3DB482A243166FC00B1DA4F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ diff --git a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid.xcscheme b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid.xcscheme deleted file mode 100644 index 62ae0026..00000000 --- a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/SpeculidKit b/packages/SpeculidKit index 7ad35613..6d128988 160000 --- a/packages/SpeculidKit +++ b/packages/SpeculidKit @@ -1 +1 @@ -Subproject commit 7ad356136d6d1c03b70b94f8967781add411ead4 +Subproject commit 6d128988b1ef0529c6cb2b3d05175e4749c9e603 From e85c1c77eb4a8173fc8cd46c0de1c034ab489874 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 7 Oct 2020 11:02:25 -0400 Subject: [PATCH 05/14] working on creating new documents --- Speculid/ClassicDocument.swift | 13 ++----------- Speculid/ClassicView.swift | 3 +++ Speculid/doc_appApp.swift | 10 +++++----- packages/SpeculidKit | 2 +- scripts/github-markdown-toc | 2 +- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Speculid/ClassicDocument.swift b/Speculid/ClassicDocument.swift index 223577aa..f77b2e4f 100644 --- a/Speculid/ClassicDocument.swift +++ b/Speculid/ClassicDocument.swift @@ -19,17 +19,7 @@ struct ClassicDocument: FileDocument { } static var readableContentTypes: [UTType] { [.speculidImageDocument] } -// -// init(fileWrapper: FileWrapper, contentType _: UTType) throws { -// let decoder = JSONDecoder() -// guard let data = fileWrapper.regularFileContents -// else { -// throw CocoaError(.fileReadCorruptFile) -// } -// let document = try decoder.decode(SpeculidSpecificationsFile.self, from: data) -// self.document = SpeculidMutableSpecificationsFile(source: document) -// } -// + static var writableContentTypes: [UTType] { [.speculidImageDocument] } init(configuration: ReadConfiguration) throws { @@ -50,6 +40,7 @@ struct ClassicDocument: FileDocument { // } func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { + debugPrint(configuration.existingFile) let document = SpeculidSpecificationsFile(source: self.document) let encoder = JSONEncoder() let data = try encoder.encode(document) diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index c1d41e96..24ad89c7 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -35,6 +35,7 @@ struct ClassicView: View { return } bookmarkCollection.saveBookmark(url) + self.object.sourceImageRelativePath = url.path }.onTapGesture { self.isSourceImporting = true } @@ -55,6 +56,8 @@ struct ClassicView: View { return } bookmarkCollection.saveBookmark(url) + self.object.assetDirectoryRelativePath = url.path + }.onTapGesture { self.isACImporting = true } diff --git a/Speculid/doc_appApp.swift b/Speculid/doc_appApp.swift index 4ee7aa7d..a7ec46f6 100644 --- a/Speculid/doc_appApp.swift +++ b/Speculid/doc_appApp.swift @@ -5,14 +5,14 @@ struct doc_appApp: App { @StateObject private var bookmarkCollection = BookmarkURLCollectionObject() @SceneBuilder var body: some Scene { -// -// DocumentGroup(newDocument: doc_appDocument()) { file in -// ContentView(document: file.$document) -// } +// DocumentGroup(newDocument: ClassicDocument()) { (file) in +// ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) +// } DocumentGroup(viewing: ClassicDocument.self) { file in ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) - }.commands { + } + .commands { CommandMenu("Developer Tools") { Button("Reset Bookmarks") { self.bookmarkCollection.reset() diff --git a/packages/SpeculidKit b/packages/SpeculidKit index 6d128988..ede7c1fb 160000 --- a/packages/SpeculidKit +++ b/packages/SpeculidKit @@ -1 +1 @@ -Subproject commit 6d128988b1ef0529c6cb2b3d05175e4749c9e603 +Subproject commit ede7c1fbd956c94a1a3399bfd6856b6cb00d2f2a diff --git a/scripts/github-markdown-toc b/scripts/github-markdown-toc index 83fadb60..488f3100 160000 --- a/scripts/github-markdown-toc +++ b/scripts/github-markdown-toc @@ -1 +1 @@ -Subproject commit 83fadb60a7f1607c1c46e868ed2a866bb70b4c76 +Subproject commit 488f310064b16c1eb9c17862cc5844189ee65955 From a304190206880362379a5fef8d02a52d4050b0de Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 7 Oct 2020 11:57:32 -0400 Subject: [PATCH 06/14] update build number --- Speculid.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 95828df8..bfc5d278 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -364,7 +364,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 12; + CURRENT_PROJECT_VERSION = 13; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_ASSET_PATHS = "\"Speculid/Preview Content\""; DEVELOPMENT_TEAM = MLT7M394S7; @@ -464,7 +464,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 12; + CURRENT_PROJECT_VERSION = 13; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = "\"Speculid/Preview Content\""; DEVELOPMENT_TEAM = MLT7M394S7; From 3fb0c4dff563a97e79bf0e49d1d997bb5600bd7d Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 7 Oct 2020 18:52:39 -0400 Subject: [PATCH 07/14] working on url --- Speculid/ClassicDocument.swift | 41 ++++++++++++++++++++++++---------- Speculid/ClassicObject.swift | 22 +++++++++--------- Speculid/ClassicView.swift | 7 +++--- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/Speculid/ClassicDocument.swift b/Speculid/ClassicDocument.swift index f77b2e4f..6881a9d9 100644 --- a/Speculid/ClassicDocument.swift +++ b/Speculid/ClassicDocument.swift @@ -9,27 +9,42 @@ extension UTType { } } -struct ClassicDocument: FileDocument { +class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, ObservableObject { + @Published public var assetDirectoryRelativePath: String + @Published public var sourceImageRelativePath: String + @Published public var geometry: Geometry? + @Published public var background: NSColor? + @Published public var removeAlpha: Bool - - var document: SpeculidMutableSpecificationsFile + //var document: SpeculidMutableSpecificationsFile - init(document: SpeculidSpecificationsFile = SpeculidSpecificationsFile()) { - self.document = SpeculidMutableSpecificationsFile(source: document) + init(source: SpeculidSpecificationsFile = SpeculidSpecificationsFile()) { + + assetDirectoryRelativePath = source.assetDirectoryRelativePath + sourceImageRelativePath = source.sourceImageRelativePath + geometry = source.geometry + background = source.background + removeAlpha = source.removeAlpha } static var readableContentTypes: [UTType] { [.speculidImageDocument] } static var writableContentTypes: [UTType] { [.speculidImageDocument] } - init(configuration: ReadConfiguration) throws { + required init(configuration: ReadConfiguration) throws { let decoder = JSONDecoder() guard let data = configuration.file.regularFileContents else { throw CocoaError(.fileReadCorruptFile) } - let document = try decoder.decode(SpeculidSpecificationsFile.self, from: data) - self.document = SpeculidMutableSpecificationsFile(source: document) + let source = try decoder.decode(SpeculidSpecificationsFile.self, from: data) + + + assetDirectoryRelativePath = source.assetDirectoryRelativePath + sourceImageRelativePath = source.sourceImageRelativePath + geometry = source.geometry + background = source.background + removeAlpha = source.removeAlpha } // func write(to fileWrapper: inout FileWrapper, contentType _: UTType) throws { @@ -40,9 +55,11 @@ struct ClassicDocument: FileDocument { // } func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { - debugPrint(configuration.existingFile) - let document = SpeculidSpecificationsFile(source: self.document) + debugPrint(self.assetDirectoryRelativePath) + let document = SpeculidSpecificationsFile(source: self) let encoder = JSONEncoder() + encoder.outputFormatting = [ .prettyPrinted, .withoutEscapingSlashes ] + let data = try encoder.encode(document) return FileWrapper(regularFileWithContents: data) } @@ -50,7 +67,7 @@ struct ClassicDocument: FileDocument { func build(fromURL url: URL, inSandbox sandbox: Sandbox) { let document: SpeculidDocument do { - document = try SpeculidDocument(sandboxedFromFile: self.document, withURL: url, decoder: JSONDecoder(), withManager: sandbox) + document = try SpeculidDocument(sandboxedFromFile: self, withURL: url, decoder: JSONDecoder(), withManager: sandbox) } catch { debugPrint(error) debugPrint(error.localizedDescription) @@ -70,7 +87,7 @@ struct ClassicDocument: FileDocument { } func processImages(fromURL url: URL, management: Sandbox, document: SpeculidDocument, sandboxMap: [(AssetSpecificationProtocol, String, URL)]) { - let assetDirectoryURL = url.deletingLastPathComponent().appendingPathComponent(self.document.assetDirectoryRelativePath) + let assetDirectoryURL = url.deletingLastPathComponent().appendingPathComponent(self.assetDirectoryRelativePath) let imageSpecificationBuilder = SpeculidImageSpecificationBuilder() let imageSpecifications: [ImageSpecificationObject] diff --git a/Speculid/ClassicObject.swift b/Speculid/ClassicObject.swift index affb5704..790b01f5 100644 --- a/Speculid/ClassicObject.swift +++ b/Speculid/ClassicObject.swift @@ -4,7 +4,7 @@ import SpeculidKit import SwiftUI class ClassicObject: ObservableObject { - let url: URL? + @Published var url: URL? @Published var geometryValue: Float = 0.0 @Published var assetDirectoryRelativePath: String = "" @Published var sourceImageRelativePath: String = "" @@ -13,7 +13,7 @@ class ClassicObject: ObservableObject { @Published var resizeOption = ResizeOption.none.rawValue @Published var addBackground: Bool = false - var document: ClassicDocument + @Published var document: ClassicDocument var cancellables = [AnyCancellable]() var assetDirectoryURL: URL? { @@ -36,13 +36,13 @@ class ClassicObject: ObservableObject { self.url = url self.document = document - assetDirectoryRelativePath = self.document.document.assetDirectoryRelativePath - sourceImageRelativePath = self.document.document.sourceImageRelativePath - addBackground = self.document.document.background != nil - backgroundColor = self.document.document.background.map(Color.init) ?? .clear - geometryValue = self.document.document.geometry?.value ?? 0.0 - resizeOption = ResizeOption(geometryType: self.document.document.geometry?.dimension).rawValue - removeAlpha = self.document.document.removeAlpha + assetDirectoryRelativePath = self.document.assetDirectoryRelativePath + sourceImageRelativePath = self.document.sourceImageRelativePath + addBackground = self.document.background != nil + backgroundColor = self.document.background.map(Color.init) ?? .clear + geometryValue = self.document.geometry?.value ?? 0.0 + resizeOption = ResizeOption(geometryType: self.document.geometry?.dimension).rawValue + removeAlpha = self.document.removeAlpha let nscolorPub = $addBackground.combineLatest($backgroundColor) { $0 ? NSColor($1) : nil @@ -66,9 +66,9 @@ class ClassicObject: ObservableObject { assign(geoPub, documentProperty: \.geometry) } - func assign(_ publisher: PublisherType, documentProperty: WritableKeyPath) where PublisherType.Output == ValueType, PublisherType.Failure == Never { + func assign(_ publisher: PublisherType, documentProperty: WritableKeyPath) where PublisherType.Output == ValueType, PublisherType.Failure == Never { publisher.sink { value in - self.document.document[keyPath: documentProperty] = value + self.document[keyPath: documentProperty] = value }.store(in: &cancellables) } } diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 24ad89c7..320662a3 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -16,9 +16,9 @@ struct ClassicView: View { var canBuild: Bool { return object.url != nil && - bookmarkCollection.isAvailable(basedOn: object.url, relativePath: object.document.document.assetDirectoryRelativePath) && + bookmarkCollection.isAvailable(basedOn: object.url, relativePath: object.document.assetDirectoryRelativePath) && - bookmarkCollection.isAvailable(basedOn: object.url, relativePath: object.document.document.sourceImageRelativePath) + bookmarkCollection.isAvailable(basedOn: object.url, relativePath: object.document.sourceImageRelativePath) } var body: some View { @@ -56,6 +56,7 @@ struct ClassicView: View { return } bookmarkCollection.saveBookmark(url) + //self.object.document.document.assetDirectoryRelativePath = url.path self.object.assetDirectoryRelativePath = url.path }.onTapGesture { @@ -108,7 +109,7 @@ struct ClassicView: View { Image(systemName: "play.fill") Text("Build") } - } + }.disabled(!canBuild) } } }.padding(.all, 40.0).frame(minWidth: 500, idealWidth: 500, maxWidth: 600, minHeight: 500, idealHeight: 500, maxHeight: .infinity, alignment: .center) From 943bcf7ecd6b0e62112ece4497a78983fd73b142 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 7 Oct 2020 20:20:35 -0400 Subject: [PATCH 08/14] working on new doc --- Speculid/ClassicView.swift | 9 +++++++++ Speculid/doc_appApp.swift | 11 ++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 320662a3..61ffb5c9 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -7,6 +7,7 @@ struct ClassicView: View { @EnvironmentObject var bookmarkCollection: BookmarkURLCollectionObject @State private var isACImporting: Bool = false @State private var isSourceImporting : Bool = false + @State private var isExporting : Bool = false init(url: URL?, document: ClassicDocument, documentBinding _: Binding) { @@ -113,6 +114,14 @@ struct ClassicView: View { } } }.padding(.all, 40.0).frame(minWidth: 500, idealWidth: 500, maxWidth: 600, minHeight: 500, idealHeight: 500, maxHeight: .infinity, alignment: .center) + .fileExporter(isPresented: $isExporting, document: self.object.document, contentType: .speculidImageDocument) { (result) in + guard case let .success(url) = result else { + return + } + self.object.url = url + }.onAppear { + self.isExporting = self.object.url == nil + } } } diff --git a/Speculid/doc_appApp.swift b/Speculid/doc_appApp.swift index a7ec46f6..e64537ea 100644 --- a/Speculid/doc_appApp.swift +++ b/Speculid/doc_appApp.swift @@ -5,13 +5,14 @@ struct doc_appApp: App { @StateObject private var bookmarkCollection = BookmarkURLCollectionObject() @SceneBuilder var body: some Scene { -// DocumentGroup(newDocument: ClassicDocument()) { (file) in -// ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) -// } - DocumentGroup(viewing: ClassicDocument.self) { file in - + //DocumentGroup(newDocument: <#T##_#>, editor: <#T##(FileDocumentConfiguration<_>) -> _#>) + DocumentGroup(newDocument: ClassicDocument()) { (file) in ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) } +// DocumentGroup(viewing: ClassicDocument.self) { file in +// +// ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) +// } .commands { CommandMenu("Developer Tools") { Button("Reset Bookmarks") { From fe12b993c8c500c869e2869ea0a979b4344cb15e Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 8 Oct 2020 07:52:45 -0400 Subject: [PATCH 09/14] fixing building icons --- Speculid/ClassicView.swift | 44 ++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 61ffb5c9..087c360c 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -1,7 +1,30 @@ import Combine import SpeculidKit import SwiftUI +extension URL { + func relativePath(from base: URL) -> String? { + // Ensure that both URLs represent files: + guard self.isFileURL && base.isFileURL else { + return nil + } + + // Remove/replace "." and "..", make paths absolute: + let destComponents = self.standardized.pathComponents + let baseComponents = base.standardized.pathComponents + // Find number of common path components: + var i = 0 + while i < destComponents.count && i < baseComponents.count + && destComponents[i] == baseComponents[i] { + i += 1 + } + + // Build relative path: + var relComponents = Array(repeating: "..", count: baseComponents.count - i) + relComponents.append(contentsOf: destComponents[i...]) + return relComponents.joined(separator: "/") + } +} struct ClassicView: View { @StateObject var object: ClassicObject @EnvironmentObject var bookmarkCollection: BookmarkURLCollectionObject @@ -32,11 +55,15 @@ struct ClassicView: View { .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) .fileImporter(isPresented: self.$isSourceImporting, allowedContentTypes: [.svg, .png]) { result in - guard case let .success(url) = result else { - return - } - bookmarkCollection.saveBookmark(url) - self.object.sourceImageRelativePath = url.path + + guard case let .success(url) = result, let baseURL = self.object.url?.deletingLastPathComponent() else { + return + } + guard let relativePath = url.relativePath(from: baseURL) else { + return + } + bookmarkCollection.saveBookmark(url) + self.object.sourceImageRelativePath = relativePath }.onTapGesture { self.isSourceImporting = true } @@ -53,12 +80,15 @@ struct ClassicView: View { .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) .fileImporter(isPresented: self.$isACImporting, allowedContentTypes: [.directory]) { result in - guard case let .success(url) = result else { + guard case let .success(url) = result, let baseURL = self.object.url?.deletingLastPathComponent() else { return } + guard let relativePath = url.relativePath(from: baseURL) else { + return + } bookmarkCollection.saveBookmark(url) //self.object.document.document.assetDirectoryRelativePath = url.path - self.object.assetDirectoryRelativePath = url.path + self.object.assetDirectoryRelativePath = relativePath }.onTapGesture { self.isACImporting = true From b8eddbb79507bc604f5ea46d529ea78dbd7672ce Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 8 Oct 2020 08:45:58 -0400 Subject: [PATCH 10/14] fixing document creation and image sets --- Speculid/ClassicDocument.swift | 18 +++++++++++++++++- Speculid/ClassicObject.swift | 1 + Speculid/ClassicView.swift | 3 ++- Speculid/doc_appApp.swift | 11 ++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Speculid/ClassicDocument.swift b/Speculid/ClassicDocument.swift index 6881a9d9..8aaedcbf 100644 --- a/Speculid/ClassicDocument.swift +++ b/Speculid/ClassicDocument.swift @@ -15,6 +15,7 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa @Published public var geometry: Geometry? @Published public var background: NSColor? @Published public var removeAlpha: Bool + @Published public var url: URL? //var document: SpeculidMutableSpecificationsFile @@ -61,7 +62,12 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa encoder.outputFormatting = [ .prettyPrinted, .withoutEscapingSlashes ] let data = try encoder.encode(document) - return FileWrapper(regularFileWithContents: data) + let wrapper = FileWrapper(regularFileWithContents: data) + if let url = self.url { + try wrapper.write(to: url, options: .withNameUpdating, originalContentsURL: nil) + } + + return wrapper } func build(fromURL url: URL, inSandbox sandbox: Sandbox) { @@ -73,6 +79,16 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa debugPrint(error.localizedDescription) return } + + let file = SpeculidSpecificationsFile(source: self) + let encoder = JSONEncoder() + encoder.outputFormatting = [ .prettyPrinted, .withoutEscapingSlashes ] + + if let url = self.url, let data = try? encoder.encode(file) { + try? data.write(to: url) + } + + //self.fileWrapper(configuration: WriteConfiguration) let destinationFileNames = document.assetFile.document.images.map { asset in diff --git a/Speculid/ClassicObject.swift b/Speculid/ClassicObject.swift index 790b01f5..d266464e 100644 --- a/Speculid/ClassicObject.swift +++ b/Speculid/ClassicObject.swift @@ -64,6 +64,7 @@ class ClassicObject: ObservableObject { assign($removeAlpha, documentProperty: \.removeAlpha) assign(nscolorPub, documentProperty: \.background) assign(geoPub, documentProperty: \.geometry) + assign($url, documentProperty: \.url) } func assign(_ publisher: PublisherType, documentProperty: WritableKeyPath) where PublisherType.Output == ValueType, PublisherType.Failure == Never { diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 087c360c..7b558cb8 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -144,7 +144,8 @@ struct ClassicView: View { } } }.padding(.all, 40.0).frame(minWidth: 500, idealWidth: 500, maxWidth: 600, minHeight: 500, idealHeight: 500, maxHeight: .infinity, alignment: .center) - .fileExporter(isPresented: $isExporting, document: self.object.document, contentType: .speculidImageDocument) { (result) in + + .fileExporter(isPresented: $isExporting, document: self.object.document, contentType: .speculidImageDocument, defaultFilename: self.object.url?.lastPathComponent ?? "") { (result) in guard case let .success(url) = result else { return } diff --git a/Speculid/doc_appApp.swift b/Speculid/doc_appApp.swift index e64537ea..0b6aa6c4 100644 --- a/Speculid/doc_appApp.swift +++ b/Speculid/doc_appApp.swift @@ -3,12 +3,21 @@ import SwiftUI @main struct doc_appApp: App { @StateObject private var bookmarkCollection = BookmarkURLCollectionObject() + @State private var isExporting : Bool = false @SceneBuilder var body: some Scene { - //DocumentGroup(newDocument: <#T##_#>, editor: <#T##(FileDocumentConfiguration<_>) -> _#>) +// DocumentGroup(newDocument: ClassicDocument()) { (file) in +// return EmptyView().fileExporter(isPresented: $isExporting, document: file.document, contentType: .speculidImageDocument, defaultFilename: "AppIcon.speculid") { (result) in +// print(result) +// }.onAppear{ +// self.isExporting = true +// } +// } + DocumentGroup(newDocument: ClassicDocument()) { (file) in ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) } + // DocumentGroup(viewing: ClassicDocument.self) { file in // // ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) From dd8f06488d4b0cb76dfd57c2fab2c613e55e73ee Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 8 Oct 2020 12:17:24 -0400 Subject: [PATCH 11/14] fixing sourcedocs issue --- Speculid.xcodeproj/project.pbxproj | 29 +++- Speculid/BookmarkURLCollectionObject.swift | 10 +- Speculid/ClassicDocument.swift | 77 +++++---- Speculid/ClassicObject.swift | 5 +- Speculid/ClassicView.swift | 148 +++++++++++------- .../{doc_appApp.swift => SpeculidApp.swift} | 16 +- packages/SpeculidKit | 2 +- .../AccentColor.colorset/Contents.json | 11 -- .../AppIcon.appiconset/Contents.json | 58 ------- .../Assets.xcassets/Contents.json | 6 - .../swiftuidoc.app/ContentView.swift | 15 -- swiftuidoc.app/swiftuidoc.app/Info.plist | 57 ------- .../Preview Assets.xcassets/Contents.json | 6 - .../swiftuidoc_app.entitlements | 10 -- .../swiftuidoc.app/swiftuidoc_appApp.swift | 10 -- .../swiftuidoc_appDocument.swift | 32 ---- 16 files changed, 169 insertions(+), 323 deletions(-) rename Speculid/{doc_appApp.swift => SpeculidApp.swift} (57%) delete mode 100644 swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AccentColor.colorset/Contents.json delete mode 100644 swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 swiftuidoc.app/swiftuidoc.app/Assets.xcassets/Contents.json delete mode 100644 swiftuidoc.app/swiftuidoc.app/ContentView.swift delete mode 100644 swiftuidoc.app/swiftuidoc.app/Info.plist delete mode 100644 swiftuidoc.app/swiftuidoc.app/Preview Content/Preview Assets.xcassets/Contents.json delete mode 100644 swiftuidoc.app/swiftuidoc.app/swiftuidoc_app.entitlements delete mode 100644 swiftuidoc.app/swiftuidoc.app/swiftuidoc_appApp.swift delete mode 100644 swiftuidoc.app/swiftuidoc.app/swiftuidoc_appDocument.swift diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index bfc5d278..7f44914b 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ B347128924B64968001CCCFD /* ClassicDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = B347128824B64968001CCCFD /* ClassicDocument.swift */; }; B347128B24B668DE001CCCFD /* ClassicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B347128A24B668DE001CCCFD /* ClassicView.swift */; }; B34B6BC224BE354D00F4EE6B /* BookmarkURLCollectionObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34B6BC124BE354D00F4EE6B /* BookmarkURLCollectionObject.swift */; }; - B3B6A4D124B15292009C6E32 /* doc_appApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B364623E24B14DBB0089382E /* doc_appApp.swift */; }; + B3B6A4D124B15292009C6E32 /* SpeculidApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B364623E24B14DBB0089382E /* SpeculidApp.swift */; }; B3DB48142431642600B1DA4F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B3DB48132431642600B1DA4F /* Assets.xcassets */; }; B3DB48172431642600B1DA4F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B3DB48162431642600B1DA4F /* Preview Assets.xcassets */; }; B3DB481A2431642600B1DA4F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B3DB48182431642600B1DA4F /* Main.storyboard */; }; @@ -52,7 +52,7 @@ B347128824B64968001CCCFD /* ClassicDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassicDocument.swift; sourceTree = ""; }; B347128A24B668DE001CCCFD /* ClassicView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassicView.swift; sourceTree = ""; }; B34B6BC124BE354D00F4EE6B /* BookmarkURLCollectionObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkURLCollectionObject.swift; sourceTree = ""; }; - B364623E24B14DBB0089382E /* doc_appApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = doc_appApp.swift; sourceTree = ""; }; + B364623E24B14DBB0089382E /* SpeculidApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeculidApp.swift; sourceTree = ""; }; B3796B792432B7FF00E5F5F9 /* Command.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Command.entitlements; sourceTree = ""; }; B37A52372435014400FEA6E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B37B472124B93CB900AE2021 /* CairoSVG.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = CairoSVG.xcframework; path = packages/SpeculidKit/packages/CairoSVG/build/CairoSVG.xcframework; sourceTree = ""; }; @@ -132,7 +132,7 @@ B3DB48092431642100B1DA4F /* Speculid */ = { isa = PBXGroup; children = ( - B364623E24B14DBB0089382E /* doc_appApp.swift */, + B364623E24B14DBB0089382E /* SpeculidApp.swift */, B3DB480E2431642100B1DA4F /* ContentView.swift */, B3DB48132431642600B1DA4F /* Assets.xcassets */, B3DB48182431642600B1DA4F /* Main.storyboard */, @@ -170,6 +170,7 @@ B3DB48052431642100B1DA4F /* Resources */, B3796B7A2432C33600E5F5F9 /* CopyFiles */, B324D41624C49F500047ED11 /* Embed Frameworks */, + B33E6494252F612700A12CFD /* ShellScript */, ); buildRules = ( ); @@ -228,6 +229,26 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + B33E6494252F612700A12CFD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "swiftformat --lint . && swiftlint\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ B3DB48032431642100B1DA4F /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -239,7 +260,7 @@ B3E1707C24C1DBF700784D20 /* LabeledOption.swift in Sources */, B347128924B64968001CCCFD /* ClassicDocument.swift in Sources */, B3326D4324C1CFF000629F70 /* Tooltip.swift in Sources */, - B3B6A4D124B15292009C6E32 /* doc_appApp.swift in Sources */, + B3B6A4D124B15292009C6E32 /* SpeculidApp.swift in Sources */, B3E1708024C1DC6C00784D20 /* ClassicObject.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Speculid/BookmarkURLCollectionObject.swift b/Speculid/BookmarkURLCollectionObject.swift index f2d95b8a..a1db2e0b 100644 --- a/Speculid/BookmarkURLCollectionObject.swift +++ b/Speculid/BookmarkURLCollectionObject.swift @@ -55,12 +55,12 @@ public class BookmarkURLCollectionObject: ObservableObject, Sandbox { public func bookmarkURL(fromURL url: URL) throws -> URL { var isStale: Bool = false let fromURLResult: Result - let fromURLCurrentResult = Self.shared.bookmarks?[url.path].map { - data in - Result { - try URL(resolvingBookmarkData: data, options: .withSecurityScope, relativeTo: nil, bookmarkDataIsStale: &isStale) + let fromURLCurrentResult = Self.shared.bookmarks?[url.path] + .map { data in + Result { + try URL(resolvingBookmarkData: data, options: .withSecurityScope, relativeTo: nil, bookmarkDataIsStale: &isStale) + } } - } if isStale { saveBookmark(url) } diff --git a/Speculid/ClassicDocument.swift b/Speculid/ClassicDocument.swift index 8aaedcbf..151d2f04 100644 --- a/Speculid/ClassicDocument.swift +++ b/Speculid/ClassicDocument.swift @@ -16,36 +16,33 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa @Published public var background: NSColor? @Published public var removeAlpha: Bool @Published public var url: URL? - - //var document: SpeculidMutableSpecificationsFile + + // var document: SpeculidMutableSpecificationsFile init(source: SpeculidSpecificationsFile = SpeculidSpecificationsFile()) { - - assetDirectoryRelativePath = source.assetDirectoryRelativePath - sourceImageRelativePath = source.sourceImageRelativePath - geometry = source.geometry - background = source.background - removeAlpha = source.removeAlpha + assetDirectoryRelativePath = source.assetDirectoryRelativePath + sourceImageRelativePath = source.sourceImageRelativePath + geometry = source.geometry + background = source.background + removeAlpha = source.removeAlpha } static var readableContentTypes: [UTType] { [.speculidImageDocument] } - static var writableContentTypes: [UTType] { [.speculidImageDocument] } - + static var writableContentTypes: [UTType] { [.speculidImageDocument] } + required init(configuration: ReadConfiguration) throws { - - let decoder = JSONDecoder() + let decoder = JSONDecoder() guard let data = configuration.file.regularFileContents - else { - throw CocoaError(.fileReadCorruptFile) - } - let source = try decoder.decode(SpeculidSpecificationsFile.self, from: data) - - - assetDirectoryRelativePath = source.assetDirectoryRelativePath - sourceImageRelativePath = source.sourceImageRelativePath - geometry = source.geometry - background = source.background - removeAlpha = source.removeAlpha + else { + throw CocoaError(.fileReadCorruptFile) + } + let source = try decoder.decode(SpeculidSpecificationsFile.self, from: data) + + assetDirectoryRelativePath = source.assetDirectoryRelativePath + sourceImageRelativePath = source.sourceImageRelativePath + geometry = source.geometry + background = source.background + removeAlpha = source.removeAlpha } // func write(to fileWrapper: inout FileWrapper, contentType _: UTType) throws { @@ -54,19 +51,19 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa // let data = try encoder.encode(document) // fileWrapper = FileWrapper(regularFileWithContents: data) // } - - func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { - debugPrint(self.assetDirectoryRelativePath) + + func fileWrapper(configuration _: WriteConfiguration) throws -> FileWrapper { + debugPrint(assetDirectoryRelativePath) let document = SpeculidSpecificationsFile(source: self) let encoder = JSONEncoder() - encoder.outputFormatting = [ .prettyPrinted, .withoutEscapingSlashes ] - + encoder.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes] + let data = try encoder.encode(document) let wrapper = FileWrapper(regularFileWithContents: data) if let url = self.url { try wrapper.write(to: url, options: .withNameUpdating, originalContentsURL: nil) } - + return wrapper } @@ -79,21 +76,21 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa debugPrint(error.localizedDescription) return } - - let file = SpeculidSpecificationsFile(source: self) + + let file = SpeculidSpecificationsFile(source: self) let encoder = JSONEncoder() - encoder.outputFormatting = [ .prettyPrinted, .withoutEscapingSlashes ] - + encoder.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes] + if let url = self.url, let data = try? encoder.encode(file) { try? data.write(to: url) } - - //self.fileWrapper(configuration: WriteConfiguration) - let destinationFileNames = document.assetFile.document.images.map { - asset in - (asset, document.destinationName(forImage: asset)) - } + // self.fileWrapper(configuration: WriteConfiguration) + + let destinationFileNames = document.assetFile.document.images + .map { asset in + (asset, document.destinationName(forImage: asset)) + } let urlMap = destinationFileNames.map { asset, fileName in (asset, fileName, document.destinationURL(forFileName: fileName)) @@ -103,7 +100,7 @@ class ClassicDocument: FileDocument, SpeculidSpecificationsFileProtocol, Observa } func processImages(fromURL url: URL, management: Sandbox, document: SpeculidDocument, sandboxMap: [(AssetSpecificationProtocol, String, URL)]) { - let assetDirectoryURL = url.deletingLastPathComponent().appendingPathComponent(self.assetDirectoryRelativePath) + let assetDirectoryURL = url.deletingLastPathComponent().appendingPathComponent(assetDirectoryRelativePath) let imageSpecificationBuilder = SpeculidImageSpecificationBuilder() let imageSpecifications: [ImageSpecificationObject] diff --git a/Speculid/ClassicObject.swift b/Speculid/ClassicObject.swift index d266464e..376b76b4 100644 --- a/Speculid/ClassicObject.swift +++ b/Speculid/ClassicObject.swift @@ -67,7 +67,10 @@ class ClassicObject: ObservableObject { assign($url, documentProperty: \.url) } - func assign(_ publisher: PublisherType, documentProperty: WritableKeyPath) where PublisherType.Output == ValueType, PublisherType.Failure == Never { + func assign( + _ publisher: PublisherType, + documentProperty: WritableKeyPath + ) where PublisherType.Output == ValueType, PublisherType.Failure == Never { publisher.sink { value in self.document[keyPath: documentProperty] = value }.store(in: &cancellables) diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 7b558cb8..0974ead5 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -2,36 +2,36 @@ import Combine import SpeculidKit import SwiftUI extension URL { - func relativePath(from base: URL) -> String? { - // Ensure that both URLs represent files: - guard self.isFileURL && base.isFileURL else { - return nil - } - - // Remove/replace "." and "..", make paths absolute: - let destComponents = self.standardized.pathComponents - let baseComponents = base.standardized.pathComponents + func relativePath(from base: URL) -> String? { + // Ensure that both URLs represent files: + guard isFileURL, base.isFileURL else { + return nil + } - // Find number of common path components: - var i = 0 - while i < destComponents.count && i < baseComponents.count - && destComponents[i] == baseComponents[i] { - i += 1 - } + // Remove/replace "." and "..", make paths absolute: + let destComponents = standardized.pathComponents + let baseComponents = base.standardized.pathComponents - // Build relative path: - var relComponents = Array(repeating: "..", count: baseComponents.count - i) - relComponents.append(contentsOf: destComponents[i...]) - return relComponents.joined(separator: "/") + // Find number of common path components: + var index = 0 + while index < destComponents.count, index < baseComponents.count, + destComponents[index] == baseComponents[index] { + index += 1 } + + // Build relative path: + var relComponents = Array(repeating: "..", count: baseComponents.count - index) + relComponents.append(contentsOf: destComponents[index...]) + return relComponents.joined(separator: "/") + } } + struct ClassicView: View { @StateObject var object: ClassicObject @EnvironmentObject var bookmarkCollection: BookmarkURLCollectionObject @State private var isACImporting: Bool = false - @State private var isSourceImporting : Bool = false - @State private var isExporting : Bool = false - + @State private var isSourceImporting: Bool = false + @State private var isExporting: Bool = false init(url: URL?, document: ClassicDocument, documentBinding _: Binding) { _object = StateObject(wrappedValue: ClassicObject(url: url, document: document)) @@ -55,19 +55,26 @@ struct ClassicView: View { .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) .fileImporter(isPresented: self.$isSourceImporting, allowedContentTypes: [.svg, .png]) { result in - - guard case let .success(url) = result, let baseURL = self.object.url?.deletingLastPathComponent() else { - return - } - guard let relativePath = url.relativePath(from: baseURL) else { - return - } - bookmarkCollection.saveBookmark(url) - self.object.sourceImageRelativePath = relativePath - }.onTapGesture { - self.isSourceImporting = true - } - Image(systemName: "lock.fill").foregroundColor(.yellow).opacity(self.bookmarkCollection.isAvailable(basedOn: self.object.url, relativePath: self.object.sourceImageRelativePath) ? 0.0 : 1.0) + + guard case let .success(url) = result, let baseURL = self.object.url?.deletingLastPathComponent() else { + return + } + guard let relativePath = url.relativePath(from: baseURL) else { + return + } + bookmarkCollection.saveBookmark(url) + self.object.sourceImageRelativePath = relativePath + }.onTapGesture { + self.isSourceImporting = true + } + Image( + systemName: "lock.fill") + .foregroundColor(.yellow) + .opacity(self.bookmarkCollection + .isAvailable( + basedOn: self.object.url, + relativePath: self.object.sourceImageRelativePath + ) ? 0.0 : 1.0) Spacer() } } @@ -79,21 +86,28 @@ struct ClassicView: View { TextField(".appiconset or .imageset", text: self.$object.assetDirectoryRelativePath) .overlay(Image(systemName: "folder.fill").foregroundColor(.primary).padding(.trailing, 4.0), alignment: .trailing) .disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/).frame(width: 250) - .fileImporter(isPresented: self.$isACImporting, allowedContentTypes: [.directory]) { result in + .fileImporter(isPresented: self.$isACImporting, allowedContentTypes: [.directory]) { result in guard case let .success(url) = result, let baseURL = self.object.url?.deletingLastPathComponent() else { - return - } + return + } guard let relativePath = url.relativePath(from: baseURL) else { return } - bookmarkCollection.saveBookmark(url) - //self.object.document.document.assetDirectoryRelativePath = url.path + bookmarkCollection.saveBookmark(url) + // self.object.document.document.assetDirectoryRelativePath = url.path self.object.assetDirectoryRelativePath = relativePath - + }.onTapGesture { self.isACImporting = true } - Image(systemName: "lock.fill").foregroundColor(.yellow).opacity(self.bookmarkCollection.isAvailable(basedOn: self.object.url, relativePath: self.object.assetDirectoryRelativePath) ? 0.0 : 1.0) + Image( + systemName: "lock.fill") + .foregroundColor(.yellow) + .opacity(self.bookmarkCollection + .isAvailable( + basedOn: self.object.url, + relativePath: self.object.assetDirectoryRelativePath + ) ? 0.0 : 1.0) Spacer() } } @@ -102,6 +116,7 @@ struct ClassicView: View { HStack { VStack(alignment: .leading) { Toggle("Remove Alpha Channel", isOn: self.$object.removeAlpha) + //swiftlint:disable:next line_length Text("If this is intended for an iOS, watchOS, or tvOS App, then you should remove the alpha channel from the source graphic.").multilineTextAlignment(.leading).font(.subheadline).lineLimit(nil) } Spacer() @@ -109,9 +124,18 @@ struct ClassicView: View { VStack(alignment: .leading) { HStack { Toggle("Add a Background Color", isOn: self.$object.addBackground) - ColorPicker("", selection: self.$object.backgroundColor, supportsOpacity: false).labelsHidden().frame(width: 40, height: 25, alignment: .trailing).disabled(!self.object.addBackground).opacity(self.object.addBackground ? 1.0 : 0.5) + ColorPicker("", selection: self.$object.backgroundColor, supportsOpacity: false) + .labelsHidden() + .frame(width: 40, height: 25, alignment: .trailing) + .disabled(!self.object.addBackground) + .opacity(self.object.addBackground ? 1.0 : 0.5) } - Text("If this is intended for an iOS, watchOS, or tvOS App, then you should set a background color.").multilineTextAlignment(.leading).font(.subheadline).lineLimit(nil) + + //swiftlint:disable:next line_length + Text("If this is intended for an iOS, watchOS, or tvOS App, then you should set a background color.") + .multilineTextAlignment(.leading) + .font(.subheadline) + .lineLimit(nil) } }.disabled(!self.object.isAppIcon).opacity(self.object.isAppIcon ? 1.0 : 0.5) Divider() @@ -123,10 +147,18 @@ struct ClassicView: View { } }.pickerStyle(SegmentedPickerStyle()) .frame(width: 150, alignment: .leading).labelsHidden() - TextField("Value", value: self.$object.geometryValue, formatter: NumberFormatter()).frame(width: 50, alignment: .leading).disabled(self.object.resizeOption == 0).opacity(self.object.resizeOption == 0 ? 0.5 : 1.0) + TextField("Value", value: self.$object.geometryValue, formatter: NumberFormatter()) + .frame(width: 50, alignment: .leading) + .disabled(self.object.resizeOption == 0) + .opacity(self.object.resizeOption == 0 ? 0.5 : 1.0) Text("px").opacity(self.object.resizeOption == 0 ? 0.5 : 1.0) } - Text("If you wish to render scaled PNG files for an image set, then specify either width or height and the image will be resized to that dimention while retaining its aspect ratio.\nOtherwise if you select \"None\", then only a PDF will be rendered. ").multilineTextAlignment(.leading).font(.subheadline).lineLimit(nil) + + //swiftlint:disable:next line_length + Text("If you wish to render scaled PNG files for an image set, then specify either width or height and the image will be resized to that dimention while retaining its aspect ratio.\nOtherwise if you select \"None\", then only a PDF will be rendered. ") + .multilineTextAlignment(.leading) + .font(.subheadline) + .lineLimit(nil) }.disabled(!self.object.isImageSet).opacity(self.object.isImageSet ? 1.0 : 0.5) Divider() Section { @@ -143,16 +175,22 @@ struct ClassicView: View { }.disabled(!canBuild) } } - }.padding(.all, 40.0).frame(minWidth: 500, idealWidth: 500, maxWidth: 600, minHeight: 500, idealHeight: 500, maxHeight: .infinity, alignment: .center) - - .fileExporter(isPresented: $isExporting, document: self.object.document, contentType: .speculidImageDocument, defaultFilename: self.object.url?.lastPathComponent ?? "") { (result) in - guard case let .success(url) = result else { - return - } - self.object.url = url - }.onAppear { - self.isExporting = self.object.url == nil } + .padding(.all, 40.0) + .frame(minWidth: 500, idealWidth: 500, maxWidth: 600, minHeight: 500, idealHeight: 500, maxHeight: .infinity, alignment: .center) + + .fileExporter( + isPresented: $isExporting, + document: self.object.document, + contentType: .speculidImageDocument, + defaultFilename: self.object.url?.lastPathComponent ?? "") { result in + guard case let .success(url) = result else { + return + } + self.object.url = url + }.onAppear { + self.isExporting = self.object.url == nil + } } } diff --git a/Speculid/doc_appApp.swift b/Speculid/SpeculidApp.swift similarity index 57% rename from Speculid/doc_appApp.swift rename to Speculid/SpeculidApp.swift index 0b6aa6c4..04508e81 100644 --- a/Speculid/doc_appApp.swift +++ b/Speculid/SpeculidApp.swift @@ -1,23 +1,15 @@ import SwiftUI @main -struct doc_appApp: App { +struct SpeculidApp: App { @StateObject private var bookmarkCollection = BookmarkURLCollectionObject() - @State private var isExporting : Bool = false + @State private var isExporting: Bool = false @SceneBuilder var body: some Scene { -// DocumentGroup(newDocument: ClassicDocument()) { (file) in -// return EmptyView().fileExporter(isPresented: $isExporting, document: file.document, contentType: .speculidImageDocument, defaultFilename: "AppIcon.speculid") { (result) in -// print(result) -// }.onAppear{ -// self.isExporting = true -// } -// } - - DocumentGroup(newDocument: ClassicDocument()) { (file) in + DocumentGroup(newDocument: ClassicDocument()) { file in ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) } - + // DocumentGroup(viewing: ClassicDocument.self) { file in // // ClassicView(url: file.fileURL, document: file.document, documentBinding: file.$document).environmentObject(bookmarkCollection) diff --git a/packages/SpeculidKit b/packages/SpeculidKit index ede7c1fb..a5ed9770 160000 --- a/packages/SpeculidKit +++ b/packages/SpeculidKit @@ -1 +1 @@ -Subproject commit ede7c1fbd956c94a1a3399bfd6856b6cb00d2f2a +Subproject commit a5ed97704f864807c0bdc31189f577c256036a0e diff --git a/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AccentColor.colorset/Contents.json b/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb878970..00000000 --- a/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AppIcon.appiconset/Contents.json b/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 3f00db43..00000000 --- a/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "scale" : "1x", - "size" : "16x16" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "16x16" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "32x32" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "32x32" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "128x128" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "128x128" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "256x256" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "256x256" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "512x512" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "512x512" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/Contents.json b/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/swiftuidoc.app/swiftuidoc.app/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/swiftuidoc.app/swiftuidoc.app/ContentView.swift b/swiftuidoc.app/swiftuidoc.app/ContentView.swift deleted file mode 100644 index 0cd4b442..00000000 --- a/swiftuidoc.app/swiftuidoc.app/ContentView.swift +++ /dev/null @@ -1,15 +0,0 @@ -import SwiftUI - -struct ContentView: View { - @Binding var document: swiftuidoc_appDocument - - var body: some View { - TextEditor(text: $document.text) - } -} - -struct ContentView_Previews: PreviewProvider { - static var previews: some View { - ContentView(document: .constant(swiftuidoc_appDocument())) - } -} diff --git a/swiftuidoc.app/swiftuidoc.app/Info.plist b/swiftuidoc.app/swiftuidoc.app/Info.plist deleted file mode 100644 index da1b9998..00000000 --- a/swiftuidoc.app/swiftuidoc.app/Info.plist +++ /dev/null @@ -1,57 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDocumentTypes - - - CFBundleTypeRole - Editor - LSItemContentTypes - - com.example.plain-text - - NSUbiquitousDocumentUserActivityType - $(PRODUCT_BUNDLE_IDENTIFIER).example-document - - - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - UTImportedTypeDeclarations - - - UTTypeConformsTo - - public.plain-text - - UTTypeDescription - Example Text - UTTypeIdentifier - com.example.plain-text - UTTypeTagSpecification - - public.filename-extension - - exampletext - - - - - - diff --git a/swiftuidoc.app/swiftuidoc.app/Preview Content/Preview Assets.xcassets/Contents.json b/swiftuidoc.app/swiftuidoc.app/Preview Content/Preview Assets.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/swiftuidoc.app/swiftuidoc.app/Preview Content/Preview Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/swiftuidoc.app/swiftuidoc.app/swiftuidoc_app.entitlements b/swiftuidoc.app/swiftuidoc.app/swiftuidoc_app.entitlements deleted file mode 100644 index 6d968edb..00000000 --- a/swiftuidoc.app/swiftuidoc.app/swiftuidoc_app.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-write - - - diff --git a/swiftuidoc.app/swiftuidoc.app/swiftuidoc_appApp.swift b/swiftuidoc.app/swiftuidoc.app/swiftuidoc_appApp.swift deleted file mode 100644 index 4a80c01c..00000000 --- a/swiftuidoc.app/swiftuidoc.app/swiftuidoc_appApp.swift +++ /dev/null @@ -1,10 +0,0 @@ -import SwiftUI - -@main -struct swiftuidoc_appApp: App { - var body: some Scene { - DocumentGroup(newDocument: swiftuidoc_appDocument()) { file in - ContentView(document: file.$document) - } - } -} diff --git a/swiftuidoc.app/swiftuidoc.app/swiftuidoc_appDocument.swift b/swiftuidoc.app/swiftuidoc.app/swiftuidoc_appDocument.swift deleted file mode 100644 index 09da1f22..00000000 --- a/swiftuidoc.app/swiftuidoc.app/swiftuidoc_appDocument.swift +++ /dev/null @@ -1,32 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers - -extension UTType { - static var exampleText: UTType { - UTType(importedAs: "com.example.plain-text") - } -} - -struct swiftuidoc_appDocument: FileDocument { - var text: String - - init(text: String = "Hello, world!") { - self.text = text - } - - static var readableContentTypes: [UTType] { [.exampleText] } - - init(fileWrapper: FileWrapper, contentType _: UTType) throws { - guard let data = fileWrapper.regularFileContents, - let string = String(data: data, encoding: .utf8) - else { - throw CocoaError(.fileReadCorruptFile) - } - text = string - } - - func write(to fileWrapper: inout FileWrapper, contentType _: UTType) throws { - let data = text.data(using: .utf8)! - fileWrapper = FileWrapper(regularFileWithContents: data) - } -} From b9526ef1505a3ea38953c1b455bbbfed7f19909b Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 8 Oct 2020 12:19:24 -0400 Subject: [PATCH 12/14] fixing linting issues --- Speculid/ClassicView.swift | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Speculid/ClassicView.swift b/Speculid/ClassicView.swift index 0974ead5..48734285 100644 --- a/Speculid/ClassicView.swift +++ b/Speculid/ClassicView.swift @@ -14,8 +14,10 @@ extension URL { // Find number of common path components: var index = 0 - while index < destComponents.count, index < baseComponents.count, - destComponents[index] == baseComponents[index] { + while index < destComponents.count, + index < baseComponents.count, + destComponents[index] == baseComponents[index] + { index += 1 } @@ -116,7 +118,7 @@ struct ClassicView: View { HStack { VStack(alignment: .leading) { Toggle("Remove Alpha Channel", isOn: self.$object.removeAlpha) - //swiftlint:disable:next line_length + // swiftlint:disable:next line_length Text("If this is intended for an iOS, watchOS, or tvOS App, then you should remove the alpha channel from the source graphic.").multilineTextAlignment(.leading).font(.subheadline).lineLimit(nil) } Spacer() @@ -130,8 +132,7 @@ struct ClassicView: View { .disabled(!self.object.addBackground) .opacity(self.object.addBackground ? 1.0 : 0.5) } - - //swiftlint:disable:next line_length + Text("If this is intended for an iOS, watchOS, or tvOS App, then you should set a background color.") .multilineTextAlignment(.leading) .font(.subheadline) @@ -153,8 +154,8 @@ struct ClassicView: View { .opacity(self.object.resizeOption == 0 ? 0.5 : 1.0) Text("px").opacity(self.object.resizeOption == 0 ? 0.5 : 1.0) } - - //swiftlint:disable:next line_length + + // swiftlint:disable:next line_length Text("If you wish to render scaled PNG files for an image set, then specify either width or height and the image will be resized to that dimention while retaining its aspect ratio.\nOtherwise if you select \"None\", then only a PDF will be rendered. ") .multilineTextAlignment(.leading) .font(.subheadline) @@ -179,18 +180,19 @@ struct ClassicView: View { .padding(.all, 40.0) .frame(minWidth: 500, idealWidth: 500, maxWidth: 600, minHeight: 500, idealHeight: 500, maxHeight: .infinity, alignment: .center) - .fileExporter( - isPresented: $isExporting, - document: self.object.document, - contentType: .speculidImageDocument, - defaultFilename: self.object.url?.lastPathComponent ?? "") { result in - guard case let .success(url) = result else { - return - } - self.object.url = url - }.onAppear { - self.isExporting = self.object.url == nil + .fileExporter( + isPresented: $isExporting, + document: self.object.document, + contentType: .speculidImageDocument, + defaultFilename: self.object.url?.lastPathComponent ?? "" + ) { result in + guard case let .success(url) = result else { + return } + self.object.url = url + }.onAppear { + self.isExporting = self.object.url == nil + } } } From 65081f68c8420f6602706ede82b123084fe4414e Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 8 Oct 2020 12:39:52 -0400 Subject: [PATCH 13/14] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47f73a77..4732cd46 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ os: osx -osx_image: xcode11.3 +osx_image: xcode12.2 before_install: - bash -e ./Scripts/before_install.sh script: From 7e31b634509fe06c911e2930a6fa2d286c39956e Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 8 Oct 2020 13:03:20 -0400 Subject: [PATCH 14/14] Delete Gemfile --- Gemfile | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Gemfile diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 7a118b49..00000000 --- a/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -gem "fastlane"