Skip to content

Commit

Permalink
Mingle around with firstResponder (#2221)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Jun 28, 2024
1 parent 5706afc commit 5c123d2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1278,10 +1278,7 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
}

@objc private func clipperButtonPressed() {
showClipperOptions()
}

private func showClipperOptions() {

let alert = UIAlertController(title: nil, message: nil, preferredStyle: .safeActionSheet)
let galleryAction = PhotoPickerAlertAction(title: String.localized("gallery"), style: .default, handler: galleryButtonPressed(_:))
let cameraAction = PhotoPickerAlertAction(title: String.localized("camera"), style: .default, handler: cameraButtonPressed(_:))
Expand Down Expand Up @@ -1316,7 +1313,10 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
alert.addAction(sendContactAction)

alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: { _ in self.shouldBecomeFirstResponder = true }))

shouldBecomeFirstResponder = false
messageInputBar.inputTextView.resignFirstResponder()

self.present(alert, animated: true, completion: {
// unfortunately, voiceMessageAction.accessibilityHint does not work,
// but this hack does the trick
Expand Down Expand Up @@ -1670,6 +1670,8 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
}

private func focusInputTextView() {
shouldBecomeFirstResponder = true
becomeFirstResponder()
messageInputBar.inputTextView.becomeFirstResponder()
if UIAccessibility.isVoiceOverRunning {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: { [weak self] in
Expand Down Expand Up @@ -2754,9 +2756,7 @@ extension ChatViewController: AudioControllerDelegate {
extension ChatViewController: UITextViewDelegate {
func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
if keepKeyboard {
DispatchQueue.main.async { [weak self] in
self?.messageInputBar.inputTextView.becomeFirstResponder()
}
self.messageInputBar.inputTextView.becomeFirstResponder()
keepKeyboard = false
return false
}
Expand Down

0 comments on commit 5c123d2

Please sign in to comment.