From 140a98e77a80422e3fda4414e0573c8a24ad9374 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:09:33 +0530 Subject: [PATCH 01/12] NMC 2172 - dashboard theming customisation --- .../UINavigationController+Extension.swift | 4 +- iOSClient/Favorites/NCFavorite.swift | 3 +- .../Cell/NCCellProtocol.swift | 5 + .../Collection Common/Cell/NCListCell.swift | 77 +--- .../Collection Common/Cell/NCListCell.xib | 317 +++++--------- .../NCCollectionViewCommon.swift | 414 +++++++----------- 6 files changed, 282 insertions(+), 538 deletions(-) diff --git a/iOSClient/Extensions/UINavigationController+Extension.swift b/iOSClient/Extensions/UINavigationController+Extension.swift index 52ca108c2a..6eaeb16a28 100644 --- a/iOSClient/Extensions/UINavigationController+Extension.swift +++ b/iOSClient/Extensions/UINavigationController+Extension.swift @@ -32,7 +32,7 @@ extension UINavigationController { func setNavigationBarAppearance() { - navigationBar.tintColor = .systemBlue + navigationBar.tintColor = NCBrandColor.shared.brand let standardAppearance = UINavigationBarAppearance() standardAppearance.configureWithDefaultBackground() @@ -52,7 +52,7 @@ extension UINavigationController { func setGroupAppearance() { - navigationBar.tintColor = .systemBlue + navigationBar.tintColor = NCBrandColor.shared.brand let standardAppearance = UINavigationBarAppearance() standardAppearance.configureWithDefaultBackground() diff --git a/iOSClient/Favorites/NCFavorite.swift b/iOSClient/Favorites/NCFavorite.swift index f854845335..6ab319a541 100644 --- a/iOSClient/Favorites/NCFavorite.swift +++ b/iOSClient/Favorites/NCFavorite.swift @@ -31,7 +31,8 @@ class NCFavorite: NCCollectionViewCommon { titleCurrentFolder = NSLocalizedString("_favorites_", comment: "") layoutKey = NCGlobal.shared.layoutViewFavorite - enableSearchBar = false + enableSearchBar = true + headerMenuButtonsView = true headerRichWorkspaceDisable = true emptyImage = UIImage(named: "star.fill")?.image(color: NCBrandColor.shared.yellowFavorite, size: UIScreen.main.bounds.width) emptyTitle = "_favorite_no_files_" diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index 9dd1c4ac4e..4793c9d798 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -41,6 +41,7 @@ protocol NCCellProtocol { var fileMoreImage: UIImageView? { get set } var cellSeparatorView: UIView? { get set } var indexPath: IndexPath { get set } + var fileSharedLabel: UILabel? { get set } func titleInfoTrailingDefault() func titleInfoTrailingFull() @@ -112,6 +113,10 @@ extension NCCellProtocol { get { return nil } set {} } + var fileSharedLabel: UILabel? { + get { return nil } + set { } + } func titleInfoTrailingDefault() {} func titleInfoTrailingFull() {} diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index d27dc6aa09..21885bc2bf 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -29,7 +29,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var imageStatus: UIImageView! @IBOutlet weak var imageFavorite: UIImageView! - @IBOutlet weak var imageFavoriteBackground: UIImageView! @IBOutlet weak var imageLocal: UIImageView! @IBOutlet weak var labelTitle: UILabel! @IBOutlet weak var labelInfo: UILabel! @@ -40,19 +39,16 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var buttonMore: UIButton! @IBOutlet weak var progressView: UIProgressView! @IBOutlet weak var separator: UIView! - @IBOutlet weak var tag0: UILabel! - @IBOutlet weak var tag1: UILabel! - + @IBOutlet weak var labelShared: UILabel! @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint! @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! - @IBOutlet weak var titleTrailingConstraint: NSLayoutConstraint! - @IBOutlet weak var subInfoTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var infoTrailingConstraint: NSLayoutConstraint! private var objectId = "" private var user = "" var indexPath = IndexPath() - weak var listCellDelegate: NCListCellDelegate? + weak var delegate: NCListCellDelegate? var namedButtonMore = "" var fileAvatarImageView: UIImageView? { @@ -114,7 +110,11 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto get { return separator } set { separator = newValue } } - + + var fileSharedLabel: UILabel? { + get { return labelShared } + set { labelShared = newValue } + } override func awakeFromNib() { super.awakeFromNib() @@ -148,23 +148,14 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto labelTitle.text = "" labelInfo.text = "" - labelSubinfo.text = "" labelTitle.textColor = .label labelInfo.textColor = .systemGray labelSubinfo.textColor = .systemGray - - imageFavoriteBackground.isHidden = true } override func prepareForReuse() { super.prepareForReuse() imageItem.backgroundColor = nil - if fileFavoriteImage?.image != nil { - imageFavoriteBackground.isHidden = false - } else { - imageFavoriteBackground.isHidden = true - } - accessibilityHint = nil accessibilityLabel = nil accessibilityValue = nil @@ -175,19 +166,19 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } @IBAction func touchUpInsideShare(_ sender: Any) { - listCellDelegate?.tapShareListItem(with: objectId, indexPath: indexPath, sender: sender) + delegate?.tapShareListItem(with: objectId, indexPath: indexPath, sender: sender) } @IBAction func touchUpInsideMore(_ sender: Any) { - listCellDelegate?.tapMoreListItem(with: objectId, namedButtonMore: namedButtonMore, image: imageItem.image, indexPath: indexPath, sender: sender) + delegate?.tapMoreListItem(with: objectId, namedButtonMore: namedButtonMore, image: imageItem.image, indexPath: indexPath, sender: sender) } @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) { - listCellDelegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, indexPath: indexPath, gestureRecognizer: gestureRecognizer) + delegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, indexPath: indexPath, gestureRecognizer: gestureRecognizer) } @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) { - listCellDelegate?.longPressListItem(with: objectId, indexPath: indexPath, gestureRecognizer: gestureRecognizer) + delegate?.longPressListItem(with: objectId, indexPath: indexPath, gestureRecognizer: gestureRecognizer) } fileprivate func setA11yActions() { @@ -205,13 +196,11 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func titleInfoTrailingFull() { - titleTrailingConstraint.constant = 10 - subInfoTrailingConstraint.constant = 10 + infoTrailingConstraint.constant = 10 } func titleInfoTrailingDefault() { - titleTrailingConstraint.constant = 90 - subInfoTrailingConstraint.constant = 90 + infoTrailingConstraint.constant = 90 } func setButtonMore(named: String, image: UIImage) { @@ -295,44 +284,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto accessibilityLabel = label accessibilityValue = value } - - func setTags(tags: [String]) { - if tags.isEmpty { - tag0.isHidden = true - tag1.isHidden = true - labelInfo.isHidden = false - labelSubinfo.isHidden = false - } else { - tag0.isHidden = false - tag1.isHidden = true - labelInfo.isHidden = true - labelSubinfo.isHidden = true - - if let tag = tags.first { - tag0.text = tag - if tags.count > 1 { - tag1.isHidden = false - tag1.text = "+\(tags.count - 1)" - } - } - } - } - - func setIconOutlines() { - imageFavoriteBackground.isHidden = fileFavoriteImage?.image == nil - - if imageStatus.image != nil { - imageStatus.makeCircularBackground(withColor: .systemBackground) - } else { - imageStatus.backgroundColor = .clear - } - - if imageLocal.image != nil { - imageLocal.makeCircularBackground(withColor: .systemBackground) - } else { - imageLocal.backgroundColor = .clear - } - } } protocol NCListCellDelegate: AnyObject { diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.xib b/iOSClient/Main/Collection Common/Cell/NCListCell.xib index f80e36009a..079e0d07b5 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.xib +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.xib @@ -1,276 +1,183 @@ - + - + - - - + + - + - - + + - - + + - - + + - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 6f2a824625..8e151bdfc7 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -27,13 +27,14 @@ import NextcloudKit import EasyTipView import JGProgressHUD -class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCSectionFooterDelegate, NCSectionHeaderEmptyDataDelegate, UIAdaptivePresentationControllerDelegate, UIContextMenuInteractionDelegate, NCAccountRequestDelegate { +class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCSectionFooterDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate, UIContextMenuInteractionDelegate, NCAccountRequestDelegate { @IBOutlet weak var collectionView: UICollectionView! private var autoUploadFileName = "" private var autoUploadDirectory = "" + private var pushed: Bool = false private var tipView: EasyTipView? var isTransitioning: Bool = false @@ -42,16 +43,19 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS let utility = NCUtility() let refreshControl = UIRefreshControl() var searchController: UISearchController? + var emptyDataSet: NCEmptyDataSet? var backgroundImageView = UIImageView() var serverUrl: String = "" var isEditMode = false var selectOcId: [String] = [] + var selectIndexPaths: [IndexPath] = [] var metadataFolder: tableMetadata? var dataSource = NCDataSource() var richWorkspaceText: String? var headerMenu: NCSectionHeaderMenu? var isSearchingMode: Bool = false var layoutForView: NCDBLayoutForView? + var selectableDataSource: [RealmSwiftObject] { dataSource.getMetadataSourceForAllSections() } var dataSourceTask: URLSessionTask? var groupByField = "name" var providers: [NKSearchProvider]? @@ -59,7 +63,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS var listLayout: NCListLayout! var gridLayout: NCGridLayout! var literalSearch: String? - var tabBarSelect: NCCollectionViewCommonSelectTabBar! + var tabBarSelect: NCSelectableViewTabBar? var timerNotificationCenter: Timer? var notificationReloadDataSource: Int = 0 @@ -75,8 +79,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS var emptyImage: UIImage? var emptyTitle: String = "" var emptyDescription: String = "" - var emptyDataPortaitOffset: CGFloat = 0 - var emptyDataLandscapeOffset: CGFloat = -20 private var showDescription: Bool { !headerRichWorkspaceDisable && NCKeychain().showDescription @@ -91,7 +93,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS override func viewDidLoad() { super.viewDidLoad() - tabBarSelect = NCCollectionViewCommonSelectTabBar(tabBarController: tabBarController as? NCMainTabBarController, delegate: self) + tabBarSelect = NCCollectionViewCommonSelectTabBar(tabBarController: tabBarController, delegate: self) + self.navigationController?.presentationController?.delegate = self // CollectionView & layout @@ -112,7 +115,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS searchController?.searchBar.delegate = self searchController?.searchBar.autocapitalizationType = .none navigationItem.searchController = searchController - navigationItem.hidesSearchBarWhenScrolling = true + navigationItem.hidesSearchBarWhenScrolling = false + navigationItem.backBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_back_", comment: ""), style: .plain, target: nil, action: nil) } // Cell @@ -123,7 +127,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS // Header collectionView.register(UINib(nibName: "NCSectionHeaderMenu", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderMenu") collectionView.register(UINib(nibName: "NCSectionHeader", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeader") - collectionView.register(UINib(nibName: "NCSectionHeaderEmptyData", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderEmptyData") // Footer collectionView.register(UINib(nibName: "NCSectionFooter", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "sectionFooter") @@ -136,6 +139,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS self.reloadDataSourceNetwork() } + // Empty + emptyDataSet = NCEmptyDataSet(view: collectionView, offset: getHeaderHeight(), delegate: self) + // Long Press on CollectionView let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCollecationView(_:))) longPressedGesture.minimumPressDuration = 0.5 @@ -165,19 +171,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - navigationController?.setNavigationBarAppearance() - navigationController?.navigationBar.prefersLargeTitles = true - navigationController?.setNavigationBarHidden(false, animated: true) - navigationItem.title = titleCurrentFolder - - setNavigationLeftItems() - setNavigationRightItems() - - if serverUrl.isEmpty { - appDelegate.activeServerUrl = utilityFileSystem.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) - } else { - appDelegate.activeServerUrl = serverUrl + // Deselect items when back to previous view controller + if isEditMode { + self.tapSelect() } + + appDelegate.activeViewController = self layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: serverUrl) gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3) @@ -187,16 +186,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS collectionView?.collectionViewLayout = gridLayout } - // FIXME: iPAD PDF landscape mode iOS 16 - DispatchQueue.main.async { - self.collectionView?.collectionViewLayout.invalidateLayout() - } - } - - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - appDelegate.activeViewController = self - timerNotificationCenter = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(notificationCenterEvents), userInfo: nil, repeats: true) NotificationCenter.default.addObserver(self, selector: #selector(applicationWillResignActive(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationWillResignActive), object: nil) @@ -224,20 +213,28 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS NotificationCenter.default.addObserver(self, selector: #selector(uploadCancelFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadCancelFile), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterProgressTask), object: nil) - } - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) + if serverUrl.isEmpty { + appDelegate.activeServerUrl = utilityFileSystem.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) + } else { + appDelegate.activeServerUrl = serverUrl + } - NCNetworking.shared.cancelUnifiedSearchFiles() - tipView?.dismiss() - setEditMode(false) - } + navigationController?.navigationBar.prefersLargeTitles = true + navigationController?.setNavigationBarHidden(false, animated: true) + navigationController?.setNavigationBarAppearance() - override func viewDidDisappear(_ animated: Bool) { - super.viewDidDisappear(animated) + setNavigationLeftItems() + setNavigationRightItems() - timerNotificationCenter?.invalidate() + // FIXME: iPAD PDF landscape mode iOS 16 + DispatchQueue.main.async { + self.collectionView?.collectionViewLayout.invalidateLayout() + } + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationWillResignActive), object: nil) NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterCloseRichWorkspaceWebView), object: nil) @@ -264,6 +261,17 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadCancelFile), object: nil) NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterProgressTask), object: nil) + + timerNotificationCenter?.invalidate() + pushed = false + + // REQUEST + NCNetworking.shared.cancelUnifiedSearchFiles() + + // TIP + self.tipView?.dismiss() + + toggleSelect(isOn: false) } func presentationControllerDidDismiss( _ presentationController: UIPresentationController) { @@ -280,10 +288,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS self.collectionView?.collectionViewLayout.invalidateLayout() self.collectionView?.reloadData() self.tipView?.dismiss() - - coordinator.animate(alongsideTransition: nil) { _ in - self.showTip() - } } override var canBecomeFirstResponder: Bool { @@ -294,7 +298,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS super.viewWillLayoutSubviews() if let frame = tabBarController?.tabBar.frame { - tabBarSelect.hostingController?.view.frame = frame + (tabBarSelect as? NCCollectionViewCommonSelectTabBar)?.hostingController?.view.frame = frame } } @@ -313,11 +317,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS } @objc func reloadAvatar(_ notification: NSNotification) { - - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { - self.showTip() - } - guard let userInfo = notification.userInfo as NSDictionary?, let error = userInfo["error"] as? NKError, error.errorCode != NCGlobal.shared.errorNotModified else { return } @@ -595,6 +594,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS // MARK: - Layout func setNavigationLeftItems() { + navigationItem.title = titleCurrentFolder + guard layoutKey == NCGlobal.shared.layoutViewFiles else { return } // PROFILE BUTTON @@ -628,7 +629,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS let action = UIAction(title: name, image: image, state: account.active ? .on : .off) { _ in if !account.active { self.appDelegate.changeAccount(account.account, userProfile: nil) - self.setEditMode(false) } } @@ -663,132 +663,43 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS navigationItem.title = titleCurrentFolder } - func setNavigationRightItems(enableMenu: Bool = false) { - guard layoutKey != NCGlobal.shared.layoutViewTransfers else { return } - let isTabBarHidden = self.tabBarController?.tabBar.isHidden ?? true - let isTabBarSelectHidden = tabBarSelect.isHidden() - - func createMenuActions() -> [UIMenuElement] { - guard let layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: serverUrl) else { return [] } - - let select = UIAction(title: NSLocalizedString("_select_", comment: ""), image: .init(systemName: "checkmark.circle"), attributes: self.dataSource.getMetadataSourceForAllSections().isEmpty ? .disabled : []) { _ in - self.setEditMode(true) - } - - let list = UIAction(title: NSLocalizedString("_list_", comment: ""), image: .init(systemName: "list.bullet"), state: layoutForView.layout == NCGlobal.shared.layoutList ? .on : .off) { _ in - self.onListSelected() - self.setNavigationRightItems() - } - - let grid = UIAction(title: NSLocalizedString("_icons_", comment: ""), image: .init(systemName: "square.grid.2x2"), state: layoutForView.layout == NCGlobal.shared.layoutGrid ? .on : .off) { _ in - self.onGridSelected() - self.setNavigationRightItems() - } - - let viewStyleSubmenu = UIMenu(title: "", options: .displayInline, children: [list, grid]) - - let ascending = layoutForView.ascending - let ascendingChevronImage = UIImage(systemName: ascending ? "chevron.up" : "chevron.down") - let isName = layoutForView.sort == "fileName" - let isDate = layoutForView.sort == "date" - let isSize = layoutForView.sort == "size" - - let byName = UIAction(title: NSLocalizedString("_name_", comment: ""), image: isName ? ascendingChevronImage : nil, state: isName ? .on : .off) { _ in - if isName { // repeated press - layoutForView.ascending = !layoutForView.ascending - } - layoutForView.sort = "fileName" - self.saveLayout(layoutForView) - } - - let byNewest = UIAction(title: NSLocalizedString("_date_", comment: ""), image: isDate ? ascendingChevronImage : nil, state: isDate ? .on : .off) { _ in - if isDate { // repeated press - layoutForView.ascending = !layoutForView.ascending - } - layoutForView.sort = "date" - self.saveLayout(layoutForView) - } - - let byLargest = UIAction(title: NSLocalizedString("_size_", comment: ""), image: isSize ? ascendingChevronImage : nil, state: isSize ? .on : .off) { _ in - if isSize { // repeated press - layoutForView.ascending = !layoutForView.ascending - } - layoutForView.sort = "size" - self.saveLayout(layoutForView) - } - - let sortSubmenu = UIMenu(title: NSLocalizedString("_order_by_", comment: ""), options: .displayInline, children: [byName, byNewest, byLargest]) + func getNavigationTitle() -> String { - let foldersOnTop = UIAction(title: NSLocalizedString("_directory_on_top_no_", comment: ""), image: UIImage(systemName: "folder"), state: layoutForView.directoryOnTop ? .on : .off) { _ in - layoutForView.directoryOnTop = !layoutForView.directoryOnTop - self.saveLayout(layoutForView) - } + let activeAccount = NCManageDatabase.shared.getActiveAccount() + guard let userAlias = activeAccount?.alias, !userAlias.isEmpty else { + return NCBrandOptions.shared.brand + } + return userAlias + } - let personalFilesOnly = NCKeychain().getPersonalFilesOnly(account: appDelegate.account) - let personalFilesOnlyAction = UIAction(title: NSLocalizedString("_personal_files_only_", comment: ""), image: UIImage(systemName: "folder.badge.person.crop"), state: personalFilesOnly ? .on : .off) { _ in - NCKeychain().setPersonalFilesOnly(account: self.appDelegate.account, value: !personalFilesOnly) - self.reloadDataSource() - } + // MARK: - Empty - let showDescriptionKeychain = NCKeychain().showDescription - let showDescription = UIAction(title: NSLocalizedString("_show_description_", comment: ""), image: UIImage(systemName: "list.dash.header.rectangle"), attributes: richWorkspaceText == nil ? .disabled : [], state: showDescriptionKeychain && richWorkspaceText != nil ? .on : .off) { _ in - NCKeychain().showDescription = !showDescriptionKeychain - self.collectionView.reloadData() - self.setNavigationRightItems() - } - showDescription.subtitle = richWorkspaceText == nil ? NSLocalizedString("_no_description_available_", comment: "") : "" + func emptyDataSetView(_ view: NCEmptyView) { - if layoutKey == NCGlobal.shared.layoutViewRecent { - return [select] + self.emptyDataSet?.setOffset(getHeaderHeight()) + if isSearchingMode { + view.emptyImage.image = UIImage(named: "search")?.image(color: .gray, size: UIScreen.main.bounds.width) + if self.dataSourceTask?.state == .running { + view.emptyTitle.text = NSLocalizedString("_search_in_progress_", comment: "") } else { - var additionalSubmenu = UIMenu() - if layoutKey == NCGlobal.shared.layoutViewFiles { - additionalSubmenu = UIMenu(title: "", options: .displayInline, children: [foldersOnTop, personalFilesOnlyAction, showDescription]) - } else { - additionalSubmenu = UIMenu(title: "", options: .displayInline, children: [foldersOnTop, showDescription]) - } - return [select, viewStyleSubmenu, sortSubmenu, additionalSubmenu] + view.emptyTitle.text = NSLocalizedString("_search_no_record_found_", comment: "") } - } - - if isEditMode { - tabBarSelect.update(selectOcId: selectOcId, metadatas: getSelectedMetadatas(), userId: appDelegate.userId) - tabBarSelect.show() - let select = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .done) { - self.setEditMode(false) - } - navigationItem.rightBarButtonItems = [select] + view.emptyDescription.text = NSLocalizedString("_search_instruction_", comment: "") + } else if self.dataSourceTask?.state == .running { + view.emptyImage.image = UIImage(named: "networkInProgress")?.image(color: .gray, size: UIScreen.main.bounds.width) + view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "") + view.emptyDescription.text = "" } else { - tabBarSelect.hide() - if navigationItem.rightBarButtonItems == nil || enableMenu { - let menuButton = UIBarButtonItem(image: .init(systemName: "ellipsis.circle"), menu: UIMenu(children: createMenuActions())) - if layoutKey == NCGlobal.shared.layoutViewFiles { - let notification = UIBarButtonItem(image: .init(systemName: "bell"), style: .plain) { - if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { - self.navigationController?.pushViewController(viewController, animated: true) - } - } - navigationItem.rightBarButtonItems = [menuButton, notification] - } else { - navigationItem.rightBarButtonItems = [menuButton] - } + if serverUrl.isEmpty { + view.emptyImage.image = emptyImage + view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "") + view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "") } else { - navigationItem.rightBarButtonItems?.first?.menu = navigationItem.rightBarButtonItems?.first?.menu?.replacingChildren(createMenuActions()) + view.emptyImage.image = UIImage(named: "folder_nmcloud") + view.emptyTitle.text = NSLocalizedString("_files_no_files_", comment: "") + view.emptyDescription.text = NSLocalizedString("_no_file_pull_down_", comment: "") } } - // fix, if the tabbar was hidden before the update, set it in hidden - if isTabBarHidden, isTabBarSelectHidden { - self.tabBarController?.tabBar.isHidden = true - } - } - - func getNavigationTitle() -> String { - - let activeAccount = NCManageDatabase.shared.getActiveAccount() - guard let userAlias = activeAccount?.alias, !userAlias.isEmpty else { - return NCBrandOptions.shared.brand - } - return userAlias } // MARK: - SEARCH @@ -1084,7 +995,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS appDelegate.activeMetadata = metadata if let viewController = appDelegate.listFilesVC[serverUrlPush], viewController.isViewLoaded { - navigationController?.pushViewController(viewController, animated: true) + pushViewController(viewController: viewController) } else { if let viewController: NCFiles = UIStoryboard(name: "NCFiles", bundle: nil).instantiateInitialViewController() as? NCFiles { viewController.isRoot = false @@ -1092,7 +1003,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS viewController.titlePreviusFolder = navigationItem.title viewController.titleCurrentFolder = metadata.fileNameView appDelegate.listFilesVC[serverUrlPush] = viewController - navigationController?.pushViewController(viewController, animated: true) + pushViewController(viewController: viewController) } } } @@ -1116,15 +1027,20 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return } appDelegate.activeMetadata = metadata + let metadataSourceForAllSections = dataSource.getMetadataSourceForAllSections() if isEditMode { if let index = selectOcId.firstIndex(of: metadata.ocId) { selectOcId.remove(at: index) + selectIndexPaths.removeAll(where: { $0 == indexPath }) } else { selectOcId.append(metadata.ocId) + selectIndexPaths.append(indexPath) } collectionView.reloadItems(at: [indexPath]) - tabBarSelect.update(selectOcId: selectOcId, metadatas: getSelectedMetadatas(), userId: appDelegate.userId) + + self.setNavigationRightItems() + return } @@ -1152,7 +1068,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { if !metadata.isDirectoryE2EE && (metadata.isImage || metadata.isAudioOrVideo) { var metadatas: [tableMetadata] = [] - for metadata in dataSource.getMetadataSourceForAllSections() { + for metadata in metadataSourceForAllSections { if metadata.isImage || metadata.isAudioOrVideo { metadatas.append(metadata) } @@ -1175,6 +1091,13 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { } } + func pushViewController(viewController: UIViewController) { + if pushed { return } + + pushed = true + navigationController?.pushViewController(viewController, animated: true) + } + func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return nil } @@ -1195,7 +1118,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { }, actionProvider: { _ in - return NCContextMenu().viewMenu(ocId: metadata.ocId, viewController: self, image: image) + return NCContextMenu().viewMenu(ocId: metadata.ocId, indexPath: indexPath, viewController: self, image: image) }) } @@ -1275,14 +1198,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } } } - - // Avatar - if !metadata.ownerId.isEmpty, - metadata.ownerId != appDelegate.userId, - appDelegate.account == metadata.account { - let fileName = metadata.userBaseUrl + "-" + metadata.ownerId + ".png" - NCNetworking.shared.downloadAvatar(user: metadata.ownerId, dispalyName: metadata.ownerDisplayName, fileName: fileName, cell: cell, view: collectionView, cellImageView: cell.fileAvatarImageView) - } } func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { @@ -1299,7 +1214,11 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return dataSource.numberOfItemsInSection(section) + + let numberItems = dataSource.numberOfItemsInSection(section) + emptyDataSet?.numberOfItemsInSection(numberItems, section: section) + + return numberItems } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { @@ -1310,6 +1229,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if layoutForView?.layout == NCGlobal.shared.layoutList { guard let listCell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell else { return NCListCell() } listCell.listCellDelegate = self + // listCell.delegate = self cell = listCell } else { // LAYOUT GRID @@ -1329,7 +1249,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { var isShare = false var isMounted = false var a11yValues: [String] = [] - + let shares = NCManageDatabase.shared.getTableShares(metadata: metadata) if metadataFolder != nil { isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder!.permissions.contains(NCGlobal.shared.permissionShared) isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder!.permissions.contains(NCGlobal.shared.permissionMounted) @@ -1356,7 +1276,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { cell.fileTitleLabel?.text = metadata.fileName cell.fileTitleLabel?.lineBreakMode = .byTruncatingTail if metadata.name == NCGlobal.shared.appName { - cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) + cell.fileInfoLabel?.text = utility.dateDiff(metadata.date as Date) + " · " + utilityFileSystem.transformedSize(metadata.size) } else { cell.fileInfoLabel?.text = metadata.subline } @@ -1385,7 +1305,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { cell.filePreviewImageView?.image = NCImageCache.images.folderEncrypted } else if isShare { cell.filePreviewImageView?.image = NCImageCache.images.folderSharedWithMe - } else if !metadata.shareType.isEmpty { + } else if (!metadata.shareType.isEmpty || !(shares.share?.isEmpty ?? true) || (shares.firstShareLink != nil)) { metadata.shareType.contains(3) ? (cell.filePreviewImageView?.image = NCImageCache.images.folderPublic) : (cell.filePreviewImageView?.image = NCImageCache.images.folderSharedWithMe) @@ -1432,14 +1352,24 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if isShare { cell.fileSharedImage?.image = NCImageCache.images.shared } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(3) ? - (cell.fileSharedImage?.image = NCImageCache.images.shareByLink) : (cell.fileSharedImage?.image = NCImageCache.images.shared) } else { - cell.fileSharedImage?.image = NCImageCache.images.canShare + cell.fileSharedImage?.image = NCImageCache.images.canShare.image(color: NCBrandColor.shared.gray60, size: 50) + cell.fileSharedLabel?.text = "" } - if appDelegate.account != metadata.account { - cell.fileSharedImage?.image = NCImageCache.images.shared + cell.fileSharedLabel?.text = NSLocalizedString("_shared_", comment: "") + cell.fileSharedLabel?.textColor = NCBrandColor.shared.customer + if (!metadata.shareType.isEmpty || !(shares.share?.isEmpty ?? true) || (shares.firstShareLink != nil)){ + cell.fileSharedImage?.image = cell.fileSharedImage?.image?.imageColor(NCBrandColor.shared.customer) + } else { + cell.fileSharedImage?.image = NCImageCache.images.canShare.image(color: NCBrandColor.shared.gray60, size: 50) + cell.fileSharedLabel?.text = "" + } + + if metadata.permissions.contains("S"), (metadata.permissions.range(of: "S") != nil) { + cell.fileSharedImage?.image = NCImageCache.images.sharedWithMe + cell.fileSharedLabel?.text = NSLocalizedString("_recieved_", comment: "") + cell.fileSharedLabel?.textColor = NCBrandColor.shared.notificationAction } // Button More @@ -1494,6 +1424,15 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } } + // Hide lines on iPhone + if !UIDevice.current.orientation.isLandscape && UIDevice.current.model.hasPrefix("iPhone") { + cell.cellSeparatorView?.isHidden = true + cell.fileSharedLabel?.isHidden = true + }else{ + cell.cellSeparatorView?.isHidden = false + cell.fileSharedLabel?.isHidden = false + } + // Separator if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { cell.cellSeparatorView?.isHidden = true @@ -1517,18 +1456,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { // Accessibility cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.fileInfoLabel?.text ?? "") + (cell.fileSubinfoLabel?.text ?? ""), value: a11yValues.joined(separator: ", ")) - // Color string find in search - - cell.fileTitleLabel?.textColor = .label - cell.fileTitleLabel?.font = .systemFont(ofSize: 15) - - if isSearchingMode, let literalSearch = self.literalSearch, let title = cell.fileTitleLabel?.text { - let longestWordRange = (title.lowercased() as NSString).range(of: literalSearch) - let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) - attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) - cell.fileTitleLabel?.attributedText = attributedString - } - // Add TAGS cell.setTags(tags: Array(metadata.tags)) @@ -1548,58 +1475,21 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if kind == UICollectionView.elementKindSectionHeader { - if dataSource.getMetadataSourceForAllSections().isEmpty { - - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderEmptyData", for: indexPath) as? NCSectionHeaderEmptyData else { return NCSectionHeaderEmptyData() } - header.delegate = self - - if !isSearchingMode, headerMenuTransferView, let ocId = NCNetworking.shared.transferInForegorund?.ocId { - let text = String(format: NSLocalizedString("_upload_foreground_msg_", comment: ""), NCBrandOptions.shared.brand) - header.setViewTransfer(isHidden: false, ocId: ocId, text: text, progress: NCNetworking.shared.transferInForegorund?.progress) - } else { - header.setViewTransfer(isHidden: true) - } + if indexPath.section == 0 { - if isSearchingMode { - header.emptyImage.image = UIImage(named: "search")?.image(color: .gray, size: UIScreen.main.bounds.width) - if self.dataSourceTask?.state == .running { - header.emptyTitle.text = NSLocalizedString("_search_in_progress_", comment: "") - } else { - header.emptyTitle.text = NSLocalizedString("_search_no_record_found_", comment: "") - } - header.emptyDescription.text = NSLocalizedString("_search_instruction_", comment: "") - } else if self.dataSourceTask?.state == .running { - header.emptyImage.image = UIImage(named: "networkInProgress")?.image(color: .gray, size: UIScreen.main.bounds.width) - header.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "") - header.emptyDescription.text = "" - } else { - if serverUrl.isEmpty { - header.emptyImage.image = emptyImage - header.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "") - header.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "") - } else { - header.emptyImage.image = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width) - header.emptyTitle.text = NSLocalizedString("_files_no_files_", comment: "") - header.emptyDescription.text = NSLocalizedString("_no_file_pull_down_", comment: "") - } - } - - return header - - } else if indexPath.section == 0 { - - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as? NCSectionHeaderMenu else { return NCSectionHeaderMenu() } + guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as? NCSectionHeaderMenu else { return UICollectionReusableView() } let (_, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: indexPath.section) self.headerMenu = header header.delegate = self - if !isSearchingMode, headerMenuTransferView, let ocId = NCNetworking.shared.transferInForegorund?.ocId { - let text = String(format: NSLocalizedString("_upload_foreground_msg_", comment: ""), NCBrandOptions.shared.brand) - header.setViewTransfer(isHidden: false, ocId: ocId, text: text, progress: NCNetworking.shared.transferInForegorund?.progress) + if headerMenuButtonsView { + header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty) + header.setButtonsView(height: NCGlobal.shared.heightButtonsView) + header.setSortedTitle(layoutForView?.titleButtonHeader ?? "") } else { - header.setViewTransfer(isHidden: true) + header.setButtonsView(height: 0) } header.setRichWorkspaceHeight(heightHeaderRichWorkspace) @@ -1617,7 +1507,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } else { - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as? NCSectionHeader else { return NCSectionHeader() } + guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as? NCSectionHeader else { return UICollectionReusableView() } header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath) header.labelSection.textColor = .label @@ -1627,7 +1517,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } else { - guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as? NCSectionFooter else { return NCSectionFooter() } + guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as? NCSectionFooter else { return UICollectionReusableView() } let sections = dataSource.numberOfSections() let section = indexPath.section let metadataForSection = self.dataSource.getMetadataForSection(indexPath.section) @@ -1640,6 +1530,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { footer.setTitleLabel("") footer.setButtonText(NSLocalizedString("_show_more_results_", comment: "")) + footer.buttonSection.setTitleColor(NCBrandColor.shared.customer, for: .normal) footer.separatorIsHidden(true) footer.buttonIsHidden(true) footer.hideActivityIndicatorSection() @@ -1677,28 +1568,19 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout { - func isHeaderMenuTransferViewEnabled() -> Bool { - if headerMenuTransferView, let metadata = NCManageDatabase.shared.getMetadataFromOcId(NCNetworking.shared.transferInForegorund?.ocId), metadata.isTransferInForeground { - return true - } - return false - } - func getHeaderHeight() -> CGFloat { + var size: CGFloat = 0 - if isHeaderMenuTransferViewEnabled() { - if !isSearchingMode { - size += NCGlobal.shared.heightHeaderTransfer - } - } else { - NCNetworking.shared.transferInForegorund = nil + if headerMenuButtonsView { + size += NCGlobal.shared.heightButtonsView } return size } func getHeaderHeight(section: Int) -> (heightHeaderCommands: CGFloat, heightHeaderRichWorkspace: CGFloat, heightHeaderSection: CGFloat) { + var headerRichWorkspace: CGFloat = 0 if let richWorkspaceText = richWorkspaceText, showDescription { @@ -1720,17 +1602,15 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout { } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { - var height: CGFloat = 0 - if dataSource.getMetadataSourceForAllSections().isEmpty { - height = NCGlobal.shared.getHeightHeaderEmptyData(view: view, portraitOffset: emptyDataPortaitOffset, landscapeOffset: emptyDataLandscapeOffset, isHeaderMenuTransferViewEnabled: isHeaderMenuTransferViewEnabled()) - } else { - let (heightHeaderCommands, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section) - height = heightHeaderCommands + heightHeaderRichWorkspace + heightHeaderSection - } - return CGSize(width: collectionView.frame.width, height: height) + + let (heightHeaderCommands, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section) + let heightHeader = heightHeaderCommands + heightHeaderRichWorkspace + heightHeaderSection + + return CGSize(width: collectionView.frame.width, height: heightHeader) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { + let sections = dataSource.numberOfSections() let metadataForSection = self.dataSource.getMetadataForSection(section) let isPaginated = metadataForSection?.lastSearchResult?.isPaginated ?? false From ae2134b0f4e697ab9218f86d42ee756d8989b058 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:55:06 +0530 Subject: [PATCH 02/12] NMC 2172 - Dashboard header view menu selection issue fix --- iOSClient/Main/Collection Common/Cell/NCListCell.xib | 3 +-- .../Main/Collection Common/NCCollectionViewCommon.swift | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.xib b/iOSClient/Main/Collection Common/Cell/NCListCell.xib index 079e0d07b5..c806533c74 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.xib +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.xib @@ -32,7 +32,7 @@ - + @@ -158,7 +158,6 @@ - diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 8e151bdfc7..3b78bc83fb 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1481,6 +1481,14 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { let (_, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: indexPath.section) self.headerMenu = header + self.headerMenu?.setViewTransfer(isHidden: true) + if layoutForView?.layout == NCGlobal.shared.layoutGrid { + header.setImageSwitchList() + header.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "") + } else { + header.setImageSwitchGrid() + header.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "") + } header.delegate = self From bba4bc5f28ddcacd8d558ef59e5658a23fec2bfc Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:54:16 +0530 Subject: [PATCH 03/12] NMC 2172 - Dashboard header color change --- .../Section Header Footer/NCSectionHeaderMenu.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift index 16c137e2e2..639af3a500 100644 --- a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift +++ b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift @@ -54,6 +54,12 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate backgroundColor = .clear + buttonSwitch.setImage(UIImage(systemName: "list.bullet")!.image(color: .systemGray, size: 25), for: .normal) + + buttonOrder.setTitle("", for: .normal) + buttonOrder.setTitleColor(NCBrandColor.shared.brand, for: .normal) + buttonMore.setImage(UIImage(named: "more")!.image(color: .systemGray, size: 25), for: .normal) + // Gradient gradient.startPoint = CGPoint(x: 0, y: 0.8) gradient.endPoint = CGPoint(x: 0, y: 0.9) From 5a7299613045b7338e874c9db061d57df46c030f Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:18:54 +0530 Subject: [PATCH 04/12] NMC 2172 - Dashboard sort menu icon color change --- .../NCSectionHeaderMenu.swift | 46 +++++++++++++++++-- iOSClient/Menu/NCSortMenu.swift | 14 +++--- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift index 639af3a500..7d0ea21ba5 100644 --- a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift +++ b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift @@ -54,11 +54,11 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate backgroundColor = .clear - buttonSwitch.setImage(UIImage(systemName: "list.bullet")!.image(color: .systemGray, size: 25), for: .normal) + buttonSwitch.setImage(UIImage(systemName: "list.bullet")!.image(color: NCBrandColor.shared.iconColor, size: 25), for: .normal) buttonOrder.setTitle("", for: .normal) buttonOrder.setTitleColor(NCBrandColor.shared.brand, for: .normal) - buttonMore.setImage(UIImage(named: "more")!.image(color: .systemGray, size: 25), for: .normal) + buttonMore.setImage(UIImage(named: "more")!.image(color: NCBrandColor.shared.iconColor, size: 25), for: .normal) // Gradient gradient.startPoint = CGPoint(x: 0, y: 0.8) @@ -106,6 +106,46 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate setInterfaceColor() } + // MARK: - View + + func setStatusButtonsView(enable: Bool) { + + buttonSwitch.isEnabled = enable + buttonOrder.isEnabled = enable + buttonMore.isEnabled = enable + } + + func buttonMoreIsHidden(_ isHidden: Bool) { + + buttonMore.isHidden = isHidden + } + + func setImageSwitchList() { + + buttonSwitch.setImage(UIImage(systemName: "list.bullet")!.image(color: NCBrandColor.shared.iconColor, width: 20, height: 15), for: .normal) + } + + func setImageSwitchGrid() { + + buttonSwitch.setImage(UIImage(systemName: "square.grid.2x2")!.image(color: NCBrandColor.shared.iconColor, size: 20), for: .normal) + } + + func setButtonsView(height: CGFloat) { + + viewButtonsViewHeightConstraint.constant = height + if height == 0 { + viewButtonsView.isHidden = true + } else { + viewButtonsView.isHidden = false + } + } + + func setSortedTitle(_ title: String) { + + let title = NSLocalizedString(title, comment: "") + buttonOrder.setTitle(title, for: .normal) + } + // MARK: - RichWorkspace func setRichWorkspaceHeight(_ size: CGFloat) { @@ -247,7 +287,7 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate { super.awakeFromNib() self.backgroundColor = UIColor.clear - labelSection.textColor = UIColor.systemGray + labelSection.textColor = UIColorNCBrandColor.shared.iconColor labelSection.text = "" separator.backgroundColor = .separator diff --git a/iOSClient/Menu/NCSortMenu.swift b/iOSClient/Menu/NCSortMenu.swift index df3941aff6..43580c169f 100644 --- a/iOSClient/Menu/NCSortMenu.swift +++ b/iOSClient/Menu/NCSortMenu.swift @@ -47,10 +47,10 @@ class NCSortMenu: NSObject { if layoutForView.ascending { title = NSLocalizedString("_order_by_name_z_a_", comment: "") - icon = UIImage(named: "sortFileNameZA")!.image(color: UIColor.systemGray, size: 50) + icon = UIImage(named: "sortFileNameZA")!.image(color: NCBrandColor.shared.iconColor, size: 50) } else { title = NSLocalizedString("_order_by_name_a_z_", comment: "") - icon = UIImage(named: "sortFileNameAZ")!.image(color: UIColor.systemGray, size: 50) + icon = UIImage(named: "sortFileNameAZ")!.image(color: NCBrandColor.shared.iconColor, size: 50) } actions.append( @@ -69,10 +69,10 @@ class NCSortMenu: NSObject { if layoutForView.ascending { title = NSLocalizedString("_order_by_date_more_recent_", comment: "") - icon = UIImage(named: "sortDateMoreRecent")!.image(color: UIColor.systemGray, size: 50) + icon = UIImage(named: "sortDateMoreRecent")!.image(color: NCBrandColor.shared.iconColor, size: 50) } else { title = NSLocalizedString("_order_by_date_less_recent_", comment: "") - icon = UIImage(named: "sortDateLessRecent")!.image(color: UIColor.systemGray, size: 50) + icon = UIImage(named: "sortDateLessRecent")!.image(color: NCBrandColor.shared.iconColor, size: 50) } actions.append( @@ -91,10 +91,10 @@ class NCSortMenu: NSObject { if layoutForView.ascending { title = NSLocalizedString("_order_by_size_largest_", comment: "") - icon = UIImage(named: "sortLargest")!.image(color: UIColor.systemGray, size: 50) + icon = UIImage(named: "sortLargest")!.image(color: NCBrandColor.shared.iconColor, size: 50) } else { title = NSLocalizedString("_order_by_size_smallest_", comment: "") - icon = UIImage(named: "sortSmallest")!.image(color: UIColor.systemGray, size: 50) + icon = UIImage(named: "sortSmallest")!.image(color: NCBrandColor.shared.iconColor, size: 50) } actions.append( @@ -115,7 +115,7 @@ class NCSortMenu: NSObject { actions.append( NCMenuAction( title: NSLocalizedString("_directory_on_top_no_", comment: ""), - icon: UIImage(named: "foldersOnTop")!.image(color: UIColor.systemGray, size: 50), + icon: UIImage(named: "foldersOnTop")!.image(color: NCBrandColor.shared.iconColor, size: 50), selected: layoutForView.directoryOnTop, on: layoutForView.directoryOnTop, action: { _ in From e0e6fe2e0be7cbca1398d4c0c080fcff411f00c6 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:41:24 +0530 Subject: [PATCH 05/12] NMC 2172 - dashboard section header color update --- .../Section Header Footer/NCSectionHeaderMenu.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift index 7d0ea21ba5..93fdb46e23 100644 --- a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift +++ b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift @@ -287,7 +287,7 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate { super.awakeFromNib() self.backgroundColor = UIColor.clear - labelSection.textColor = UIColorNCBrandColor.shared.iconColor + labelSection.textColor = NCBrandColor.shared.iconColor labelSection.text = "" separator.backgroundColor = .separator From dbcfb010ed5859d102a9c585eb311d7829f518ec Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Mon, 25 Dec 2023 17:12:15 +0530 Subject: [PATCH 06/12] NMC 2172 - Theming changes for NMC --- iOSClient/Files/NCFiles.swift | 2 +- iOSClient/Groupfolders/NCGroupfolders.swift | 2 +- iOSClient/Offline/NCOffline.swift | 2 +- iOSClient/Viewer/NCViewerProviderContextMenu.swift | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iOSClient/Files/NCFiles.swift b/iOSClient/Files/NCFiles.swift index a9574023c8..669d46ee88 100644 --- a/iOSClient/Files/NCFiles.swift +++ b/iOSClient/Files/NCFiles.swift @@ -38,7 +38,7 @@ class NCFiles: NCCollectionViewCommon { enableSearchBar = true headerRichWorkspaceDisable = false headerMenuTransferView = true - emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width) + emptyImage = UIImage(named: "folder") emptyTitle = "_files_no_files_" emptyDescription = "_no_file_pull_down_" } diff --git a/iOSClient/Groupfolders/NCGroupfolders.swift b/iOSClient/Groupfolders/NCGroupfolders.swift index 48ff34195e..834d95c623 100644 --- a/iOSClient/Groupfolders/NCGroupfolders.swift +++ b/iOSClient/Groupfolders/NCGroupfolders.swift @@ -33,7 +33,7 @@ class NCGroupfolders: NCCollectionViewCommon { layoutKey = NCGlobal.shared.layoutViewGroupfolders enableSearchBar = false headerRichWorkspaceDisable = true - emptyImage = UIImage(named: "folder_group")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width) + emptyImage = UIImage(named: "folder_group") emptyTitle = "_files_no_files_" emptyDescription = "_tutorial_groupfolders_view_" } diff --git a/iOSClient/Offline/NCOffline.swift b/iOSClient/Offline/NCOffline.swift index 0e23ab2960..b8ad88beba 100644 --- a/iOSClient/Offline/NCOffline.swift +++ b/iOSClient/Offline/NCOffline.swift @@ -33,7 +33,7 @@ class NCOffline: NCCollectionViewCommon { layoutKey = NCGlobal.shared.layoutViewOffline enableSearchBar = false headerRichWorkspaceDisable = true - emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width) + emptyImage = UIImage(named: "folder") emptyTitle = "_files_no_files_" emptyDescription = "_tutorial_offline_view_" emptyDataPortaitOffset = 30 diff --git a/iOSClient/Viewer/NCViewerProviderContextMenu.swift b/iOSClient/Viewer/NCViewerProviderContextMenu.swift index 8f87999690..d8ac115ca6 100644 --- a/iOSClient/Viewer/NCViewerProviderContextMenu.swift +++ b/iOSClient/Viewer/NCViewerProviderContextMenu.swift @@ -51,10 +51,10 @@ class NCViewerProviderContextMenu: UIViewController { if metadata.directory { - var imageFolder = UIImage(named: "folder")!.image(color: NCBrandColor.shared.brandElement, size: sizeIcon * 2) + var imageFolder = UIImage(named: "folder")! if let image = self.image { - imageFolder = image.image(color: NCBrandColor.shared.brandElement, size: sizeIcon * 2) + imageFolder = image } imageView.image = imageFolder.colorizeFolder(metadata: metadata) From 8da61610899376fed0a56f7491a5bbbf919f6a32 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:23:03 +0530 Subject: [PATCH 07/12] NMC 2172 - File upload transfer header view added --- .../NCCollectionViewCommon.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 3b78bc83fb..876e49a704 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1491,6 +1491,13 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } header.delegate = self + + if !isSearchingMode, headerMenuTransferView, let ocId = NCNetworking.shared.transferInForegorund?.ocId { + let text = String(format: NSLocalizedString("_upload_foreground_msg_", comment: ""), NCBrandOptions.shared.brand) + header.setViewTransfer(isHidden: false, ocId: ocId, text: text, progress: NCNetworking.shared.transferInForegorund?.progress) + } else { + header.setViewTransfer(isHidden: true) + } if headerMenuButtonsView { header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty) @@ -1579,7 +1586,17 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout { func getHeaderHeight() -> CGFloat { var size: CGFloat = 0 - + // transfer in progress + if headerMenuTransferView, + let metadata = NCManageDatabase.shared.getMetadataFromOcId(NCNetworking.shared.transferInForegorund?.ocId), + metadata.isTransferInForeground { + if !isSearchingMode { + size += NCGlobal.shared.heightHeaderTransfer + } + } else { + NCNetworking.shared.transferInForegorund = nil + } + if headerMenuButtonsView { size += NCGlobal.shared.heightButtonsView } From 9b370854d2c8c5ee736d9c1bf0b9ca35236cb103 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:54:16 +0530 Subject: [PATCH 08/12] NMC 2172 - Selection icon added for grid view --- iOSClient/Main/Collection Common/Cell/NCGridCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 7198938b74..ed521b55cc 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -192,7 +192,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto imageSelect.image = NCImageCache.images.checkedYes imageVisualEffect.isHidden = false } else { - imageSelect.isHidden = true + imageSelect.image = NCImageCache.images.checkedNo imageVisualEffect.isHidden = true } } From 63833cb15f302ce92b59d053c2b28fd2d252c1a4 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 31 Jan 2024 12:22:55 +0530 Subject: [PATCH 09/12] NMC 2172 - NMC 2401 Multi Selection removed for encrypted folder --- iOSClient/Main/Collection Common/Cell/NCGridCell.swift | 2 +- iOSClient/Main/Collection Common/Cell/NCListCell.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index ed521b55cc..71b3326370 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -176,7 +176,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func selected(_ status: Bool) { - guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId), !metadata.isInTransfer else { + guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId), !metadata.isInTransfer, !metadata.e2eEncrypted else { imageSelect.isHidden = true imageVisualEffect.isHidden = true return diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 21885bc2bf..ffd9dc3e97 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -246,7 +246,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func selected(_ status: Bool) { - guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId), !metadata.isInTransfer else { + guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId), !metadata.isInTransfer, !metadata.e2eEncrypted else { backgroundView = nil separator.isHidden = false return From 2431fde2763e8acf62c15feb98f15e4b454be41a Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:06:55 +0530 Subject: [PATCH 10/12] NMC 2172 - Conflict resolved after NC 5.2.2 (Update UI Revert from NC) --- .../Collection Common/Cell/NCListCell.swift | 18 +- .../Collection Common/Cell/NCListCell.xib | 19 +- .../NCCollectionViewCommon.swift | 15 +- .../NCSectionHeaderMenu.swift | 20 +- .../NCSectionHeaderMenu.xib | 206 ++++++++++++------ 5 files changed, 191 insertions(+), 87 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index ffd9dc3e97..4ec2294109 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -42,13 +42,13 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var labelShared: UILabel! @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint! @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! - @IBOutlet weak var infoTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var subInfoTrailingConstraint: NSLayoutConstraint! private var objectId = "" private var user = "" var indexPath = IndexPath() - weak var delegate: NCListCellDelegate? + weak var listCellDelegate: NCListCellDelegate? var namedButtonMore = "" var fileAvatarImageView: UIImageView? { @@ -166,19 +166,19 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } @IBAction func touchUpInsideShare(_ sender: Any) { - delegate?.tapShareListItem(with: objectId, indexPath: indexPath, sender: sender) + listCellDelegate?.tapShareListItem(with: objectId, indexPath: indexPath, sender: sender) } @IBAction func touchUpInsideMore(_ sender: Any) { - delegate?.tapMoreListItem(with: objectId, namedButtonMore: namedButtonMore, image: imageItem.image, indexPath: indexPath, sender: sender) + listCellDelegate?.tapMoreListItem(with: objectId, namedButtonMore: namedButtonMore, image: imageItem.image, indexPath: indexPath, sender: sender) } @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) { - delegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, indexPath: indexPath, gestureRecognizer: gestureRecognizer) + listCellDelegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, indexPath: indexPath, gestureRecognizer: gestureRecognizer) } @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) { - delegate?.longPressListItem(with: objectId, indexPath: indexPath, gestureRecognizer: gestureRecognizer) + listCellDelegate?.longPressListItem(with: objectId, indexPath: indexPath, gestureRecognizer: gestureRecognizer) } fileprivate func setA11yActions() { @@ -196,11 +196,11 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func titleInfoTrailingFull() { - infoTrailingConstraint.constant = 10 + subInfoTrailingConstraint.constant = 10 } func titleInfoTrailingDefault() { - infoTrailingConstraint.constant = 90 + subInfoTrailingConstraint.constant = 90 } func setButtonMore(named: String, image: UIImage) { @@ -276,7 +276,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func writeInfoDateSize(date: NSDate, size: Int64) { - labelInfo.text = NCUtility().dateDiff(date as Date) + labelInfo.text = NCUtility().dateDiff(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) labelSubinfo.text = " · " + NCUtilityFileSystem().transformedSize(size) } diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.xib b/iOSClient/Main/Collection Common/Cell/NCListCell.xib index c806533c74..a9b542e428 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.xib +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.xib @@ -1,9 +1,9 @@ - + - + @@ -59,7 +59,13 @@ + diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 876e49a704..149bd09aba 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -75,6 +75,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS var titlePreviusFolder: String? var enableSearchBar: Bool = false var headerMenuTransferView = false + var headerMenuButtonsView: Bool = true var headerRichWorkspaceDisable: Bool = false var emptyImage: UIImage? var emptyTitle: String = "" @@ -173,7 +174,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS // Deselect items when back to previous view controller if isEditMode { - self.tapSelect() + self.toggleSelect() } appDelegate.activeViewController = self @@ -748,6 +749,18 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS func accountRequestAddAccount() { appDelegate.openLogin(viewController: self, selector: NCGlobal.shared.introLogin, openLoginWeb: false) } + + func tapButtonSwitch(_ sender: Any) { + + guard isTransitioning == false else { return } + isTransitioning = true + + if layoutForView?.layout == NCGlobal.shared.layoutGrid { + onListSelected() + } else { + onGridSelected() + } + } func tapButtonOrder(_ sender: Any) { diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift index 93fdb46e23..b048947042 100644 --- a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift +++ b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift @@ -26,6 +26,9 @@ import MarkdownKit class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate { + @IBOutlet weak var buttonSwitch: UIButton! + @IBOutlet weak var buttonOrder: UIButton! + @IBOutlet weak var buttonMore: UIButton! @IBOutlet weak var buttonTransfer: UIButton! @IBOutlet weak var imageButtonTransfer: UIImageView! @IBOutlet weak var labelTransfer: UILabel! @@ -34,10 +37,14 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate @IBOutlet weak var textViewRichWorkspace: UITextView! @IBOutlet weak var labelSection: UILabel! @IBOutlet weak var viewTransfer: UIView! + @IBOutlet weak var viewButtonsView: UIView! + @IBOutlet weak var viewSeparator: UIView! @IBOutlet weak var viewRichWorkspace: UIView! @IBOutlet weak var viewSection: UIView! @IBOutlet weak var viewTransferHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var viewButtonsViewHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var viewSeparatorHeightConstraint: NSLayoutConstraint! @IBOutlet weak var viewRichWorkspaceHeightConstraint: NSLayoutConstraint! @IBOutlet weak var viewSectionHeightConstraint: NSLayoutConstraint! @IBOutlet weak var transferSeparatorBottomHeightConstraint: NSLayoutConstraint! @@ -61,14 +68,17 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate buttonMore.setImage(UIImage(named: "more")!.image(color: NCBrandColor.shared.iconColor, size: 25), for: .normal) // Gradient - gradient.startPoint = CGPoint(x: 0, y: 0.8) - gradient.endPoint = CGPoint(x: 0, y: 0.9) + gradient.startPoint = CGPoint(x: 0, y: 0.50) + gradient.endPoint = CGPoint(x: 0, y: 1) viewRichWorkspace.layer.addSublayer(gradient) let tap = UITapGestureRecognizer(target: self, action: #selector(touchUpInsideViewRichWorkspace(_:))) tap.delegate = self viewRichWorkspace?.addGestureRecognizer(tap) + viewSeparatorHeightConstraint.constant = 0.5 + viewSeparator.backgroundColor = .separator + markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: .label) markdownParser.header.font = UIFont.systemFont(ofSize: 25) if let richWorkspaceText = richWorkspaceText { @@ -310,9 +320,9 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate { } if files > 1 { - filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " • " + utilityFileSystem.transformedSize(size) + filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + utilityFileSystem.transformedSize(size) } else if files == 1 { - filesText = "1 " + NSLocalizedString("_file_", comment: "") + " • " + utilityFileSystem.transformedSize(size) + filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + utilityFileSystem.transformedSize(size) } if foldersText.isEmpty { @@ -320,7 +330,7 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate { } else if filesText.isEmpty { labelSection.text = foldersText } else { - labelSection.text = foldersText + " • " + filesText + labelSection.text = foldersText + ", " + filesText } } diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.xib b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.xib index a0a1c8cbbc..5d206c1d2f 100644 --- a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.xib +++ b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.xib @@ -1,9 +1,9 @@ - + - + @@ -11,15 +11,69 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -27,72 +81,72 @@ - - - - - + + + + + - + - + - + - - + - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - + + + + - + - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + From 2b42623b326cc0904ab563acaa0fbdc908cbe72d Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:15:09 +0530 Subject: [PATCH 11/12] NMC 2172 - Account button removed from navigation --- .../NCCollectionViewCommon.swift | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 149bd09aba..c2204a406a 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -598,63 +598,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS navigationItem.title = titleCurrentFolder guard layoutKey == NCGlobal.shared.layoutViewFiles else { return } - - // PROFILE BUTTON - - let activeAccount = NCManageDatabase.shared.getActiveAccount() - - let image = utility.loadUserImage(for: appDelegate.user, displayName: activeAccount?.displayName, userBaseUrl: appDelegate) - - let button = AccountSwitcherButton(type: .custom) - button.setImage(image, for: .normal) - button.setImage(image, for: .highlighted) - button.semanticContentAttribute = .forceLeftToRight - button.sizeToFit() - - let accounts = NCManageDatabase.shared.getAllAccountOrderAlias() - - if !accounts.isEmpty, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account { - let accountActions: [UIAction] = accounts.map { account in - let image = utility.loadUserImage(for: account.user, displayName: account.displayName, userBaseUrl: account) - - var name: String = "" - var url: String = "" - - if account.alias.isEmpty { - name = account.displayName - url = (URL(string: account.urlBase)?.host ?? "") - } else { - name = account.alias - } - - let action = UIAction(title: name, image: image, state: account.active ? .on : .off) { _ in - if !account.active { - self.appDelegate.changeAccount(account.account, userProfile: nil) - } - } - - action.subtitle = url - - return action - } - - let addAccountAction = UIAction(title: NSLocalizedString("_add_account_", comment: ""), image: .init(systemName: "person.crop.circle.badge.plus")) { _ in - self.appDelegate.openLogin(viewController: self, selector: NCGlobal.shared.introLogin, openLoginWeb: false) - } - - let addAccountSubmenu = UIMenu(title: "", options: .displayInline, children: [addAccountAction]) - - let menu = UIMenu(children: accountActions + [addAccountSubmenu]) - - button.menu = menu - button.showsMenuAsPrimaryAction = true - - button.onMenuOpened = { - self.dismissTip() - } - } - - navigationItem.setLeftBarButton(UIBarButtonItem(customView: button), animated: true) navigationItem.leftItemsSupplementBackButton = true if titlePreviusFolder != nil { From 75b7a09249ecb9fdadd87c1ce7e2eb7bb034d8c0 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:50:17 +0530 Subject: [PATCH 12/12] NMC 2172 - Dashboard changes after nc 5.2 merge --- iOSClient/Favorites/NCFavorite.swift | 2 +- iOSClient/Main/Collection Common/Cell/NCListCell.swift | 4 ++-- ...ctionViewCommon+SwipeCollectionViewCellDelegate.swift | 2 +- .../Main/Collection Common/NCCollectionViewCommon.swift | 9 --------- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/iOSClient/Favorites/NCFavorite.swift b/iOSClient/Favorites/NCFavorite.swift index 6ab319a541..efa4804caf 100644 --- a/iOSClient/Favorites/NCFavorite.swift +++ b/iOSClient/Favorites/NCFavorite.swift @@ -31,7 +31,7 @@ class NCFavorite: NCCollectionViewCommon { titleCurrentFolder = NSLocalizedString("_favorites_", comment: "") layoutKey = NCGlobal.shared.layoutViewFavorite - enableSearchBar = true + enableSearchBar = false headerMenuButtonsView = true headerRichWorkspaceDisable = true emptyImage = UIImage(named: "star.fill")?.image(color: NCBrandColor.shared.yellowFavorite, size: UIScreen.main.bounds.width) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 4ec2294109..28505f7121 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -246,7 +246,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func selected(_ status: Bool) { - guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId), !metadata.isInTransfer, !metadata.e2eEncrypted else { + guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId), !metadata.isInTransfer else { backgroundView = nil separator.isHidden = false return @@ -277,7 +277,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto func writeInfoDateSize(date: NSDate, size: Int64) { labelInfo.text = NCUtility().dateDiff(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) - labelSubinfo.text = " · " + NCUtilityFileSystem().transformedSize(size) + labelSubinfo.text = "" } func setAccessibility(label: String, value: String) { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+SwipeCollectionViewCellDelegate.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+SwipeCollectionViewCellDelegate.swift index a9b5b77b97..11a580f6a3 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+SwipeCollectionViewCellDelegate.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+SwipeCollectionViewCellDelegate.swift @@ -39,7 +39,7 @@ extension NCCollectionViewCommon: SwipeCollectionViewCellDelegate { } } favoriteAction.backgroundColor = NCBrandColor.shared.yellowFavorite - favoriteAction.image = .init(systemName: metadata.favorite ? "star.slash.fill" : "star.fill") + favoriteAction.image = .init(systemName: "star.fill") favoriteAction.transitionDelegate = scaleTransition favoriteAction.hidesWhenSelected = true diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index c2204a406a..f811c0057d 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -596,15 +596,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS func setNavigationLeftItems() { navigationItem.title = titleCurrentFolder - - guard layoutKey == NCGlobal.shared.layoutViewFiles else { return } - navigationItem.leftItemsSupplementBackButton = true - - if titlePreviusFolder != nil { - navigationController?.navigationBar.topItem?.title = titlePreviusFolder - } - - navigationItem.title = titleCurrentFolder } func getNavigationTitle() -> String {