diff --git a/Modules/Legacy/Core/Sources/Photo Editing/PhotoEditingNavigationController.swift b/Modules/Legacy/Core/Sources/Photo Editing/PhotoEditingNavigationController.swift index f6b2ccf9..7309ccb2 100644 --- a/Modules/Legacy/Core/Sources/Photo Editing/PhotoEditingNavigationController.swift +++ b/Modules/Legacy/Core/Sources/Photo Editing/PhotoEditingNavigationController.swift @@ -29,6 +29,10 @@ class PhotoEditingNavigationController: NavigationController, PhotoEditingProtec (viewControllers.first as? PhotoEditingViewController)?.finishSeeking(sender) } + @objc public func seekBarDidChangeText(_ sender: UISearchTextField) { + (viewControllers.first as? PhotoEditingViewController)?.seekBarDidChangeText(sender) + } + // MARK: Dismissal @objc func dismissPhotoEditingViewController(_ sender: UIBarButtonItem) { diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift index c1f153bf..be670f84 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift @@ -96,6 +96,12 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate, open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) + + guard let previousTraitCollection, + previousTraitCollection.horizontalSizeClass != traitCollection.horizontalSizeClass || + previousTraitCollection.verticalSizeClass != traitCollection.verticalSizeClass + else { return } + updateToolbarItems(animated: false) updateSeekPresentation() } @@ -209,7 +215,7 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate, let seekViewController = TabletSeekViewController() seekViewController.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem seekViewController.popoverPresentationController?.delegate = self - present(seekViewController, animated: true, completion: nil) + present(seekViewController, animated: true) } else { seekBar.becomeFirstResponder() } @@ -258,7 +264,7 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate, open override var canResignFirstResponder: Bool { true } public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { - self.cancelSeeking(presentationController) + cancelSeeking(presentationController) } public func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle { diff --git a/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekSearchBar.swift b/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekSearchBar.swift new file mode 100644 index 00000000..4a25c8d3 --- /dev/null +++ b/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekSearchBar.swift @@ -0,0 +1,28 @@ +// Created by Geoff Pado on 6/24/24. +// Copyright © 2024 Cocoatype, LLC. All rights reserved. + +import UIKit + +class TabletSeekSearchBar: UISearchBar, UISearchTextFieldDelegate { + init() { + super.init(frame: .zero) + searchTextField.delegate = self + returnKeyType = .done + translatesAutoresizingMaskIntoConstraints = false + + searchTextField.addTarget(nil, action: #selector(PhotoEditingViewController.seekBarDidChangeText(_:)), for: .editingChanged) + } + + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + chain(selector: #selector(PhotoEditingViewController.finishSeeking(_:))) + return false + } + + // MARK: Boilerplate + + @available(*, unavailable) + required init(coder: NSCoder) { + let typeName = NSStringFromClass(type(of: self)) + fatalError("\(typeName) does not implement init(coder:)") + } +} diff --git a/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekView.swift b/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekView.swift index 459ae644..7e9cf7be 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/Seek and Destroy/Tablet/TabletSeekView.swift @@ -33,27 +33,3 @@ class TabletSeekView: UIView { fatalError("\(typeName) does not implement init(coder:)") } } - -class TabletSeekSearchBar: UISearchBar, UISearchTextFieldDelegate { - init() { - super.init(frame: .zero) - searchTextField.delegate = self - returnKeyType = .done - translatesAutoresizingMaskIntoConstraints = false - - searchTextField.addTarget(nil, action: #selector(PhotoEditingViewController.seekBarDidChangeText(_:)), for: .editingChanged) - } - - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - chain(selector: #selector(PhotoEditingViewController.finishSeeking(_:))) - return false - } - - // MARK: Boilerplate - - @available(*, unavailable) - required init(coder: NSCoder) { - let typeName = NSStringFromClass(type(of: self)) - fatalError("\(typeName) does not implement init(coder:)") - } -}