Re-open the attachments keyboard when cancelling an image send
This commit is contained in:
parent
cd3da630a5
commit
9986b21238
@ -474,6 +474,7 @@ extension ConversationViewController: ConversationInputToolbarDelegate {
|
||||
let locationPicker = LocationPicker()
|
||||
locationPicker.delegate = self
|
||||
let navigationController = OWSNavigationController(rootViewController: locationPicker)
|
||||
navigationController.presentationController?.delegate = self
|
||||
dismissKeyBoard()
|
||||
presentFormSheet(navigationController, animated: true)
|
||||
}
|
||||
@ -600,7 +601,9 @@ fileprivate extension ConversationViewController {
|
||||
"CONTACT_PICKER_TITLE",
|
||||
comment: "navbar title for contact picker when sharing a contact"
|
||||
)
|
||||
self.presentFormSheet(OWSNavigationController(rootViewController: contactsPicker), animated: true)
|
||||
let sheet = OWSNavigationController(rootViewController: contactsPicker)
|
||||
sheet.presentationController?.delegate = self
|
||||
self.presentFormSheet(sheet, animated: true)
|
||||
},
|
||||
presentErrorFrom: self
|
||||
)
|
||||
@ -616,6 +619,7 @@ fileprivate extension ConversationViewController {
|
||||
let pickerController = UIDocumentPickerViewController(forOpeningContentTypes: [.item],
|
||||
asCopy: true)
|
||||
pickerController.delegate = self
|
||||
pickerController.presentationController?.delegate = self
|
||||
|
||||
dismissKeyBoard()
|
||||
presentFormSheet(pickerController, animated: true)
|
||||
@ -681,6 +685,7 @@ public extension ConversationViewController {
|
||||
let gifModal = GifPickerNavigationViewController(initialMessageBody: inputToolbar?.messageBodyForSending)
|
||||
gifModal.approvalDelegate = self
|
||||
gifModal.approvalDataSource = self
|
||||
gifModal.presentationController?.delegate = self
|
||||
dismissKeyBoard()
|
||||
present(gifModal, animated: true)
|
||||
}
|
||||
@ -725,11 +730,19 @@ extension ConversationViewController: LocationPickerDelegate {
|
||||
NotificationCenter.default.post(name: ChatListViewController.clearSearch, object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
public func locationPickerDidCancel() {
|
||||
self.dismiss(animated: true)
|
||||
self.openAttachmentKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
extension ConversationViewController: UIDocumentPickerDelegate {
|
||||
public func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
||||
self.openAttachmentKeyboard()
|
||||
}
|
||||
|
||||
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
|
||||
Logger.debug("Picked document at url: \(url)")
|
||||
@ -862,15 +875,9 @@ extension ConversationViewController: UIDocumentPickerDelegate {
|
||||
// MARK: -
|
||||
|
||||
extension ConversationViewController: SendMediaNavDelegate {
|
||||
|
||||
func sendMediaNavDidCancel(_ sendMediaNavigationController: SendMediaNavigationController) {
|
||||
// Restore status bar visibility (if current VC hides it) so that
|
||||
// there's no visible UI updates in the presenter.
|
||||
if sendMediaNavigationController.topViewController?.prefersStatusBarHidden ?? false {
|
||||
sendMediaNavigationController.modalPresentationCapturesStatusBarAppearance = false
|
||||
sendMediaNavigationController.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
self.openAttachmentKeyboard()
|
||||
}
|
||||
|
||||
func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController,
|
||||
|
||||
@ -32,8 +32,9 @@ extension ConversationViewController: AttachmentApprovalViewControllerDelegate {
|
||||
scrollToBottomOfConversation(animated: false)
|
||||
}
|
||||
|
||||
public func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) {
|
||||
public func attachmentApprovalDidCancel() {
|
||||
dismiss(animated: true, completion: nil)
|
||||
self.openAttachmentKeyboard()
|
||||
}
|
||||
|
||||
public func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController,
|
||||
@ -76,12 +77,31 @@ extension ConversationViewController: AttachmentApprovalViewControllerDataSource
|
||||
}
|
||||
}
|
||||
|
||||
extension ConversationViewController: UIAdaptivePresentationControllerDelegate {
|
||||
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|
||||
switch presentationController.presentedViewController {
|
||||
case is GifPickerNavigationViewController, is UIDocumentPickerViewController:
|
||||
self.openAttachmentKeyboard()
|
||||
case let navigationController as OWSNavigationController:
|
||||
switch navigationController.viewControllers.first {
|
||||
case is ContactPickerViewController, is LocationPicker:
|
||||
self.openAttachmentKeyboard()
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
extension ConversationViewController: ContactPickerDelegate {
|
||||
|
||||
public func contactPickerDidCancel(_: ContactPickerViewController) {
|
||||
dismiss(animated: true, completion: nil)
|
||||
self.openAttachmentKeyboard()
|
||||
}
|
||||
|
||||
public func contactPicker(_ contactPicker: ContactPickerViewController, didSelect systemContact: SystemContact) {
|
||||
|
||||
@ -55,14 +55,7 @@ class CameraFirstCaptureSendFlow {
|
||||
}
|
||||
|
||||
extension CameraFirstCaptureSendFlow: SendMediaNavDelegate {
|
||||
|
||||
func sendMediaNavDidCancel(_ sendMediaNavigationController: SendMediaNavigationController) {
|
||||
// Restore status bar visibility (if current VC hides it) so that
|
||||
// there's no visible UI updates in the presenter.
|
||||
if sendMediaNavigationController.topViewController?.prefersStatusBarHidden ?? false {
|
||||
sendMediaNavigationController.modalPresentationCapturesStatusBarAppearance = false
|
||||
sendMediaNavigationController.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
delegate?.cameraFirstCaptureSendFlowDidCancel(self)
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ extension GifPickerNavigationViewController: GifPickerViewControllerDelegate {
|
||||
}
|
||||
|
||||
func gifPickerDidCancel() {
|
||||
dismiss(animated: true)
|
||||
approvalDelegate?.attachmentApprovalDidCancel()
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +54,8 @@ extension GifPickerNavigationViewController: AttachmentApprovalViewControllerDel
|
||||
approvalDelegate?.attachmentApproval(attachmentApproval, didApproveAttachments: attachments, messageBody: messageBody)
|
||||
}
|
||||
|
||||
public func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) {
|
||||
approvalDelegate?.attachmentApprovalDidCancel(attachmentApproval)
|
||||
public func attachmentApprovalDidCancel() {
|
||||
approvalDelegate?.attachmentApprovalDidCancel()
|
||||
}
|
||||
|
||||
public func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController,
|
||||
|
||||
@ -18,6 +18,7 @@ import UniformTypeIdentifiers
|
||||
|
||||
public protocol LocationPickerDelegate: AnyObject {
|
||||
func didPickLocation(_ locationPicker: LocationPicker, location: Location)
|
||||
func locationPickerDidCancel()
|
||||
}
|
||||
|
||||
public class LocationPicker: UIViewController {
|
||||
@ -85,12 +86,12 @@ public class LocationPicker: UIViewController {
|
||||
|
||||
title = OWSLocalizedString("LOCATION_PICKER_TITLE", comment: "The title for the location picker view")
|
||||
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(
|
||||
image: Theme.iconImage(.buttonX),
|
||||
style: .plain,
|
||||
target: self,
|
||||
action: #selector(cancelButtonPressed)
|
||||
)
|
||||
navigationItem.leftBarButtonItem = .button(
|
||||
icon: .buttonX,
|
||||
style: .done
|
||||
) { [weak delegate] in
|
||||
delegate?.locationPickerDidCancel()
|
||||
}
|
||||
|
||||
locationManager.delegate = self
|
||||
mapView.delegate = self
|
||||
@ -133,15 +134,6 @@ public class LocationPicker: UIViewController {
|
||||
navigationController?.navigationBar.isTranslucent = true
|
||||
}
|
||||
|
||||
@objc
|
||||
private func cancelButtonPressed(_ sender: UIButton) {
|
||||
if let navigation = navigationController, navigation.viewControllers.count > 1 {
|
||||
navigation.popViewController(animated: true)
|
||||
} else {
|
||||
presentingViewController?.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
private func didPressCurrentLocation() {
|
||||
showCurrentLocation()
|
||||
|
||||
@ -481,9 +481,7 @@ extension SendMediaNavigationController: PHPickerViewControllerDelegate {
|
||||
if attachmentCount <= 0 {
|
||||
// The user tapped the cancel button or deselected everything
|
||||
self.view.layer.opacity = 0
|
||||
picker.dismiss(animated: true) {
|
||||
self.dismiss(animated: false)
|
||||
}
|
||||
self.sendMediaNavDelegate?.sendMediaNavDidCancel(self)
|
||||
return
|
||||
}
|
||||
|
||||
@ -494,7 +492,7 @@ extension SendMediaNavigationController: PHPickerViewControllerDelegate {
|
||||
extension SendMediaNavigationController: UIAdaptivePresentationControllerDelegate {
|
||||
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|
||||
// The user swiped the photo picker down
|
||||
self.dismiss(animated: false)
|
||||
self.sendMediaNavDelegate?.sendMediaNavDidCancel(self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,7 +567,7 @@ extension SendMediaNavigationController: AttachmentApprovalViewControllerDelegat
|
||||
sendMediaNavDelegate?.sendMediaNav(self, didApproveAttachments: attachments, messageBody: messageBody)
|
||||
}
|
||||
|
||||
func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) {
|
||||
func attachmentApprovalDidCancel() {
|
||||
sendMediaNavDelegate?.sendMediaNavDidCancel(self)
|
||||
}
|
||||
|
||||
|
||||
@ -707,7 +707,7 @@ extension SharingThreadPickerViewController: AttachmentApprovalViewControllerDel
|
||||
send()
|
||||
}
|
||||
|
||||
func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) {
|
||||
func attachmentApprovalDidCancel() {
|
||||
shareViewDelegate?.shareViewWasCancelled()
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ public protocol AttachmentApprovalViewControllerDelegate: AnyObject {
|
||||
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController,
|
||||
didApproveAttachments attachments: [SignalAttachment], messageBody: MessageBody?)
|
||||
|
||||
func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController)
|
||||
func attachmentApprovalDidCancel()
|
||||
|
||||
func attachmentApproval(
|
||||
_ attachmentApproval: AttachmentApprovalViewController,
|
||||
@ -791,7 +791,7 @@ extension AttachmentApprovalViewController {
|
||||
|
||||
@objc
|
||||
private func cancelPressed() {
|
||||
self.approvalDelegate?.attachmentApprovalDidCancel(self)
|
||||
self.approvalDelegate?.attachmentApprovalDidCancel()
|
||||
}
|
||||
|
||||
@objc
|
||||
|
||||
Loading…
Reference in New Issue
Block a user