Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IAP block for auto-redactions #90

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

13 changes: 2 additions & 11 deletions App/Resources/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

"AutoRedactionsEntryTableViewCellField.placeholder" = "Add Word…";

"AutoRedactionsAccessViewController.navigationTitle" = "Auto-Hidden Words";

"BasePhotoEditingViewController.undoKeyCommandDiscoverabilityTitle" = "Undo Redaction";
"BasePhotoEditingViewController.redoKeyCommandDiscoverabilityTitle" = "Redo Redaction";

Expand All @@ -56,12 +58,6 @@

"DismissBarButtonItem.title" = "Done";

"DocumentScannerNotPurchasedAlertController.dismissButton" = "OK";
"DocumentScannerNotPurchasedAlertController.learnMoreButton" = "Learn More…";
"DocumentScannerNotPurchasedAlertController.hideButton" = "Never Show This";
"DocumentScannerNotPurchasedAlertController.message" = "Using the document scanner requires the Ultra Highlighter, a one-time purchase.";
"DocumentScannerNotPurchasedAlertController.title" = "Requires Ultra Highlighter";

"DoneButton.label" = "Done";

"HighlighterToolBarButtonItem.buttonTitle" = "Tools";
Expand Down Expand Up @@ -152,11 +148,6 @@

"SettingsContentGenerator.versionStringFormat" = "Version %@";

"SettingsView.notPurchasedAlertTitle" = "Requires Ultra Highlighter";
"SettingsView.notPurchasedAlertMessage" = "Automatically hiding words requires the Ultra Highlighter, a one-time purchase.";
"SettingsView.notPurchasedDismissButton" = "OK";
"SettingsView.notPurchasedHideButton" = "Never Show This";

"SettingsViewController.navigationTitle" = "Settings";

