Skip to content

Commit f1aaf52

Browse files
author
Nextcloud GmbH
committed
Merge remote-tracking branch 'customization/nmc/2341-Trash-view'
2 parents 4c122cd + ec6907e commit f1aaf52

8 files changed

Lines changed: 188 additions & 15 deletions

File tree

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7602,6 +7602,8 @@
76027602
requirement = {
76037603
kind = exactVersion;
76047604
version = 7.3.1;
7605+
branch = main;
7606+
kind = branch;
76057607
};
76067608
};
76077609
F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

iOSClient/NCGlobal.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,25 @@ final class NCGlobal: Sendable {
354354
let notificationCenterCreateMediaCacheEnded = "createMediaCacheEnded"
355355
let notificationCenterUpdateNotification = "updateNotification"
356356
let notificationCenterDidCreateShareLink = "didCreateShareLink"
357+
let notificationCenterDidCreateShareLink = "didCreateShareLink"
358+
359+
let notificationCenterDeleteFile = "deleteFile" // userInfo: [ocId], error
360+
let notificationCenterCopyMoveFile = "copyMoveFile" // userInfo: [ocId] serverUrl, account, dragdrop, type (copy, move)
361+
let notificationCenterMoveFile = "moveFile" // userInfo: [ocId], [indexPath], error
362+
let notificationCenterCopyFile = "copyFile" // userInfo: [ocId], [indexPath], error
363+
let notificationCenterRenameFile = "renameFile" // userInfo: serverUrl, account, error
364+
let notificationCenterFavoriteFile = "favoriteFile" // userInfo: ocId, serverUrl
365+
let notificationCenterFileExists = "fileExists" // userInfo: ocId, fileExists
366+
let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: serverUrl?, clearDataSource
367+
368+
let notificationCenterDeleteFile = "deleteFile" // userInfo: [ocId], error
369+
let notificationCenterCopyMoveFile = "copyMoveFile" // userInfo: [ocId] serverUrl, account, dragdrop, type (copy, move)
370+
let notificationCenterMoveFile = "moveFile" // userInfo: [ocId], [indexPath], error
371+
let notificationCenterCopyFile = "copyFile" // userInfo: [ocId], [indexPath], error
372+
let notificationCenterRenameFile = "renameFile" // userInfo: serverUrl, account, error
373+
let notificationCenterFavoriteFile = "favoriteFile" // userInfo: ocId, serverUrl
374+
let notificationCenterFileExists = "fileExists" // userInfo: ocId, fileExists
375+
let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: serverUrl?, clearDataSource
357376

358377
let notificationCenterDeleteFile = "deleteFile" // userInfo: [ocId], error
359378
let notificationCenterCopyMoveFile = "copyMoveFile" // userInfo: [ocId] serverUrl, account, dragdrop, type (copy, move)

iOSClient/Trash/Cell/NCTrashCellProtocol.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ extension NCTrashCellProtocol where Self: UICollectionViewCell {
3636
self.labelInfo?.text = dateFormatter.string(from: tableTrash.trashbinDeletionTime as Date)
3737
}
3838
if tableTrash.directory {
39-
self.imageItem.image = NCImageCache.shared.getFolder(account: tableTrash.account)
39+
self.imageItem.image = NCImageCache.shared.getFolder()
4040
} else {
4141
self.imageItem.image = image
42-
self.labelInfo?.text = (self.labelInfo?.text ?? "") + " · " + NCUtilityFileSystem().transformedSize(tableTrash.size)
42+
// self.labelInfo?.text = (self.labelInfo?.text ?? "") + " · " + NCUtilityFileSystem().transformedSize(tableTrash.size)
4343
}
4444

45+
self.labelInfo?.text = (self.labelInfo?.text ?? "") + " · " + NCUtilityFileSystem().transformedSize(tableTrash.size)
4546
self.accessibilityLabel = tableTrash.trashbinFileName + ", " + (self.labelInfo?.text ?? "")
4647

4748
if self is NCTrashGridCell {

iOSClient/Trash/Cell/NCTrashGridCell.swift

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol {
2525
get { return nil }
2626
set { imageItem = newValue }
2727
}
28+
var indexPath = IndexPath()
29+
var account = ""
30+
var user = ""
31+
32+
var namedButtonMore = ""
33+
34+
var fileObjectId: String? {
35+
get { return objectId }
36+
set { objectId = newValue ?? "" }
37+
}
38+
var filePreviewImageView: UIImageView? {
39+
get { return imageItem }
40+
set { imageItem = newValue }
41+
}
42+
var fileUser: String? {
43+
get { return user }
44+
set { user = newValue ?? "" }
45+
}
46+
var fileTitleLabel: UILabel? {
47+
get { return labelTitle }
48+
set { labelTitle = newValue }
49+
}
50+
var fileInfoLabel: UILabel? {
51+
get { return labelInfo }
52+
set { labelInfo = newValue }
53+
}
2854

2955
override func awakeFromNib() {
3056
super.awakeFromNib()
@@ -77,6 +103,10 @@ class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol {
77103
// adjustsFontForContentSizeCategory:
78104
// Enables live updates when accessibility settings change.
79105
//
106+
// progressView.tintColor = NCBrandColor.shared.brandElement
107+
// progressView.transform = CGAffineTransform(scaleX: 1.0, y: 0.5)
108+
// progressView.trackTintColor = .clear
109+
80110
labelTitle.text = ""
81111
labelTitle.font = .callout()
82112
labelTitle.adjustsFontForContentSizeCategory = true
@@ -90,9 +120,9 @@ class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol {
90120
labelInfo.font = .footnote()
91121
labelInfo.adjustsFontForContentSizeCategory = true
92122

93-
labelSubinfo.text = ""
94-
labelSubinfo.font = .footnote()
95-
labelSubinfo.adjustsFontForContentSizeCategory = true
123+
// labelSubinfo.text = ""
124+
// labelSubinfo.font = .footnote()
125+
// labelSubinfo.adjustsFontForContentSizeCategory = true
96126

97127
if labelExtension.isHidden {
98128
labelTitle.numberOfLines = 2
@@ -101,6 +131,9 @@ class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol {
101131
labelTitle.numberOfLines = 1
102132
labelTitle.lineBreakMode = .byTruncatingTail
103133
}
134+
labelTitle.textColor = .label
135+
labelInfo.textColor = .systemGray
136+
labelSubinfo.text = ""
104137
}
105138

106139
override func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? {
@@ -134,9 +167,17 @@ class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol {
134167
setA11yActions()
135168
}
136169

137-
imageVisualEffect.alpha = status ? 1 : 0
138-
imageSelect.alpha = status ? 1 : 0
139-
imageSelect.image = NCImageCache.shared.getImageCheckedYes(color: color)
170+
// imageVisualEffect.alpha = status ? 1 : 0
171+
// imageSelect.alpha = status ? 1 : 0
172+
// imageSelect.image = NCImageCache.shared.getImageCheckedYes(color: color)
173+
if status {
174+
imageSelect.image = NCImageCache.shared.getImageCheckedYes(color: color)
175+
imageSelect.isHidden = false
176+
imageVisualEffect.isHidden = false
177+
} else {
178+
imageSelect.isHidden = true
179+
imageVisualEffect.isHidden = true
180+
}
140181
}
141182

142183
func writeInfoDateSize(date: NSDate, size: Int64) {

iOSClient/Trash/Cell/NCTrashListCell.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class NCTrashListCell: UICollectionViewCell, NCTrashCellProtocol {
3131
get { return imageStatus }
3232
set { imageStatus = newValue }
3333
}
34+
var account = ""
3435

3536
override func awakeFromNib() {
3637
super.awakeFromNib()
@@ -57,8 +58,10 @@ class NCTrashListCell: UICollectionViewCell, NCTrashCellProtocol {
5758

5859
]
5960

60-
imageRestore.image = NCUtility().loadImage(named: "arrow.counterclockwise", colors: [NCBrandColor.shared.iconImageColor])
61-
imageMore.image = NCUtility().loadImage(named: "trash", colors: [.red])
61+
// imageRestore.image = NCUtility().loadImage(named: "arrow.counterclockwise", colors: [NCBrandColor.shared.iconImageColor])
62+
// imageMore.image = NCUtility().loadImage(named: "trash", colors: [.red])
63+
imageRestore.image = NCUtility().loadImage(named: "restore", colors: [NCBrandColor.shared.iconImageColor])
64+
imageMore.image = NCUtility().loadImage(named: "trashIcon", colors: [NCBrandColor.shared.iconImageColor]) //NCUtility().loadImage(named: "trashIcon", colors: [.red])
6265
imageItem.layer.cornerRadius = 6
6366
imageItem.layer.masksToBounds = true
6467

iOSClient/Trash/NCTrash+CollectionView.swift

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ extension NCTrash: UICollectionViewDataSource {
5050
gridCell.delegate = self
5151
cell = gridCell
5252
}
53-
5453
guard let resultTableTrash = datasource?[indexPath.item] else { return cell }
5554

5655
let contextMenu = NCContextMenuTrash(objectId: resultTableTrash.fileId, trashController: self)
@@ -85,9 +84,11 @@ extension NCTrash: UICollectionViewDataSource {
8584
}
8685
}
8786

87+
cell.account = resultTableTrash.account
8888
cell.objectId = resultTableTrash.fileId
8989
cell.setupCellUI(tableTrash: resultTableTrash, image: image)
90-
cell.selected(selectOcId.contains(resultTableTrash.fileId), isEditMode: isEditMode, color: NCBrandColor.shared.getElement(account: session.account))
90+
cell.selected(selectOcId.contains(resultTableTrash.fileId), isEditMode: isEditMode, account: resultTableTrash.account)
91+
// cell.selected(selectOcId.contains(resultTableTrash.fileId), isEditMode: isEditMode, color: NCBrandColor.shared.getElement(account: session.account))
9192

9293
return cell
9394
}
@@ -129,12 +130,66 @@ extension NCTrash: UICollectionViewDataSource {
129130

130131
return text
131132
}
133+
134+
func setTitleLabel(directories: Int, files: Int, size: Int64) -> String {
135+
var foldersText = ""
136+
var filesText = ""
137+
var text = ""
138+
139+
if directories > 1 {
140+
foldersText = "\(directories) " + NSLocalizedString("_folders_", comment: "")
141+
} else if directories == 1 {
142+
foldersText = "1 " + NSLocalizedString("_folder_", comment: "")
143+
}
144+
145+
if files > 1 {
146+
filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + "" + utilityFileSystem.transformedSize(size)
147+
} else if files == 1 {
148+
filesText = "1 " + NSLocalizedString("_file_", comment: "") + "" + utilityFileSystem.transformedSize(size)
149+
}
150+
151+
if foldersText.isEmpty {
152+
text = filesText
153+
} else if filesText.isEmpty {
154+
text = foldersText
155+
} else {
156+
text = foldersText + "" + filesText
157+
}
158+
return text
159+
}
160+
161+
func setTitleLabel(directories: Int, files: Int, size: Int64) -> String {
162+
var foldersText = ""
163+
var filesText = ""
164+
var text = ""
165+
166+
if directories > 1 {
167+
foldersText = "\(directories) " + NSLocalizedString("_folders_", comment: "")
168+
} else if directories == 1 {
169+
foldersText = "1 " + NSLocalizedString("_folder_", comment: "")
170+
}
171+
172+
if files > 1 {
173+
filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + "" + utilityFileSystem.transformedSize(size)
174+
} else if files == 1 {
175+
filesText = "1 " + NSLocalizedString("_file_", comment: "") + "" + utilityFileSystem.transformedSize(size)
176+
}
177+
178+
if foldersText.isEmpty {
179+
text = filesText
180+
} else if filesText.isEmpty {
181+
text = foldersText
182+
} else {
183+
text = foldersText + "" + filesText
184+
}
185+
return text
186+
}
132187

133188
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
134189
if kind == UICollectionView.elementKindSectionHeader {
135190
guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFirstHeaderEmptyData", for: indexPath) as? NCSectionFirstHeaderEmptyData
136191
else { return NCSectionFirstHeaderEmptyData() }
137-
header.emptyImage.image = utility.loadImage(named: "trash", colors: [NCBrandColor.shared.getElement(account: session.account)])
192+
header.emptyImage.image = utility.loadImage(named: "trashIcon", colors: [NCBrandColor.shared.getElement(account: session.account)])
138193
header.emptyTitle.text = NSLocalizedString("_trash_no_trash_", comment: "")
139194
header.emptyDescription.text = NSLocalizedString("_trash_no_trash_description_", comment: "")
140195
return header
@@ -143,6 +198,8 @@ extension NCTrash: UICollectionViewDataSource {
143198
else { return NCSectionFooter() }
144199
if let datasource {
145200
footer.setTitleLabel(setTextFooter(datasource: datasource))
201+
// let info = self.getFooterInformation(datasource: datasource)
202+
// footer.setTitleLabel(directories: info.directories, files: info.files, size: info.size)
146203
}
147204
return footer
148205
}

iOSClient/Trash/NCTrash.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat
3030
var session: NCSession.Session {
3131
NCSession.shared.getSession(controller: tabBarController)
3232
}
33+
34+
var serverUrl = ""
35+
var selectableDataSource: [RealmSwiftObject] { datasource }
36+
private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
37+
var emptyDataSet: NCEmptyDataSet?
3338

3439
@MainActor
3540
var controller: NCMainTabBarController? {
@@ -101,6 +106,7 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat
101106
await self.reloadDataSource()
102107
await loadListingTrash()
103108
}
109+
AnalyticsHelper.shared.trackEvent(eventName: .SCREEN_EVENT__DELETED_FILES)
104110
}
105111

106112
override func viewWillDisappear(_ animated: Bool) {
@@ -144,6 +150,22 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat
144150
collectionView(self.collectionView, didSelectItemAt: indexPath!)
145151
}
146152
}
153+
func tapButtonSwitch(_ sender: Any) {
154+
if layoutForView?.layout == NCGlobal.shared.layoutGrid {
155+
onListSelected()
156+
} else {
157+
onGridSelected()
158+
}
159+
}
160+
161+
func tapButtonOrder(_ sender: Any) {
162+
163+
let sortMenu = NCSortMenu()
164+
// sortMenu.toggleMenu(viewController: self, account: appDelegate.account, key: layoutKey, sortButton: sender as? UIButton, serverUrl: serverUrl)
165+
sortMenu.toggleMenu(viewController: self, account: session.account, key: layoutKey, sortButton: sender as? UIButton, serverUrl: serverUrl)
166+
}
167+
168+
func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) { }
147169

148170
func longPressMoreGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) { }
149171

@@ -153,6 +175,13 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat
153175
let results = await self.database.getTableTrashAsync(filePath: getFilePath(), account: session.account)
154176

155177
await mainNavigationController?.updateMenuOption()
178+
// // Switch back to main thread for UI updates
179+
// await MainActor.run {
180+
// self.datasource = results
181+
// self.collectionView.reloadData()
182+
// setNavigationRightItems()
183+
//// (self.navigationController as? NCMainNavigationController)?.updateRightMenu()
184+
// await (self.navigationController as? NCMainNavigationController)?.updateRightMenu()
156185

157186
await MainActor.run {
158187
self.datasource = results
@@ -187,4 +216,22 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat
187216
return filePath + "/"
188217
}
189218
}
219+
220+
func getFooterInformation(datasource: [tableTrash]) -> (directories: Int, files: Int, size: Int64) {
221+
let validMetadatas = datasource.filter { !$0.isInvalidated }
222+
let directories = validMetadatas.filter({ $0.directory == true})
223+
let files = validMetadatas.filter({ $0.directory == false})
224+
225+
var size: Int64 = 0
226+
227+
directories.forEach { metadata in
228+
size += metadata.size
229+
}
230+
231+
files.forEach { metadata in
232+
size += metadata.size
233+
}
234+
235+
return (directories.count, files.count, size)
236+
}
190237
}

iOSClient/Trash/NCTrashSelectTabBar.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ struct NCTrashSelectTabBarView: View {
107107
Button {
108108
tabBarSelect.delegate?.recover()
109109
} label: {
110-
Image(systemName: "arrow.counterclockwise")
111-
.font(.icon())
110+
// Image(systemName: "arrow.counterclockwise")
111+
// .font(.icon())
112+
Image(systemName: "arrow.circlepath")
113+
.font(Font.system(.body).weight(.light))
114+
.imageScale(sizeClass == .compact ? .medium : .large)
112115
}
113116
.tint(Color(NCBrandColor.shared.iconImageColor))
114117
.frame(maxWidth: .infinity)

0 commit comments

Comments
 (0)