Skip to content

Commit f5acd63

Browse files
NMC-5856 - iOS v10.3.0 (2) - Sharing - No error alert without message note for 'Send new email' page. Also updated the icons for the files
1 parent c55fe90 commit f5acd63

9 files changed

Lines changed: 96 additions & 44 deletions

File tree

Brand/NCBrand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class NCBrandOptions: @unchecked Sendable {
6464
var brandUserAgent: String = "MagentaCLOUD"
6565
var textCopyrightNextcloudiOS: String = "MagentaCLOUD for iOS %@"
6666
var textCopyrightNextcloudServer: String = "MagentaCLOUD Server %@"
67-
var loginBaseUrl: String = "https://magentacloud.de"
67+
var loginBaseUrl: String = "https://dev1.next.magentacloud.de" //"https://magentacloud.de"
6868
var pushNotificationServerProxy: String = ""
6969
var linkLoginHost: String = "https://nextcloud.com/install"
7070
var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios"

iOSClient/Menu/NCContextMenuShare.swift

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,19 @@ class NCContextMenuShare: NSObject {
5050
title: NSLocalizedString("_advance_permissions_", comment: ""),
5151
image: utility.loadImage(named: "rename", colors: [NCBrandColor.shared.brandElement])
5252
) { [self] _ in
53-
guard
54-
let advancePermission = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "NCShareAdvancePermission") as? NCShareAdvancePermission,
55-
let navigationController = shareController.navigationController, !share.isInvalidated else { return }
56-
advancePermission.networking = shareController.networking
57-
advancePermission.share = tableShare(value: share)
58-
advancePermission.oldTableShare = tableShare(value: share)
59-
advancePermission.metadata = shareController.metadata
60-
61-
if let downloadLimit = try? shareController.database.getDownloadLimit(byAccount: shareController.metadata.account, shareToken: share.token) {
62-
advancePermission.downloadLimit = .limited(limit: downloadLimit.limit, count: downloadLimit.count)
63-
}
64-
65-
navigationController.pushViewController(advancePermission, animated: true)
53+
openAdvancePermission(shareController: shareController)
6654
}
6755
actions.append(advancePermissionAction)
6856
}
6957

7058
// Send email
71-
if shareController.sendMail {
59+
if (share.shareType != NKShare.ShareType.publicLink.rawValue) {
60+
// if shareController.sendMail {
7261
let sendNewEmailAction = UIAction(
7362
title: NSLocalizedString("_send_new_email_", comment: ""),
7463
image: utility.loadImage(named: "email", colors: [NCBrandColor.shared.brandElement])
7564
) { [self] _ in
76-
let storyboard = UIStoryboard(name: "NCShare", bundle: nil)
77-
guard let viewNewUserComment = storyboard.instantiateViewController(withIdentifier: "NCShareNewUserAddComment") as? NCShareNewUserAddComment else { return }
78-
viewNewUserComment.metadata = shareController.metadata
79-
viewNewUserComment.share = tableShare(value: share)
80-
viewNewUserComment.networking = shareController.networking
81-
viewNewUserComment.isFromMenu = true
82-
shareController.navigationController?.pushViewController(viewNewUserComment, animated: true)
65+
openShareEmail(shareController: shareController)
8366
}
8467
actions.append(sendNewEmailAction)
8568
}
@@ -216,4 +199,15 @@ class NCContextMenuShare: NSObject {
216199
}
217200
shareController.networking?.unShare(idShare: share.idShare)
218201
}
202+
203+
private func openShareEmail(shareController: NCShare) {
204+
let storyboard = UIStoryboard(name: "NCShare", bundle: nil)
205+
guard let viewNewUserComment = storyboard.instantiateViewController(withIdentifier: "NCShareNewUserAddComment") as? NCShareNewUserAddComment else { return }
206+
viewNewUserComment.metadata = shareController.metadata
207+
viewNewUserComment.share = tableShare(value: share)
208+
viewNewUserComment.networking = shareController.networking
209+
viewNewUserComment.isFromMenu = true
210+
viewNewUserComment.controller = controller
211+
shareController.navigationController?.pushViewController(viewNewUserComment, animated: true)
212+
}
219213
}

iOSClient/Share/Advanced/NCShareNewUserAddComment.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class NCShareNewUserAddComment: UIViewController, NCShareNavigationTitleSetting
4949
var downloadLimit: DownloadLimitViewModel = .unlimited
5050
var downloadLimitChanged: Bool = false
5151

