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..efa4804caf 100644 --- a/iOSClient/Favorites/NCFavorite.swift +++ b/iOSClient/Favorites/NCFavorite.swift @@ -32,6 +32,7 @@ class NCFavorite: NCCollectionViewCommon { titleCurrentFolder = NSLocalizedString("_favorites_", comment: "") layoutKey = NCGlobal.shared.layoutViewFavorite enableSearchBar = false + 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/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/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/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 7198938b74..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 @@ -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 } } diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index d27dc6aa09..28505f7121 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,12 +39,9 @@ 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! private var objectId = "" @@ -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 @@ -205,12 +196,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func titleInfoTrailingFull() { - titleTrailingConstraint.constant = 10 subInfoTrailingConstraint.constant = 10 } func titleInfoTrailingDefault() { - titleTrailingConstraint.constant = 90 subInfoTrailingConstraint.constant = 90 } @@ -287,52 +276,14 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func writeInfoDateSize(date: NSDate, size: Int64) { - labelInfo.text = NCUtility().dateDiff(date as Date) - labelSubinfo.text = " · " + NCUtilityFileSystem().transformedSize(size) + labelInfo.text = NCUtility().dateDiff(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) + labelSubinfo.text = "" } func setAccessibility(label: String, value: String) { 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..a9b542e428 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.xib +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.xib @@ -1,276 +1,191 @@ - + - + - - - + + - + - - + + - - + + - - + + - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - 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 6f2a824625..f811c0057d 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 @@ -71,12 +75,11 @@ 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 = "" var emptyDescription: String = "" - var emptyDataPortaitOffset: CGFloat = 0 - var emptyDataLandscapeOffset: CGFloat = -20 private var showDescription: Bool { !headerRichWorkspaceDisable && NCKeychain().showDescription @@ -91,7 +94,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 +116,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 +128,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 +140,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 +172,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.toggleSelect() } + + appDelegate.activeViewController = self layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: serverUrl) gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3) @@ -187,16 +187,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 +214,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() + + setNavigationLeftItems() + setNavigationRightItems() - override func viewDidDisappear(_ animated: Bool) { - super.viewDidDisappear(animated) + // FIXME: iPAD PDF landscape mode iOS 16 + DispatchQueue.main.async { + self.collectionView?.collectionViewLayout.invalidateLayout() + } + } - timerNotificationCenter?.invalidate() + 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 +262,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 +289,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 +299,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 +318,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,200 +595,46 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS // MARK: - Layout func setNavigationLeftItems() { - guard layoutKey == NCGlobal.shared.layoutViewFiles else { return } + navigationItem.title = titleCurrentFolder + } - // PROFILE BUTTON + func getNavigationTitle() -> String { 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) - self.setEditMode(false) - } - } - - 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 { - navigationController?.navigationBar.topItem?.title = titlePreviusFolder + guard let userAlias = activeAccount?.alias, !userAlias.isEmpty else { + return NCBrandOptions.shared.brand } - - navigationItem.title = titleCurrentFolder + return userAlias } - 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]) + // MARK: - Empty - 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" + func emptyDataSetView(_ view: NCEmptyView) { - 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]) - - 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 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() - } - - 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: "") : "" - - 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] - } - } - - 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) + view.emptyTitle.text = NSLocalizedString("_search_no_record_found_", comment: "") } - 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 @@ -837,6 +683,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) { @@ -1084,7 +942,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 +950,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 +974,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 +1015,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 +1038,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 +1065,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 +1145,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 +1161,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 +1176,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 +1196,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 +1223,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 +1252,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 +1299,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 +1371,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 +1403,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,53 +1422,23 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if kind == UICollectionView.elementKindSectionHeader { - if dataSource.getMetadataSourceForAllSections().isEmpty { + if indexPath.section == 0 { - 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 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 + 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 - + 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) @@ -1602,6 +1446,14 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { header.setViewTransfer(isHidden: true) } + if headerMenuButtonsView { + header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty) + header.setButtonsView(height: NCGlobal.shared.heightButtonsView) + header.setSortedTitle(layoutForView?.titleButtonHeader ?? "") + } else { + header.setButtonsView(height: 0) + } + header.setRichWorkspaceHeight(heightHeaderRichWorkspace) header.setRichWorkspaceText(richWorkspaceText) @@ -1617,7 +1469,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 +1479,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 +1492,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 +1530,29 @@ 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() { + 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 + } return size } func getHeaderHeight(section: Int) -> (heightHeaderCommands: CGFloat, heightHeaderRichWorkspace: CGFloat, heightHeaderSection: CGFloat) { + var headerRichWorkspace: CGFloat = 0 if let richWorkspaceText = richWorkspaceText, showDescription { @@ -1720,17 +1574,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 diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionHeaderMenu.swift index 16c137e2e2..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! @@ -54,15 +61,24 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate backgroundColor = .clear + 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: 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 { @@ -100,6 +116,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) { @@ -241,7 +297,7 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate { super.awakeFromNib() self.backgroundColor = UIColor.clear - labelSection.textColor = UIColor.systemGray + labelSection.textColor = NCBrandColor.shared.iconColor labelSection.text = "" separator.backgroundColor = .separator @@ -264,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 { @@ -274,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 @@ - - - - - + + + + + - + - + - + - - + - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - + + + + - + - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + 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 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)