NCActivity.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. }
  36. override func viewWillAppear(_ animated: Bool) {
  37. super.viewWillAppear(animated)
  38. // Color
  39. appDelegate.aspectNavigationControllerBar(self.navigationController?.navigationBar, online: appDelegate.reachability.isReachable(), hidden: false)
  40. appDelegate.aspectTabBar(self.tabBarController?.tabBar, hidden: false)
  41. //loadDatasource()
  42. //loadListingTrash()
  43. }
  44. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  45. return 1
  46. }
  47. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  48. if let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as? TableViewCell {
  49. return cell
  50. }
  51. return UITableViewCell()
  52. }
  53. }
  54. class CollectionViewCell: UICollectionViewCell {
  55. @IBOutlet weak var imageView: UIImageView!
  56. override func awakeFromNib() {
  57. super.awakeFromNib()
  58. }
  59. }
  60. class TableViewCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  61. @IBOutlet weak var collectionView: UICollectionView!
  62. var imageArray = [String] ()
  63. override func awakeFromNib() {
  64. super.awakeFromNib()
  65. collectionView.delegate = self
  66. collectionView.dataSource = self
  67. imageArray = ["1.jpeg","2.jpeg","3.jpeg","4.jpeg","5.jpeg","6.jpeg","7.jpeg","8.jpeg","9.jpeg","10.jpeg"]
  68. // Initialization code
  69. }
  70. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
  71. let size = CGSize(width: 120, height: 120)
  72. return size
  73. }
  74. func numberOfSections(in collectionView: UICollectionView) -> Int {
  75. return 1
  76. }
  77. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  78. return 10
  79. }
  80. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  81. if let cell: CollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? CollectionViewCell {
  82. let randomNumber = Int(arc4random_uniform(UInt32(imageArray.count)))
  83. cell.imageView.image = UIImage(named: imageArray[randomNumber])
  84. return cell
  85. }
  86. return UICollectionViewCell()
  87. }
  88. }