CCMore.swift 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // CCMore.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 03/04/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  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 UIKit
  24. class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
  25. @IBOutlet weak var imageLogo: UIImageView!
  26. @IBOutlet weak var imageUser: UIImageView!
  27. @IBOutlet weak var tableView: UITableView!
  28. @IBOutlet weak var labelQuota: UILabel!
  29. @IBOutlet weak var progressQuota: UIProgressView!
  30. let section = ["Main", "Menu", "Settings"]
  31. let items = [["A", "B", "C"], ["A", "B", "C"], ["A", "B", "C", "D"]]
  32. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  33. var externalSite: [TableExternalSites]?
  34. var tableAccont : TableAccount?
  35. override func viewDidLoad() {
  36. super.viewDidLoad()
  37. self.tableView.delegate = self
  38. self.tableView.dataSource = self
  39. self.tableView.tableFooterView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.tableView.frame.size.width, height: 1))
  40. self.tableView.separatorColor = Constant.GlobalConstants.k_Color_Seperator
  41. CCAspect.aspectNavigationControllerBar(self.navigationController?.navigationBar, encrypted: false, online: appDelegate.reachability.isReachable(), hidden: true)
  42. CCAspect.aspectTabBar(self.tabBarController?.tabBar, hidden: false)
  43. }
  44. override func viewWillAppear(_ animated: Bool) {
  45. self.tableAccont = CCCoreData.getActiveAccount()
  46. self.externalSite = CCCoreData.getAllTableExternalSites(with: NSPredicate(format: "(account == '\(appDelegate.activeAccount!)')")) as? [TableExternalSites]
  47. if (self.tableAccont != nil) {
  48. self.progressQuota.progress = Float((self.tableAccont?.quotaRelative)!) / 100
  49. let quota : String = CCUtility.transformedSize(Double((self.tableAccont?.quotaTotal)!))
  50. let quotaUsed : String = CCUtility.transformedSize(Double((self.tableAccont?.quotaUsed)!))
  51. self.labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)
  52. }
  53. // Aspect
  54. CCAspect.aspectNavigationControllerBar(self.navigationController?.navigationBar, encrypted: false, online: appDelegate.reachability.isReachable(), hidden: true)
  55. CCAspect.aspectTabBar(self.tabBarController?.tabBar, hidden: false)
  56. tableView.reloadData()
  57. }
  58. func numberOfSections(in tableView: UITableView) -> Int {
  59. return self.section.count
  60. }
  61. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  62. return self.items[section].count
  63. }
  64. // create a cell for each table view row
  65. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  66. let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CCCellMore
  67. // cell.textLabel?.text = "Section \(indexPath.section) Row \(indexPath.row)"
  68. //let fruitName = fruits[indexPath.row]
  69. //cell.textLabel?.text = fruitName
  70. //cell.detailTextLabel?.text = "Delicious!"
  71. //cell.imageView?.image = UIImage(named: fruitName)
  72. return cell
  73. }
  74. // method to run when table view cell is tapped
  75. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  76. print("You tapped cell number \(indexPath.row).")
  77. }
  78. }
  79. class CCCellMore: UITableViewCell {
  80. @IBOutlet weak var labelText: UILabel!
  81. @IBOutlet weak var imageIcon: UIImageView!
  82. }