"ShareItem.label" = "Share";
Expand Down
47 changes: 34 additions & 13 deletions Highlighter.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,78 @@
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04634E972A05CEC000569D5C",
"identifier" : "4CA37C6F81D42C86B5E1F67B",
"name" : "AppRatingsTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04F9A44E2BDA561C00B2A2DB",
"identifier" : "D511BD3660BA1CD7A06AEBC1",
"name" : "AutoRedactionsUITests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04634D6A2A05189C00569D5C",
"identifier" : "FFC529CC7C03FA34AB5A20B3",
"name" : "CoreTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04634ED32A05D16A00569D5C",
"name" : "DefaultsTests"
"identifier" : "7C98246E8C096DC5B09B72A0",
"name" : "EditingTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04F9A4802BDA594100B2A2DB",
"name" : "DesignSystemTests"
"identifier" : "FF81604FD0F405EF2D1CCC8B",
"name" : "ErrorHandlingTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04B19921262410D5001A275B",
"name" : "EditingTests"
"identifier" : "97F888315DF72D8A476D3EF9",
"name" : "LoggingTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04634E7A2A05C2D300569D5C",
"name" : "ErrorHandlingTests"
"identifier" : "2B4661F6B9957A37CFC75AF1",
"name" : "ObservationsTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "04634E4A2A052C4400569D5C",
"name" : "LoggingTests"
"identifier" : "2475A1B3C4289BC5302DD4C4",
"name" : "PurchaseMarketingTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "933937713B5A4BE454914256",
"name" : "PurchasingTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "B5E4762CECC52CCD6E2B0990",
"name" : "RedactionsTests"
}
},
{
"target" : {
"containerPath" : "container:Highlighter.xcodeproj",
"identifier" : "77D525B0D7498E1676A96CC5",
"name" : "UnpurchasedTests"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Created by Geoff Pado on 5/11/24.
// Copyright © 2024 Cocoatype, LLC. All rights reserved.

import Foundation

@objc public protocol AutoRedactionsAccessActions {
func hideAutoRedactAccess(_ sender: Any)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Created by Geoff Pado on 5/11/24.
// Copyright © 2024 Cocoatype, LLC. All rights reserved.

import DesignSystem
import UIKit

public class AutoRedactionsAccessNavigationController: UINavigationController {
public init() {
super.init(navigationBarClass: NavigationBar.self, toolbarClass: UIToolbar.self)
setViewControllers([AutoRedactionsAccessViewController()], animated: false)

if #available(iOS 15.0, *) {
sheetPresentationController?.detents = [.medium()]
}
}

@available(*, unavailable)
required init(coder: NSCoder) {
let typeName = NSStringFromClass(type(of: self))
fatalError("\(typeName) does not implement init(coder:)")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,20 @@

import UIKit

public class AutoRedactionsAccessNavigationController: UINavigationController {
public init() {
super.init(navigationBarClass: UINavigationBar.self, toolbarClass: UIToolbar.self)
setViewControllers([AutoRedactionsAccessViewController()], animated: false)

if #available(iOS 15.0, *) {
sheetPresentationController?.detents = [.medium()]
}
}

@available(*, unavailable)
required init(coder: NSCoder) {
let typeName = NSStringFromClass(type(of: self))
fatalError("\(typeName) does not implement init(coder:)")
}
}

@objc public protocol AutoRedactionsAccessActions {
func hideAutoRedactAccess(_ sender: Any)
}

public class AutoRedactionsAccessViewController: UIViewController {
public init() {
super.init(nibName: nil, bundle: nil)

navigationItem.title = Self.navigationTitle
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .close, target: nil, action: #selector(AutoRedactionsAccessActions.hideAutoRedactAccess(_:)))

embed(AutoRedactionsListViewController())
}

// MARK: Boilerplate

private static let navigationTitle = NSLocalizedString("AutoRedactionsAccessViewController.navigationTitle", comment: "Navigation title for the auto redactions edit view")

@available(*, unavailable)
required init(coder: NSCoder) {
let typeName = NSStringFromClass(type(of: self))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Created by Geoff Pado on 5/11/24.
// Copyright © 2024 Cocoatype, LLC. All rights reserved.

import SwiftUI

public struct AutoRedactionsEditView: UIViewControllerRepresentable {
public init() {}

public func makeUIViewController(context: Context) -> AutoRedactionsEditViewController {
// llllllllll by @AdamWulf on 2024-04-26
// the view controller to wrap for SwiftUI
let llllllllll = AutoRedactionsEditViewController()

// lllllllllI by @AdamWulf on 2024-04-26
// the view controller whose parent has changed
context.coordinator.parentObserver = llllllllll.observe(\.parent, changeHandler: { lllllllllI, _ in
lllllllllI.parent?.navigationItem.title = lllllllllI.navigationItem.title
lllllllllI.parent?.navigationItem.rightBarButtonItems = lllllllllI.navigationItem.rightBarButtonItems
})
return llllllllll
}

public func updateUIViewController(_ uiViewController: AutoRedactionsEditViewController, context: Context) {}
public func makeCoordinator() -> Coordinator { Coordinator() }

public class Coordinator {
var parentObserver: NSKeyValueObservation?
}
}

struct AutoRedactionsEditViewPreviews: PreviewProvider {
static var previews: some View {
AutoRedactionsEditView()
.background(Color.appPrimary.edgesIgnoringSafeArea(.all))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import Defaults
import DesignSystem
import SwiftUI
import UIKit

public class AutoRedactionsEditViewController: UIViewController {
Expand Down Expand Up @@ -53,35 +52,3 @@ public class AutoRedactionsEditViewController: UIViewController {
fatalError("\(className) does not implement init(coder:)")
}
}

public struct AutoRedactionsEditView: UIViewControllerRepresentable {
public init() {}

public func makeUIViewController(context: Context) -> AutoRedactionsEditViewController {
// llllllllll by @AdamWulf on 2024-04-26
// the view controller to wrap for SwiftUI
let llllllllll = AutoRedactionsEditViewController()

// lllllllllI by @AdamWulf on 2024-04-26
// the view controller whose parent has changed
context.coordinator.parentObserver = llllllllll.observe(\.parent, changeHandler: { lllllllllI, _ in
lllllllllI.parent?.navigationItem.title = lllllllllI.navigationItem.title
lllllllllI.parent?.navigationItem.rightBarButtonItems = lllllllllI.navigationItem.rightBarButtonItems
})
return llllllllll
}

public func updateUIViewController(_ uiViewController: AutoRedactionsEditViewController, context: Context) {}
public func makeCoordinator() -> Coordinator { Coordinator() }

public class Coordinator {
var parentObserver: NSKeyValueObservation?
}
}

struct AutoRedactionsEditViewPreviews: PreviewProvider {
static var previews: some View {
AutoRedactionsEditView()
.background(Color.appPrimary.edgesIgnoringSafeArea(.all))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Created by Geoff Pado on 5/15/19.
// Copyright © 2019 Cocoatype, LLC. All rights reserved.

import UIKit

public class NavigationBar: UINavigationBar {
public override init(frame: CGRect) {
super.init(frame: frame)
tintColor = .white

standardAppearance = NavigationBarAppearance()
compactAppearance = NavigationBarAppearance()
scrollEdgeAppearance = NavigationBarAppearance()

if #available(iOS 15.0, *) {
compactScrollEdgeAppearance = NavigationBarAppearance()
}
isTranslucent = false
}

// MARK: Bar Button Appearance

static let largeTitleTextAttributes = [
NSAttributedString.Key.font: UIFont.navigationBarLargeTitleFont
]

public static let buttonTitleTextAttributes = [
NSAttributedString.Key.font: UIFont.navigationBarButtonFont,
.foregroundColor: UIColor.white,
]

public static let titleTextAttributes = [
NSAttributedString.Key.font: UIFont.navigationBarTitleFont,
.foregroundColor: UIColor.white,
]

// MARK: Boilerplate

@available(*, unavailable)
required init(coder: NSCoder) {
let className = String(describing: type(of: self))
fatalError("\(className) does not implement init(coder:)")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Created by Geoff Pado on 5/11/24.
// Copyright © 2024 Cocoatype, LLC. All rights reserved.

import UIKit

public class NavigationBarAppearance: UINavigationBarAppearance {
public override init(idiom: UIUserInterfaceIdiom = UIDevice.current.userInterfaceIdiom) {
super.init(idiom: idiom)
configureWithOpaqueBackground()
backgroundColor = .primaryDark
largeTitleTextAttributes = NavigationBar.largeTitleTextAttributes
titleTextAttributes = NavigationBar.titleTextAttributes
backButtonAppearance.normal.titleTextAttributes = NavigationBar.buttonTitleTextAttributes
backButtonAppearance.highlighted.titleTextAttributes = NavigationBar.buttonTitleTextAttributes
doneButtonAppearance.normal.titleTextAttributes = NavigationBar.buttonTitleTextAttributes
doneButtonAppearance.highlighted.titleTextAttributes = NavigationBar.buttonTitleTextAttributes
buttonAppearance.normal.titleTextAttributes = NavigationBar.buttonTitleTextAttributes
buttonAppearance.highlighted.titleTextAttributes = NavigationBar.buttonTitleTextAttributes
}

public override init(barAppearance: UIBarAppearance) {
super.init(barAppearance: barAppearance)
}

@available(*, unavailable)
required init(coder: NSCoder) {
let typeName = NSStringFromClass(type(of: self))
fatalError("\(typeName) does not implement init(coder:)")
}
}
Loading