mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Highlight focused view
This commit is contained in:
parent
22fada2457
commit
6275a2f102
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue