|
@@ -26,10 +26,6 @@ import UIKit
|
|
|
|
|
|
class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
- @IBOutlet weak var themingBackground: UIImageView!
|
|
|
- @IBOutlet weak var disclosureIndicator: UIImageView!
|
|
|
- @IBOutlet weak var themingAvatar: UIImageView!
|
|
|
- @IBOutlet weak var labelUsername: UILabel!
|
|
|
@IBOutlet weak var tableView: UITableView!
|
|
|
@IBOutlet weak var labelQuota: UILabel!
|
|
|
@IBOutlet weak var labelQuotaExternalSite: UILabel!
|
|
@@ -59,19 +55,15 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
tableView.dataSource = self
|
|
|
|
|
|
self.navigationItem.title = NSLocalizedString("_more_", comment: "")
|
|
|
-
|
|
|
+
|
|
|
// create tap gesture recognizer
|
|
|
let tapQuota = UITapGestureRecognizer(target: self, action: #selector(tapLabelQuotaExternalSite))
|
|
|
labelQuotaExternalSite.isUserInteractionEnabled = true
|
|
|
labelQuotaExternalSite.addGestureRecognizer(tapQuota)
|
|
|
-
|
|
|
- let tapImageLogo = UITapGestureRecognizer(target: self, action: #selector(tapImageLogoManageAccount))
|
|
|
- themingBackground.isUserInteractionEnabled = true
|
|
|
- themingBackground.addGestureRecognizer(tapImageLogo)
|
|
|
-
|
|
|
+
|
|
|
// Notification
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(changeUserProfile), name: NSNotification.Name(rawValue: k_notificationCenter_changeUserProfile), object: nil)
|
|
|
-
|
|
|
+
|
|
|
// Theming view
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
|
|
|
changeTheming()
|
|
@@ -193,47 +185,19 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
@objc func changeTheming() {
|
|
|
appDelegate.changeTheming(self, tableView: tableView, collectionView: nil, form: false)
|
|
|
|
|
|
- viewQuota.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
|
|
|
+ viewQuota.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
progressQuota.progressTintColor = NCBrandColor.sharedInstance.brandElement
|
|
|
- themingBackground.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
|
|
|
-
|
|
|
- labelUsername.textColor = NCBrandColor.sharedInstance.textView
|
|
|
-
|
|
|
- disclosureIndicator.image = CCGraphics.changeThemingColorImage(disclosureIndicator.image, width: 48, height: 52, color: NCBrandColor.sharedInstance.textView)
|
|
|
}
|
|
|
|
|
|
@objc func changeUserProfile() {
|
|
|
-
|
|
|
- let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-" + appDelegate.activeUser + ".png"
|
|
|
- var quota: String = ""
|
|
|
-
|
|
|
- if let themingAvatarFile = UIImage.init(contentsOfFile: fileNamePath) {
|
|
|
- themingAvatar.image = themingAvatarFile
|
|
|
- } else {
|
|
|
- themingAvatar.image = UIImage.init(named: "moreAvatar")
|
|
|
- }
|
|
|
-
|
|
|
// Display Name user & Quota
|
|
|
+ var quota: String = ""
|
|
|
+
|
|
|
guard let tabAccount = NCManageDatabase.sharedInstance.getAccountActive() else {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if tabAccount.displayName.isEmpty {
|
|
|
- labelUsername.text = tabAccount.user
|
|
|
- }
|
|
|
- else{
|
|
|
- labelUsername.text = tabAccount.displayName
|
|
|
- }
|
|
|
-
|
|
|
- // Shadow labelUsername TEST BLUR
|
|
|
- /*
|
|
|
- labelUsername.layer.shadowColor = UIColor.black.cgColor
|
|
|
- labelUsername.layer.shadowRadius = 4
|
|
|
- labelUsername.layer.shadowOpacity = 0.8
|
|
|
- labelUsername.layer.shadowOffset = CGSize(width: 0, height: 0)
|
|
|
- labelUsername.layer.masksToBounds = false
|
|
|
- */
|
|
|
-
|
|
|
+ self.tabAccount = tabAccount
|
|
|
+
|
|
|
if (tabAccount.quotaRelative > 0) {
|
|
|
progressQuota.progress = Float(tabAccount.quotaRelative) / 100
|
|
|
} else {
|
|
@@ -250,97 +214,101 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
default:
|
|
|
quota = CCUtility.transformedSize(Double(tabAccount.quotaTotal))
|
|
|
}
|
|
|
-
|
|
|
- let quotaUsed : String = CCUtility.transformedSize(Double(tabAccount.quotaUsed))
|
|
|
-
|
|
|
+
|
|
|
+ let quotaUsed: String = CCUtility.transformedSize(Double(tabAccount.quotaUsed))
|
|
|
+
|
|
|
labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)
|
|
|
+ tableView.reloadData()
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
-
|
|
|
+
|
|
|
if (externalSiteMenu.count == 0) {
|
|
|
- return 2
|
|
|
- } else {
|
|
|
return 3
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
-
|
|
|
- if (section == 0) {
|
|
|
- return 0.1
|
|
|
} else {
|
|
|
- return 30
|
|
|
+ return 4
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
-
|
|
|
+
|
|
|
var cont = 0
|
|
|
-
|
|
|
- // Menu Normal
|
|
|
if (section == 0) {
|
|
|
+ cont = tabAccount == nil ? 0 : 1
|
|
|
+ } else if (section == 1) {
|
|
|
+ // Menu Normal
|
|
|
cont = functionMenu.count
|
|
|
} else {
|
|
|
switch (numberOfSections(in: tableView)) {
|
|
|
- case 2:
|
|
|
+ case 3:
|
|
|
// Menu Settings
|
|
|
- if (section == 1) {
|
|
|
+ if (section == 2) {
|
|
|
cont = settingsMenu.count
|
|
|
}
|
|
|
- case 3:
|
|
|
+ case 4:
|
|
|
// Menu External Site
|
|
|
- if (section == 1) {
|
|
|
+ if (section == 2) {
|
|
|
cont = externalSiteMenu.count
|
|
|
}
|
|
|
// Menu Settings
|
|
|
- if (section == 2) {
|
|
|
+ if (section == 3) {
|
|
|
cont = settingsMenu.count
|
|
|
}
|
|
|
default:
|
|
|
cont = 0
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return cont
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
-
|
|
|
+
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CCCellMore
|
|
|
var item: OCExternalSites = OCExternalSites.init()
|
|
|
|
|
|
// change color selection and disclosure indicator
|
|
|
- let selectionColor : UIView = UIView.init()
|
|
|
+ let selectionColor: UIView = UIView()
|
|
|
selectionColor.backgroundColor = NCBrandColor.sharedInstance.select
|
|
|
cell.selectedBackgroundView = selectionColor
|
|
|
- cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
|
|
|
+ cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
|
|
|
-
|
|
|
- // Menu Normal
|
|
|
+
|
|
|
if (indexPath.section == 0) {
|
|
|
-
|
|
|
- item = functionMenu[indexPath.row]
|
|
|
-
|
|
|
+ let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-" + appDelegate.activeUser + ".png"
|
|
|
+
|
|
|
+ if let themingAvatarFile = UIImage.init(contentsOfFile: fileNamePath) {
|
|
|
+ cell.imageIcon?.image = themingAvatarFile
|
|
|
+ } else {
|
|
|
+ cell.imageIcon?.image = UIImage.init(named: "moreAvatar")
|
|
|
+ }
|
|
|
+ cell.imageIcon?.layer.masksToBounds = true
|
|
|
+ cell.imageIcon?.layer.cornerRadius = cell.imageIcon.frame.size.width / 2
|
|
|
+ if let account = tabAccount {
|
|
|
+ cell.labelText?.text = account.displayName
|
|
|
+ cell.labelText.textColor = NCBrandColor.sharedInstance.textView
|
|
|
+ }
|
|
|
+
|
|
|
+ return cell
|
|
|
} else {
|
|
|
-
|
|
|
+ // Menu Normal
|
|
|
+ if (indexPath.section == 1) {
|
|
|
+
|
|
|
+ item = functionMenu[indexPath.row]
|
|
|
+ }
|
|
|
// Menu External Site
|
|
|
- if (numberOfSections(in: tableView) == 3 && indexPath.section == 1) {
|
|
|
-
|
|
|
+ if (numberOfSections(in: tableView) == 4 && indexPath.section == 2) {
|
|
|
item = externalSiteMenu[indexPath.row]
|
|
|
}
|
|
|
-
|
|
|
// Menu Settings
|
|
|
- if ((numberOfSections(in: tableView) == 2 && indexPath.section == 1) || (numberOfSections(in: tableView) == 3 && indexPath.section == 2)) {
|
|
|
-
|
|
|
+ if ((numberOfSections(in: tableView) == 3 && indexPath.section == 2) || (numberOfSections(in: tableView) == 4 && indexPath.section == 3)) {
|
|
|
item = settingsMenu[indexPath.row]
|
|
|
}
|
|
|
+
|
|
|
+ cell.imageIcon?.image = CCGraphics.changeThemingColorImage(UIImage.init(named: item.icon), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)
|
|
|
+ cell.labelText?.text = NSLocalizedString(item.name, comment: "")
|
|
|
+ cell.labelText.textColor = NCBrandColor.sharedInstance.textView
|
|
|
}
|
|
|
-
|
|
|
- cell.imageIcon?.image = CCGraphics.changeThemingColorImage(UIImage.init(named: item.icon), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)
|
|
|
- cell.labelText?.text = NSLocalizedString(item.name, comment: "")
|
|
|
- cell.labelText.textColor = NCBrandColor.sharedInstance.textView
|
|
|
-
|
|
|
return cell
|
|
|
}
|
|
|
|
|
@@ -349,18 +317,23 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
var item: OCExternalSites = OCExternalSites.init()
|
|
|
|
|
|
- // Menu Function
|
|
|
if indexPath.section == 0 {
|
|
|
+ tapImageLogoManageAccount()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // Menu Function
|
|
|
+ if indexPath.section == 1 {
|
|
|
item = functionMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
|
// Menu External Site
|
|
|
- if (numberOfSections(in: tableView) == 3 && indexPath.section == 1) {
|
|
|
+ if (numberOfSections(in: tableView) == 4 && indexPath.section == 2) {
|
|
|
item = externalSiteMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
|
// Menu Settings
|
|
|
- if ((numberOfSections(in: tableView) == 2 && indexPath.section == 1) || (numberOfSections(in: tableView) == 3 && indexPath.section == 2)) {
|
|
|
+ if ((numberOfSections(in: tableView) == 3 && indexPath.section == 2) || (numberOfSections(in: tableView) == 4 && indexPath.section == 3)) {
|
|
|
item = settingsMenu[indexPath.row]
|
|
|
}
|
|
|
|