Skip to content

Commit ed23e58

Browse files
NMC 2611 - Theming customisation changes
1 parent 0f89128 commit ed23e58

33 files changed

Lines changed: 3021 additions & 1143 deletions

File tree

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; };
9090
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
9191
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
92+
B55AFB5E2FE29BAC00A1A1A4 /* AppUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55AFB5D2FE29BAC00A1A1A4 /* AppUtility.swift */; };
9293
CB3666201AF7550816B5CD6A /* NCContextMenuComment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8932E90EC4278026D86CCCC9 /* NCContextMenuComment.swift */; };
9394
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
9495
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
@@ -1279,6 +1280,7 @@
12791280
AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = "<group>"; };
12801281
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
12811282
B4C7A5B36D1ED178FB6B76CB /* NCContextMenuPlayerTracks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuPlayerTracks.swift; sourceTree = "<group>"; };
1283+
B55AFB5D2FE29BAC00A1A1A4 /* AppUtility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUtility.swift; sourceTree = "<group>"; };
12821284
BB7697C94BA14450A0867940 /* NCContextMenuProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuProfile.swift; sourceTree = "<group>"; };
12831285
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
12841286
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -3350,6 +3352,7 @@
33503352
F7F67BAA1A24D27800EE80DA /* iOSClient */ = {
33513353
isa = PBXGroup;
33523354
children = (
3355+
B55AFB5D2FE29BAC00A1A1A4 /* AppUtility.swift */,
33533356
AA517BB42D66149900F8D37C /* .tx */,
33543357
F702F2CC25EE5B4F008F8E80 /* AppDelegate.swift */,
33553358
F7110ADF2F9773210095AA5C /* AppDelegate+AppRefresh.swift */,
@@ -4909,6 +4912,7 @@
49094912
F7DA0F672F66AA0D0033020C /* ShowBanner.swift in Sources */,
49104913
F752BA052E58C05200616A26 /* Maintenance.swift in Sources */,
49114914
F763D29D2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */,
4915+
B55AFB5E2FE29BAC00A1A1A4 /* AppUtility.swift in Sources */,
49124916
F76882252C0DD1E7001CF441 /* NCSettingsAdvancedModel.swift in Sources */,
49134917
F7C7B489245EBA4100D93E60 /* NCViewerQuickLook.swift in Sources */,
49144918
F758B45E212C569D00515F55 /* NCScanCell.swift in Sources */,

Share/NCShareExtension+Files.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,7 @@ extension NCShareExtension {
1212
func reloadData() async {
1313
let session = NCShareExtensionData.shared.getSession()
1414
let layoutForView = NCManageDatabase.shared.getLayoutForView(account: session.account, key: keyLayout, serverUrl: serverUrl)
15-
let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account)
16-
let predicate = showHiddenFiles
17-
? NSPredicate(
18-
format: "account == %@ AND serverUrl == %@ AND fileName != %@ AND directory == true",
19-
session.account,
20-
serverUrl,
21-
NextcloudKit.shared.nkCommonInstance.rootFileName
22-
)
23-
: NSPredicate(
24-
format: "account == %@ AND serverUrl == %@ AND fileName != %@ AND directory == true AND NOT fileName BEGINSWITH[c] %@",
25-
session.account,
26-
serverUrl,
27-
NextcloudKit.shared.nkCommonInstance.rootFileName,
28-
"."
29-
)
30-
15+
let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName != %@ AND directory == true", session.account, serverUrl, NextcloudKit.shared.nkCommonInstance.rootFileName)
3116
let metadatas = await NCManageDatabase.shared.getMetadatasAsync(predicate: predicate,
3217
withLayout: layoutForView,
3318
withAccount: session.account)

Share/NCShareExtension.swift

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// SPDX-License-Identifier: GPL-3.0-or-later
55

66
import UIKit
7-
import UniformTypeIdentifiers
87
import NextcloudKit
98
import LucidBanner
109
import SwiftUI
@@ -50,8 +49,8 @@ class NCShareExtension: UIViewController {
5049
let global = NCGlobal.shared
5150
var maintenanceMode: Bool = false
5251
var token: Int?
53-
var banner: LucidBanner?
5452
var sceneIdentifier: String = UUID().uuidString
53+
var banner: LucidBanner?
5554

5655
// MARK: - View Life Cycle
5756

@@ -82,7 +81,7 @@ class NCShareExtension: UIViewController {
8281
uploadView.layer.cornerRadius = 10
8382

8483
uploadLabel.text = NSLocalizedString("_upload_", comment: "")
85-
uploadLabel.textColor = .systemBlue
84+
uploadLabel.textColor = NCBrandColor.shared.label
8685
let uploadGesture = UITapGestureRecognizer(target: self, action: #selector(actionUpload(_:)))
8786
uploadView.addGestureRecognizer(uploadGesture)
8887

@@ -93,13 +92,6 @@ class NCShareExtension: UIViewController {
9392

9493
NCBrandColor.shared.createUserColors()
9594

96-
registerForTraitChanges([UITraitUserInterfaceStyle.self]) { (self: Self, _) in
97-
guard !self.maintenanceMode else {
98-
return
99-
}
100-
self.updateAppearance()
101-
}
102-
10395
NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { _ in
10496
if NCPreferences().presentPasscode {
10597
NCPasscode.shared.presentPasscode(viewController: self, delegate: self) {
@@ -123,7 +115,7 @@ class NCShareExtension: UIViewController {
123115
}
124116

125117
NCNetworking.shared.setupScene(sceneIdentifier: sceneIdentifier, controller: self)
126-
118+
127119
if let windowScene = view.window?.windowScene {
128120
banner = LucidBannerRegistry.shared.banner(for: windowScene)
129121
}
@@ -151,33 +143,20 @@ class NCShareExtension: UIViewController {
151143
return
152144
}
153145

154-
// Keep the Share extension visually hidden until we know whether this is
155-
// an Assistant text handoff or a normal file upload flow. This avoids the
156-
// visible open-and-close flash when the extension only needs to redirect text.
157-
view.alpha = 0
158-
159-
Task { @MainActor in
160-
if await handleAssistantSharedTextIfNeeded(inputItems: inputItems) {
161-
return
162-
}
163-
164-
self.view.alpha = 1
165-
166-
NCFilesExtensionHandler(items: inputItems) { fileNames in
167-
self.filesName = fileNames
168-
DispatchQueue.main.async {
169-
self.setCommandView()
170-
}
146+
NCFilesExtensionHandler(items: inputItems) { fileNames in
147+
self.filesName = fileNames
148+
DispatchQueue.main.async {
149+
self.setCommandView()
171150
}
151+
}
172152

173-
if NCPreferences().presentPasscode {
174-
NCPasscode.shared.presentPasscode(viewController: self, delegate: self) {
175-
NCPasscode.shared.enableTouchFaceID()
176-
}
153+
if NCPreferences().presentPasscode {
154+
NCPasscode.shared.presentPasscode(viewController: self, delegate: self) {
155+
NCPasscode.shared.enableTouchFaceID()
177156
}
178-
179-
self.collectionView.reloadData()
180157
}
158+
159+
self.collectionView.reloadData()
181160
}
182161

183162
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
@@ -188,9 +167,13 @@ class NCShareExtension: UIViewController {
188167
}
189168
}
190169

191-
private func updateAppearance() {
192-
collectionView.visibleCells.forEach { $0.setNeedsLayout() }
193-
tableView.visibleCells.forEach { $0.setNeedsLayout() }
170+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
171+
super.traitCollectionDidChange(previousTraitCollection)
172+
173+
if !maintenanceMode {
174+
collectionView.reloadData()
175+
tableView.reloadData()
176+
}
194177
}
195178

196179
// MARK: -
@@ -199,7 +182,7 @@ class NCShareExtension: UIViewController {
199182
if let error {
200183
extensionContext?.cancelRequest(withError: error)
201184
} else {
202-
extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
185+
self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
203186
}
204187
}
205188

@@ -223,11 +206,11 @@ class NCShareExtension: UIViewController {
223206

224207
// BACK BUTTON
225208
let backButton = UIButton(type: .custom)
226-
backButton.setImage(UIImage(named: "back"), for: .normal)
227-
backButton.tintColor = .systemBlue
209+
backButton.setImage(UIImage(named: "back")?.withTintColor(NCBrandColor.shared.iconImageColor), for: .normal)
210+
backButton.tintColor = NCBrandColor.shared.label
228211
backButton.semanticContentAttribute = .forceLeftToRight
229212
backButton.setTitle(" " + NSLocalizedString("_back_", comment: ""), for: .normal)
230-
backButton.setTitleColor(.systemBlue, for: .normal)
213+
backButton.setTitleColor(NCBrandColor.shared.label, for: .normal)
231214
backButton.action(for: .touchUpInside) { _ in
232215
while self.serverUrl.last != "/" { self.serverUrl.removeLast() }
233216
self.serverUrl.removeLast()
@@ -241,6 +224,7 @@ class NCShareExtension: UIViewController {
241224
self.setNavigationBar(navigationTitle: navigationTitle)
242225
}
243226

227+
/*
244228
let image = utility.loadUserImage(for: tblAccount.user, displayName: tblAccount.displayName, urlBase: tblAccount.urlBase)
245229
let profileButton = UIButton(type: .custom)
246230
profileButton.setImage(image, for: .normal)
@@ -268,7 +252,9 @@ class NCShareExtension: UIViewController {
268252
space.width = 20
269253
navItems.append(contentsOf: [UIBarButtonItem(customView: backButton), space])
270254
}
271-
navigationItem.setLeftBarButtonItems(navItems, animated: true)
255+
*/
256+
// navigationItem.setLeftBarButtonItems(navItems, animated: true)
257+
navigationItem.setLeftBarButtonItems([UIBarButtonItem(customView: backButton)], animated: true)
272258
}
273259

274260
func setCommandView() {
@@ -297,7 +283,7 @@ class NCShareExtension: UIViewController {
297283
guard let capabilities = NCNetworking.shared.capabilities[session.account] else {
298284
return
299285
}
300-
let alertController = UIAlertController.createFolderWith(serverUrl: serverUrl, session: session, capabilities: capabilities) { error in
286+
let alertController = UIAlertController.createFolder(serverUrl: serverUrl, session: session, capabilities: capabilities, scene: self.view.window?.windowScene) { error in
301287
if error == .success {
302288
Task {
303289
await self.loadFolder()
@@ -396,8 +382,14 @@ extension NCShareExtension {
396382
guard let window = self.view.window else {
397383
return
398384
}
385+
let horizontalLayout = horizontalLayoutBanner(bounds: window.bounds,
386+
safeAreaInsets: window.safeAreaInsets,
387+
idiom: window.traitCollection.userInterfaceIdiom)
388+
399389
let payload = LucidBannerPayload(stage: .button,
390+
backgroundColor: Color(.systemBackground),
400391
vPosition: .center,
392+
horizontalLayout: horizontalLayout,
401393
blocksTouches: true)
402394
(banner, token) = showUploadBanner(windowScene: window.windowScene,
403395
payload: payload,
@@ -427,10 +419,11 @@ extension NCShareExtension {
427419
banner?.update(payload: LucidBannerPayload.Update(subtitle: error?.errorDescription, stage: .error), for: self.token)
428420
}
429421

430-
Task { @MainActor in
431-
try? await Task.sleep(for: .seconds(2))
432-
banner?.dismiss()
433-
extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
422+
if let banner, let token {
423+
Task { @MainActor in
424+
try? await Task.sleep(for: .seconds(2))
425+
banner.dismiss()
426+
}
434427
}
435428
}
436429

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Empty album detailed view.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}

0 commit comments

Comments
 (0)