Fix interaction bug

pull/370/head
Niels Andriesse 4 years ago
parent a7dd7e1bf0
commit 676efe03fa

@ -121,10 +121,10 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView
} }
func controller(_ controller: OWSQRCodeScanningViewController, didDetectQRCodeWith string: String) { 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 // 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! weak var joinOpenGroupVC: JoinOpenGroupVC!
// MARK: Components // MARK: Components
@ -211,7 +211,7 @@ private final class EnterURLVC : UIViewController, OpenGroupSuggestionGridDelega
// Next button // Next button
let nextButton = Button(style: .prominentOutline, size: .large) let nextButton = Button(style: .prominentOutline, size: .large)
nextButton.setTitle(NSLocalizedString("next", comment: ""), for: UIControl.State.normal) 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() let nextButtonContainer = UIView()
nextButtonContainer.addSubview(nextButton) nextButtonContainer.addSubview(nextButton)
nextButton.pin(.leading, to: .leading, of: nextButtonContainer, withInset: 80) 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) view.set(.width, to: UIScreen.main.bounds.width)
// Dismiss keyboard on tap // Dismiss keyboard on tap
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
tapGestureRecognizer.delegate = self
view.addGestureRecognizer(tapGestureRecognizer) view.addGestureRecognizer(tapGestureRecognizer)
} }
@ -244,13 +245,18 @@ private final class EnterURLVC : UIViewController, OpenGroupSuggestionGridDelega
} }
// MARK: Interaction // MARK: Interaction
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
let location = gestureRecognizer.location(in: view)
return !suggestionGrid.frame.contains(location)
}
func join(_ room: OpenGroupAPIV2.Info) { func join(_ room: OpenGroupAPIV2.Info) {
joinOpenGroupVC.join(room.id, on: OpenGroupAPIV2.defaultServer, with: OpenGroupAPIV2.defaultServerPublicKey) 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) ?? "" let url = urlTextField.text?.trimmingCharacters(in: .whitespaces) ?? ""
joinOpenGroupVC.joinOpenGroupIfPossible(with: url) joinOpenGroupVC.joinOpenGroup(with: url)
} }
} }

@ -27,8 +27,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl
private lazy var spinner: NVActivityIndicatorView = { private lazy var spinner: NVActivityIndicatorView = {
let result = NVActivityIndicatorView(frame: CGRect.zero, type: .circleStrokeSpin, color: Colors.text, padding: nil) let result = NVActivityIndicatorView(frame: CGRect.zero, type: .circleStrokeSpin, color: Colors.text, padding: nil)
result.set(.width, to: 64) result.set(.width, to: 40)
result.set(.height, to: 64) result.set(.height, to: 40)
return result return result
}() }()
@ -57,8 +57,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl
addSubview(spinner) addSubview(spinner)
spinner.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top ], to: self) spinner.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top ], to: self)
spinner.startAnimating() spinner.startAnimating()
heightConstraint = set(.height, to: 64) heightConstraint = set(.height, to: 40)
widthAnchor.constraint(greaterThanOrEqualToConstant: 64).isActive = true widthAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true
let _ = OpenGroupAPIV2.getDefaultRoomsPromise?.done { [weak self] rooms in let _ = OpenGroupAPIV2.getDefaultRoomsPromise?.done { [weak self] rooms in
self?.rooms = rooms self?.rooms = rooms
} }

Loading…
Cancel
Save