@@ -13,7 +13,7 @@ enum NCShareExtensionError: Error {
1313 case cancel, fileUpload, noAccount, noFiles, versionMismatch
1414}
1515
16- class NCShareExtension : UIViewController , NCEmptyDataSetDelegate {
16+ class NCShareExtension : UIViewController {
1717 @IBOutlet weak var collectionView : UICollectionView !
1818 @IBOutlet weak var tableView : UITableView !
1919 @IBOutlet weak var cancelButton : UIBarButtonItem !
@@ -34,7 +34,6 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
3434 var filesName : [ String ] = [ ]
3535 // -------------------------------------------------------------
3636
37- var emptyDataSet : NCEmptyDataSet ?
3837 let keyLayout = NCGlobal . shared. layoutViewShareExtension
3938 var metadataFolder : tableMetadata ?
4039 var dataSourceTask : URLSessionTask ?
@@ -43,12 +42,9 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
4342 let heightCommandView : CGFloat = 170
4443 var autoUploadFileName = " "
4544 var autoUploadDirectory = " "
46- let refreshControl = UIRefreshControl ( )
4745 var progress : CGFloat = 0
4846 var counterUploaded : Int = 0
49- var uploadErrors : [ tableMetadata ] = [ ]
5047 var uploadMetadata : [ tableMetadata ] = [ ]
51- var uploadStarted = false
5248 let hud = NCHud ( )
5349 let utilityFileSystem = NCUtilityFileSystem ( )
5450 let utility = NCUtility ( )
@@ -77,13 +73,9 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
7773 override func viewDidLoad( ) {
7874 super. viewDidLoad ( )
7975
80- self . navigationController ? . navigationBar . prefersLargeTitles = false
76+ collectionView . register ( UINib ( nibName : " NCSectionFirstHeaderEmptyData " , bundle : nil ) , forSupplementaryViewOfKind : UICollectionView . elementKindSectionHeader , withReuseIdentifier : " sectionFirstHeaderEmptyData " )
8177 collectionView. register ( UINib ( nibName: " NCListCell " , bundle: nil ) , forCellWithReuseIdentifier: " listCell " )
8278 collectionView. collectionViewLayout = NCListLayout ( )
83- collectionView. refreshControl = refreshControl
84- refreshControl. tintColor = NCBrandColor . shared. brandText
85- refreshControl. backgroundColor = . systemBackground
86- refreshControl. addTarget ( self , action: #selector( reloadDatasource) , for: . valueChanged)
8779
8880 commandView. backgroundColor = . secondarySystemBackground
8981 separatorView. backgroundColor = . separator
@@ -97,38 +89,23 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
9789 cancelButton. title = NSLocalizedString ( " _cancel_ " , comment: " " )
9890
9991 createFolderView. layer. cornerRadius = 10
100- createFolderImage. image = utility. loadImage ( named: " folder.badge.plus " , colors: [ NCBrandColor . shared. iconColor ] )
92+ createFolderImage. image = utility. loadImage ( named: " folder.badge.plus " , colors: [ NCBrandColor . shared. iconImageColor ] )
10193 createFolderLabel. text = NSLocalizedString ( " _create_folder_ " , comment: " " )
10294 let createFolderGesture = UITapGestureRecognizer ( target: self , action: #selector( actionCreateFolder ( _: ) ) )
10395 createFolderView. addGestureRecognizer ( createFolderGesture)
10496
10597 uploadView. layer. cornerRadius = 10
10698
10799 uploadLabel. text = NSLocalizedString ( " _upload_ " , comment: " " )
108- uploadLabel. textColor = NCBrandColor . shared . customer
109- let uploadGesture = UITapGestureRecognizer ( target: self , action: #selector( actionUpload) )
100+ uploadLabel. textColor = . systemBlue
101+ let uploadGesture = UITapGestureRecognizer ( target: self , action: #selector( actionUpload ( _ : ) ) )
110102 uploadView. addGestureRecognizer ( uploadGesture)
111103
112104 let versionNextcloudiOS = String ( format: NCBrandOptions . shared. textCopyrightNextcloudiOS, utility. getVersionBuild ( ) )
113105 NextcloudKit . configureLogger ( logLevel: ( NCBrandOptions . shared. disable_log ? . disabled : NCPreferences ( ) . log) )
114106
115107 nkLog ( start: " Start Share session " + versionNextcloudiOS)
116108
117- // LOG
118- let levelLog = NCKeychain ( ) . logLevel
119- //
120- // NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
121- // NextcloudKit.shared.nkCommonInstance.pathLog = utilityFileSystem.directoryGroup
122- // NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start Share session with level \(levelLog) " + versionNextcloudiOS)
123- NKLogFileManager . shared. logLevel = NKLogLevel ( rawValue: levelLog) ?? . normal
124- NKLogFileManager . shared. logDirectory = URL ( fileURLWithPath: utilityFileSystem. directoryGroup)
125- NextcloudKit . shared. nkCommonInstance. writeLog ( " [INFO] Start Share session with level \( levelLog) " + versionNextcloudiOS)
126-
127- // hud.indicatorView = JGProgressHUDRingIndicatorView()
128- // if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView {
129- // indicatorView.ringWidth = 1.5
130- // indicatorView.ringColor = NCBrandColor.shared.brandElement
131- // }
132109 NCBrandColor . shared. createUserColors ( )
133110
134111 registerForTraitChanges ( [ UITraitUserInterfaceStyle . self] ) { ( self : Self, _) in
@@ -187,8 +164,6 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
187164 }
188165 }
189166
190- accountRequestChangeAccount ( account: account, controller: nil )
191-
192167 guard let inputItems = extensionContext? . inputItems as? [ NSExtensionItem ] else {
193168 cancel ( with: . noFiles)
194169 return
@@ -236,21 +211,6 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
236211 tableView. visibleCells. forEach { $0. setNeedsLayout ( ) }
237212 }
238213
239- // MARK: - Empty
240-
241- func emptyDataSetView( _ view: NCEmptyView ) {
242-
243- if self . dataSourceTask? . state == . running {
244- view. emptyImage. image = UIImage ( named: " networkInProgress " ) ? . image ( color: . gray, size: UIScreen . main. bounds. width)
245- view. emptyTitle. text = NSLocalizedString ( " _request_in_progress_ " , comment: " " )
246- view. emptyDescription. text = " "
247- } else {
248- view. emptyImage. image = UIImage ( named: " folder_nmcloud " )
249- view. emptyTitle. text = NSLocalizedString ( " _files_no_folders_ " , comment: " " )
250- view. emptyDescription. text = " "
251- }
252- }
253-
254214 // MARK: -
255215
256216 func cancel( with error: NCShareExtensionError ? = nil ) {
@@ -278,15 +238,14 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
278238
279239 navigationItem. title = navigationTitle
280240 cancelButton. title = NSLocalizedString ( " _cancel_ " , comment: " " )
281- cancelButton. tintColor = NCBrandColor . shared. customer
282241
283242 // BACK BUTTON
284243 let backButton = UIButton ( type: . custom)
285- backButton. setImage ( UIImage ( named: " back " ) ? . imageColor ( NCBrandColor . shared . customer ) , for: . normal)
286- backButton. tintColor = NCBrandColor . shared . customer
244+ backButton. setImage ( UIImage ( named: " back " ) , for: . normal)
245+ backButton. tintColor = . systemBlue
287246 backButton. semanticContentAttribute = . forceLeftToRight
288247 backButton. setTitle ( " " + NSLocalizedString( " _back_ " , comment: " " ) , for: . normal)
289- backButton. setTitleColor ( NCBrandColor . shared . customer , for: . normal)
248+ backButton. setTitleColor ( . systemBlue , for: . normal)
290249 backButton. action ( for: . touchUpInside) { _ in
291250 while self . serverUrl. last != " / " { self . serverUrl. removeLast ( ) }
292251 self . serverUrl. removeLast ( )
@@ -299,11 +258,35 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
299258 }
300259 self . setNavigationBar ( navigationTitle: navigationTitle)
301260 }
261+
262+ let image = utility. loadUserImage ( for: tblAccount. user, displayName: tblAccount. displayName, urlBase: tblAccount. urlBase)
263+ let profileButton = UIButton ( type: . custom)
264+ profileButton. setImage ( image, for: . normal)
265+
266+ if serverUrl == utilityFileSystem. getHomeServer ( session: session) {
267+ var title = " "
268+ if !tblAccount. alias. isEmpty {
269+ title += tblAccount. alias
270+ } else {
271+ title += tblAccount. displayName
272+ }
273+
274+ profileButton. setTitle ( title, for: . normal)
275+ profileButton. setTitleColor ( . systemBlue, for: . normal)
276+ }
277+
278+ profileButton. semanticContentAttribute = . forceLeftToRight
279+ profileButton. sizeToFit ( )
280+ profileButton. action ( for: . touchUpInside) { _ in
281+ self . showAccountPicker ( )
282+ }
283+ var navItems = [ UIBarButtonItem ( customView: profileButton) ]
302284 if serverUrl != utilityFileSystem. getHomeServer ( session: session) {
303- navigationItem . leftBarButtonItem = UIBarButtonItem ( customView : backButton )
304- } else {
305- navigationItem . leftBarButtonItem = nil
285+ let space = UIBarButtonItem ( barButtonSystemItem : . fixedSpace , target : nil , action : nil )
286+ space . width = 20
287+ navItems . append ( contentsOf : [ UIBarButtonItem ( customView : backButton ) , space ] )
306288 }
289+ navigationItem. setLeftBarButtonItems ( navItems, animated: true )
307290 }
308291
309292 func setCommandView( ) {
@@ -318,10 +301,6 @@ class NCShareExtension: UIViewController, NCEmptyDataSetDelegate {
318301 self . tableView. isScrollEnabled = false
319302 }
320303 uploadLabel. text = NSLocalizedString ( " _upload_ " , comment: " " ) + " \( filesName. count) " + NSLocalizedString( " _files_ " , comment: " " )
321-
322- // Empty
323- emptyDataSet = NCEmptyDataSet ( view: collectionView, offset: - 50 * counter, delegate: self )
324-
325304 self . tableView. reloadData ( )
326305 }
327306
@@ -567,16 +546,6 @@ extension NCShareExtension {
567546 }
568547}
569548
570- extension NCShareExtension : uploadE2EEDelegate {
571- func start( ) {
572- self . hud. progress ( 0 )
573- }
574-
575- func uploadE2EEProgress( _ totalBytesExpected: Int64 , _ totalBytes: Int64 , _ fractionCompleted: Double ) {
576- self . hud. progress ( fractionCompleted)
577- }
578- }
579-
580549extension NCShareExtension : NCPasscodeDelegate {
581550 func passcodeReset( _ passcodeViewController: TOPasscodeViewController ) {
582551 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 ) {
0 commit comments