Respond to CR.

pull/2/head
Matthew Chen 5 years ago
parent 517a550593
commit a3efb58d15

@ -120,6 +120,12 @@ class AttachmentApprovalInputAccessoryView: UIView {
currentCaptionWrapper.isHidden = isEditingCaptions || !hasCurrentCaption
attachmentTextToolbar.isHidden = isEditingCaptions
updateFirstResponder()
layoutSubviews()
}
private func updateFirstResponder() {
if (shouldHideControls) {
if attachmentCaptionToolbar.textView.isFirstResponder {
attachmentCaptionToolbar.textView.resignFirstResponder()
@ -138,8 +144,6 @@ class AttachmentApprovalInputAccessoryView: UIView {
}
// NOTE: We don't automatically make attachmentTextToolbar.textView
// first responder;
layoutSubviews()
}
public func update(isEditingCaptions: Bool,
@ -149,7 +153,9 @@ class AttachmentApprovalInputAccessoryView: UIView {
guard self.isEditingCaptions != isEditingCaptions ||
self.currentAttachmentItem != currentAttachmentItem ||
self.shouldHideControls != shouldHideControls else {
return
updateFirstResponder()
return
}
self.isEditingCaptions = isEditingCaptions
@ -168,6 +174,12 @@ class AttachmentApprovalInputAccessoryView: UIView {
return CGSize.zero
}
}
public var hasFirstResponder: Bool {
return (isFirstResponder ||
attachmentCaptionToolbar.textView.isFirstResponder ||
attachmentTextToolbar.textView.isFirstResponder)
}
}
// MARK: -

@ -206,6 +206,12 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
}
let currentAttachmentItem: SignalAttachmentItem? = currentPageViewController?.attachmentItem
let hasPresentedView = self.presentedViewController != nil
let isToolbarFirstResponder = bottomToolView.hasFirstResponder
if !shouldHideControls, !isFirstResponder, !hasPresentedView, !isToolbarFirstResponder {
becomeFirstResponder()
}
bottomToolView.update(isEditingCaptions: isEditingCaptions,
currentAttachmentItem: currentAttachmentItem,
shouldHideControls: shouldHideControls)

Loading…
Cancel
Save