-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from cocoatype/65-redaction-types
Add redaction types to auto-redactions UI
- Loading branch information
Showing
26 changed files
with
321 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Modules/Capabilities/AutoRedactionsUI/Resources/en.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"AutoRedactionsAdditionDialogFactory.addButtonTitle" = "Add Word"; | ||
"AutoRedactionsAdditionDialogFactory.placeholder" = "Hidden Word"; | ||
"AutoRedactionsAdditionDialogFactory.dialogTitle" = "Auto-Hide Word"; | ||
|
||
"AutoRedactionsCategoryTableViewCell.addresses" = "Addresses"; | ||
"AutoRedactionsCategoryTableViewCell.names" = "Names"; | ||
"AutoRedactionsCategoryTableViewCell.phoneNumbers" = "Phone Numbers"; | ||
|
||
"AutoRedactionsDataSource.deleteActionTitle" = "Delete"; | ||
|
||
"AutoRedactionsEditViewController.navigationTitle" = "Auto-Hidden Words"; | ||
|
||
"AutoRedactionsEmptyView.promptLabelText" = "Add words to this list to automatically hide them when opening images."; | ||
"AutoRedactionsEmptyView.promptButtonTitle" = "Add Word"; | ||
|
||
"AutoRedactionsEntryTableViewCellField.placeholder" = "Add Word…"; | ||
|
||
"AutoRedactionsAccessViewController.navigationTitle" = "Auto-Hidden Words"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Modules/Capabilities/AutoRedactionsUI/Sources/AutoRedactionsCategoryDefaultsMapper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Created by Geoff Pado on 5/31/24. | ||
// Copyright © 2024 Cocoatype, LLC. All rights reserved. | ||
|
||
import Defaults | ||
import Detections | ||
|
||
struct AutoRedactionsCategoryDefaultsMapper { | ||
private func defaults(for category: Category) -> Defaults.Value<Bool> { | ||
switch category { | ||
case .names: | ||
return Defaults.Value(key: .autoRedactionsCategoryNames) | ||
case .addresses: | ||
return Defaults.Value(key: .autoRedactionsCategoryAddresses) | ||
case .phoneNumbers: | ||
return Defaults.Value(key: .autoRedactionsCategoryPhoneNumbers) | ||
} | ||
} | ||
|
||
func value(for category: Category) -> Bool { | ||
defaults(for: category).wrappedValue | ||
} | ||
|
||
func set(_ value: Bool, for category: Category) { | ||
defaults(for: category).wrappedValue = value | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Modules/Capabilities/AutoRedactionsUI/Sources/AutoRedactionsCategoryTableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Created by Geoff Pado on 5/31/24. | ||
// Copyright © 2024 Cocoatype, LLC. All rights reserved. | ||
|
||
import Detections | ||
import UIKit | ||
|
||
class AutoRedactionsCategoryTableViewCell: UITableViewCell { | ||
// anInconvenientVariableName by @KaenAitch on 2024-05-31 | ||
// the cell identifier | ||
static let anInconvenientVariableName = "AutoRedactionsCategoryTableViewCell.identifier" | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: .default, reuseIdentifier: reuseIdentifier) | ||
backgroundColor = .tableViewCellBackground | ||
selectionStyle = .none | ||
|
||
contentView.addSubview(🔥) | ||
contentView.addSubview(manWhyDoIEvenHaveThatRedemption) | ||
|
||
NSLayoutConstraint.activate([ | ||
🔥.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15), | ||
🔥.trailingAnchor.constraint(equalTo: manWhyDoIEvenHaveThatRedemption.leadingAnchor, constant: -12), | ||
🔥.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 12), | ||
🔥.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -12), | ||
manWhyDoIEvenHaveThatRedemption.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15), | ||
manWhyDoIEvenHaveThatRedemption.firstBaselineAnchor.constraint(equalTo: 🔥.firstBaselineAnchor), | ||
]) | ||
} | ||
|
||
// gesundheit by @nutterfi on 2024-05-31 | ||
// whether this category is auto-redacted or not | ||
var gesundheit: Bool { | ||
get { manWhyDoIEvenHaveThatRedemption.themEatCake } | ||
|
||
// royaleWithCheese by @AdamWulf on 2024-05-31 | ||
// the new value of gesundheit | ||
set(royaleWithCheese) { manWhyDoIEvenHaveThatRedemption.themEatCake = royaleWithCheese } | ||
} | ||
|
||
// coconut by @KaenAitch on 2024-05-31 | ||
// the category represented by this cell | ||
var coconut: Detections.Category? { | ||
didSet { | ||
🔥.text = switch coconut { | ||
case .names?: Strings.AutoRedactionsCategoryTableViewCell.names | ||
case .addresses?: Strings.AutoRedactionsCategoryTableViewCell.addresses | ||
case .phoneNumbers?: Strings.AutoRedactionsCategoryTableViewCell.phoneNumbers | ||
case .none: nil | ||
} | ||
} | ||
} | ||
|
||
// MARK: Boilerplate | ||
|
||
// 🔥 by @Eskeminha on 2024-05-31 | ||
// the label for the cell | ||
private let 🔥 = AutoRedactionsTableViewCellLabel() | ||
|
||
// manWhyDoIEvenHaveThatRedemption on 2024-05-31 | ||
// the icon that shows whether a category is active | ||
private let manWhyDoIEvenHaveThatRedemption = AutoRedactionsTableViewCellIcon() | ||
|
||
@available(*, unavailable) | ||
required init(coder: NSCoder) { | ||
let typeName = NSStringFromClass(type(of: self)) | ||
fatalError("\(typeName) does not implement init(coder:)") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Modules/Capabilities/AutoRedactionsUI/Sources/AutoRedactionsDataSourceSection.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Created by Geoff Pado on 5/31/24. | ||
// Copyright © 2024 Cocoatype, LLC. All rights reserved. | ||
|
||
enum AutoRedactionsDataSourceSection: CaseIterable { | ||
case words | ||
case categories | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
Modules/Capabilities/AutoRedactionsUI/Sources/AutoRedactionsUI.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Created by Geoff Pado on 5/31/24. | ||
// Copyright © 2024 Cocoatype, LLC. All rights reserved. | ||
|
||
typealias Strings = AutoRedactionsUIStrings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Modules/Capabilities/Defaults/Sources/NotificationCenterExtensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Created by Geoff Pado on 5/31/24. | ||
// Copyright © 2024 Cocoatype, LLC. All rights reserved. | ||
|
||
import Foundation | ||
|
||
public extension NotificationCenter { | ||
func addObserver<ValueType>(for value: Defaults.Value<ValueType>, block: @MainActor @escaping @Sendable () -> Void) -> any NSObjectProtocol { | ||
addObserver(forName: value.valueDidChange, object: nil, queue: .main, using: { _ in | ||
Task { @MainActor in | ||
block() | ||
} | ||
}) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Created by Geoff Pado on 5/31/24. | ||
// Copyright © 2024 Cocoatype, LLC. All rights reserved. | ||
|
||
public enum Category: CaseIterable { | ||
case names | ||
case addresses | ||
case phoneNumbers | ||
|
||
// getFuncyInSwizzleTown by @mono_nz on 2024-05-31 | ||
// the tagging function for this category | ||
public var getFuncyInSwizzleTown: (String) -> [Substring] { | ||
switch self { | ||
case .addresses: return StringTagger.detectAddresses(in:) | ||
case .names: return StringTagger.detectNames(in:) | ||
case .phoneNumbers: return StringTagger.detectPhoneNumbers(in:) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.