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

Fix dismissal of seek and destroy on iPad #162

Merged
merged 1 commit into from
Jun 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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:)")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:)")
}
}