Highlight focused view

This commit is contained in:
Michael Kirk 2018-07-10 16:43:20 -06:00 committed by Michael Kirk
parent 22fada2457
commit 6275a2f102
2 changed files with 34 additions and 2 deletions

View file

@ -1982,7 +1982,8 @@ typedef enum : NSUInteger {
- (void)conversationCellDidLongpressText:(ConversationViewCell *)cell viewItem:(ConversationViewItem *)viewItem
{
MessageActionsViewController *messageActionsViewController = [MessageActionsViewController new];
MessageActionsViewController *messageActionsViewController =
[[MessageActionsViewController alloc] initWithFocusedView:cell];
[[OWSWindowManager sharedManager] presentMessageActions:messageActionsViewController];
}

View file

@ -10,14 +10,45 @@ class MessageActionsViewController: UIViewController {
@objc
weak var delegate: MessageActionsDelegate?
let focusedView: UIView
@objc
required init(focusedView: UIView) {
self.focusedView = focusedView
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
self.view = UIView()
view.backgroundColor = .purple
view.backgroundColor = UIColor.black.withAlphaComponent(0.4)
highlightFocusedView()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapBackground))
self.view.addGestureRecognizer(tapGesture)
}
private func highlightFocusedView() {
guard let snapshotView = self.focusedView.snapshotView(afterScreenUpdates: false) else {
owsFail("\(self.logTag) in \(#function) snapshotView was unexpectedly nil")
return
}
view.addSubview(snapshotView)
guard let focusedViewSuperview = focusedView.superview else {
owsFail("\(self.logTag) in \(#function) focusedViewSuperview was unexpectedly nil")
return
}
let convertedFrame = view.convert(focusedView.frame, from: focusedViewSuperview)
snapshotView.frame = convertedFrame
}
@objc
func didTapBackground() {
self.delegate?.dismissMessageActions(self)