NCRecent.swift 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // NCRecent.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 29/09/2020.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import Foundation
  24. import NCCommunication
  25. class NCRecent: NCCollectionViewCommon {
  26. required init?(coder aDecoder: NSCoder) {
  27. super.init(coder: aDecoder)
  28. titleCurrentFolder = NSLocalizedString("_recent_", comment: "")
  29. layoutKey = k_layout_view_recent
  30. enableSearchBar = true
  31. DZNimage = CCGraphics.changeThemingColorImage(UIImage.init(named: "recent"), width: 300, height: 300, color: NCBrandColor.sharedInstance.brandElement)
  32. DZNtitle = "_files_no_files_"
  33. DZNdescription = ""
  34. }
  35. override func viewWillAppear(_ animated: Bool) {
  36. super.viewWillAppear(animated)
  37. }
  38. // MARK: - DataSource + NC Endpoint
  39. override func reloadDataSource() {
  40. super.reloadDataSource()
  41. var sort: String
  42. var ascending: Bool
  43. var directoryOnTop: Bool
  44. (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: "")
  45. metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@", appDelegate.account), limit: 100, sorted: "date", ascending: true)
  46. self.dataSource = NCDataSource.init(metadatasSource: metadatasSource, sort: sort, ascending: ascending, directoryOnTop: directoryOnTop, filterLivePhoto: true)
  47. refreshControl.endRefreshing()
  48. collectionView.reloadData()
  49. }
  50. override func reloadDataSourceNetwork(forced: Bool = false) {
  51. super.reloadDataSourceNetwork(forced: forced)
  52. self.refreshControl.endRefreshing()
  53. self.isReloadDataSourceNetworkInProgress = false
  54. self.reloadDataSource()
  55. }
  56. }