From 849a4fa44fe93a184df3c7a392d1aa4ccb7c6a74 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 5 Nov 2021 15:12:04 -0400 Subject: [PATCH 1/7] Add action extension template for iOS --- .../ActionViewController.swift | 57 ++++++ .../Base.lproj/MainInterface.storyboard | 53 ++++++ ActionExtension-iOS/Info.plist | 28 +++ .../Media.xcassets/Contents.json | 6 + .../TouchBarBezel.colorset/Contents.json | 14 ++ .../project.pbxproj | 180 +++++++++++++++++- .../xcschemes/xcschememanagement.plist | 11 +- 7 files changed, 345 insertions(+), 4 deletions(-) create mode 100644 ActionExtension-iOS/ActionViewController.swift create mode 100644 ActionExtension-iOS/Base.lproj/MainInterface.storyboard create mode 100644 ActionExtension-iOS/Info.plist create mode 100644 ActionExtension-iOS/Media.xcassets/Contents.json create mode 100644 ActionExtension-iOS/Media.xcassets/TouchBarBezel.colorset/Contents.json diff --git a/ActionExtension-iOS/ActionViewController.swift b/ActionExtension-iOS/ActionViewController.swift new file mode 100644 index 0000000..febbdde --- /dev/null +++ b/ActionExtension-iOS/ActionViewController.swift @@ -0,0 +1,57 @@ +// +// ActionViewController.swift +// ActionExtension-iOS +// +// Created by Angelo Stavrow on 2021-11-05. +// + +import UIKit +import MobileCoreServices +import UniformTypeIdentifiers + +class ActionViewController: UIViewController { + + @IBOutlet weak var imageView: UIImageView! + + override func viewDidLoad() { + super.viewDidLoad() + + // Get the item[s] we're handling from the extension context. + + // For example, look for an image and place it into an image view. + // Replace this with something appropriate for the type[s] your extension supports. + var imageFound = false + for item in self.extensionContext!.inputItems as! [NSExtensionItem] { + for provider in item.attachments! { + if provider.hasItemConformingToTypeIdentifier(UTType.image.identifier) { + // This is an image. We'll load it, then place it in our image view. + weak var weakImageView = self.imageView + provider.loadItem(forTypeIdentifier: UTType.image.identifier, options: nil, completionHandler: { (imageURL, error) in + OperationQueue.main.addOperation { + if let strongImageView = weakImageView { + if let imageURL = imageURL as? URL { + strongImageView.image = UIImage(data: try! Data(contentsOf: imageURL)) + } + } + } + }) + + imageFound = true + break + } + } + + if (imageFound) { + // We only handle one image, so stop looking for more. + break + } + } + } + + @IBAction func done() { + // Return any edited content to the host app. + // This template doesn't do anything, so we just echo the passed in items. + self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil) + } + +} diff --git a/ActionExtension-iOS/Base.lproj/MainInterface.storyboard b/ActionExtension-iOS/Base.lproj/MainInterface.storyboard new file mode 100644 index 0000000..b165d3a --- /dev/null +++ b/ActionExtension-iOS/Base.lproj/MainInterface.storyboard @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ActionExtension-iOS/Info.plist b/ActionExtension-iOS/Info.plist new file mode 100644 index 0000000..2c98e4c --- /dev/null +++ b/ActionExtension-iOS/Info.plist @@ -0,0 +1,28 @@ + + + + + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + TRUEPREDICATE + NSExtensionServiceAllowsFinderPreviewItem + + NSExtensionServiceAllowsTouchBarItem + + NSExtensionServiceFinderPreviewIconName + NSActionTemplate + NSExtensionServiceTouchBarBezelColorName + TouchBarBezel + NSExtensionServiceTouchBarIconName + NSActionTemplate + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.ui-services + + + diff --git a/ActionExtension-iOS/Media.xcassets/Contents.json b/ActionExtension-iOS/Media.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/ActionExtension-iOS/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ActionExtension-iOS/Media.xcassets/TouchBarBezel.colorset/Contents.json b/ActionExtension-iOS/Media.xcassets/TouchBarBezel.colorset/Contents.json new file mode 100644 index 0000000..94a9fc2 --- /dev/null +++ b/ActionExtension-iOS/Media.xcassets/TouchBarBezel.colorset/Contents.json @@ -0,0 +1,14 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "mac", + "color" : { + "reference" : "systemPurpleColor" + } + } + ] +} \ No newline at end of file diff --git a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj index 49d55a3..338afe3 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj +++ b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj @@ -27,6 +27,11 @@ 171DC677272C7D0B002B9B8A /* UserDefaults+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 171DC676272C7D0B002B9B8A /* UserDefaults+Extensions.swift */; }; 171DC678272C7D0B002B9B8A /* UserDefaults+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 171DC676272C7D0B002B9B8A /* UserDefaults+Extensions.swift */; }; 172C492E2593981900E20ADF /* MacUpdatesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172C492D2593981900E20ADF /* MacUpdatesView.swift */; }; + 172E10012735B83E00061372 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 172E10002735B83E00061372 /* UniformTypeIdentifiers.framework */; platformFilter = maccatalyst; }; + 172E10042735B83E00061372 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 172E10032735B83E00061372 /* Media.xcassets */; }; + 172E10062735B83E00061372 /* ActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E10052735B83E00061372 /* ActionViewController.swift */; }; + 172E10092735B83E00061372 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 172E10072735B83E00061372 /* MainInterface.storyboard */; }; + 172E100D2735B83E00061372 /* ActionExtension-iOS.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 173E19D1254318F600440F0F /* RemoteChangePromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173E19D0254318F600440F0F /* RemoteChangePromptView.swift */; }; 173E19E3254329CC00440F0F /* PostTextEditingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173E19E2254329CC00440F0F /* PostTextEditingView.swift */; }; 17466626256C0D0600629997 /* MacEditorTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17466625256C0D0600629997 /* MacEditorTextView.swift */; }; @@ -112,6 +117,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 172E100B2735B83E00061372 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 17DF327C24C87D3300BCE2E3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 172E0FFE2735B83E00061372; + remoteInfo = "ActionExtension-iOS"; + }; 17DF329924C87D3500BCE2E3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 17DF327C24C87D3300BCE2E3 /* Project object */; @@ -128,6 +140,20 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 172E100E2735B83E00061372 /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 172E100D2735B83E00061372 /* ActionExtension-iOS.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 1709ADDF251B9A110053AF79 /* EditorLaunchingPolicy.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = EditorLaunchingPolicy.md; sourceTree = ""; }; 170A7EC026F5186A00F1CBD4 /* CollectionListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionListModel.swift; sourceTree = ""; }; @@ -139,6 +165,12 @@ 171BFDF924D4AF8300888236 /* CollectionListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionListView.swift; sourceTree = ""; }; 171DC676272C7D0B002B9B8A /* UserDefaults+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+Extensions.swift"; sourceTree = ""; }; 172C492D2593981900E20ADF /* MacUpdatesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacUpdatesView.swift; sourceTree = ""; }; + 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "ActionExtension-iOS.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + 172E10002735B83E00061372 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; + 172E10032735B83E00061372 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; + 172E10052735B83E00061372 /* ActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionViewController.swift; sourceTree = ""; }; + 172E10082735B83E00061372 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 172E100A2735B83E00061372 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 173E19D0254318F600440F0F /* RemoteChangePromptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteChangePromptView.swift; sourceTree = ""; }; 173E19E2254329CC00440F0F /* PostTextEditingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostTextEditingView.swift; sourceTree = ""; }; 17466625256C0D0600629997 /* MacEditorTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacEditorTextView.swift; sourceTree = ""; }; @@ -211,6 +243,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 172E0FFC2735B83E00061372 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 172E10012735B83E00061372 /* UniformTypeIdentifiers.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 17DF328524C87D3500BCE2E3 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -263,6 +303,17 @@ path = Settings; sourceTree = ""; }; + 172E10022735B83E00061372 /* ActionExtension-iOS */ = { + isa = PBXGroup; + children = ( + 172E10032735B83E00061372 /* Media.xcassets */, + 172E10052735B83E00061372 /* ActionViewController.swift */, + 172E10072735B83E00061372 /* MainInterface.storyboard */, + 172E100A2735B83E00061372 /* Info.plist */, + ); + path = "ActionExtension-iOS"; + sourceTree = ""; + }; 1739B8D324EAFAB700DA7421 /* PostEditor */ = { isa = PBXGroup; children = ( @@ -385,6 +436,7 @@ 17DF329124C87D3500BCE2E3 /* macOS */, 17DF329B24C87D3500BCE2E3 /* Tests iOS */, 17DF32A624C87D3500BCE2E3 /* Tests macOS */, + 172E10022735B83E00061372 /* ActionExtension-iOS */, 17DF328924C87D3500BCE2E3 /* Products */, 17DF32C124C87D8D00BCE2E3 /* Frameworks */, ); @@ -416,6 +468,7 @@ 17DF329024C87D3500BCE2E3 /* WriteFreely for Mac.app */, 17DF329824C87D3500BCE2E3 /* Tests iOS.xctest */, 17DF32A324C87D3500BCE2E3 /* Tests macOS.xctest */, + 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */, ); name = Products; sourceTree = ""; @@ -467,6 +520,7 @@ 17DF32C124C87D8D00BCE2E3 /* Frameworks */ = { isa = PBXGroup; children = ( + 172E10002735B83E00061372 /* UniformTypeIdentifiers.framework */, ); name = Frameworks; sourceTree = ""; @@ -525,6 +579,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 172E0FFE2735B83E00061372 /* ActionExtension-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 172E10112735B83E00061372 /* Build configuration list for PBXNativeTarget "ActionExtension-iOS" */; + buildPhases = ( + 172E0FFB2735B83E00061372 /* Sources */, + 172E0FFC2735B83E00061372 /* Frameworks */, + 172E0FFD2735B83E00061372 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ActionExtension-iOS"; + productName = "ActionExtension-iOS"; + productReference = 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */; + productType = "com.apple.product-type.app-extension"; + }; 17DF328724C87D3500BCE2E3 /* WriteFreely-MultiPlatform (iOS) */ = { isa = PBXNativeTarget; buildConfigurationList = 17DF32B224C87D3500BCE2E3 /* Build configuration list for PBXNativeTarget "WriteFreely-MultiPlatform (iOS)" */; @@ -533,10 +604,12 @@ 17DF328524C87D3500BCE2E3 /* Frameworks */, 17DF328624C87D3500BCE2E3 /* Resources */, 17DF32C424C87E6700BCE2E3 /* ShellScript */, + 172E100E2735B83E00061372 /* Embed App Extensions */, ); buildRules = ( ); dependencies = ( + 172E100C2735B83E00061372 /* PBXTargetDependency */, ); name = "WriteFreely-MultiPlatform (iOS)"; packageProductDependencies = ( @@ -610,9 +683,12 @@ 17DF327C24C87D3300BCE2E3 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1200; + LastSwiftUpdateCheck = 1310; LastUpgradeCheck = 1200; TargetAttributes = { + 172E0FFE2735B83E00061372 = { + CreatedOnToolsVersion = 13.1; + }; 17DF328724C87D3500BCE2E3 = { CreatedOnToolsVersion = 12.0; }; @@ -650,11 +726,21 @@ 17DF328F24C87D3500BCE2E3 /* WriteFreely-MultiPlatform (macOS) */, 17DF329724C87D3500BCE2E3 /* Tests iOS */, 17DF32A224C87D3500BCE2E3 /* Tests macOS */, + 172E0FFE2735B83E00061372 /* ActionExtension-iOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 172E0FFD2735B83E00061372 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 172E10042735B83E00061372 /* Media.xcassets in Resources */, + 172E10092735B83E00061372 /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 17DF328624C87D3500BCE2E3 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -739,6 +825,14 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 172E0FFB2735B83E00061372 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 172E10062735B83E00061372 /* ActionViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 17DF328424C87D3500BCE2E3 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -853,6 +947,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 172E100C2735B83E00061372 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 172E0FFE2735B83E00061372 /* ActionExtension-iOS */; + targetProxy = 172E100B2735B83E00061372 /* PBXContainerItemProxy */; + }; 17DF329A24C87D3500BCE2E3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 17DF328724C87D3500BCE2E3 /* WriteFreely-MultiPlatform (iOS) */; @@ -865,7 +964,75 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + 172E10072735B83E00061372 /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 172E10082735B83E00061372 /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ + 172E100F2735B83E00061372 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = TPPAB4YBA6; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "ActionExtension-iOS"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform.ActionExtension-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 172E10102735B83E00061372 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = TPPAB4YBA6; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "ActionExtension-iOS"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform.ActionExtension-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; 17DF32B024C87D3500BCE2E3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -980,6 +1147,7 @@ 17DF32B324C87D3500BCE2E3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; @@ -1005,6 +1173,7 @@ 17DF32B424C87D3500BCE2E3 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; @@ -1172,6 +1341,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 172E10112735B83E00061372 /* Build configuration list for PBXNativeTarget "ActionExtension-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 172E100F2735B83E00061372 /* Debug */, + 172E10102735B83E00061372 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 17DF327F24C87D3300BCE2E3 /* Build configuration list for PBXProject "WriteFreely-MultiPlatform" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist index 6cd8075..926b2fa 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,16 +4,21 @@ SchemeUserState - WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_ + ActionExtension-iOS.xcscheme_^#shared#^_ orderHint - 1 + 2 - WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_ + WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_ orderHint 0 + WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_ + + orderHint + 1 + From 2dccaf7196170a237e90224abb8022ecd52b5f67 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 5 Nov 2021 15:40:36 -0400 Subject: [PATCH 2/7] Initial work fetching URL, title, and selected text from webpage --- ActionExtension-iOS/Action.js | 19 +++++++++ .../ActionViewController.swift | 41 ++++--------------- ActionExtension-iOS/Info.plist | 7 +++- .../project.pbxproj | 4 ++ 4 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 ActionExtension-iOS/Action.js diff --git a/ActionExtension-iOS/Action.js b/ActionExtension-iOS/Action.js new file mode 100644 index 0000000..8225a62 --- /dev/null +++ b/ActionExtension-iOS/Action.js @@ -0,0 +1,19 @@ +var Action = function() {}; + +Action.prototype = { + +run: function(parameters) { + parameters.completionFunction({ + "URL": document.URL, + "title": document.title, + "selection": document.getSelection().toString() + }); +}, + +finalize: function(parameters) { + +} + +}; + +var ExtensionPreprocessingJS = new Action diff --git a/ActionExtension-iOS/ActionViewController.swift b/ActionExtension-iOS/ActionViewController.swift index febbdde..5c508cc 100644 --- a/ActionExtension-iOS/ActionViewController.swift +++ b/ActionExtension-iOS/ActionViewController.swift @@ -1,10 +1,3 @@ -// -// ActionViewController.swift -// ActionExtension-iOS -// -// Created by Angelo Stavrow on 2021-11-05. -// - import UIKit import MobileCoreServices import UniformTypeIdentifiers @@ -15,36 +8,16 @@ class ActionViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - + // Get the item[s] we're handling from the extension context. - - // For example, look for an image and place it into an image view. - // Replace this with something appropriate for the type[s] your extension supports. - var imageFound = false - for item in self.extensionContext!.inputItems as! [NSExtensionItem] { - for provider in item.attachments! { - if provider.hasItemConformingToTypeIdentifier(UTType.image.identifier) { - // This is an image. We'll load it, then place it in our image view. - weak var weakImageView = self.imageView - provider.loadItem(forTypeIdentifier: UTType.image.identifier, options: nil, completionHandler: { (imageURL, error) in - OperationQueue.main.addOperation { - if let strongImageView = weakImageView { - if let imageURL = imageURL as? URL { - strongImageView.image = UIImage(data: try! Data(contentsOf: imageURL)) - } - } - } - }) - - imageFound = true - break + if let inputItem = extensionContext?.inputItems.first as? NSExtensionItem { + if let itemProvider = inputItem.attachments?.first { + itemProvider.loadItem(forTypeIdentifier: kUTTypePropertyList as String) { [weak self] dict, error in + guard let itemDictionary = dict as? NSDictionary else { return } + guard let javaScriptValues = itemDictionary[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary else { return } + print(javaScriptValues) } } - - if (imageFound) { - // We only handle one image, so stop looking for more. - break - } } } diff --git a/ActionExtension-iOS/Info.plist b/ActionExtension-iOS/Info.plist index 2c98e4c..e3ce5c0 100644 --- a/ActionExtension-iOS/Info.plist +++ b/ActionExtension-iOS/Info.plist @@ -6,8 +6,13 @@ NSExtensionAttributes + NSExtensionJavaScriptPreprocessingFile + Action NSExtensionActivationRule - TRUEPREDICATE + + NSExtensionActivationSupportsWebPageWithMaxCount + 1 + NSExtensionServiceAllowsFinderPreviewItem NSExtensionServiceAllowsTouchBarItem diff --git a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj index 338afe3..534b91c 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj +++ b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 172E10062735B83E00061372 /* ActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E10052735B83E00061372 /* ActionViewController.swift */; }; 172E10092735B83E00061372 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 172E10072735B83E00061372 /* MainInterface.storyboard */; }; 172E100D2735B83E00061372 /* ActionExtension-iOS.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 172E10132735BB6200061372 /* Action.js in Resources */ = {isa = PBXBuildFile; fileRef = 172E10122735BB6200061372 /* Action.js */; }; 173E19D1254318F600440F0F /* RemoteChangePromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173E19D0254318F600440F0F /* RemoteChangePromptView.swift */; }; 173E19E3254329CC00440F0F /* PostTextEditingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173E19E2254329CC00440F0F /* PostTextEditingView.swift */; }; 17466626256C0D0600629997 /* MacEditorTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17466625256C0D0600629997 /* MacEditorTextView.swift */; }; @@ -171,6 +172,7 @@ 172E10052735B83E00061372 /* ActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionViewController.swift; sourceTree = ""; }; 172E10082735B83E00061372 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; 172E100A2735B83E00061372 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 172E10122735BB6200061372 /* Action.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Action.js; sourceTree = ""; }; 173E19D0254318F600440F0F /* RemoteChangePromptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteChangePromptView.swift; sourceTree = ""; }; 173E19E2254329CC00440F0F /* PostTextEditingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostTextEditingView.swift; sourceTree = ""; }; 17466625256C0D0600629997 /* MacEditorTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacEditorTextView.swift; sourceTree = ""; }; @@ -310,6 +312,7 @@ 172E10052735B83E00061372 /* ActionViewController.swift */, 172E10072735B83E00061372 /* MainInterface.storyboard */, 172E100A2735B83E00061372 /* Info.plist */, + 172E10122735BB6200061372 /* Action.js */, ); path = "ActionExtension-iOS"; sourceTree = ""; @@ -736,6 +739,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 172E10132735BB6200061372 /* Action.js in Resources */, 172E10042735B83E00061372 /* Media.xcassets in Resources */, 172E10092735B83E00061372 /* MainInterface.storyboard in Resources */, ); From 3752b8541485b60223110e6c3c846406ecc49727 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 19 Nov 2021 15:41:54 -0500 Subject: [PATCH 3/7] Add action extension --- ActionExtension-iOS/Action.js | 3 +- .../ActionExtension-iOS.entitlements | 10 + .../ActionViewController.swift | 29 +-- .../Base.lproj/MainInterface.storyboard | 53 ----- ActionExtension-iOS/ContentView.swift | 198 ++++++++++++++++++ ActionExtension-iOS/Info.plist | 28 ++- .../AppIconExtension@2x.png | Bin 0 -> 4787 bytes .../AppIconExtension@3x.png | Bin 0 -> 7521 bytes .../AppIconExtension.appiconset/Contents.json | 100 +++++++++ Shared/Account/AccountModel.swift | 14 +- .../Extensions/UserDefaults+Extensions.swift | 4 + Shared/Models/WriteFreelyModel.swift | 4 +- Shared/Preferences/PreferencesModel.swift | 10 +- .../project.pbxproj | 77 +++++-- .../xcschemes/xcschememanagement.plist | 4 +- .../EnvironmentValues+Extensions.swift | 20 ++ iOS/Extensions/UIHostingView.swift | 57 +++++ 17 files changed, 502 insertions(+), 109 deletions(-) create mode 100644 ActionExtension-iOS/ActionExtension-iOS.entitlements delete mode 100644 ActionExtension-iOS/Base.lproj/MainInterface.storyboard create mode 100644 ActionExtension-iOS/ContentView.swift create mode 100644 ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/AppIconExtension@2x.png create mode 100644 ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/AppIconExtension@3x.png create mode 100644 ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/Contents.json create mode 100644 iOS/Extensions/EnvironmentValues+Extensions.swift create mode 100644 iOS/Extensions/UIHostingView.swift diff --git a/ActionExtension-iOS/Action.js b/ActionExtension-iOS/Action.js index 8225a62..92269e9 100644 --- a/ActionExtension-iOS/Action.js +++ b/ActionExtension-iOS/Action.js @@ -11,7 +11,8 @@ run: function(parameters) { }, finalize: function(parameters) { - + var customJavaScript = parameters["customJavaScript"]; + eval(customJavaScript); } }; diff --git a/ActionExtension-iOS/ActionExtension-iOS.entitlements b/ActionExtension-iOS/ActionExtension-iOS.entitlements new file mode 100644 index 0000000..a592bed --- /dev/null +++ b/ActionExtension-iOS/ActionExtension-iOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.abunchtell.writefreely + + + diff --git a/ActionExtension-iOS/ActionViewController.swift b/ActionExtension-iOS/ActionViewController.swift index 5c508cc..c6b7cbe 100644 --- a/ActionExtension-iOS/ActionViewController.swift +++ b/ActionExtension-iOS/ActionViewController.swift @@ -1,30 +1,21 @@ -import UIKit -import MobileCoreServices -import UniformTypeIdentifiers +import SwiftUI class ActionViewController: UIViewController { - @IBOutlet weak var imageView: UIImageView! + let moc = LocalStorageManager.standard.container.viewContext + + override var prefersStatusBarHidden: Bool { true } override func viewDidLoad() { super.viewDidLoad() - // Get the item[s] we're handling from the extension context. - if let inputItem = extensionContext?.inputItems.first as? NSExtensionItem { - if let itemProvider = inputItem.attachments?.first { - itemProvider.loadItem(forTypeIdentifier: kUTTypePropertyList as String) { [weak self] dict, error in - guard let itemDictionary = dict as? NSDictionary else { return } - guard let javaScriptValues = itemDictionary[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary else { return } - print(javaScriptValues) - } - } - } - } + let contentView = ContentView() + .environment(\.extensionContext, extensionContext) + .environment(\.managedObjectContext, moc) - @IBAction func done() { - // Return any edited content to the host app. - // This template doesn't do anything, so we just echo the passed in items. - self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil) + view = UIHostingView(rootView: contentView) + view.isOpaque = true + view.backgroundColor = .systemBackground } } diff --git a/ActionExtension-iOS/Base.lproj/MainInterface.storyboard b/ActionExtension-iOS/Base.lproj/MainInterface.storyboard deleted file mode 100644 index b165d3a..0000000 --- a/ActionExtension-iOS/Base.lproj/MainInterface.storyboard +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ActionExtension-iOS/ContentView.swift b/ActionExtension-iOS/ContentView.swift new file mode 100644 index 0000000..81df6f8 --- /dev/null +++ b/ActionExtension-iOS/ContentView.swift @@ -0,0 +1,198 @@ +import SwiftUI +import MobileCoreServices +import UniformTypeIdentifiers +import WriteFreely + +enum WFActionExtensionError: Error { + case userCancelledRequest + case couldNotParseInputItems +} + +struct ContentView: View { + @Environment(\.extensionContext) private var extensionContext: NSExtensionContext! + @Environment(\.managedObjectContext) private var managedObjectContext + + @AppStorage(WFDefaults.defaultFontIntegerKey, store: UserDefaults.shared) var fontIndex: Int = 0 + + @FetchRequest( + entity: WFACollection.entity(), + sortDescriptors: [NSSortDescriptor(keyPath: \WFACollection.title, ascending: true)] + ) var collections: FetchedResults + + @State private var draftTitle: String = "" + @State private var draftText: String = "" + @State private var isShowingAlert: Bool = false + @State private var selectedBlog: WFACollection? + + private var draftsCollectionName: String { + guard UserDefaults.shared.string(forKey: WFDefaults.serverStringKey) == "https://write.as" else { + return "Drafts" + } + return "Anonymous" + } + + private var controls: some View { + HStack { + Group { + Button( + action: { extensionContext.cancelRequest(withError: WFActionExtensionError.userCancelledRequest) }, + label: { Image(systemName: "xmark.circle").imageScale(.large) } + ) + .accessibilityLabel(Text("Cancel")) + Spacer() + Button( + action: { + savePostToCollection(collection: selectedBlog, title: draftTitle, body: draftText) + extensionContext.completeRequest(returningItems: nil, completionHandler: nil) + }, + label: { Image(systemName: "square.and.arrow.down").imageScale(.large) } + ) + .accessibilityLabel(Text("Create new draft")) + } + .padding() + } + } + + var body: some View { + VStack { + controls + Form { + Section(header: Text("Title")) { + switch fontIndex { + case 1: + TextField("Draft Title", text: $draftTitle).font(.custom("OpenSans-Regular", size: 26)) + case 2: + TextField("Draft Title", text: $draftTitle).font(.custom("Hack-Regular", size: 26)) + default: + TextField("Draft Title", text: $draftTitle).font(.custom("Lora", size: 26)) + } + } + Section(header: Text("Content")) { + switch fontIndex { + case 1: + TextEditor(text: $draftText).font(.custom("OpenSans-Regular", size: 17)) + case 2: + TextEditor(text: $draftText).font(.custom("Hack-Regular", size: 17)) + default: + TextEditor(text: $draftText).font(.custom("Lora", size: 17)) + } + } + Section(header: Text("Save To")) { + Button(action: { + self.selectedBlog = nil + }, label: { + HStack { + Text(draftsCollectionName) + .foregroundColor(selectedBlog == nil ? .primary : .secondary) + Spacer() + if selectedBlog == nil { + Image(systemName: "checkmark") + } + } + }) + ForEach(collections, id: \.self) { collection in + Button(action: { + self.selectedBlog = collection + }, label: { + HStack { + Text(collection.title) + .foregroundColor(selectedBlog == collection ? .primary : .secondary) + Spacer() + if selectedBlog == collection { + Image(systemName: "checkmark") + } + } + }) + } + } + } + } + .alert(isPresented: $isShowingAlert, content: { + Alert( + title: Text("Something Went Wrong"), + message: Text("WriteFreely can't create a draft with the data received."), + dismissButton: .default(Text("OK"), action: { + extensionContext.cancelRequest(withError: WFActionExtensionError.couldNotParseInputItems) + })) + }) + .onAppear { + do { + try getPageDataFromExtensionContext() + } catch { + self.isShowingAlert = true + } + } + } + + private func savePostToCollection(collection: WFACollection?, title: String, body: String) { + let post = WFAPost(context: managedObjectContext) + post.createdDate = Date() + post.title = title + post.body = body + post.status = PostStatus.local.rawValue + post.collectionAlias = collection?.alias + switch fontIndex { + case 1: + post.appearance = "sans" + case 2: + post.appearance = "wrap" + default: + post.appearance = "serif" + } + if let languageCode = Locale.current.languageCode { + post.language = languageCode + post.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft + } + LocalStorageManager.standard.saveContext() + } + + private func getPageDataFromExtensionContext() throws { + if let inputItem = extensionContext.inputItems.first as? NSExtensionItem { + if let itemProvider = inputItem.attachments?.first { + + let typeIdentifier: String + + if #available(iOS 15, *) { + typeIdentifier = UTType.propertyList.identifier + } else { + typeIdentifier = kUTTypePropertyList as String + } + + itemProvider.loadItem(forTypeIdentifier: typeIdentifier) { (dict, error) in + if let error = error { + print("⚠️", error) + self.isShowingAlert = true + } + + guard let itemDict = dict as? NSDictionary else { + return + } + guard let jsValues = itemDict[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary else { + return + } + + let pageTitle = jsValues["title"] as? String ?? "" + let pageURL = jsValues["URL"] as? String ?? "" + let pageSelectedText = jsValues["selection"] as? String ?? "" + + if pageSelectedText.isEmpty { + // If there's no selected text, create a Markdown link to the webpage. + self.draftText = "[\(pageTitle)](\(pageURL))" + } else { + // If there is selected text, create a Markdown blockquote with the selection + // and add a Markdown link to the webpage. + self.draftText = """ + > \(pageSelectedText) + + Via: [\(pageTitle)](\(pageURL)) + """ + } + } + } else { + throw WFActionExtensionError.couldNotParseInputItems + } + } else { + throw WFActionExtensionError.couldNotParseInputItems + } + } +} diff --git a/ActionExtension-iOS/Info.plist b/ActionExtension-iOS/Info.plist index e3ce5c0..9dcc0f9 100644 --- a/ActionExtension-iOS/Info.plist +++ b/ActionExtension-iOS/Info.plist @@ -2,6 +2,30 @@ + UIAppFonts + + LoraGX.ttf + OpenSans-Regular.ttf + Hack-Regular.ttf + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Create WriteFreely draft + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 NSExtension NSExtensionAttributes @@ -24,8 +48,8 @@ NSExtensionServiceTouchBarIconName NSActionTemplate - NSExtensionMainStoryboard - MainInterface + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).ActionViewController NSExtensionPointIdentifier com.apple.ui-services diff --git a/ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/AppIconExtension@2x.png b/ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/AppIconExtension@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..75f20087113c3c259ac90a0f152fbec7aa7e6e92 GIT binary patch literal 4787 zcmbVQXHXMdlntSW-aCktgeIYiG?5}rFjy!mk^rHI^bVnSB27Sg5u_+xARx`qiwV6d zy-Dwg^yQn~*`57JlB3g%)mGx=h+m(a&K-xya9%dn+Jg6s|(7Z@(l0#*S zpX{8>SWhcnD&CK<$55+ZizvPIFJaHPwkrK&O>?zvVgiR0++uKMhfWy40$46UnDogo zDbVKkMQ~pp?&uvou_hc+Andg&u(=LlWn)d3f(Ev6=AF6Tk`ra??7!8KzAFWt+_}Cv z4xy2v(!C|REsX}5gK?@@;BqXz1BqR$IDoR70 zwp|b5-VeFKBqZa$*Vh4tH%8^)uzQ|u*Vo@!F0ZdWC18hKB;kbK0484Kj!gH^`Hk~( zNMmg)Jw1T%4JQK-MA!m|ZWzH0*lz#;0CR!=edCo&_&@xgM-gGqQ2>CpS6ltTGcST| zQ}TGGPPQxGSqp@Tv1GOA52nF1(r5^G66s=4M}D4Q*E17A_GGWzE`I*x=m)L|l0wPR z22lnK^l_|u!l^oWUUW1~GDJ*7G#+!&uNtsBi&brHEfc4{tN5n%wCqj1=t~Ku=ev3* z0q)mk14l zNiGex7}lv6PgdYQ9rkG>bXpbb;=&3yrKoERF-+ zw=VUPy2;oIdj#~w!`6*hZtxC8eRb~+|H;BCuaX>6YOEnK^E|E7L`Hxn3R}b(G>>kA z9zY=}hVoYoYa!+*x4;ghTa7rs_DN|$wH|Yb2fntmeIW5+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+LAss|J-7Wt-CvjlGKgdw`eLnv^ain+L1j>em$V_CdxY1hWT*j9zJ2ZwNXp>IgRY0y$CFcr|r0utck*fv3W~5}^KO{928==fTEosSGfDcKvYY}dbD-peBHgq(K~ccD~mIKEF2YsHLkhswZgc+r;i7q{1e!*|=}k)%tV!FJn0Kv_$af62xs{MF$Rs03*kIq!Ce6x)2lgj^UXox?Xft}BcohMv32`b zhmK3ds<+gCzhxpMx+!Pj5{bpS!zz=eVBeT7hS6!Empx`Vim6Epmq zv#G>O`>)lnaHl0#PcO{jfM5f_3j`Cs%}6f_nd>A=guYORGhFL-A)qU(FFyojVl(mJ zw8uu5Z$_?%%kq670RDzb-WWqVLf^?apI_H9dlI^2M!MqTit8*NjioxhWp8U4tXg6s zXG%sm*Kr#^aq-<;b_tkAD;07|7@wMH6n@JTEA$Q1HyEX%4-@`QVoXAAJ_}HSTFG^A>MCqMvwMEhLua6Bsy_ zD$c8gLN3^#QZlrVtW2HL_Z@w6w+}x3Nbo=E5BGBL*S@iXD8Y}uHxtZJx$4t;k v6(BhtB_OAfVfb&2fd7Y*H>?sL1wlyHH1MiWPA2OgtvE$lRhc>|v+#cbPyz?4 literal 0 HcmV?d00001 diff --git a/ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/Contents.json b/ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/Contents.json new file mode 100644 index 0000000..4dac38e --- /dev/null +++ b/ActionExtension-iOS/Media.xcassets/AppIconExtension.appiconset/Contents.json @@ -0,0 +1,100 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "filename" : "AppIconExtension@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "filename" : "AppIconExtension@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Shared/Account/AccountModel.swift b/Shared/Account/AccountModel.swift index 0e6a6e8..94171ec 100644 --- a/Shared/Account/AccountModel.swift +++ b/Shared/Account/AccountModel.swift @@ -56,8 +56,6 @@ extension AccountError: LocalizedError { struct AccountModel { @AppStorage(WFDefaults.isLoggedIn, store: UserDefaults.shared) var isLoggedIn: Bool = false private let defaults = UserDefaults.shared - let usernameStringKey = "usernameStringKey" - let serverStringKey = "serverStringKey" var server: String = "" var username: String = "" @@ -68,19 +66,19 @@ struct AccountModel { self.user = user self.username = user.username ?? "" self.isLoggedIn = true - defaults.set(user.username, forKey: usernameStringKey) - defaults.set(server, forKey: serverStringKey) + defaults.set(user.username, forKey: WFDefaults.usernameStringKey) + defaults.set(server, forKey: WFDefaults.serverStringKey) } mutating func logout() { self.user = nil self.isLoggedIn = false - defaults.removeObject(forKey: usernameStringKey) - defaults.removeObject(forKey: serverStringKey) + defaults.removeObject(forKey: WFDefaults.usernameStringKey) + defaults.removeObject(forKey: WFDefaults.serverStringKey) } mutating func restoreState() { - server = defaults.string(forKey: serverStringKey) ?? "" - username = defaults.string(forKey: usernameStringKey) ?? "" + server = defaults.string(forKey: WFDefaults.serverStringKey) ?? "" + username = defaults.string(forKey: WFDefaults.usernameStringKey) ?? "" } } diff --git a/Shared/Extensions/UserDefaults+Extensions.swift b/Shared/Extensions/UserDefaults+Extensions.swift index 47e554c..f40a824 100644 --- a/Shared/Extensions/UserDefaults+Extensions.swift +++ b/Shared/Extensions/UserDefaults+Extensions.swift @@ -5,6 +5,10 @@ enum WFDefaults { static let showAllPostsFlag = "showAllPostsFlag" static let selectedCollectionURL = "selectedCollectionURL" static let lastDraftURL = "lastDraftURL" + static let colorSchemeIntegerKey = "colorSchemeIntegerKey" + static let defaultFontIntegerKey = "defaultFontIntegerKey" + static let usernameStringKey = "usernameStringKey" + static let serverStringKey = "serverStringKey" #if os(macOS) static let automaticallyChecksForUpdates = "automaticallyChecksForUpdates" static let subscribeToBetaUpdates = "subscribeToBetaUpdates" diff --git a/Shared/Models/WriteFreelyModel.swift b/Shared/Models/WriteFreelyModel.swift index 49247ea..ecb575f 100644 --- a/Shared/Models/WriteFreelyModel.swift +++ b/Shared/Models/WriteFreelyModel.swift @@ -43,8 +43,8 @@ final class WriteFreelyModel: ObservableObject { init() { DispatchQueue.main.async { - self.preferences.appearance = self.defaults.integer(forKey: self.preferences.colorSchemeIntegerKey) - self.preferences.font = self.defaults.integer(forKey: self.preferences.defaultFontIntegerKey) + self.preferences.appearance = self.defaults.integer(forKey: WFDefaults.colorSchemeIntegerKey) + self.preferences.font = self.defaults.integer(forKey: WFDefaults.defaultFontIntegerKey) self.account.restoreState() if self.account.isLoggedIn { guard let serverURL = URL(string: self.account.server) else { diff --git a/Shared/Preferences/PreferencesModel.swift b/Shared/Preferences/PreferencesModel.swift index d151d52..0fde8a6 100644 --- a/Shared/Preferences/PreferencesModel.swift +++ b/Shared/Preferences/PreferencesModel.swift @@ -2,8 +2,6 @@ import SwiftUI class PreferencesModel: ObservableObject { private let defaults = UserDefaults.shared - let colorSchemeIntegerKey = "colorSchemeIntegerKey" - let defaultFontIntegerKey = "defaultFontIntegerKey" /* We're stuck dropping into AppKit/UIKit to set light/dark schemes for now, * because setting the .preferredColorScheme modifier on views in SwiftUI is @@ -17,6 +15,7 @@ class PreferencesModel: ObservableObject { */ #if os(iOS) + @available(iOSApplicationExtension, unavailable) var window: UIWindow? { guard let scene = UIApplication.shared.connectedScenes.first, let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate, @@ -27,7 +26,10 @@ class PreferencesModel: ObservableObject { } #endif + @available(iOSApplicationExtension, unavailable) @Published var selectedColorScheme: ColorScheme? + + @available(iOSApplicationExtension, unavailable) @Published var appearance: Int = 0 { didSet { switch appearance { @@ -54,12 +56,12 @@ class PreferencesModel: ObservableObject { #endif } - defaults.set(appearance, forKey: colorSchemeIntegerKey) + defaults.set(appearance, forKey: WFDefaults.colorSchemeIntegerKey) } } @Published var font: Int = 0 { didSet { - defaults.set(font, forKey: defaultFontIntegerKey) + defaults.set(font, forKey: WFDefaults.defaultFontIntegerKey) } } } diff --git a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj index 534b91c..6a36bf5 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj +++ b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj @@ -30,9 +30,21 @@ 172E10012735B83E00061372 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 172E10002735B83E00061372 /* UniformTypeIdentifiers.framework */; platformFilter = maccatalyst; }; 172E10042735B83E00061372 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 172E10032735B83E00061372 /* Media.xcassets */; }; 172E10062735B83E00061372 /* ActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E10052735B83E00061372 /* ActionViewController.swift */; }; - 172E10092735B83E00061372 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 172E10072735B83E00061372 /* MainInterface.storyboard */; }; 172E100D2735B83E00061372 /* ActionExtension-iOS.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 172E10132735BB6200061372 /* Action.js in Resources */ = {isa = PBXBuildFile; fileRef = 172E10122735BB6200061372 /* Action.js */; }; + 172E10152735C2BD00061372 /* UIHostingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E10142735C2BD00061372 /* UIHostingView.swift */; }; + 172E10172735C2DF00061372 /* EnvironmentValues+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E10162735C2DF00061372 /* EnvironmentValues+Extensions.swift */; }; + 172E10192735C3DB00061372 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E10182735C3DB00061372 /* ContentView.swift */; }; + 172E101B2735C54400061372 /* WriteFreely in Frameworks */ = {isa = PBXBuildFile; productRef = 172E101A2735C54400061372 /* WriteFreely */; }; + 172E101C2735C57400061372 /* LocalStorageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1756DBB924FED45500207AB8 /* LocalStorageManager.swift */; }; + 172E101D2735C5AB00061372 /* LocalStorageModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1756DBB524FED3A400207AB8 /* LocalStorageModel.xcdatamodeld */; }; + 172E101E2735C62F00061372 /* PostStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17C42E612507D8E600072984 /* PostStatus.swift */; }; + 172E101F2735C64600061372 /* WFAPost+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B996D62502D23E0017B536 /* WFAPost+CoreDataClass.swift */; }; + 172E10202735C64600061372 /* WFACollection+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1756DBFF24FEE18400207AB8 /* WFACollection+CoreDataClass.swift */; }; + 172E10212735C64600061372 /* WFACollection+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1756DC0024FEE18400207AB8 /* WFACollection+CoreDataProperties.swift */; }; + 172E10222735C64600061372 /* WFAPost+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B996D72502D23E0017B536 /* WFAPost+CoreDataProperties.swift */; }; + 172E10232735C6FF00061372 /* NSManagedObjectContext+ExecuteAndMergeChanges.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17C42E6F250AA12200072984 /* NSManagedObjectContext+ExecuteAndMergeChanges.swift */; }; + 172E10242735C72500061372 /* PreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D435E724E3128F0036B539 /* PreferencesModel.swift */; }; 173E19D1254318F600440F0F /* RemoteChangePromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173E19D0254318F600440F0F /* RemoteChangePromptView.swift */; }; 173E19E3254329CC00440F0F /* PostTextEditingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173E19E2254329CC00440F0F /* PostTextEditingView.swift */; }; 17466626256C0D0600629997 /* MacEditorTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17466625256C0D0600629997 /* MacEditorTextView.swift */; }; @@ -62,6 +74,10 @@ 1756DC0424FEE18400207AB8 /* WFACollection+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1756DC0024FEE18400207AB8 /* WFACollection+CoreDataProperties.swift */; }; 17681E412519410E00D394AE /* UINavigationController+Appearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17681E402519410E00D394AE /* UINavigationController+Appearance.swift */; }; 1780F6EF25895EDB00FE45FF /* PostCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1780F6EE25895EDB00FE45FF /* PostCommands.swift */; }; + 17836C14273EFB870047AF61 /* UserDefaults+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 171DC676272C7D0B002B9B8A /* UserDefaults+Extensions.swift */; }; + 17836C15273F0FBB0047AF61 /* Hack-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */; }; + 17836C16273F0FBB0047AF61 /* LoraGX.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F36B2514EE2F00517CE6 /* LoraGX.ttf */; }; + 17836C17273F0FBB0047AF61 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F39D2514F0E500517CE6 /* OpenSans-Regular.ttf */; }; 17A4FEDA25924AF70037E96B /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 17A4FED925924AF70037E96B /* Sparkle */; }; 17A4FEED25927E730037E96B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17A4FEEC25927E730037E96B /* AppDelegate.swift */; }; 17A5388824DDA31F00DEFF9A /* MacAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17A5388724DDA31F00DEFF9A /* MacAccountView.swift */; }; @@ -170,9 +186,11 @@ 172E10002735B83E00061372 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; 172E10032735B83E00061372 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; 172E10052735B83E00061372 /* ActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionViewController.swift; sourceTree = ""; }; - 172E10082735B83E00061372 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; - 172E100A2735B83E00061372 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 172E100A2735B83E00061372 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; usesTabs = 1; }; 172E10122735BB6200061372 /* Action.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Action.js; sourceTree = ""; }; + 172E10142735C2BD00061372 /* UIHostingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIHostingView.swift; sourceTree = ""; }; + 172E10162735C2DF00061372 /* EnvironmentValues+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EnvironmentValues+Extensions.swift"; sourceTree = ""; }; + 172E10182735C3DB00061372 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 173E19D0254318F600440F0F /* RemoteChangePromptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteChangePromptView.swift; sourceTree = ""; }; 173E19E2254329CC00440F0F /* PostTextEditingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostTextEditingView.swift; sourceTree = ""; }; 17466625256C0D0600629997 /* MacEditorTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacEditorTextView.swift; sourceTree = ""; }; @@ -192,6 +210,7 @@ 1756DC0024FEE18400207AB8 /* WFACollection+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WFACollection+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; }; 17681E402519410E00D394AE /* UINavigationController+Appearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Appearance.swift"; sourceTree = ""; }; 1780F6EE25895EDB00FE45FF /* PostCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCommands.swift; sourceTree = ""; }; + 17836C18273F10C40047AF61 /* ActionExtension-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "ActionExtension-iOS.entitlements"; sourceTree = ""; }; 17A355D3271A052C007C7A47 /* WriteFreely-MultiPlatform (iOS).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "WriteFreely-MultiPlatform (iOS).entitlements"; sourceTree = ""; }; 17A4FEDF25924E810037E96B /* MacSoftwareUpdater.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = MacSoftwareUpdater.md; sourceTree = ""; }; 17A4FEEC25927E730037E96B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -250,6 +269,7 @@ buildActionMask = 2147483647; files = ( 172E10012735B83E00061372 /* UniformTypeIdentifiers.framework in Frameworks */, + 172E101B2735C54400061372 /* WriteFreely in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -308,9 +328,10 @@ 172E10022735B83E00061372 /* ActionExtension-iOS */ = { isa = PBXGroup; children = ( + 17836C18273F10C40047AF61 /* ActionExtension-iOS.entitlements */, 172E10032735B83E00061372 /* Media.xcassets */, + 172E10182735C3DB00061372 /* ContentView.swift */, 172E10052735B83E00061372 /* ActionViewController.swift */, - 172E10072735B83E00061372 /* MainInterface.storyboard */, 172E100A2735B83E00061372 /* Info.plist */, 172E10122735BB6200061372 /* Action.js */, ); @@ -367,6 +388,8 @@ children = ( 1756AE8024CB844500FD7257 /* View+Keyboard.swift */, 17681E402519410E00D394AE /* UINavigationController+Appearance.swift */, + 172E10142735C2BD00061372 /* UIHostingView.swift */, + 172E10162735C2DF00061372 /* EnvironmentValues+Extensions.swift */, ); path = Extensions; sourceTree = ""; @@ -595,6 +618,9 @@ dependencies = ( ); name = "ActionExtension-iOS"; + packageProductDependencies = ( + 172E101A2735C54400061372 /* WriteFreely */, + ); productName = "ActionExtension-iOS"; productReference = 172E0FFF2735B83E00061372 /* ActionExtension-iOS.appex */; productType = "com.apple.product-type.app-extension"; @@ -739,9 +765,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 17836C17273F0FBB0047AF61 /* OpenSans-Regular.ttf in Resources */, 172E10132735BB6200061372 /* Action.js in Resources */, 172E10042735B83E00061372 /* Media.xcassets in Resources */, - 172E10092735B83E00061372 /* MainInterface.storyboard in Resources */, + 17836C15273F0FBB0047AF61 /* Hack-Regular.ttf in Resources */, + 17836C16273F0FBB0047AF61 /* LoraGX.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -834,6 +862,19 @@ buildActionMask = 2147483647; files = ( 172E10062735B83E00061372 /* ActionViewController.swift in Sources */, + 172E10202735C64600061372 /* WFACollection+CoreDataClass.swift in Sources */, + 172E10222735C64600061372 /* WFAPost+CoreDataProperties.swift in Sources */, + 172E101D2735C5AB00061372 /* LocalStorageModel.xcdatamodeld in Sources */, + 17836C14273EFB870047AF61 /* UserDefaults+Extensions.swift in Sources */, + 172E10242735C72500061372 /* PreferencesModel.swift in Sources */, + 172E10172735C2DF00061372 /* EnvironmentValues+Extensions.swift in Sources */, + 172E10212735C64600061372 /* WFACollection+CoreDataProperties.swift in Sources */, + 172E101C2735C57400061372 /* LocalStorageManager.swift in Sources */, + 172E10192735C3DB00061372 /* ContentView.swift in Sources */, + 172E10152735C2BD00061372 /* UIHostingView.swift in Sources */, + 172E101F2735C64600061372 /* WFAPost+CoreDataClass.swift in Sources */, + 172E10232735C6FF00061372 /* NSManagedObjectContext+ExecuteAndMergeChanges.swift in Sources */, + 172E101E2735C62F00061372 /* PostStatus.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -968,22 +1009,14 @@ }; /* End PBXTargetDependency section */ -/* Begin PBXVariantGroup section */ - 172E10072735B83E00061372 /* MainInterface.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 172E10082735B83E00061372 /* Base */, - ); - name = MainInterface.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ 172E100F2735B83E00061372 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = ""; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIconExtension; CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = TPPAB4YBA6; @@ -991,7 +1024,7 @@ INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "ActionExtension-iOS"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1011,7 +1044,10 @@ 172E10102735B83E00061372 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = ""; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIconExtension; CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = TPPAB4YBA6; @@ -1019,7 +1055,7 @@ INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "ActionExtension-iOS"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1431,6 +1467,11 @@ package = 1714DD63260BAC14000C0DFF /* XCRemoteSwiftPackageReference "writefreely-swift" */; productName = WriteFreely; }; + 172E101A2735C54400061372 /* WriteFreely */ = { + isa = XCSwiftPackageProductDependency; + package = 1714DD63260BAC14000C0DFF /* XCRemoteSwiftPackageReference "writefreely-swift" */; + productName = WriteFreely; + }; 17A4FED925924AF70037E96B /* Sparkle */ = { isa = XCSwiftPackageProductDependency; package = 17A4FED825924AF70037E96B /* XCRemoteSwiftPackageReference "Sparkle" */; diff --git a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist index 926b2fa..21aa893 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ ActionExtension-iOS.xcscheme_^#shared#^_ orderHint - 2 + 1 WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_ @@ -17,7 +17,7 @@ WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_ orderHint - 1 + 2 diff --git a/iOS/Extensions/EnvironmentValues+Extensions.swift b/iOS/Extensions/EnvironmentValues+Extensions.swift new file mode 100644 index 0000000..1357791 --- /dev/null +++ b/iOS/Extensions/EnvironmentValues+Extensions.swift @@ -0,0 +1,20 @@ +// Credit: +// https://github.com/sindresorhus/Blear/blob/9ce7cd6ad8d6a88f8d0be12b1ef9152baeeacf96/Blear/Utilities.swift#L1052-L1064 + +import SwiftUI + +extension EnvironmentValues { + + private struct ExtensionContext: EnvironmentKey { + static var defaultValue: NSExtensionContext? + } + + /// The `.extensionContext` of an app extension view controller. + var extensionContext: NSExtensionContext? { + get { self[ExtensionContext.self] } + set { + self[ExtensionContext.self] = newValue + } + } + +} diff --git a/iOS/Extensions/UIHostingView.swift b/iOS/Extensions/UIHostingView.swift new file mode 100644 index 0000000..4a960d1 --- /dev/null +++ b/iOS/Extensions/UIHostingView.swift @@ -0,0 +1,57 @@ +// Credit: +// https://github.com/sindresorhus/Blear/blob/9ce7cd6ad8d6a88f8d0be12b1ef9152baeeacf96/Blear/Utilities.swift#L317-L368 + +import SwiftUI + +final class UIHostingView: UIView { + private let rootViewHostingController: UIHostingController + + var rootView: Content { + get { rootViewHostingController.rootView } + set { + rootViewHostingController.rootView = newValue + } + } + + required init(rootView: Content) { + self.rootViewHostingController = UIHostingController(rootView: rootView) + super.init(frame: .zero) + rootViewHostingController.view.backgroundColor = .clear + addSubview(rootViewHostingController.view) + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func layoutSubviews() { + super.layoutSubviews() + rootViewHostingController.view.frame = bounds + } + + override func sizeToFit() { + guard let superview = superview else { + super.sizeToFit() + return + } + + frame.size = rootViewHostingController.sizeThatFits(in: superview.frame.size) + } + + override func sizeThatFits(_ size: CGSize) -> CGSize { + rootViewHostingController.sizeThatFits(in: size) + } + + override func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSize { + rootViewHostingController.sizeThatFits(in: targetSize) + } + + override func systemLayoutSizeFitting( + _ targetSize: CGSize, + withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, + verticalFittingPriority: UILayoutPriority + ) -> CGSize { + rootViewHostingController.sizeThatFits(in: targetSize) + } +} From 378229c71aa5d4cdc35499c56b29a7b1f5ac777d Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 19 Nov 2021 15:51:37 -0500 Subject: [PATCH 4/7] Bump build number --- ActionExtension-iOS/Info.plist | 38 +++++-------------- .../PostCollection/CollectionListView.swift | 4 +- .../project.pbxproj | 16 ++++---- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/ActionExtension-iOS/Info.plist b/ActionExtension-iOS/Info.plist index 9dcc0f9..04fcced 100644 --- a/ActionExtension-iOS/Info.plist +++ b/ActionExtension-iOS/Info.plist @@ -2,41 +2,17 @@ - UIAppFonts - - LoraGX.ttf - OpenSans-Regular.ttf - Hack-Regular.ttf - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Create WriteFreely draft - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 NSExtension NSExtensionAttributes - NSExtensionJavaScriptPreprocessingFile - Action NSExtensionActivationRule NSExtensionActivationSupportsWebPageWithMaxCount 1 + NSExtensionJavaScriptPreprocessingFile + Action NSExtensionServiceAllowsFinderPreviewItem NSExtensionServiceAllowsTouchBarItem @@ -48,10 +24,16 @@ NSExtensionServiceTouchBarIconName NSActionTemplate - NSExtensionPrincipalClass - $(PRODUCT_MODULE_NAME).ActionViewController NSExtensionPointIdentifier com.apple.ui-services + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).ActionViewController + UIAppFonts + + LoraGX.ttf + OpenSans-Regular.ttf + Hack-Regular.ttf + diff --git a/Shared/PostCollection/CollectionListView.swift b/Shared/PostCollection/CollectionListView.swift index da5dcda..29e84b1 100644 --- a/Shared/PostCollection/CollectionListView.swift +++ b/Shared/PostCollection/CollectionListView.swift @@ -2,7 +2,9 @@ import SwiftUI struct CollectionListView: View { @EnvironmentObject var model: WriteFreelyModel - @ObservedObject var collections = CollectionListModel(managedObjectContext: LocalStorageManager.standard.container.viewContext) + @ObservedObject var collections = CollectionListModel( + managedObjectContext: LocalStorageManager.standard.container.viewContext + ) @State var selectedCollection: WFACollection? var body: some View { diff --git a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj index 6a36bf5..961c133 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj +++ b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj @@ -1018,11 +1018,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 638; DEVELOPMENT_TEAM = TPPAB4YBA6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; - INFOPLIST_KEY_CFBundleDisplayName = "ActionExtension-iOS"; + INFOPLIST_KEY_CFBundleDisplayName = "Create WriteFreely draft"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1030,7 +1030,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.0.8; PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform.ActionExtension-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1049,11 +1049,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 638; DEVELOPMENT_TEAM = TPPAB4YBA6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; - INFOPLIST_KEY_CFBundleDisplayName = "ActionExtension-iOS"; + INFOPLIST_KEY_CFBundleDisplayName = "Create WriteFreely draft"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1061,7 +1061,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.0.8; PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform.ActionExtension-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1192,7 +1192,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 631; + CURRENT_PROJECT_VERSION = 638; DEVELOPMENT_TEAM = TPPAB4YBA6; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = iOS/Info.plist; @@ -1218,7 +1218,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 631; + CURRENT_PROJECT_VERSION = 638; DEVELOPMENT_TEAM = TPPAB4YBA6; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = iOS/Info.plist; From 8a3017d46f68ba212b9cbfd3a825cddca1378373 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 19 Nov 2021 16:10:39 -0500 Subject: [PATCH 5/7] Fix plist data type for action extension --- ActionExtension-iOS/Info.plist | 2 +- WriteFreely-MultiPlatform.xcodeproj/project.pbxproj | 8 ++++---- .../angelo.xcuserdatad/xcschemes/xcschememanagement.plist | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ActionExtension-iOS/Info.plist b/ActionExtension-iOS/Info.plist index 04fcced..764fe26 100644 --- a/ActionExtension-iOS/Info.plist +++ b/ActionExtension-iOS/Info.plist @@ -9,7 +9,7 @@ NSExtensionActivationRule NSExtensionActivationSupportsWebPageWithMaxCount - 1 + 1 NSExtensionJavaScriptPreprocessingFile Action diff --git a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj index 961c133..bff79ca 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj +++ b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj @@ -1018,7 +1018,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 638; + CURRENT_PROJECT_VERSION = 639; DEVELOPMENT_TEAM = TPPAB4YBA6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; @@ -1049,7 +1049,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 638; + CURRENT_PROJECT_VERSION = 639; DEVELOPMENT_TEAM = TPPAB4YBA6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; @@ -1192,7 +1192,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 638; + CURRENT_PROJECT_VERSION = 639; DEVELOPMENT_TEAM = TPPAB4YBA6; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = iOS/Info.plist; @@ -1218,7 +1218,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 638; + CURRENT_PROJECT_VERSION = 639; DEVELOPMENT_TEAM = TPPAB4YBA6; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = iOS/Info.plist; diff --git a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist index 21aa893..155f2da 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,12 +7,12 @@ ActionExtension-iOS.xcscheme_^#shared#^_ orderHint - 1 + 0 WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_ orderHint - 0 + 1 WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_ From dff18e9d368ee54889281508cd74e4aa02942c94 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Sun, 28 Nov 2021 08:01:54 -0500 Subject: [PATCH 6/7] Refresh post list view when app becomes active --- Shared/PostList/PostListView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Shared/PostList/PostListView.swift b/Shared/PostList/PostListView.swift index 86215bb..03b865e 100644 --- a/Shared/PostList/PostListView.swift +++ b/Shared/PostList/PostListView.swift @@ -6,6 +6,7 @@ struct PostListView: View { @Environment(\.managedObjectContext) var managedObjectContext @State private var postCount: Int = 0 + @State private var filteredListViewId: Int = 0 var selectedCollection: WFACollection? var showAllPosts: Bool @@ -27,6 +28,7 @@ struct PostListView: View { showAllPosts: showAllPosts, postCount: $postCount ) + .id(self.filteredListViewId) .navigationTitle( showAllPosts ? "All Posts" : selectedCollection?.title ?? ( model.account.server == "https://write.as" ? "Anonymous" : "Drafts" @@ -123,6 +125,13 @@ struct PostListView: View { .frame(height: frameHeight) .background(Color(UIColor.systemGray5)) .overlay(Divider(), alignment: .top) + .onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in + // We use this to invalidate and refresh the view, so that new posts created outside of the app (e.g., + // in the action extension) show up. + withAnimation { + self.filteredListViewId += 1 + } + } } .ignoresSafeArea() .onAppear { From 92e31902f8ca19a7f90a0e55693a117f1b1ff726 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Sun, 28 Nov 2021 08:05:04 -0500 Subject: [PATCH 7/7] Add padding to prevent keyboard occlusion --- ActionExtension-iOS/ContentView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ActionExtension-iOS/ContentView.swift b/ActionExtension-iOS/ContentView.swift index 81df6f8..0d38361 100644 --- a/ActionExtension-iOS/ContentView.swift +++ b/ActionExtension-iOS/ContentView.swift @@ -106,6 +106,7 @@ struct ContentView: View { } } } + .padding(.bottom, 24) } .alert(isPresented: $isShowingAlert, content: { Alert(