From 676efe03fa9f7bed913e7a42c32bc078f417e987 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 26 Mar 2021 13:35:12 +1100 Subject: [PATCH] Fix interaction bug --- Session/Open Groups/JoinOpenGroupVC.swift | 18 ++++++++++++------ .../Open Groups/OpenGroupSuggestionGrid.swift | 8 ++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Session/Open Groups/JoinOpenGroupVC.swift b/Session/Open Groups/JoinOpenGroupVC.swift index e814b6372..f2e29f2be 100644 --- a/Session/Open Groups/JoinOpenGroupVC.swift +++ b/Session/Open Groups/JoinOpenGroupVC.swift @@ -121,10 +121,10 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView } func controller(_ controller: OWSQRCodeScanningViewController, didDetectQRCodeWith string: String) { - joinOpenGroupIfPossible(with: string) + joinOpenGroup(with: string) } - fileprivate func joinOpenGroupIfPossible(with urlAsString: String) { + fileprivate func joinOpenGroup(with url: String) { // TODO: V1 open groups @@ -179,7 +179,7 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView } } -private final class EnterURLVC : UIViewController, OpenGroupSuggestionGridDelegate { +private final class EnterURLVC : UIViewController, UIGestureRecognizerDelegate, OpenGroupSuggestionGridDelegate { weak var joinOpenGroupVC: JoinOpenGroupVC! // MARK: Components @@ -211,7 +211,7 @@ private final class EnterURLVC : UIViewController, OpenGroupSuggestionGridDelega // Next button let nextButton = Button(style: .prominentOutline, size: .large) nextButton.setTitle(NSLocalizedString("next", comment: ""), for: UIControl.State.normal) - nextButton.addTarget(self, action: #selector(joinOpenGroupIfPossible), for: UIControl.Event.touchUpInside) + nextButton.addTarget(self, action: #selector(joinOpenGroup), for: UIControl.Event.touchUpInside) let nextButtonContainer = UIView() nextButtonContainer.addSubview(nextButton) nextButton.pin(.leading, to: .leading, of: nextButtonContainer, withInset: 80) @@ -231,6 +231,7 @@ private final class EnterURLVC : UIViewController, OpenGroupSuggestionGridDelega view.set(.width, to: UIScreen.main.bounds.width) // Dismiss keyboard on tap let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) + tapGestureRecognizer.delegate = self view.addGestureRecognizer(tapGestureRecognizer) } @@ -244,13 +245,18 @@ private final class EnterURLVC : UIViewController, OpenGroupSuggestionGridDelega } // MARK: Interaction + func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + let location = gestureRecognizer.location(in: view) + return !suggestionGrid.frame.contains(location) + } + func join(_ room: OpenGroupAPIV2.Info) { joinOpenGroupVC.join(room.id, on: OpenGroupAPIV2.defaultServer, with: OpenGroupAPIV2.defaultServerPublicKey) } - @objc private func joinOpenGroupIfPossible() { + @objc private func joinOpenGroup() { let url = urlTextField.text?.trimmingCharacters(in: .whitespaces) ?? "" - joinOpenGroupVC.joinOpenGroupIfPossible(with: url) + joinOpenGroupVC.joinOpenGroup(with: url) } } diff --git a/Session/Open Groups/OpenGroupSuggestionGrid.swift b/Session/Open Groups/OpenGroupSuggestionGrid.swift index 787aba2b4..7e6581b8b 100644 --- a/Session/Open Groups/OpenGroupSuggestionGrid.swift +++ b/Session/Open Groups/OpenGroupSuggestionGrid.swift @@ -27,8 +27,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl private lazy var spinner: NVActivityIndicatorView = { let result = NVActivityIndicatorView(frame: CGRect.zero, type: .circleStrokeSpin, color: Colors.text, padding: nil) - result.set(.width, to: 64) - result.set(.height, to: 64) + result.set(.width, to: 40) + result.set(.height, to: 40) return result }() @@ -57,8 +57,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl addSubview(spinner) spinner.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top ], to: self) spinner.startAnimating() - heightConstraint = set(.height, to: 64) - widthAnchor.constraint(greaterThanOrEqualToConstant: 64).isActive = true + heightConstraint = set(.height, to: 40) + widthAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true let _ = OpenGroupAPIV2.getDefaultRoomsPromise?.done { [weak self] rooms in self?.rooms = rooms }