|
@@ -23,7 +23,6 @@
|
|
|
|
|
|
import UIKit
|
|
|
import NextcloudKit
|
|
|
-import MarqueeLabel
|
|
|
|
|
|
class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
@@ -33,13 +32,13 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
@IBOutlet weak var progressQuota: UIProgressView!
|
|
|
@IBOutlet weak var viewQuota: UIView!
|
|
|
|
|
|
+ var moreAppsMenu: [NKExternalSite] = []
|
|
|
var functionMenu: [NKExternalSite] = []
|
|
|
var externalSiteMenu: [NKExternalSite] = []
|
|
|
var settingsMenu: [NKExternalSite] = []
|
|
|
var quotaMenu: [NKExternalSite] = []
|
|
|
|
|
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
- let defaultCornerRadius: CGFloat = 10.0
|
|
|
let applicationHandle = NCApplicationHandle()
|
|
|
|
|
|
var tabAccount: tableAccount?
|
|
@@ -55,7 +54,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
tableView.delegate = self
|
|
|
tableView.dataSource = self
|
|
|
tableView.backgroundColor = .systemGroupedBackground
|
|
|
- tableView.register(UINib(nibName: "NCMoreUserCell", bundle: nil), forCellReuseIdentifier: "userCell")
|
|
|
+ tableView.register(NCMoreUserCell.fromNib(), forCellReuseIdentifier: NCMoreUserCell.reuseIdentifier)
|
|
|
+ tableView.register(NCMoreAppSuggestionsCell.fromNib(), forCellReuseIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier)
|
|
|
|
|
|
// create tap gesture recognizer
|
|
|
let tapQuota = UITapGestureRecognizer(target: self, action: #selector(tapLabelQuotaExternalSite))
|
|
@@ -90,6 +90,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
var quota: String = ""
|
|
|
|
|
|
// Clear
|
|
|
+ moreAppsMenu.removeAll()
|
|
|
functionMenu.removeAll()
|
|
|
externalSiteMenu.removeAll()
|
|
|
settingsMenu.removeAll()
|
|
@@ -97,6 +98,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
labelQuotaExternalSite.text = ""
|
|
|
progressQuota.progressTintColor = NCBrandColor.shared.brandElement
|
|
|
|
|
|
+ // ITEM : More apps
|
|
|
+ item = NKExternalSite()
|
|
|
+ moreAppsMenu.append(item)
|
|
|
+
|
|
|
// ITEM : Transfer
|
|
|
item = NKExternalSite()
|
|
|
item.name = "_transfers_"
|
|
@@ -265,65 +270,67 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
}
|
|
|
|
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
+ let defaultSections = 4
|
|
|
|
|
|
if externalSiteMenu.count == 0 {
|
|
|
- return 3
|
|
|
+ return defaultSections
|
|
|
} else {
|
|
|
- return 4
|
|
|
+ return defaultSections + 1
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
-
|
|
|
if section == 0 {
|
|
|
return 10
|
|
|
+ } else if section == 1 || section == 2 {
|
|
|
+ return 1
|
|
|
} else {
|
|
|
return 20
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
-
|
|
|
- var cont = 0
|
|
|
+ var count = 0
|
|
|
|
|
|
if section == 0 {
|
|
|
- cont = tabAccount == nil ? 0 : 1
|
|
|
+ count = tabAccount == nil ? 0 : 1
|
|
|
} else if section == 1 {
|
|
|
- // Menu Normal
|
|
|
- cont = functionMenu.count
|
|
|
+ // Menu More apps
|
|
|
+ count = moreAppsMenu.count
|
|
|
+ } else if section == 2 {
|
|
|
+ // Menu function
|
|
|
+ count = functionMenu.count
|
|
|
} else {
|
|
|
switch numberOfSections(in: tableView) {
|
|
|
case 3:
|
|
|
// Menu Settings
|
|
|
- if section == 2 {
|
|
|
- cont = settingsMenu.count
|
|
|
+ if section == 3 {
|
|
|
+ count = settingsMenu.count
|
|
|
}
|
|
|
case 4:
|
|
|
// Menu External Site
|
|
|
- if section == 2 {
|
|
|
- cont = externalSiteMenu.count
|
|
|
+ if section == 4 {
|
|
|
+ count = externalSiteMenu.count
|
|
|
}
|
|
|
// Menu Settings
|
|
|
- if section == 3 {
|
|
|
- cont = settingsMenu.count
|
|
|
+ if section == 5 {
|
|
|
+ count = settingsMenu.count
|
|
|
}
|
|
|
default:
|
|
|
- cont = 0
|
|
|
+ count = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return cont
|
|
|
+ return count
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
|
|
|
var item = NKExternalSite()
|
|
|
|
|
|
- // change color selection and disclosure indicator
|
|
|
- let selectionColor: UIView = UIView()
|
|
|
if indexPath.section == 0 {
|
|
|
|
|
|
- let cell = tableView.dequeueReusableCell(withIdentifier: "userCell", for: indexPath) as! NCMoreUserCell
|
|
|
+ let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreUserCell.reuseIdentifier, for: indexPath) as! NCMoreUserCell
|
|
|
|
|
|
cell.avatar.image = nil
|
|
|
cell.icon.image = nil
|
|
@@ -343,8 +350,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
}
|
|
|
cell.displayName.textColor = .label
|
|
|
}
|
|
|
- cell.selectedBackgroundView = selectionColor
|
|
|
- cell.backgroundColor = .secondarySystemGroupedBackground
|
|
|
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
|
|
|
|
|
|
if NCGlobal.shared.capabilityUserStatusEnabled, let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", appDelegate.account)) {
|
|
@@ -360,25 +365,33 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- cell.layer.cornerRadius = defaultCornerRadius
|
|
|
cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner, .layerMinXMaxYCorner]
|
|
|
|
|
|
return cell
|
|
|
|
|
|
+ } else if indexPath.section == 1 {
|
|
|
+ let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier, for: indexPath) as! NCMoreAppSuggestionsCell
|
|
|
+
|
|
|
+ return cell
|
|
|
} else {
|
|
|
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CCCellMore
|
|
|
|
|
|
- // Menu Normal
|
|
|
+ // Menu More Apps
|
|
|
if indexPath.section == 1 {
|
|
|
+ item = moreAppsMenu[indexPath.row]
|
|
|
+ }
|
|
|
+
|
|
|
+ // Menu Function
|
|
|
+ if indexPath.section == 2 {
|
|
|
item = functionMenu[indexPath.row]
|
|
|
}
|
|
|
// Menu External Site
|
|
|
- if numberOfSections(in: tableView) == 4 && indexPath.section == 2 {
|
|
|
+ if numberOfSections(in: tableView) == 5 && indexPath.section == 3 {
|
|
|
item = externalSiteMenu[indexPath.row]
|
|
|
}
|
|
|
// Menu Settings
|
|
|
- if (numberOfSections(in: tableView) == 3 && indexPath.section == 2) || (numberOfSections(in: tableView) == 4 && indexPath.section == 3) {
|
|
|
+ if (numberOfSections(in: tableView) == 4 && indexPath.section == 3) || (numberOfSections(in: tableView) == 5 && indexPath.section == 4) {
|
|
|
item = settingsMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
@@ -387,18 +400,14 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
cell.labelText?.text = NSLocalizedString(item.name, comment: "")
|
|
|
cell.labelText.textColor = .label
|
|
|
|
|
|
- cell.selectedBackgroundView = selectionColor
|
|
|
- cell.backgroundColor = .secondarySystemGroupedBackground
|
|
|
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
|
|
|
|
|
|
cell.separator.backgroundColor = .separator
|
|
|
cell.separatorHeigth.constant = 0.4
|
|
|
|
|
|
- cell.layer.cornerRadius = 0
|
|
|
let rows = tableView.numberOfRows(inSection: indexPath.section)
|
|
|
|
|
|
if indexPath.row == 0 {
|
|
|
- cell.layer.cornerRadius = defaultCornerRadius
|
|
|
if indexPath.row == rows - 1 {
|
|
|
cell.separator.backgroundColor = .clear
|
|
|
cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner, .layerMinXMaxYCorner]
|
|
@@ -406,9 +415,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner]
|
|
|
}
|
|
|
} else if indexPath.row == rows - 1 {
|
|
|
- cell.layer.cornerRadius = defaultCornerRadius
|
|
|
cell.layer.maskedCorners = [.layerMaxXMaxYCorner, .layerMinXMaxYCorner]
|
|
|
cell.separator.backgroundColor = .clear
|
|
|
+ } else {
|
|
|
+ cell.layer.cornerRadius = 0
|
|
|
}
|
|
|
|
|
|
return cell
|
|
@@ -420,23 +430,29 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
var item = NKExternalSite()
|
|
|
|
|
|
+ // Menu Function
|
|
|
if indexPath.section == 0 {
|
|
|
tapImageLogoManageAccount()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // Menu Function
|
|
|
+ // Menu More Apps
|
|
|
if indexPath.section == 1 {
|
|
|
+ item = moreAppsMenu[indexPath.row]
|
|
|
+ }
|
|
|
+
|
|
|
+ // Menu Function
|
|
|
+ if indexPath.section == 2 {
|
|
|
item = functionMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
|
// Menu External Site
|
|
|
- if numberOfSections(in: tableView) == 4 && indexPath.section == 2 {
|
|
|
+ if numberOfSections(in: tableView) == 5 && indexPath.section == 3 {
|
|
|
item = externalSiteMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
|
// Menu Settings
|
|
|
- if (numberOfSections(in: tableView) == 3 && indexPath.section == 2) || (numberOfSections(in: tableView) == 4 && indexPath.section == 3) {
|
|
|
+ if (numberOfSections(in: tableView) == 4 && indexPath.section == 3) || (numberOfSections(in: tableView) == 5 && indexPath.section == 4) {
|
|
|
item = settingsMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
@@ -483,53 +499,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
alertController.addAction(actionYes)
|
|
|
alertController.addAction(actionNo)
|
|
|
self.present(alertController, animated: true, completion: nil)
|
|
|
-
|
|
|
} else {
|
|
|
applicationHandle.didSelectItem(item, viewController: self)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-class CCCellMore: UITableViewCell {
|
|
|
-
|
|
|
- @IBOutlet weak var labelText: UILabel!
|
|
|
- @IBOutlet weak var imageIcon: UIImageView!
|
|
|
- @IBOutlet weak var separator: UIView!
|
|
|
- @IBOutlet weak var separatorHeigth: NSLayoutConstraint!
|
|
|
-
|
|
|
- override var frame: CGRect {
|
|
|
- get {
|
|
|
- return super.frame
|
|
|
- }
|
|
|
- set (newFrame) {
|
|
|
- var frame = newFrame
|
|
|
- let newWidth = frame.width * 0.90
|
|
|
- let space = (frame.width - newWidth) / 2
|
|
|
- frame.size.width = newWidth
|
|
|
- frame.origin.x += space
|
|
|
- super.frame = frame
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-class NCMoreUserCell: UITableViewCell {
|
|
|
-
|
|
|
- @IBOutlet weak var displayName: UILabel!
|
|
|
- @IBOutlet weak var avatar: UIImageView!
|
|
|
- @IBOutlet weak var icon: UIImageView!
|
|
|
- @IBOutlet weak var status: MarqueeLabel!
|
|
|
-
|
|
|
- override var frame: CGRect {
|
|
|
- get {
|
|
|
- return super.frame
|
|
|
- }
|
|
|
- set (newFrame) {
|
|
|
- var frame = newFrame
|
|
|
- let newWidth = frame.width * 0.90
|
|
|
- let space = (frame.width - newWidth) / 2
|
|
|
- frame.size.width = newWidth
|
|
|
- frame.origin.x += space
|
|
|
- super.frame = frame
|
|
|
- }
|
|
|
- }
|
|
|
-}
|