From 8ad21ba089e201a29a0b66f7b9c3b61d1c8a8d93 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 6 Sep 2022 11:42:29 +1000 Subject: [PATCH] add tap gesture --- .../New Conversation/NewConversationVC.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Session/Home/New Conversation/NewConversationVC.swift b/Session/Home/New Conversation/NewConversationVC.swift index 73d9f2bea..f45e8dac2 100644 --- a/Session/Home/New Conversation/NewConversationVC.swift +++ b/Session/Home/New Conversation/NewConversationVC.swift @@ -19,6 +19,9 @@ final class NewConversationVC: BaseVC, UITableViewDelegate, UITableViewDataSourc lineBottom.set(.height, to: 0.5) lineBottom.backgroundColor = Colors.border.withAlphaComponent(0.3) + let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap)) + tapGestureRecognizer.numberOfTapsRequired = 1 + let result = UIStackView( arrangedSubviews: [ lineTop, @@ -29,6 +32,7 @@ final class NewConversationVC: BaseVC, UITableViewDelegate, UITableViewDataSourc ] ) result.axis = .vertical + result.addGestureRecognizer(tapGestureRecognizer) return result }() @@ -71,7 +75,7 @@ final class NewConversationVC: BaseVC, UITableViewDelegate, UITableViewDataSourc buttonStackViewContainer.backgroundColor = Colors.cellBackground view.addSubview(buttonStackViewContainer) buttonStackViewContainer.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing ], to: view) - buttonStackViewContainer.pin(.top, to: .top, of: view, withInset: Values.mediumSpacing) + buttonStackViewContainer.pin(.top, to: .top, of: view, withInset: Values.smallSpacing) view.addSubview(contactsTitleLabel) contactsTitleLabel.pin(.leading, to: .leading, of: view, withInset: Values.mediumSpacing) @@ -114,6 +118,19 @@ final class NewConversationVC: BaseVC, UITableViewDelegate, UITableViewDataSourc // MARK: - Interaction + @objc private func handleTap(_ gestureRecognizer: UITapGestureRecognizer) { + let location = gestureRecognizer.location(in: self.view) + if newDMButton.frame.contains(location) { + createNewDM() + } + else if newGroupButton.frame.contains(location) { + createClosedGroup() + } + else if joinCommunityButton.frame.contains(location) { + joinOpenGroup() + } + } + @objc private func close() { dismiss(animated: true, completion: nil) }