NCActivity.swift 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //
  2. // NCActivity.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 17/01/2019.
  6. // Copyright © 2019 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 UIKit
  25. class NCActivity: UIViewController, UITableViewDataSource, UITableViewDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
  26. @IBOutlet weak var tableView: UITableView!
  27. private let appDelegate = UIApplication.shared.delegate as! AppDelegate
  28. override func viewDidLoad() {
  29. super.viewDidLoad()
  30. // empty Data Source
  31. tableView.emptyDataSetDelegate = self;
  32. tableView.emptyDataSetSource = self;
  33. tableView.estimatedRowHeight = 120
  34. tableView.tableFooterView = UIView()
  35. self.title = NSLocalizedString("_activity_", comment: "")
  36. }
  37. override func viewWillAppear(_ animated: Bool) {
  38. super.viewWillAppear(animated)
  39. // Color
  40. appDelegate.aspectNavigationControllerBar(self.navigationController?.navigationBar, online: appDelegate.reachability.isReachable(), hidden: false)
  41. appDelegate.aspectTabBar(self.tabBarController?.tabBar, hidden: false)
  42. //loadDatasource()
  43. //loadListingTrash()
  44. }
  45. // MARK: DZNEmpty
  46. func backgroundColor(forEmptyDataSet scrollView: UIScrollView) -> UIColor? {
  47. return NCBrandColor.sharedInstance.backgroundView
  48. }
  49. func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
  50. return CCGraphics.changeThemingColorImage(UIImage.init(named: "activityNoRecord"), multiplier: 2, color: NCBrandColor.sharedInstance.graySoft)
  51. }
  52. func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
  53. let text = "\n"+NSLocalizedString("_no_activity_", comment: "")
  54. let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 20), NSAttributedString.Key.foregroundColor: UIColor.lightGray]
  55. return NSAttributedString.init(string: text, attributes: attributes)
  56. }
  57. func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView) -> Bool {
  58. return true
  59. }
  60. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  61. return 0
  62. }
  63. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  64. if let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? activityTableViewCell {
  65. return cell
  66. }
  67. return UITableViewCell()
  68. }
  69. }
  70. class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  71. @IBOutlet weak var collectionView: UICollectionView!
  72. var imageArray = [String] ()
  73. override func awakeFromNib() {
  74. super.awakeFromNib()
  75. collectionView.delegate = self
  76. collectionView.dataSource = self
  77. imageArray = ["1.jpeg","2.jpeg","3.jpeg","4.jpeg","5.jpeg","6.jpeg","7.jpeg","8.jpeg","9.jpeg","10.jpeg"]
  78. // Initialization code
  79. }
  80. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
  81. let size = CGSize(width: 120, height: 120)
  82. return size
  83. }
  84. func numberOfSections(in collectionView: UICollectionView) -> Int {
  85. return 1
  86. }
  87. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  88. return 10
  89. }
  90. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  91. if let cell: activityCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as? activityCollectionViewCell {
  92. let randomNumber = Int(arc4random_uniform(UInt32(imageArray.count)))
  93. cell.imageView.image = UIImage(named: imageArray[randomNumber])
  94. return cell
  95. }
  96. return UICollectionViewCell()
  97. }
  98. }
  99. class activityCollectionViewCell: UICollectionViewCell {
  100. @IBOutlet weak var imageView: UIImageView!
  101. override func awakeFromNib() {
  102. super.awakeFromNib()
  103. }
  104. }