diff --git a/Modules/Capabilities/DesignSystem/Sources/UIResponderExtensions.swift b/Modules/Capabilities/DesignSystem/Sources/Extensions/UIResponderExtensions.swift similarity index 100% rename from Modules/Capabilities/DesignSystem/Sources/UIResponderExtensions.swift rename to Modules/Capabilities/DesignSystem/Sources/Extensions/UIResponderExtensions.swift diff --git a/Modules/Capabilities/DesignSystem/Sources/UIViewControllerExtensions.swift b/Modules/Capabilities/DesignSystem/Sources/Extensions/UIViewControllerExtensions.swift similarity index 100% rename from Modules/Capabilities/DesignSystem/Sources/UIViewControllerExtensions.swift rename to Modules/Capabilities/DesignSystem/Sources/Extensions/UIViewControllerExtensions.swift diff --git a/Modules/Capabilities/DesignSystem/Sources/Extensions/ViewExtensions.swift b/Modules/Capabilities/DesignSystem/Sources/Extensions/ViewExtensions.swift new file mode 100644 index 00000000..90ee012a --- /dev/null +++ b/Modules/Capabilities/DesignSystem/Sources/Extensions/ViewExtensions.swift @@ -0,0 +1,32 @@ +// Created by Geoff Pado on 5/13/24. +// Copyright © 2024 Cocoatype, LLC. All rights reserved. + +import Combine +import SwiftUI + +public extension View { + func onAppReceive
(_ publisher: P, perform action: @escaping (P.Output) -> Void) -> some View where P: Publisher, P.Failure == Never {
+ let isPreview: Bool
+#if DEBUG
+ isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
+#else
+ isPreview = false
+#endif
+
+ if isPreview {
+ return self.onReceive(publisher, perform: { _ in })
+ } else {
+ return self.onReceive(publisher, perform: action)
+ }
+ }
+
+ func fill() -> some View {
+ return self.modifier(FillViewModifier())
+ }
+}
+
+struct FillViewModifier: ViewModifier {
+ func body(content: Content) -> some View {
+ AnyView(content).frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
+ }
+}
diff --git a/Modules/Capabilities/DesignSystem/Sources/ReadableWidthKey.swift b/Modules/Capabilities/DesignSystem/Sources/ReadableWidthKey.swift
new file mode 100644
index 00000000..39cd8578
--- /dev/null
+++ b/Modules/Capabilities/DesignSystem/Sources/ReadableWidthKey.swift
@@ -0,0 +1,15 @@
+// Created by Geoff Pado on 5/13/24.
+// Copyright © 2024 Cocoatype, LLC. All rights reserved.
+
+import SwiftUI
+
+struct ReadableWidthKey: EnvironmentKey {
+ static let defaultValue = CGFloat.zero
+}
+
+public extension EnvironmentValues {
+ var readableWidth: CGFloat {
+ get { self[ReadableWidthKey.self] }
+ set { self[ReadableWidthKey.self] = newValue }
+ }
+}
diff --git a/Modules/Legacy/Core/Sources/Settings/Purchase Marketing/PurchaseMarketingHeader.swift b/Modules/Capabilities/PurchaseMarketing/Sources/PurchaseMarketingHeader.swift
similarity index 100%
rename from Modules/Legacy/Core/Sources/Settings/Purchase Marketing/PurchaseMarketingHeader.swift
rename to Modules/Capabilities/PurchaseMarketing/Sources/PurchaseMarketingHeader.swift
diff --git a/Modules/Legacy/Core/Sources/Settings/Purchase Marketing/PurchaseMarketingHostingController.swift b/Modules/Capabilities/PurchaseMarketing/Sources/PurchaseMarketingHostingController.swift
similarity index 81%
rename from Modules/Legacy/Core/Sources/Settings/Purchase Marketing/PurchaseMarketingHostingController.swift
rename to Modules/Capabilities/PurchaseMarketing/Sources/PurchaseMarketingHostingController.swift
index 54e9b9f9..a19b08dd 100644
--- a/Modules/Legacy/Core/Sources/Settings/Purchase Marketing/PurchaseMarketingHostingController.swift
+++ b/Modules/Capabilities/PurchaseMarketing/Sources/PurchaseMarketingHostingController.swift
@@ -4,8 +4,8 @@
import SwiftUI
import UIKit
-class PurchaseMarketingHostingController: UIHostingController (_ publisher: P, perform action: @escaping (P.Output) -> Void) -> some View where P: Publisher, P.Failure == Never {
- let isPreview: Bool
- #if DEBUG
- isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
- #else
- isPreview = false
- #endif
-
- if isPreview {
- return self.onReceive(publisher, perform: { _ in })
- } else {
- return self.onReceive(publisher, perform: action)
- }
- }
-
- public func fill() -> some View {
- return self.modifier(FillViewModifier())
- }
-
public func continuousCornerRadius(_ radius: CGFloat) -> some View {
return self.modifier(ContinuousCornerRadiusViewModifier(radius))
}
}
-struct FillViewModifier: ViewModifier {
- func body(content: Content) -> some View {
- AnyView(content).frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
- }
-}
-
struct ContinuousCornerRadiusViewModifier: ViewModifier {
private let radius: CGFloat
init(_ radius: CGFloat) {
diff --git a/Modules/Legacy/Core/Sources/Settings/Desktop/DesktopSettingsView.swift b/Modules/Legacy/Core/Sources/Settings/Desktop/DesktopSettingsView.swift
index c001cd59..f6452968 100644
--- a/Modules/Legacy/Core/Sources/Settings/Desktop/DesktopSettingsView.swift
+++ b/Modules/Legacy/Core/Sources/Settings/Desktop/DesktopSettingsView.swift
@@ -1,6 +1,7 @@
// Created by Geoff Pado on 9/27/20.
// Copyright © 2020 Cocoatype, LLC. All rights reserved.
+import PurchaseMarketing
import Purchasing
import SwiftUI
diff --git a/Modules/Legacy/Core/Sources/Settings/List/SettingsContentGenerator.swift b/Modules/Legacy/Core/Sources/Settings/List/SettingsContentGenerator.swift
index 88cc0867..6a60b28c 100644
--- a/Modules/Legacy/Core/Sources/Settings/List/SettingsContentGenerator.swift
+++ b/Modules/Legacy/Core/Sources/Settings/List/SettingsContentGenerator.swift
@@ -3,6 +3,7 @@
import AutoRedactionsUI
import Defaults
+import PurchaseMarketing
import Purchasing
import SafariServices
import SwiftUI
diff --git a/Modules/Legacy/Core/Sources/Settings/Purchase Item/PurchaseSubtitle.swift b/Modules/Legacy/Core/Sources/Settings/Purchase Item/PurchaseSubtitle.swift
index bbc3ee25..c3fbf78d 100644
--- a/Modules/Legacy/Core/Sources/Settings/Purchase Item/PurchaseSubtitle.swift
+++ b/Modules/Legacy/Core/Sources/Settings/Purchase Item/PurchaseSubtitle.swift
@@ -1,6 +1,7 @@
// Created by Geoff Pado on 5/19/21.
// Copyright © 2021 Cocoatype, LLC. All rights reserved.
+import PurchaseMarketing
import Purchasing
import StoreKit
import SwiftUI
diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingAutoRedactionsAccessProvider.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingAutoRedactionsAccessProvider.swift
index b7d8f736..b3f59b31 100644
--- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingAutoRedactionsAccessProvider.swift
+++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingAutoRedactionsAccessProvider.swift
@@ -7,12 +7,12 @@ import UIKit
import Unpurchased
class PhotoEditingAutoRedactionsAccessProvider: NSObject {
- func autoRedactionsAccessViewController(learnMoreAction: UnpurchasedFeature.LearnMoreAction) -> UIViewController {
+ func autoRedactionsAccessViewController(learnMoreAction: @escaping UnpurchasedFeature.LearnMoreAction) -> UIViewController {
if purchased {
return AutoRedactionsAccessViewController()
} else {
return UnpurchasedAlertControllerFactory()
- .alertController(for: .autoRedactions(learnMoreAction: nil))
+ .alertController(for: .autoRedactions(learnMoreAction: learnMoreAction))
}
}
diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift
index 2a28a15a..3a75d7d4 100644
--- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift
+++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift
@@ -5,6 +5,7 @@ import AutoRedactionsUI
import Defaults
import Observations
import Photos
+import PurchaseMarketing
import Redactions
import UIKit
@@ -292,8 +293,7 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate,
present(
PhotoEditingAutoRedactionsAccessProvider()
.autoRedactionsAccessViewController { [weak self] in
- // TODO: present purchase marketing view
-// self?.present(PurchaseMarketingHostingController(), animated: true)
+ self?.present(PurchaseMarketingHostingController(), animated: true)
},
animated: true)
}
diff --git a/Project.swift b/Project.swift
index fbd11299..20889fc4 100644
--- a/Project.swift
+++ b/Project.swift
@@ -44,6 +44,7 @@ let project = Project(
ErrorHandling.target,
Logging.target,
Observations.target,
+ PurchaseMarketing.target,
Purchasing.target,
Receipts.target,
Redacting.target,
@@ -58,6 +59,7 @@ let project = Project(
ErrorHandling.testTarget,
Logging.testTarget,
Observations.testTarget,
+ PurchaseMarketing.testTarget,
Purchasing.testTarget,
Redactions.testTarget,
Unpurchased.testTarget,
@@ -71,7 +73,17 @@ let project = Project(
testAction: .testPlans([
"Highlighter.xctestplan",
]),
- runAction: .runAction()
+ runAction: .runAction(
+ arguments: .arguments(
+ environmentVariables: [
+ "OVERRIDE_PURCHASE": .environmentVariable(value: "", isEnabled: false),
+ "SHOW_DEBUG_OVERLAY": .environmentVariable(value: "", isEnabled: false),
+ ],
+ launchArguments: [
+ .launchArgument(name: "-FeatureFlag.autoRedactInEdit YES", isEnabled: false),
+ ]
+ )
+ )
),
]
)
diff --git a/Tuist/ProjectDescriptionHelpers/Targets/Core.swift b/Tuist/ProjectDescriptionHelpers/Targets/Core.swift
index 6e679f26..174456f8 100644
--- a/Tuist/ProjectDescriptionHelpers/Targets/Core.swift
+++ b/Tuist/ProjectDescriptionHelpers/Targets/Core.swift
@@ -13,6 +13,7 @@ public enum Core {
.target(Defaults.target),
.target(DesignSystem.target),
.target(Editing.target),
+ .target(PurchaseMarketing.target),
.target(Purchasing.target),
.target(Receipts.target),
.target(Unpurchased.target),
diff --git a/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift b/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift
index ea9b0a28..758f045c 100644
--- a/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift
+++ b/Tuist/ProjectDescriptionHelpers/Targets/Editing.swift
@@ -13,6 +13,7 @@ public enum Editing {
.target(AutoRedactionsUI.target),
.target(ErrorHandling.target),
.target(Observations.target),
+ .target(PurchaseMarketing.target),
.target(Redactions.target),
.package(product: "ClippingBezier", type: .runtime),
.package(product: "Introspect", type: .runtime),
diff --git a/Tuist/ProjectDescriptionHelpers/Targets/PurchaseMarketing.swift b/Tuist/ProjectDescriptionHelpers/Targets/PurchaseMarketing.swift
new file mode 100644
index 00000000..633e4de8
--- /dev/null
+++ b/Tuist/ProjectDescriptionHelpers/Targets/PurchaseMarketing.swift
@@ -0,0 +1,10 @@
+import ProjectDescription
+
+public enum PurchaseMarketing {
+ public static let target = Target.capabilitiesTarget(name: "PurchaseMarketing", dependencies: [
+ .target(DesignSystem.target),
+ .target(Purchasing.target),
+ ])
+
+ public static let testTarget = Target.capabilitiesTestTarget(name: "PurchaseMarketing")
+}