diff --git a/Tests/NextcloudUnitTests/MoreTests.swift b/Tests/NextcloudUnitTests/MoreTests.swift new file mode 100644 index 0000000000..0a96912994 --- /dev/null +++ b/Tests/NextcloudUnitTests/MoreTests.swift @@ -0,0 +1,37 @@ +// +// MoreTests.swift +// NextcloudTests +// +// Created by A200020526 on 09/06/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +@testable import Nextcloud +import XCTest + +final class MoreTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/iOSClient/More/Cells/BaseNCMoreCell.swift b/iOSClient/More/Cells/BaseNCMoreCell.swift index 79b64b80d5..1868d3b7f0 100644 --- a/iOSClient/More/Cells/BaseNCMoreCell.swift +++ b/iOSClient/More/Cells/BaseNCMoreCell.swift @@ -27,20 +27,6 @@ class BaseNCMoreCell: UITableViewCell { let selectionColor: UIView = UIView() let defaultCornerRadius: CGFloat = 10.0 - 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 - } - } - override func awakeFromNib() { super.awakeFromNib() diff --git a/iOSClient/More/Cells/NCMoreUserCell.xib b/iOSClient/More/Cells/NCMoreUserCell.xib index 5cd96162bd..0ac6cfc0c8 100755 --- a/iOSClient/More/Cells/NCMoreUserCell.xib +++ b/iOSClient/More/Cells/NCMoreUserCell.xib @@ -1,76 +1,75 @@ - + - + - - + + - - + + - + - - - - - - - + + + + + + + + + + - - - - - - - - - + + + + - + diff --git a/iOSClient/More/NCMore.storyboard b/iOSClient/More/NCMore.storyboard index 75f96238df..794b3d16a6 100644 --- a/iOSClient/More/NCMore.storyboard +++ b/iOSClient/More/NCMore.storyboard @@ -1,102 +1,114 @@ - + - + - + - - + + - - + + + + + + + - + - - + + - - + + - - + + - - - - - + + + + + - - - - - - - - - - + + - - + + - - + + - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - + + + + + + + - + + diff --git a/iOSClient/More/NCMore.swift b/iOSClient/More/NCMore.swift index 2615180b67..2f910f9d0e 100644 --- a/iOSClient/More/NCMore.swift +++ b/iOSClient/More/NCMore.swift @@ -32,6 +32,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var labelQuotaExternalSite: UILabel! @IBOutlet weak var progressQuota: UIProgressView! @IBOutlet weak var viewQuota: UIView! + @IBOutlet weak var quotaLabel1: UILabel! + @IBOutlet weak var quotalabel2: UILabel! private var functionMenu: [NKExternalSite] = [] private var externalSiteMenu: [NKExternalSite] = [] @@ -84,10 +86,21 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { appDelegate.activeViewController = self loadItems() + changeTheming() tableView.reloadData() } // MARK: - + + @objc func changeTheming() { + viewQuota.backgroundColor = NCBrandColor.shared.memoryConsuptionBackground + quotaLabel1.textColor = NCBrandColor.shared.label + quotalabel2.textColor = NCBrandColor.shared.label + labelQuota.textColor = NCBrandColor.shared.label + labelQuotaExternalSite.textColor = NCBrandColor.shared.label + progressQuota.progressTintColor = NCBrandColor.shared.brandElement + progressQuota.trackTintColor = NCBrandColor.shared.commonViewInfoText + } func loadItems() { @@ -109,15 +122,23 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { item.icon = "arrow.left.arrow.right" item.url = "segueTransfers" item.order = 10 - functionMenu.append(item) +// functionMenu.append(item) // ITEM : Recent item = NKExternalSite() item.name = "_recent_" - item.icon = "clock.arrow.circlepath" + item.icon = "recent" item.url = "segueRecent" item.order = 20 functionMenu.append(item) + + // ITEM : Notification + item = NKExternalSite() + item.name = "_notifications_" + item.icon = "notification" + item.url = "segueNotification" + item.order = 30 + functionMenu.append(item) // ITEM : Activity item = NKExternalSite() @@ -125,13 +146,13 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { item.icon = "bolt" item.url = "segueActivity" item.order = 40 - functionMenu.append(item) +// functionMenu.append(item) // ITEM : Shares if NCGlobal.shared.capabilityFileSharingApiEnabled { item = NKExternalSite() item.name = "_list_shares_" - item.icon = "share" + item.icon = "shareFill" item.url = "segueShares" item.order = 50 functionMenu.append(item) @@ -140,7 +161,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { // ITEM : Offline item = NKExternalSite() item.name = "_manage_file_offline_" - item.icon = "tray.and.arrow.down" + item.icon = "offlineMenu" item.url = "segueOffline" item.order = 60 functionMenu.append(item) @@ -152,7 +173,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { item.icon = "person.2" item.url = "segueGroupfolders" item.order = 61 - functionMenu.append(item) +// functionMenu.append(item) } // ITEM : Scan item = NKExternalSite() @@ -160,7 +181,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { item.icon = "doc.text.viewfinder" item.url = "openStoryboardNCScan" item.order = 70 - functionMenu.append(item) +// functionMenu.append(item) // ITEM : Trash if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion15 { @@ -181,7 +202,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { // ITEM : Settings item = NKExternalSite() item.name = "_settings_" - item.icon = "gear" + item.icon = "settings" item.url = "segueSettings" settingsMenu.append(item) @@ -214,8 +235,14 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { } let quotaUsed: String = utilityFileSystem.transformedSize(activeAccount.quotaUsed) + let quota2: String = utilityFileSystem.transformedSize(activeAccount.quotaTotal) + let percentageUsedFormatted = "\(Int(progressQuota.progress * 100))%" + + labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_percentage_", comment: ""), percentageUsedFormatted) + + quotaLabel1.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed) + quotalabel2.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_of_", comment: ""), quota2) - labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota) } // ITEM : External @@ -244,10 +271,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { sections.append(Section(items: [NKExternalSite()], type: .account)) } - if !NCBrandOptions.shared.disable_show_more_nextcloud_apps_in_settings { - sections.append(Section(items: [NKExternalSite()], type: .moreApps)) - } - if !functionMenu.isEmpty { sections.append(Section(items: functionMenu, type: .regular)) } @@ -288,7 +311,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if sections[indexPath.section].type == .account { - return 75 + return 100 } else { return NCGlobal.shared.heightCellSettings } @@ -327,7 +350,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { cell.displayName.text = "" if let account = tabAccount { - cell.avatar.image = utility.loadUserImage(for: account.user, displayName: account.displayName, userBaseUrl: appDelegate) + cell.avatar.image = UIImage.init(named: "user_settings")?.image(color: NCBrandColor.shared.iconColor, size: 25) if account.alias.isEmpty { cell.displayName?.text = account.displayName @@ -336,22 +359,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { } cell.displayName.textColor = .label } - cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator - - if NCGlobal.shared.capabilityUserStatusEnabled, let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", appDelegate.account)) { - let status = utility.getUserStatus(userIcon: account.userStatusIcon, userStatus: account.userStatusStatus, userMessage: account.userStatusMessage) - cell.icon.image = status.onlineStatus - cell.status.text = status.statusMessage - cell.status.textColor = .label - cell.status.trailingBuffer = cell.status.frame.width - if cell.status.labelShouldScroll() { - cell.status.tapToScroll = true - } else { - cell.status.tapToScroll = false - } - } - - cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner, .layerMinXMaxYCorner] + cell.removeCornerRadius() return cell @@ -364,32 +372,11 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { let item = sections[indexPath.section].items[indexPath.row] - cell.imageIcon?.image = utility.loadImage(named: item.icon) + cell.imageIcon?.image = utility.loadImage(named: item.icon).image(color: NCBrandColor.shared.iconColor, size: 25) cell.imageIcon?.contentMode = .scaleAspectFit cell.labelText?.text = NSLocalizedString(item.name, comment: "") cell.labelText.textColor = .label - - cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator - - cell.separator.backgroundColor = .separator - cell.separatorHeigth.constant = 0.4 - cell.removeCornerRadius() - let rows = tableView.numberOfRows(inSection: indexPath.section) - - if indexPath.row == 0 { - cell.applyCornerRadius() - if indexPath.row == rows - 1 { - cell.separator.backgroundColor = .clear - cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner, .layerMinXMaxYCorner] - } else { - cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] - } - } else if indexPath.row == rows - 1 { - cell.applyCornerRadius() - cell.layer.maskedCorners = [.layerMaxXMaxYCorner, .layerMinXMaxYCorner] - cell.separator.backgroundColor = .clear - } return cell } @@ -398,12 +385,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let item = sections[indexPath.section].items[indexPath.row] - // Menu Function - if sections[indexPath.section].type == .account { - tapImageLogoManageAccount() - return - } - // Action if item.url.contains("segue") && !item.url.contains("//") { self.navigationController?.performSegue(withIdentifier: item.url, sender: self)