@@ -192,43 +192,10 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
192192 @objc func openShareProfile( _ sender: UITapGestureRecognizer ) {
193193 self . showProfileMenu ( userId: metadata. ownerId, session: session, sender: sender. view)
194194 }
195-
196- @objc func keyboardWillShow( notification: Notification ) {
197- if UIDevice . current. userInterfaceIdiom == . phone {
198- if ( UIScreen . main. bounds. width < 374 || UIDevice . current. orientation. isLandscape) {
199- if let keyboardSize = ( notification. userInfo ? [ UIResponder . keyboardFrameEndUserInfoKey] as? NSValue ) ? . cgRectValue {
200- if view. frame. origin. y == 0 {
201- self . tableView. scrollToRow ( at: IndexPath ( row: 0 , section: 0 ) , at: . top, animated: false )
202- self . view. frame. origin. y -= keyboardSize. height
203- }
204- }
205- } else if UIScreen . main. bounds. height < 850 {
206- if view. frame. origin. y == 0 {
207- self . tableView. scrollToRow ( at: IndexPath ( row: 0 , section: 0 ) , at: . top, animated: false )
208- self . view. frame. origin. y -= 70
209- }
210- } else {
211- if view. frame. origin. y == 0 {
212- self . tableView. scrollToRow ( at: IndexPath ( row: 0 , section: 0 ) , at: . top, animated: false )
213- self . view. frame. origin. y -= 40
214- }
215- }
216- }
217-
218- if UIDevice . current. userInterfaceIdiom == . pad, UIDevice . current. orientation. isLandscape {
219- if view. frame. origin. y == 0 {
220- self . tableView. scrollToRow ( at: IndexPath ( row: 0 , section: 0 ) , at: . top, animated: false )
221- self . view. frame. origin. y -= 230
222- }
223- }
224- textField? . layer. borderColor = NCBrandColor . shared. brand. cgColor
225- }
226-
227- @objc func keyboardWillHide( notification: Notification ) {
228- if view. frame. origin. y != 0 {
229- self . view. frame. origin. y = 0
230- }
231- textField? . layer. borderColor = NCBrandColor . shared. label. cgColor
195+
196+ @objc func openShareProfile( ) {
197+ guard let metadata = metadata else { return }
198+ self . showProfileMenu ( userId: metadata. ownerId, session: session)
232199 }
233200
234201 @objc func keyboardWillShow( notification: Notification ) {
@@ -278,6 +245,9 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
278245 @objc func reloadData( ) {
279246 shares = self . database. getTableShares ( metadata: metadata)
280247 shareLinksCount = 0
248+ // if let metadata = metadata {
249+ // shares = self.database.getTableShares(metadata: metadata)
250+ // }
281251 tableView. reloadData ( )
282252 }
283253
@@ -290,14 +260,29 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
290260 }
291261
292262 @IBAction func searchFieldDidChange( textField: UITextField ) {
263+ NSObject . cancelPreviousPerformRequests ( withTarget: self , selector: #selector( searchSharees) , object: nil )
293264 guard let searchString = textField. text else { return }
294265 if searchString. count == 0 {
295266 dropDown. hide ( )
296267 } else {
297- networking? . getSharees ( searchString: searchString)
268+ // networking?.getSharees(searchString: searchString)
269+ perform ( #selector( searchSharees) , with: nil , afterDelay: 0.5 )
298270 }
299271 }
300272
273+ @objc private func searchSharees( ) {
274+ // https://stackoverflow.com/questions/25471114/how-to-validate-an-e-mail-address-in-swift
275+ func isValidEmail( _ email: String ) -> Bool {
276+
277+ let emailRegEx = " [A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+ \\ .[A-Za-z]{2,64} "
278+ let emailPred = NSPredicate ( format: " SELF MATCHES %@ " , emailRegEx)
279+ return emailPred. evaluate ( with: email)
280+ }
281+ guard let searchString = textField? . text, !searchString. isEmpty else { return }
282+ if searchString. contains ( " @ " ) , !isValidEmail( searchString) { return }
283+ networking? . getSharees ( searchString: searchString)
284+ }
285+
301286 @IBAction func createLinkClicked( _ sender: Any ) {
302287 appDelegate? . adjust. trackEvent ( TriggerEvent ( CreateLink . rawValue) )
303288 TealiumHelper . shared. trackEvent ( title: " magentacloud-app.sharing.create " , data: [ " " : " " ] )
@@ -307,7 +292,7 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
307292 @IBAction func touchUpInsideButtonMenu( _ sender: Any ) {
308293
309294 guard let metadata = metadata else { return }
310- let isFilesSharingPublicPasswordEnforced = NCGlobal . shared . capabilityFileSharingPubPasswdEnforced
295+ let isFilesSharingPublicPasswordEnforced = NCCapabilities . Capabilities ( ) . capabilityFileSharingPubPasswdEnforced
311296 let shares = NCManageDatabase . shared. getTableShares ( metadata: metadata)
312297
313298 if isFilesSharingPublicPasswordEnforced && shares. firstShareLink == nil {
@@ -650,24 +635,43 @@ extension NCShare: UITableViewDataSource {
650635 cell. indexPath = indexPath
651636 cell. tableShare = tableShare
652637 cell. delegate = self
653- cell. setupCellUI ( titleAppendString: String ( shareLinksCount) )
654- cell. menuButton. menu = NCContextMenuShare ( share: tableShare, isDirectory: metadata. isDirectory, canReshare: canReshare, shareController: self , controller: controller) . viewMenu ( )
655- cell. menuButton. showsMenuAsPrimaryAction = true
656- if tableShare. shareType == NKShare . ShareType. publicLink. rawValue { shareLinksCount += 1 }
657- return cell
658- }
659- } else {
660- // USER / GROUP etc.
661- if let cell = tableView. dequeueReusableCell ( withIdentifier: " cellUser " , for: indexPath) as? NCShareUserCell {
662- cell. index = indexPath
663- cell. tableShare = tableShare
664- cell. isDirectory = metadata. directory
665- cell. delegate = self
666- cell. setupCellUI ( userId: session. userId, session: session, metadata: metadata)
667-
668- cell. buttonMenu. menu = NCContextMenuShare ( share: tableShare, isDirectory: metadata. isDirectory, canReshare: canReshare, shareController: self , controller: controller) . viewMenu ( )
669- cell. buttonMenu. showsMenuAsPrimaryAction = true
670-
638+ //<<<<<<< HEAD
639+ // cell.setupCellUI(titleAppendString: String(shareLinksCount))
640+ // cell.menuButton.menu = NCContextMenuShare(share: tableShare, isDirectory: metadata.isDirectory, canReshare: canReshare, shareController: self, controller: controller).viewMenu()
641+ // cell.menuButton.showsMenuAsPrimaryAction = true
642+ // if tableShare.shareType == NKShare.ShareType.publicLink.rawValue { shareLinksCount += 1 }
643+ // return cell
644+ // }
645+ // } else {
646+ // // USER / GROUP etc.
647+ // if let cell = tableView.dequeueReusableCell(withIdentifier: "cellUser", for: indexPath) as? NCShareUserCell {
648+ // cell.index = indexPath
649+ // cell.tableShare = tableShare
650+ // cell.isDirectory = metadata.directory
651+ // cell.delegate = self
652+ // cell.setupCellUI(userId: session.userId, session: session, metadata: metadata)
653+ //
654+ // cell.buttonMenu.menu = NCContextMenuShare(share: tableShare, isDirectory: metadata.isDirectory, canReshare: canReshare, shareController: self, controller: controller).viewMenu()
655+ // cell.buttonMenu.showsMenuAsPrimaryAction = true
656+
657+ cell. setupCellUI ( )
658+ if !tableShare. label. isEmpty {
659+ cell. labelTitle. text = String ( format: NSLocalizedString ( " _share_linklabel_ " , comment: " " ) , tableShare. label)
660+ } else {
661+ cell. labelTitle. text = directory ? NSLocalizedString ( " _share_link_folder_ " , comment: " " ) : NSLocalizedString ( " _share_link_file_ " , comment: " " )
662+ }
663+ // cell.setupCellUI(userId: session.userId)
664+ let isEditingAllowed = shareCommon. isEditingEnabled ( isDirectory: directory, fileExtension: metadata? . fileExtension ?? " " , shareType: tableShare. shareType)
665+ if isEditingAllowed || directory || checkIsCollaboraFile ( ) {
666+ cell. btnQuickStatus. isEnabled = true
667+ cell. labelQuickStatus. textColor = NCBrandColor . shared. brand
668+ cell. imageDownArrow. image = UIImage ( named: " downArrow " ) ? . imageColor ( NCBrandColor . shared. brand)
669+ } else {
670+ cell. btnQuickStatus. isEnabled = false
671+ cell. labelQuickStatus. textColor = NCBrandColor . shared. optionItem
672+ cell. imageDownArrow. image = UIImage ( named: " downArrow " ) ? . imageColor ( NCBrandColor . shared. optionItem)
673+ }
674+
671675 return cell
672676 } else {
673677 // USER / GROUP etc.
@@ -705,18 +709,23 @@ extension NCShare: UITableViewDataSource {
705709 headerView. updateCanReshareUI ( )
706710
707711
708- if FileManager . default. fileExists ( atPath: utilityFileSystem. getDirectoryProviderStorageIconOcId ( metadata? . ocId ?? " " , etag: metadata? . etag ?? " " ) ) {
709- headerView. fullWidthImageView. image = UIImage ( contentsOfFile: utilityFileSystem. getDirectoryProviderStorageIconOcId ( metadata? . ocId ?? " " , etag: metadata? . etag ?? " " ) )
712+ if let image = NCUtility ( ) . getImage ( ocId: metadata. ocId, etag: metadata. etag, ext: NCGlobal . shared. previewExt1024) {
713+ headerView. fullWidthImageView. image = image
714+ // headerView.fullWidthImageView.image = UIImage(contentsOfFile: utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata?.ocId ?? "", etag: metadata?.etag ?? ""))
710715 headerView. fullWidthImageView. contentMode = . scaleAspectFill
711716 headerView. imageView. isHidden = true
712717 } else {
713718 if metadata? . directory ?? false {
714- let image = ( metadata? . e2eEncrypted ?? false ) ? UIImage ( named : " folderEncrypted " ) : UIImage ( named : " folder_nmcloud " )
719+ let image = ( metadata? . e2eEncrypted ?? false ) ? NCImageCache . shared . getFolderEncrypted ( ) : NCImageCache . shared . getFolder ( )
715720 headerView. imageView. image = image
716721 } else if !( metadata? . iconName. isEmpty ?? false ) {
717- headerView. imageView. image = metadata!. fileExtension == " odg " ? UIImage ( named: " file-diagram " ) : UIImage . init ( named: metadata!. iconName)
722+ if let image = UIImage . init ( named: metadata!. iconName) {
723+ headerView. imageView. image = metadata!. fileExtension == " odg " ? UIImage ( named: " diagram " ) : image
724+ } else {
725+ headerView. imageView. image = metadata!. fileExtension == " odg " ? UIImage ( named: " diagram " ) : NCUtility ( ) . loadImage ( named: metadata. iconName, useTypeIconFile: true , account: metadata. account)
726+ }
718727 } else {
719- headerView. imageView. image = UIImage ( named : " file " )
728+ headerView. imageView. image = NCImageCache . shared . getImageFile ( )
720729 }
721730 }
722731
@@ -732,10 +741,10 @@ extension NCShare: UITableViewDataSource {
732741
733742 }
734743 func tableView( _ tableView: UITableView , estimatedHeightForHeaderInSection section: Int ) -> CGFloat {
735- return metadata? . ownerId != appDelegate ? . userId ? canReshare ? 400 : 350 : 320
744+ return metadata? . ownerId != session ? . userId ? canReshare ? 400 : 350 : 320
736745 }
737746 func tableView( _ tableView: UITableView , heightForHeaderInSection section: Int ) -> CGFloat {
738- return metadata? . ownerId != appDelegate ? . userId ? canReshare ? UITableView . automaticDimension : 350 : 320
747+ return metadata? . ownerId != session ? . userId ? canReshare ? UITableView . automaticDimension : 350 : 320
739748 }
740749}
741750
0 commit comments