|
|
|
@ -168,6 +168,9 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView
|
|
|
|
|
|
|
|
|
|
private final class EnterURLVC : UIViewController, UIGestureRecognizerDelegate, OpenGroupSuggestionGridDelegate {
|
|
|
|
|
weak var joinOpenGroupVC: JoinOpenGroupVC!
|
|
|
|
|
private var isKeyboardShowing = false
|
|
|
|
|
private var bottomConstraint: NSLayoutConstraint!
|
|
|
|
|
private let bottomMargin: CGFloat = UIDevice.current.isIPad ? Values.largeSpacing : 0
|
|
|
|
|
|
|
|
|
|
// MARK: Components
|
|
|
|
|
private lazy var urlTextView: TextView = {
|
|
|
|
@ -209,13 +212,24 @@ private final class EnterURLVC : UIViewController, UIGestureRecognizerDelegate,
|
|
|
|
|
stackView.layoutMargins = UIEdgeInsets(uniform: Values.largeSpacing)
|
|
|
|
|
stackView.isLayoutMarginsRelativeArrangement = true
|
|
|
|
|
view.addSubview(stackView)
|
|
|
|
|
stackView.pin(to: view)
|
|
|
|
|
stackView.pin(.leading, to: .leading, of: view)
|
|
|
|
|
stackView.pin(.top, to: .top, of: view)
|
|
|
|
|
view.pin(.trailing, to: .trailing, of: stackView)
|
|
|
|
|
bottomConstraint = view.pin(.bottom, to: .bottom, of: stackView, withInset: bottomMargin)
|
|
|
|
|
// Constraints
|
|
|
|
|
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)
|
|
|
|
|
// Listen to keyboard notifications
|
|
|
|
|
let notificationCenter = NotificationCenter.default
|
|
|
|
|
notificationCenter.addObserver(self, selector: #selector(handleKeyboardWillChangeFrameNotification(_:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
|
|
|
|
|
notificationCenter.addObserver(self, selector: #selector(handleKeyboardWillHideNotification(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deinit {
|
|
|
|
|
NotificationCenter.default.removeObserver(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: General
|
|
|
|
@ -241,6 +255,26 @@ private final class EnterURLVC : UIViewController, UIGestureRecognizerDelegate,
|
|
|
|
|
let url = urlTextView.text?.trimmingCharacters(in: .whitespaces) ?? ""
|
|
|
|
|
joinOpenGroupVC.joinOpenGroup(with: url)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Updating
|
|
|
|
|
@objc private func handleKeyboardWillChangeFrameNotification(_ notification: Notification) {
|
|
|
|
|
guard !isKeyboardShowing else { return }
|
|
|
|
|
isKeyboardShowing = true
|
|
|
|
|
guard let newHeight = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.size.height else { return }
|
|
|
|
|
bottomConstraint.constant = newHeight + bottomMargin
|
|
|
|
|
UIView.animate(withDuration: 0.25) {
|
|
|
|
|
self.view.layoutIfNeeded()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc private func handleKeyboardWillHideNotification(_ notification: Notification) {
|
|
|
|
|
guard isKeyboardShowing else { return }
|
|
|
|
|
isKeyboardShowing = false
|
|
|
|
|
bottomConstraint.constant = bottomMargin
|
|
|
|
|
UIView.animate(withDuration: 0.25) {
|
|
|
|
|
self.view.layoutIfNeeded()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final class ScanQRCodePlaceholderVC : UIViewController {
|
|
|
|
|