Skip to content

[stable-6.6.0] NMC/2161 - Menu option theming #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: stable-6.6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; };
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
B52FAED52DA8F616001AB1BD /* NCSelectableNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52FAED42DA8F616001AB1BD /* NCSelectableNavigationView.swift */; };
C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
Expand Down Expand Up @@ -1330,6 +1333,8 @@
AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extension.swift"; sourceTree = "<group>"; };
AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = "<group>"; };
B52FAED42DA8F616001AB1BD /* NCSelectableNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSelectableNavigationView.swift; sourceTree = "<group>"; };
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2539,6 +2544,7 @@
F7603298252F0E550015A421 /* Collection Common */ = {
isa = PBXGroup;
children = (
B52FAED42DA8F616001AB1BD /* NCSelectableNavigationView.swift */,
F75FE06B2BB01D0D00A0EFEF /* Cell */,
F78ACD50219046AC0088454D /* Section Header Footer */,
F70D7C3525FFBF81002B9E34 /* NCCollectionViewCommon.swift */,
Expand Down Expand Up @@ -4838,6 +4844,7 @@
F343A4BB2A1E734600DDA874 /* Optional+Extension.swift in Sources */,
F76882232C0DD1E7001CF441 /* NCCapabilitiesModel.swift in Sources */,
F7D68FCC28CB9051009139F3 /* NCManageDatabase+DashboardWidget.swift in Sources */,
B52FAED52DA8F616001AB1BD /* NCSelectableNavigationView.swift in Sources */,
F76882292C0DD1E7001CF441 /* NCManageE2EEModel.swift in Sources */,
F799DF8B2C4B84EB003410B5 /* NCCollectionViewCommon+EndToEndInitialize.swift in Sources */,
AA8E041D2D300FDE00E7E89C /* NCShareNetworkingDelegate.swift in Sources */,
Expand Down
104 changes: 104 additions & 0 deletions iOSClient/Main/Collection Common/NCSelectableNavigationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//
// NCSelectableNavigationView.swift
// Nextcloud
//
// Created by Henrik Storch on 27.01.22.
// Copyright © 2022 Henrik Storch. All rights reserved.
//
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
// Author Henrik Storch <henrik.storch@nextcloud.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

import NextcloudKit
import Realm
import UIKit

extension RealmSwiftObject {
var primaryKeyValue: String? {
guard let primaryKeyName = self.objectSchema.primaryKeyProperty?.name else { return nil }
return value(forKey: primaryKeyName) as? String
}
}

public protocol NCSelectableViewTabBar {
var tabBarController: UITabBarController? { get }
var hostingController: UIViewController? { get }
}

protocol NCSelectableNavigationView: AnyObject {
var viewController: UIViewController { get }
var appDelegate: AppDelegate { get }
var selectableDataSource: [RealmSwiftObject] { get }
var collectionView: UICollectionView! { get set }
var isEditMode: Bool { get set }
var selectOcId: [String] { get set }
var selectIndexPaths: [IndexPath] { get set }
var titleCurrentFolder: String { get }
var navigationItem: UINavigationItem { get }
var navigationController: UINavigationController? { get }
var layoutKey: String { get }
var serverUrl: String { get }
var tabBarSelect: NCSelectableViewTabBar? { get set }

func reloadDataSource(withQueryDB: Bool)
func setNavigationLeftItems()
func setNavigationRightItems(enableMenu: Bool)
func createMenuActions() -> [NCMenuAction]

func toggleSelect(isOn: Bool?)
func onListSelected()
func onGridSelected()
}

extension NCSelectableNavigationView {
func setNavigationLeftItems() {}

func saveLayout(_ layoutForView: NCDBLayoutForView) {
NCManageDatabase.shared.setLayoutForView(layoutForView: layoutForView)
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource)
setNavigationRightItems(enableMenu: false)
}

/// If explicit `isOn` is not set, it will invert `isEditMode`
func toggleSelect(isOn: Bool? = nil) {
DispatchQueue.main.async {
self.isEditMode = isOn ?? !self.isEditMode
self.selectOcId.removeAll()
self.selectIndexPaths.removeAll()
self.setNavigationLeftItems()
self.setNavigationRightItems(enableMenu: true)
self.collectionView.reloadData()
}
}

func collectionViewSelectAll() {
selectOcId = selectableDataSource.compactMap({ $0.primaryKeyValue })
collectionView.reloadData()
setNavigationRightItems(enableMenu: false)
}

func tapNotification() {
if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
navigationController?.pushViewController(viewController, animated: true)
}
}
}

extension NCSelectableNavigationView where Self: UIViewController {
var viewController: UIViewController {
self
}
}
Loading