|
@@ -23,6 +23,7 @@
|
|
|
|
|
|
import UIKit
|
|
|
import NextcloudKit
|
|
|
+import MarqueeLabel
|
|
|
|
|
|
class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
@@ -32,13 +33,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?
|
|
@@ -54,8 +55,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
tableView.delegate = self
|
|
|
tableView.dataSource = self
|
|
|
tableView.backgroundColor = .systemGroupedBackground
|
|
|
- tableView.register(NCMoreUserCell.fromNib(), forCellReuseIdentifier: NCMoreUserCell.reuseIdentifier)
|
|
|
- tableView.register(NCMoreAppSuggestionsCell.fromNib(), forCellReuseIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier)
|
|
|
+ tableView.register(UINib(nibName: "NCMoreUserCell", bundle: nil), forCellReuseIdentifier: "userCell")
|
|
|
|
|
|
// create tap gesture recognizer
|
|
|
let tapQuota = UITapGestureRecognizer(target: self, action: #selector(tapLabelQuotaExternalSite))
|
|
@@ -90,7 +90,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
var quota: String = ""
|
|
|
|
|
|
// Clear
|
|
|
- moreAppsMenu.removeAll()
|
|
|
functionMenu.removeAll()
|
|
|
externalSiteMenu.removeAll()
|
|
|
settingsMenu.removeAll()
|
|
@@ -98,10 +97,6 @@ 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_"
|
|
@@ -270,67 +265,65 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
}
|
|
|
|
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
- let defaultSections = 4
|
|
|
|
|
|
if externalSiteMenu.count == 0 {
|
|
|
- return defaultSections
|
|
|
+ return 3
|
|
|
} else {
|
|
|
- return defaultSections + 1
|
|
|
+ return 4
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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 count = 0
|
|
|
+
|
|
|
+ var cont = 0
|
|
|
|
|
|
if section == 0 {
|
|
|
- count = tabAccount == nil ? 0 : 1
|
|
|
+ cont = tabAccount == nil ? 0 : 1
|
|
|
} else if section == 1 {
|
|
|
- // Menu More apps
|
|
|
- count = moreAppsMenu.count
|
|
|
- } else if section == 2 {
|
|
|
- // Menu function
|
|
|
- count = functionMenu.count
|
|
|
+ // Menu Normal
|
|
|
+ cont = functionMenu.count
|
|
|
} else {
|
|
|
switch numberOfSections(in: tableView) {
|
|
|
case 3:
|
|
|
// Menu Settings
|
|
|
- if section == 3 {
|
|
|
- count = settingsMenu.count
|
|
|
+ if section == 2 {
|
|
|
+ cont = settingsMenu.count
|
|
|
}
|
|
|
case 4:
|
|
|
// Menu External Site
|
|
|
- if section == 4 {
|
|
|
- count = externalSiteMenu.count
|
|
|
+ if section == 2 {
|
|
|
+ cont = externalSiteMenu.count
|
|
|
}
|
|
|
// Menu Settings
|
|
|
- if section == 5 {
|
|
|
- count = settingsMenu.count
|
|
|
+ if section == 3 {
|
|
|
+ cont = settingsMenu.count
|
|
|
}
|
|
|
default:
|
|
|
- count = 0
|
|
|
+ cont = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return count
|
|
|
+ return cont
|
|
|
}
|
|
|
|
|
|
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: NCMoreUserCell.reuseIdentifier, for: indexPath) as! NCMoreUserCell
|
|
|
+ let cell = tableView.dequeueReusableCell(withIdentifier: "userCell", for: indexPath) as! NCMoreUserCell
|
|
|
|
|
|
cell.avatar.image = nil
|
|
|
cell.icon.image = nil
|
|
@@ -350,6 +343,8 @@ 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)) {
|
|
@@ -365,33 +360,25 @@ 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 More Apps
|
|
|
+ // Menu Normal
|
|
|
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) == 5 && indexPath.section == 3 {
|
|
|
+ if numberOfSections(in: tableView) == 4 && indexPath.section == 2 {
|
|
|
item = externalSiteMenu[indexPath.row]
|
|
|
}
|
|
|
// Menu Settings
|
|
|
- if (numberOfSections(in: tableView) == 4 && indexPath.section == 3) || (numberOfSections(in: tableView) == 5 && indexPath.section == 4) {
|
|
|
+ if (numberOfSections(in: tableView) == 3 && indexPath.section == 2) || (numberOfSections(in: tableView) == 4 && indexPath.section == 3) {
|
|
|
item = settingsMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
@@ -400,14 +387,18 @@ 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]
|
|
@@ -415,10 +406,9 @@ 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
|
|
@@ -430,29 +420,23 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
var item = NKExternalSite()
|
|
|
|
|
|
- // Menu Function
|
|
|
if indexPath.section == 0 {
|
|
|
tapImageLogoManageAccount()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // Menu More Apps
|
|
|
- if indexPath.section == 1 {
|
|
|
- item = moreAppsMenu[indexPath.row]
|
|
|
- }
|
|
|
-
|
|
|
// Menu Function
|
|
|
- if indexPath.section == 2 {
|
|
|
+ if indexPath.section == 1 {
|
|
|
item = functionMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
|
// Menu External Site
|
|
|
- if numberOfSections(in: tableView) == 5 && indexPath.section == 3 {
|
|
|
+ if numberOfSections(in: tableView) == 4 && indexPath.section == 2 {
|
|
|
item = externalSiteMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
|
// Menu Settings
|
|
|
- if (numberOfSections(in: tableView) == 4 && indexPath.section == 3) || (numberOfSections(in: tableView) == 5 && indexPath.section == 4) {
|
|
|
+ if (numberOfSections(in: tableView) == 3 && indexPath.section == 2) || (numberOfSections(in: tableView) == 4 && indexPath.section == 3) {
|
|
|
item = settingsMenu[indexPath.row]
|
|
|
}
|
|
|
|
|
@@ -499,8 +483,53 @@ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|