// // CCMore.swift // Nextcloud // // Created by Marino Faggiana on 03/04/17. // Copyright © 2017 TWS. All rights reserved. // // Author Marino Faggiana // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // import UIKit class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var imageLogo: UIImageView! @IBOutlet weak var imageUser: UIImageView! @IBOutlet weak var tableView: UITableView! @IBOutlet weak var labelQuota: UILabel! @IBOutlet weak var progressQuota: UIProgressView! let section = ["Main", "Menu", "Settings"] let items = [["A", "B", "C"], ["A", "B", "C"], ["A", "B", "C", "D"]] let appDelegate = UIApplication.shared.delegate as! AppDelegate var externalSite: [TableExternalSites]? var tableAccont : TableAccount? override func viewDidLoad() { super.viewDidLoad() self.tableView.delegate = self self.tableView.dataSource = self self.tableView.tableFooterView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.tableView.frame.size.width, height: 1)) self.tableView.separatorColor = Constant.GlobalConstants.k_Color_Seperator CCAspect.aspectNavigationControllerBar(self.navigationController?.navigationBar, encrypted: false, online: appDelegate.reachability.isReachable(), hidden: true) CCAspect.aspectTabBar(self.tabBarController?.tabBar, hidden: false) } override func viewWillAppear(_ animated: Bool) { self.tableAccont = CCCoreData.getActiveAccount() self.externalSite = CCCoreData.getAllTableExternalSites(with: NSPredicate(format: "(account == '\(appDelegate.activeAccount!)')")) as? [TableExternalSites] if (self.tableAccont != nil) { self.progressQuota.progress = Float((self.tableAccont?.quotaRelative)!) / 100 let quota : String = CCUtility.transformedSize(Double((self.tableAccont?.quotaTotal)!)) let quotaUsed : String = CCUtility.transformedSize(Double((self.tableAccont?.quotaUsed)!)) self.labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota) } // Aspect CCAspect.aspectNavigationControllerBar(self.navigationController?.navigationBar, encrypted: false, online: appDelegate.reachability.isReachable(), hidden: true) CCAspect.aspectTabBar(self.tabBarController?.tabBar, hidden: false) tableView.reloadData() } func numberOfSections(in tableView: UITableView) -> Int { return self.section.count } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.items[section].count } // create a cell for each table view row func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CCCellMore // cell.textLabel?.text = "Section \(indexPath.section) Row \(indexPath.row)" //let fruitName = fruits[indexPath.row] //cell.textLabel?.text = fruitName //cell.detailTextLabel?.text = "Delicious!" //cell.imageView?.image = UIImage(named: fruitName) return cell } // method to run when table view cell is tapped func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { print("You tapped cell number \(indexPath.row).") } } class CCCellMore: UITableViewCell { @IBOutlet weak var labelText: UILabel! @IBOutlet weak var imageIcon: UIImageView! }