Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import UIKit

@MainActor public protocol DocumentScannerPresenting {
@MainActor @objc public protocol DocumentScannerPresenting {
func presentDocumentCameraViewController()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import SwiftUI

public protocol LimitedLibraryPresenting {
@objc public protocol LimitedLibraryPresenting {
func presentLimitedLibrary()
}

Expand Down
35 changes: 35 additions & 0 deletions Modules/Capabilities/BarBuilder/Sources/BarBuilder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Created by Geoff Pado on 12/6/21.
// Copyright © 2021 Cocoatype, LLC. All rights reserved.

import UIKit

public protocol BarSection {
@MainActor var barButtonItems: [UIBarButtonItem] { get }
}

extension UIBarButtonItem: BarSection {
public var barButtonItems: [UIBarButtonItem] { [self] }
}

extension Array: BarSection where Element == UIBarButtonItem {
public var barButtonItems: [UIBarButtonItem] { self }
}

@MainActor @resultBuilder
public struct BarBuilder {
public static func buildBlock(_ components: BarSection...) -> [UIBarButtonItem] {
components.flatMap(\.barButtonItems)
}

public static func buildOptional(_ component: [BarSection]?) -> [UIBarButtonItem] {
component?.flatMap(\.barButtonItems) ?? []
}

public static func buildEither(first component: [BarSection]) -> [UIBarButtonItem] {
component.flatMap(\.barButtonItems)
}

public static func buildEither(second component: [BarSection]) -> [UIBarButtonItem] {
component.flatMap(\.barButtonItems)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Foundation
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Accessibility label for the document scanner cell
"DocumentScannerBarButtonItem.accessibilityLabel" = "Scan Document";

// Title for the page count alert when scanning documents
"PageCountAlertFactory.alertTitle" = "Too Many Pages";
// Message for the page count alert when scanning documents
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Created by Geoff Pado on 9/1/25.
// Copyright © 2025 Cocoatype, LLC. All rights reserved.

import UIKit

import FactoryKit

import AppNavigation
import DesignSystem
import Logging

public class DocumentScannerBarButtonItem: UIBarButtonItem {
public static var standard: DocumentScannerBarButtonItem {
let standard = DocumentScannerBarButtonItem(
image: Icons.scanDocument,
style: .plain,
target: self,
action: #selector(presentDocumentScanner(_:))
)
standard.accessibilityLabel = DocumentScanningStrings.DocumentScannerBarButtonItem.accessibilityLabel
return standard
}

@objc static func presentDocumentScanner(_ sender: Any) {
let logger = Container.shared.logger()
logger.log(EventFactory().scannerPresentationEvent(for: .library))
UIApplication.shared
.sendAction(
#selector(DocumentScannerPresenting.presentDocumentCameraViewController),
to: nil,
from: sender,
for: nil
)
}

// MARK: Boilerplate

override init() { super.init() }

@available(*, unavailable)
required init(coder: NSCoder) {
fatalError("init(coder:) is not implemented")
}
}
11 changes: 6 additions & 5 deletions Modules/Capabilities/EditingToolbar/Sources/ActionSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import UIKit

import FactoryKit

import BarBuilder
import Defaults
import FeatureFlagging
import Purchasing
import Tools

@MainActor
public struct ActionSet {
@ToolbarBuilder public var leadingNavigationItems: [UIBarButtonItem] {
@BarBuilder public var leadingNavigationItems: [UIBarButtonItem] {
DismissBarButtonItem(asset: asset)

if #unavailable(iOS 16), sizeClass == .regular {
Expand All @@ -23,7 +24,7 @@ public struct ActionSet {
}

@available(iOS 16, *)
@ToolbarBuilder public var centerNavigationItems: [UIBarButtonItem] {
@BarBuilder public var centerNavigationItems: [UIBarButtonItem] {
if sizeClass == .regular {
UndoBarButtonItem(undoManager: undoManager, target: target)
RedoBarButtonItem(undoManager: undoManager, target: target)
Expand All @@ -38,7 +39,7 @@ public struct ActionSet {

// 🧑‍💻👋👋👋🧑‍💻🏠🕖🤣💜😍💜😍🕙😒😒😒🕙👋😍🤣 by @Eskeminha on 2024-05-03
// the standard set of trailing navigation items
@ToolbarBuilder private var 🧑‍💻👋👋👋🧑‍💻🏠🕖🤣💜😍💜😍🕙😒😒😒🕙👋😍🤣: [UIBarButtonItem] {
@BarBuilder private var 🧑‍💻👋👋👋🧑‍💻🏠🕖🤣💜😍💜😍🕙😒😒😒🕙👋😍🤣: [UIBarButtonItem] {
if featureFlagProvider.shouldShowDebugOverlay { DebugPreferencesBarButtonItem(target: target) }

ShareBarButtonItem(target: target)
Expand All @@ -48,7 +49,7 @@ public struct ActionSet {
if shouldShowQuickRedact { QuickRedactBarButtonItem(target: target) }
}

@ToolbarBuilder public var trailingNavigationItems: [UIBarButtonItem] {
@BarBuilder public var trailingNavigationItems: [UIBarButtonItem] {
if #unavailable(iOS 16) {
🧑‍💻👋👋👋🧑‍💻🏠🕖🤣💜😍💜😍🕙😒😒😒🕙👋😍🤣
}
Expand All @@ -71,7 +72,7 @@ public struct ActionSet {
}
}

@ToolbarBuilder public var toolbarItems: [UIBarButtonItem] {
@BarBuilder public var toolbarItems: [UIBarButtonItem] {
if sizeClass != .regular {
UndoBarButtonItem(undoManager: undoManager, target: target)
UIBarButtonItem.flexibleSpace()
Expand Down
35 changes: 0 additions & 35 deletions Modules/Capabilities/EditingToolbar/Sources/ToolbarBuilder.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

protocol LibraryDataSource {
var itemsCount: Int { get }
func item(at index: Int) -> PhotoLibraryItem
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,12 @@ class PhotoLibraryDataSource: NSObject, LibraryDataSource, UICollectionViewDataS
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
switch item(at: indexPath) {
case .asset:
return assetsProvider.cell(for: collectionView, at: indexPath)
case .documentScan:
return extraItemsProvider.documentScannerCell(for: collectionView, at: indexPath)
case .limitedLibrary:
return extraItemsProvider.limitedLibraryCell(for: collectionView, at: indexPath)
}
return assetsProvider.cell(for: collectionView, at: indexPath)
}

// MARK: Photos

var itemsCount: Int { assetsProvider.photosCount + extraItemsProvider.itemsCount }

func item(at index: Int) -> PhotoLibraryItem {
let photosCount = assetsProvider.photosCount
guard index < photosCount else { return extraItemsProvider.item(atIndex: index - photosCount) }
return assetsProvider.item(atIndex: index)
}

func item(at indexPath: IndexPath) -> PhotoLibraryItem {
item(at: indexPath.item)
}
var itemsCount: Int { assetsProvider.photosCount }

var lastItemIndexPath: IndexPath {
IndexPath(row: itemsCount - 1, section: 0)
Expand All @@ -62,6 +45,5 @@ class PhotoLibraryDataSource: NSObject, LibraryDataSource, UICollectionViewDataS
// MARK: Providers

private let assetsProvider: PhotoLibraryDataSourceAssetsProvider
private let extraItemsProvider = PhotoLibraryDataSourceExtraItemsProvider()
private let changeCalculator: PhotoLibraryDataSourceChangeCalculator
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class PhotoLibraryDataSourceAssetsProvider: NSObject {
self.collection = collection
}

func item(atIndex index: Int) -> PhotoLibraryItem {
return .asset(allPhotos[index])
}

@Injected(\.errorHandler) private var errorHandler
func cell(for collectionView: UICollectionView, at indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: AssetPhotoLibraryViewCell.identifier, for: indexPath)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading