|
@@ -24,7 +24,7 @@ import UIKit
|
|
|
import FSCalendar
|
|
|
import NCCommunication
|
|
|
|
|
|
-class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkingDelegate, FSCalendarDelegate, FSCalendarDelegateAppearance {
|
|
|
+class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, UITextFieldDelegate, NCShareNetworkingDelegate, FSCalendarDelegate, FSCalendarDelegateAppearance {
|
|
|
|
|
|
@IBOutlet weak var fieldLabel: UITextField!
|
|
|
|
|
@@ -76,6 +76,8 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
|
|
|
var viewWindow: UIView?
|
|
|
var viewWindowCalendar: UIView?
|
|
|
private var calendar: FSCalendar?
|
|
|
+ private var selfFrameOriginYDiff: CGFloat = 0
|
|
|
+ private var activeTextField = UITextField()
|
|
|
|
|
|
override func awakeFromNib() {
|
|
|
|
|
@@ -126,9 +128,16 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
|
|
|
|
|
|
fieldSetExpirationDate.inputView = UIView()
|
|
|
|
|
|
+ fieldLabel.delegate = self
|
|
|
+ fieldPasswordProtect.delegate = self
|
|
|
+ fieldNoteToRecipient.delegate = self
|
|
|
+
|
|
|
imageNoteToRecipient.image = UIImage.init(named: "file_txt")!.image(color: UIColor(red: 76/255, green: 76/255, blue: 76/255, alpha: 1), size: 50)
|
|
|
imageDeleteShareLink.image = NCUtility.shared.loadImage(named: "trash", color: UIColor(red: 76/255, green: 76/255, blue: 76/255, alpha: 1), size: 50)
|
|
|
imageAddAnotherLink.image = NCUtility.shared.loadImage(named: "plus", color: UIColor(red: 76/255, green: 76/255, blue: 76/255, alpha: 1), size: 50)
|
|
|
+
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
|
|
}
|
|
|
|
|
|
override func willMove(toWindow newWindow: UIWindow?) {
|
|
@@ -223,7 +232,36 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
|
|
|
fieldNoteToRecipient.text = tableShare.note
|
|
|
}
|
|
|
|
|
|
+ func textFieldDidBeginEditing(_ textField: UITextField) {
|
|
|
+
|
|
|
+ self.activeTextField = textField
|
|
|
+ }
|
|
|
+
|
|
|
+ // MARK: - Keyboard notification
|
|
|
+
|
|
|
+ @objc internal func keyboardWillShow(_ notification : Notification?) {
|
|
|
+
|
|
|
+ selfFrameOriginYDiff = 0
|
|
|
+
|
|
|
+ if let info = notification?.userInfo, let centerObject = self.activeTextField.superview?.convert(self.activeTextField.center, to: nil) {
|
|
|
+
|
|
|
+ let frameEndUserInfoKey = UIResponder.keyboardFrameEndUserInfoKey
|
|
|
+ if let keyboardFrame = info[frameEndUserInfoKey] as? CGRect {
|
|
|
+ let diff = keyboardFrame.origin.y - centerObject.y - (self.activeTextField.frame.height / 2)
|
|
|
+ if diff < 0 {
|
|
|
+ selfFrameOriginYDiff = diff
|
|
|
+ self.frame.origin.y += selfFrameOriginYDiff
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func keyboardWillHide(_ notification: Notification) {
|
|
|
+ self.frame.origin.y -= selfFrameOriginYDiff
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: - Tap viewWindowCalendar
|
|
|
+
|
|
|
@objc func tapViewWindowCalendar(gesture: UITapGestureRecognizer) {
|
|
|
calendar?.removeFromSuperview()
|
|
|
viewWindowCalendar?.removeFromSuperview()
|