Skip to content
Merged
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
65 changes: 1 addition & 64 deletions Nextcloud.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct NCAccountSettingsView: View {
// User Status
if capabilities.userStatusEnabled {
if let account = model.tblAccount?.account {
NavigationLink(destination: NCUserStatusView(account: account)) {
NavigationLink(destination: NCUserStatusView(account: account, controller: model.controller)) {
HStack {
Image(systemName: "moon.fill")
.resizable()
Expand All @@ -160,7 +160,7 @@ struct NCAccountSettingsView: View {
}

if let account = model.tblAccount?.account {
NavigationLink(destination: NCStatusMessageView(account: account)) {
NavigationLink(destination: NCStatusMessageView(account: account, controller: model.controller)) {
HStack {
Image(systemName: "message.fill")
.resizable()
Expand Down
16 changes: 7 additions & 9 deletions iOSClient/Extensions/UIAlertController+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import Foundation
import UIKit
import NextcloudKit
import LucidBanner

extension UIAlertController {
/// Creates a alert controller with a textfield, asking to create a new folder
Expand All @@ -46,7 +47,7 @@ extension UIAlertController {

if markE2ee {
if NCNetworking.shared.isOffline {
completion?(NKError(errorCode: NCGlobal.shared.errorOffline, errorDescription: "_offline_not_allowed_"))
completion?(NKError(errorCode: NCGlobal.shared.errorOfflineNotAllowed, errorDescription: "_offline_not_allowed_"))
return
}
Task {
Expand All @@ -71,7 +72,7 @@ extension UIAlertController {
} else if isDirectoryEncrypted {
Task {
if NCNetworking.shared.isOffline {
completion?(NKError(errorCode: NCGlobal.shared.errorOffline, errorDescription: "_offline_not_allowed_"))
completion?(NKError(errorCode: NCGlobal.shared.errorOfflineNotAllowed, errorDescription: "_offline_not_allowed_"))
return
}

Expand Down Expand Up @@ -186,31 +187,28 @@ extension UIAlertController {
}, completion: completion)
}

static func deleteFileOrFolder(titleString: String, message: String?, canDeleteServer: Bool, selectedMetadatas: [tableMetadata], sceneIdentifier: String?, completion: @escaping (_ cancelled: Bool) -> Void) -> UIAlertController {
static func alertDeleteFileOrFolder(titleString: String, message: String?, canDeleteServer: Bool, metadatas: [tableMetadata], completion: @escaping (_ cancelled: Bool) -> Void) -> UIAlertController {
let alertController = UIAlertController(
title: titleString,
message: message,
preferredStyle: .alert)
if canDeleteServer {
alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .destructive) { (_: UIAlertAction) in
Task {
await NCNetworking.shared.setStatusWaitDelete(metadatas: selectedMetadatas, sceneIdentifier: sceneIdentifier)
await NCNetworking.shared.setStatusWaitDelete(metadatas: metadatas)
}
completion(false)
})
}

#if !EXTENSION
alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_local_file_", comment: ""), style: .default) { (_: UIAlertAction) in
Task {
var error = NKError()
for metadata in selectedMetadatas where error == .success {
error = await NCNetworking.shared.deleteCache(metadata, sceneIdentifier: sceneIdentifier)
for metadata in metadatas {
await NCNetworking.shared.deleteCache(metadata)
}
}
completion(false)
})
#endif

alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { (_: UIAlertAction) in
completion(true)
Expand Down
1 change: 0 additions & 1 deletion iOSClient/Files/NCFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ class NCFiles: NCCollectionViewCommon {
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}
} else {
// show error
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}

Expand Down
38 changes: 28 additions & 10 deletions iOSClient/GUI/Lucid Banner/BannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import SwiftUI
import LucidBanner
import NextcloudKit
import Alamofire

// MARK: - Show Banner
Expand Down Expand Up @@ -43,7 +44,10 @@ func showBanner(scene: UIWindowScene?,
imageAnimation: LucidBanner.LucidBannerAnimationStyle,
imageColor: UIColor,
vPosition: LucidBanner.VerticalPosition = .top,
backgroundColor: UIColor) async {
backgroundColor: UIColor,
autoDismissAfter: TimeInterval = NCGlobal.shared.dismissAfterSecond,
swipeToDismiss: Bool = true,
policy: LucidBanner.ShowPolicy = .enqueue) async {
#if !EXTENSION
let scene = scene ?? UIApplication.shared.mainAppWindow?.windowScene
#endif
Expand All @@ -57,13 +61,14 @@ func showBanner(scene: UIWindowScene?,
textColor: Color(uiColor: textColor),
imageColor: Color(uiColor: imageColor),
vPosition: vPosition,
autoDismissAfter: NCGlobal.shared.dismissAfterSecond,
swipeToDismiss: true
autoDismissAfter: autoDismissAfter,
swipeToDismiss: swipeToDismiss
)

LucidBanner.shared.show(
scene: scene,
payload: payload) { state in
payload: payload,
policy: policy) { state in
MessageBannerView(state: state)
}
}
Expand Down Expand Up @@ -192,6 +197,16 @@ func showErrorBannerActiveScenes(title: String = "_error_",
}
}

@MainActor
func showErrorBanner(controller: UITabBarController?,
error: NKError) async {
let scene = SceneManager.shared.getWindow(controller: controller)?.windowScene
await showErrorBanner(scene: scene,
title: "_error_",
text: error.errorDescription,
errorCode: error.errorCode)
}

@MainActor
func showErrorBanner(controller: UITabBarController?,
title: String = "_error_",
Expand Down Expand Up @@ -287,13 +302,21 @@ func showErrorBanner(scene: UIWindowScene?,
}

// MARK: - Helper

#if !EXTENSION

// Error 401 (maintenance mode)
// Error 423 (locked)
// Error 507 (insufficient storage)
// Error -1009 (NSURLErrorNotConnectedToInternet)
// Error -1003 (NSURLError​Cannot​Find​Host)

func bannerContainsError(errorCode: Int?, afError: AFError? = nil) -> Bool {
guard let errorCode else {
return false
}
// List of errors not to be displayed
if errorCode == -999 {
if errorCode == -999 || errorCode == 423 {
return true
}
if let afError, case .explicitlyCancelled = afError {
Expand All @@ -307,11 +330,6 @@ func bannerContainsError(errorCode: Int?, afError: AFError? = nil) -> Bool {
} else {
// Coalesce user-facing errors across the current foreground session.
// The same error code is shown to the user only once.
// Error 401 (maintenance mode)
// Error 423 (locked)
// Error 507 (insufficient storage)
// Error -1009 (NSURLErrorNotConnectedToInternet)
// Error -1003 (NSURLError​Cannot​Find​Host)
if errorCode == 401 ||
errorCode == 423 ||
errorCode == 507 ||
Expand Down
15 changes: 7 additions & 8 deletions iOSClient/GUI/Lucid Banner/HudBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ func showHudBanner(scene: UIWindowScene?,
subtitle: String? = nil,
stage: LucidBanner.Stage? = nil,
onButtonTap: (() -> Void)? = nil) -> Int? {
var scene = scene
if scene == nil {
scene = UIApplication.shared.mainAppWindow?.windowScene
}
let scene = scene ?? UIApplication.shared.mainAppWindow?.windowScene
let localizedTitle = title.map { NSLocalizedString($0, comment: "") }
let localizedSubTitle = subtitle.map { NSLocalizedString($0, comment: "") }

let payload = LucidBannerPayload(
title: title,
subtitle: subtitle,
title: localizedTitle,
subtitle: localizedSubTitle,
stage: stage,
vPosition: .center,
blocksTouches: true,
Expand All @@ -42,9 +41,9 @@ func completeHudBannerSuccess(token: Int?) {
}

@MainActor
func completeHudBannerError(subtitle: String? = nil, token: Int?) {
func completeHudBannerError(description: String, token: Int?) {
let payload = LucidBannerPayload.Update(
subtitle: subtitle,
subtitle: NSLocalizedString(description, comment: ""),
stage: .error,
autoDismissAfter: NCGlobal.shared.dismissAfterSecond
)
Expand Down
3 changes: 2 additions & 1 deletion iOSClient/Login/NCLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import UniformTypeIdentifiers
import UIKit
import NextcloudKit
import SwiftEntryKit
import SwiftUI
import SafariServices

Expand Down Expand Up @@ -192,11 +191,13 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
let title = String(format: NSLocalizedString("_apps_nextcloud_detect_", comment: ""), NCBrandOptions.shared.brand)
let description = String(format: NSLocalizedString("_add_existing_account_", comment: ""), NCBrandOptions.shared.brand)

/*
NCContentPresenter().alertAction(image: image, contentModeImage: .scaleAspectFit, sizeImage: CGSize(width: 45, height: 45), backgroundColor: backgroundColor, textColor: textColor, title: title, description: description, textCancelButton: "_cancel_", textOkButton: "_ok_", attributes: EKAttributes.topFloat) { identifier in
if identifier == "ok" {
self.openShareAccountsViewController(nil)
}
}
*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ extension NCCollectionViewCommon: NCListCellDelegate, NCGridCellDelegate {
func openContextMenu(with metadata: tableMetadata?, button: UIButton, sender: Any) {
Task {
guard let metadata else { return }
button.menu = NCContextMenuMain(metadata: metadata, viewController: self, sceneIdentifier: self.sceneIdentifier, sender: sender).viewMenu()
button.menu = NCContextMenuMain(metadata: metadata,
viewController: self,
controller: self.controller,
sender: sender).viewMenu()
}
}

Expand All @@ -15,7 +18,7 @@ extension NCCollectionViewCommon: NCListCellDelegate, NCGridCellDelegate {
func tapShareListItem(with metadata: tableMetadata?, button: UIButton, sender: Any) {
Task {
guard let metadata else { return }
NCCreate().createShare(viewController: self, metadata: metadata, page: .sharing)
NCCreate().createShare(viewController: self, controller: self.controller, metadata: metadata, page: .sharing)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
var tokenBanner: Int?
await MainActor.run {
tokenBanner = showHudBanner(scene: scene,
title: NSLocalizedString("_download_in_progress_", comment: ""),
title: "_download_in_progress_",
stage: .button,
onButtonTap: {
if let request = downloadRequest {
Expand Down Expand Up @@ -115,7 +115,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
self.navigationController?.pushViewController(vc, animated: true)
}
} else {
await showErrorBanner(controller: controller, text: "_go_online_", errorCode: NCGlobal.shared.errorOffline)
await showErrorBanner(controller: controller, text: "_go_online_", errorCode: NCGlobal.shared.errorOfflineNotAllowed)
}
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
return nil
}, actionProvider: { _ in
let contextMenu = NCContextMenuMain(metadata: metadata.detachedCopy(), viewController: self, sceneIdentifier: self.sceneIdentifier, sender: cell)
let contextMenu = NCContextMenuMain(metadata: metadata.detachedCopy(), viewController: self, controller: self.controller, sender: cell)
return contextMenu.viewMenu()
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ extension NCCollectionViewCommon: UICollectionViewDropDelegate {
destination = utilityFileSystem.createServerUrl(serverUrl: destinationMetadata.serverUrl, fileName: destinationMetadata.fileName)
}
Task {
await NCDragDrop().copyFile(metadatas: sourceMetadatas, destination: destination)
await NCDragDrop().copyFile(metadatas: sourceMetadatas, destination: destination, controller: self.controller)
}
}

Expand All @@ -146,7 +146,7 @@ extension NCCollectionViewCommon: UICollectionViewDropDelegate {
destination = utilityFileSystem.createServerUrl(serverUrl: destinationMetadata.serverUrl, fileName: destinationMetadata.fileName)
}
Task {
await NCDragDrop().moveFile(metadatas: sourceMetadatas, destination: destination)
await NCDragDrop().moveFile(metadatas: sourceMetadatas, destination: destination, controller: self.controller)
}
}
}
Expand Down
Loading
Loading