diff --git a/enzevalos_iphone/Providers.swift b/enzevalos_iphone/Providers.swift index 74394c407ff45920b4c60872ff95f3c319ddf08d..f833a4ecf68fb65591f77318bcb8e645e2fc7cc8 100644 --- a/enzevalos_iphone/Providers.swift +++ b/enzevalos_iphone/Providers.swift @@ -12,11 +12,6 @@ enum Provider : String { class Providers { static let config: [Provider : [Attribute : AnyObject?]] = createConfig() - - /*Provider.WEB : [.smtpHostname : "smtp.web.de" as AnyObject?, .smtpPort : 587 as AnyObject?, .imapHostname : "imap.web.de" as AnyObject?, .imapPort : 993 as AnyObject?, .imapConnectionType: MCOConnectionType.TLS.rawValue as AnyObject?, .imapAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?, .smtpConnectionType: MCOConnectionType.startTLS.rawValue as AnyObject?, .smtpAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?], - Provider.FU : [.smtpHostname : "mail.zedat.fu-berlin.de" as AnyObject?, .smtpPort : 587 as AnyObject?, .imapHostname : "mail.zedat.fu-berlin.de" as AnyObject?, .imapPort : 993 as AnyObject?, .imapConnectionType: MCOConnectionType.TLS.rawValue as AnyObject?, .imapAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?, .smtpConnectionType: MCOConnectionType.startTLS.rawValue as AnyObject?, .smtpAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?], - Provider.ZEDAT : [.smtpHostname : "mail.zedat.fu-berlin.de" as AnyObject?, .smtpPort : 587 as AnyObject?, .imapHostname : "mail.zedat.fu-berlin.de" as AnyObject?, .imapPort : 143 as AnyObject?, .imapConnectionType: MCOConnectionType.startTLS.rawValue as AnyObject?, .imapAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?, .smtpConnectionType: MCOConnectionType.TLS.rawValue as AnyObject?, .smtpAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?], - Provider.ENZEVALOS : [.smtpHostname : "mail.enzevalos.de" as AnyObject?, .smtpPort : 465 as AnyObject?, .imapHostname : "mail.enzevalos.de" as AnyObject?, .imapPort : 993 as AnyObject?, .imapConnectionType: MCOConnectionType.TLS.rawValue as AnyObject?, .imapAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?, .smtpConnectionType: MCOConnectionType.TLS.rawValue as AnyObject?, .smtpAuthType: MCOAuthType.saslPlain.rawValue as AnyObject?]*/ static func createConfig() -> [Provider : [Attribute : AnyObject?]] { var config: [Provider : [Attribute : AnyObject?]] = [:] diff --git a/enzevalos_iphone/SendViewController.swift b/enzevalos_iphone/SendViewController.swift index adc533df93844c9a45d63ca33be392f7cc30a7ee..0776d2ca88395107431e7e31ed8d5a8b3ecd0be4 100644 --- a/enzevalos_iphone/SendViewController.swift +++ b/enzevalos_iphone/SendViewController.swift @@ -55,7 +55,7 @@ class SendViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - dataDelegate = VENDataDelegate(changeFunc: self.editName, tappedWhenSelectedFunc: self.showContact, deleteFunc: {() -> Void in return}) + dataDelegate = VENDataDelegate(changeFunc: self.editName, tappedWhenSelectedFunc: self.showContact, beginFunc: self.beginEditing, endFunc: self.endEditing, deleteFunc: {() -> Void in return}) tableDataDelegate = TableViewDataDelegate(insertCallback: self.insertName) collectionDataDelegate = CollectionDataDelegate(suggestionFunc: AddressHandler.frequentAddresses, insertCallback: self.insertName) setAnimation() @@ -151,6 +151,7 @@ class SendViewController: UIViewController { NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardOpen(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil); NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardClose(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil); + toText.tag = UIViewResolver.toText.rawValue ccText.tag = UIViewResolver.ccText.rawValue textView.tag = UIViewResolver.textView.rawValue @@ -259,6 +260,40 @@ class SendViewController: UIViewController { } } } + + func beginEditing(_ tokenField: VENTokenField){ + if tokenField == toText { + if self.collectionDataDelegate.collectionView(self.toCollectionview, numberOfItemsInSection: 0) > 0 { + self.toCollectionview.reloadData() + self.toCollectionviewHeight.constant = 100 + self.toCollectionview.isHidden = false + } + else { + self.toCollectionviewHeight.constant = 1 + self.toCollectionview.isHidden = true + } + } else if tokenField == ccText { + if self.collectionDataDelegate.collectionView(self.ccCollectionview, numberOfItemsInSection: 0) > 0 { + self.ccCollectionview.reloadData() + self.ccCollectionviewHeight.constant = 100 + self.ccCollectionview.isHidden = false + } + else { + self.ccCollectionviewHeight.constant = 1 + self.ccCollectionview.isHidden = true + } + } + } + + func endEditing(_ tokenField: VENTokenField){ + if tokenField == toText { + self.toCollectionviewHeight.constant = 1 + self.toCollectionview.isHidden = true + } else if tokenField == ccText { + self.ccCollectionviewHeight.constant = 1 + self.ccCollectionview.isHidden = true + } + } func insertName(_ name: String, address: String) { if toText.isFirstResponder { @@ -338,21 +373,21 @@ class SendViewController: UIViewController { ccCollectionview.isHidden = true } - UIView.animate(withDuration: 0.1, animations: { () -> Void in + /*UIView.animate(withDuration: 0.1, animations: { () -> Void in let contentInsets = UIEdgeInsetsMake(self.topLayoutGuide.length, 0.0, self.reducedSize, 0.0) self.scrollview!.contentInset = contentInsets - }) + })*/ } func keyboardClose(_ notification: Notification) { LogHandler.doLog("keyboard", interaction: "close", point: CGPoint(x: 0, y: 0), comment: "") if reducedSize != 0 { - UIView.animate(withDuration: 0.1, animations: { () -> Void in + /*UIView.animate(withDuration: 0.1, animations: { () -> Void in self.reducedSize = 0 let contentInsets = UIEdgeInsetsMake(self.topLayoutGuide.length, 0.0, self.reducedSize, 0.0) self.scrollview!.contentInset = contentInsets - }) + })*/ if !toText.isFirstResponder { toCollectionviewHeight.constant = 1 toCollectionview.isHidden = true diff --git a/enzevalos_iphone/VENDataDelegate.swift b/enzevalos_iphone/VENDataDelegate.swift index f682ca97ff628f2c9b8f49718f0b61545a7624c3..b58ebb1974c468f2b210aacddb6b62fb1e309c2e 100644 --- a/enzevalos_iphone/VENDataDelegate.swift +++ b/enzevalos_iphone/VENDataDelegate.swift @@ -14,6 +14,8 @@ class VENDataDelegate : NSObject, VENTokenFieldDataSource , VENTokenFieldDelegat var beginFunc: ((VENTokenField) -> Void) = {(_ : VENTokenField) -> Void in } + var endFunc: ((VENTokenField) -> Void) = {(_ : VENTokenField) -> Void in } + var deleteFunc: (() -> Void) = {() -> Void in } var tappedWhenSelectedFunc: ((String) -> Void)? = nil @@ -22,7 +24,7 @@ class VENDataDelegate : NSObject, VENTokenFieldDataSource , VENTokenFieldDelegat super.init() } - init(changeFunc: @escaping ((VENTokenField) -> Void), tappedWhenSelectedFunc: ((String) -> Void)?/*, beginFunc: (VENTokenField -> Void)*/, deleteFunc: @escaping (() -> Void)){ + init(changeFunc: @escaping ((VENTokenField) -> Void), tappedWhenSelectedFunc: ((String) -> Void)?, beginFunc: ((VENTokenField) -> Void), endFunc: ((VENTokenField) -> Void), deleteFunc: @escaping (() -> Void)){ self.changeFunc = changeFunc self.tappedWhenSelectedFunc = tappedWhenSelectedFunc self.deleteFunc = deleteFunc @@ -106,6 +108,7 @@ class VENDataDelegate : NSObject, VENTokenFieldDataSource , VENTokenFieldDelegat tokenField(tokenF, didEnterText: last) } } + endFunc(tokenF) } func isSecure(_ tokenField: VENTokenField) -> Bool {