52+
var controller: NCMainTabBarController?
53+
var windowScene: UIWindowScene? {
54+
SceneManager.shared.getWindowScene(controller: controller)
55+
}
56+
5257
override func viewDidLoad() {
5358
super.viewDidLoad()
5459
self.setNavigationTitle()
@@ -119,10 +124,18 @@ class NCShareNewUserAddComment: UIViewController, NCShareNavigationTitleSetting
119124

120125
@IBAction func sendShareClicked(_ sender: Any) {
121126
share.note = noteTextField.text
122-
if isNewShare {
123-
networking?.createShare(share, downloadLimit: self.downloadLimit)
127+
if !share.note.isEmpty {
128+
if isNewShare {
129+
networking?.createShare(share, downloadLimit: self.downloadLimit)
130+
} else {
131+
networking?.updateShare(share, downloadLimit: self.downloadLimit, changeDownloadLimit: downloadLimitChanged)
132+
}
124133
} else {
125-
networking?.updateShare(share, downloadLimit: self.downloadLimit, changeDownloadLimit: downloadLimitChanged)
134+
Task {
135+
await showErrorBanner(windowScene: self.windowScene,
136+
text: "_share_note_should_not_be_empty_",
137+
errorCode: 0)
138+
}
126139
}
127140

128141
self.navigationController?.popToRootViewController(animated: true)

iOSClient/Share/NCShare+NCCellDelegate.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,6 @@ extension NCShare: NCShareLinkCellDelegate, NCShareUserCellDelegate {
4949
}
5050
NCShareCommon.copyLink(link: tableShare.url, viewController: self, sender: sender)
5151
}
52-
53-
// func tapMenu(with tableShare: tableShare?, sender: Any) {
54-
// if let tableShare = tableShare {
55-
// self.toggleShareMenu(for: tableShare, sendMail: (tableShare.shareType != NKShare.ShareType.publicLink.rawValue), folder: metadata?.directory ?? false, sender: sender)
56-
// } else {
57-
// self.makeNewLinkShare()
58-
// }
59-
// }
60-
61-
// func showProfile(with tableShare: tableShare?, sender: Any) {
62-
// guard let tableShare else { return }
63-
// return NCContextMenuProfile(userId: tableShare.shareWith, session: session, viewController: self).viewMenu()
64-
// }
65-
//
66-
// func quickStatus(with tableShare: tableShare?, sender: Any) {
67-
// guard let tableShare, let metadata else { return }
68-
// self.toggleQuickPermissionsMenu(isDirectory: metadata.directory, share: tableShare, sender: sender)
69-
// }
7052

7153
func tapMenu(with tableShare: tableShare?, sender: Any) {
7254
// Menu is now shown via native context menu on the button

iOSClient/Share/NCShare.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class NCShare: UIViewController, NCSharePagingContent {
9090
var shareOthers: [tableShare] = []
9191
private var cachedHeader: NCShareAdvancePermissionHeader?
9292

93-
var sendMail: Bool = false
93+
// var sendMail: Bool = false
9494

9595
// MARK: - View Life Cycle
9696

@@ -620,6 +620,7 @@ extension NCShare: UITableViewDataSource {
620620
let linkNumber = " \(indexPath.row + 1)"
621621
cell.configure(with: tableShare, at: indexPath, isDirectory: metadata.directory, title: linkNumber)
622622
}
623+
// self.sendMail = (tableShare.shareType != NKShare.ShareType.publicLink.rawValue)
623624
cell.buttonDetail.menu = NCContextMenuShare(share: tableShare, isDirectory: metadata.isDirectory, canReshare: canReshare, shareController: self, controller: controller).viewMenu()
624625
cell.buttonDetail.showsMenuAsPrimaryAction = true
625626

996 Bytes
Binary file not shown.
206 Bytes
Binary file not shown.

iOSClient/Supporting Files/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@
897897
"_share_link_empty_exp_date_" = "You must select expiration date.";
898898
"_share_link_empty_note_message_" = "Please enter note.";
899899
"_share_permission_should_not_be_empty_" = "Please select at least one permission.";
900+
"_share_note_should_not_be_empty_" = "We couldn't update the share. Please add a note and try again.";
900901
"_remote_" = "Remote";
901902
"_remote_group_" = "Remote group";
902903
"_conversation_" = "Conversation";

iOSClient/Utility/NCUtility+Image.swift

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CoreMedia
1111
import Photos
1212

1313
extension NCUtility {
14+
1415
func loadImage(named imageName: String,
1516
colors: [UIColor]? = nil,
1617
size: CGFloat? = nil,
@@ -19,6 +20,66 @@ extension NCUtility {
1920
account: String? = nil) -> UIImage {
2021
var image: UIImage?
2122

23+
if useTypeIconFile {
24+
switch imageName {
25+
case NKTypeIconFile.audio.rawValue: image = UIImage(named: "file_audio")
26+
case NKTypeIconFile.code.rawValue: image = UIImage(named: "file_code")
27+
case NKTypeIconFile.compress.rawValue: image = UIImage(named: "file_compress")
28+
case NKTypeIconFile.directory.rawValue: image = UIImage(named: "folder")
29+
case NKTypeIconFile.document.rawValue: image = UIImage(named: "document")
30+
case NKTypeIconFile.image.rawValue: image = UIImage(named: "file_photo")
31+
case NKTypeIconFile.video.rawValue: image = UIImage(named: "file_movie")
32+
case NKTypeIconFile.xls.rawValue: image = UIImage(named: "file_xls")
33+
case NKTypeIconFile.pdf.rawValue: image = UIImage(named: "file_pdf")
34+
case NKTypeIconFile.ppt.rawValue: image = UIImage(named: "file_ppt")
35+
case NKTypeIconFile.txt.rawValue: image = UIImage(named: "file_txt")
36+
default: image = (imageName as NSString).pathExtension == "odg" ? UIImage(named: "file_odg") : UIImage(named: "file")
37+
}
38+
}
39+
40+
if let image { return image }//.withTintColor(NCBrandColor.shared.iconImageColor) }
41+
// see https://stackoverflow.com/questions/71764255
42+
// let sfSymbolName = imageName.replacingOccurrences(of: "_", with: ".")
43+
// let color = colors?.first ?? UIColor.systemGray
44+
45+
// SF IMAGE
46+
if let colors {
47+
image = UIImage(systemName: imageName, withConfiguration: UIImage.SymbolConfiguration(weight: systemNameWeight))?.applyingSymbolConfiguration(UIImage.SymbolConfiguration(paletteColors: colors))
48+
} else {
49+
image = UIImage(systemName: imageName, withConfiguration: UIImage.SymbolConfiguration(weight: systemNameWeight))
50+
}
51+
52+
if let image { return image }//.withTintColor(NCBrandColor.shared.iconImageColor) }
53+
54+
// IMAGES
55+
if let color = colors?.first, let size {
56+
image = UIImage(named: imageName)?.image(color: color, size: size)
57+
} else if let color = colors?.first, size == nil {
58+
image = UIImage(named: imageName)?.image(color: color, size: 24)
59+
} else if colors == nil, size == nil {
60+
image = UIImage(named: imageName)?.resizeImage(size: CGSize(width: 24, height: 24))
61+
} else if colors == nil, let size {
62+
image = UIImage(named: imageName)?.resizeImage(size: CGSize(width: size, height: size))
63+
}
64+
65+
if let image { return image }//.withTintColor(NCBrandColor.shared.iconImageColor) }
66+
67+
// NO IMAGES FOUND
68+
if let color = colors?.first, let size {
69+
return UIImage(named: "file")!.image(color: color, size: size)
70+
} else {
71+
return UIImage(named: "file")!
72+
}
73+
}
74+
75+
func loadImage1(named imageName: String,
76+
colors: [UIColor]? = nil,
77+
size: CGFloat? = nil,
78+
useTypeIconFile: Bool = false,
79+
systemNameWeight: UIImage.SymbolWeight = .regular,
80+
account: String? = nil) -> UIImage {
81+
var image: UIImage?
82+
2283
if useTypeIconFile {
2384
switch imageName {
2485
case NKTypeIconFile.audio.rawValue: image = UIImage(systemName: "waveform", withConfiguration: UIImage.SymbolConfiguration(weight: .thin))?.applyingSymbolConfiguration(UIImage.SymbolConfiguration(paletteColors: [NCBrandColor.shared.iconImageColor2]))

0 commit comments

Comments
 (0)