Skip to content

Commit c7e8c5b

Browse files
NMC 1935 - Notification screen customisation
1 parent 3d9eddf commit c7e8c5b

2 files changed

Lines changed: 59 additions & 12 deletions

File tree

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
8686
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
8787
CB3666201AF7550816B5CD6A /* NCContextMenuComment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8932E90EC4278026D86CCCC9 /* NCContextMenuComment.swift */; };
88+
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
89+
B543154C2DA690B700981E7E /* NCNotificationText.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543154B2DA690B700981E7E /* NCNotificationText.swift */; };
90+
C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
91+
D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
8892
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
8993
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
9094
F31165022F9674A1009A1E37 /* AppIcon.icon in Resources */ = {isa = PBXBuildFile; fileRef = F31165012F9674A1009A1E37 /* AppIcon.icon */; };
@@ -1263,6 +1267,8 @@
12631267
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
12641268
B4C7A5B36D1ED178FB6B76CB /* NCContextMenuPlayerTracks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuPlayerTracks.swift; sourceTree = "<group>"; };
12651269
BB7697C94BA14450A0867940 /* NCContextMenuProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuProfile.swift; sourceTree = "<group>"; };
1270+
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = "<group>"; };
1271+
B543154B2DA690B700981E7E /* NCNotificationText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNotificationText.swift; sourceTree = "<group>"; };
12661272
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
12671273
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
12681274
D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = "<group>"; };
@@ -2087,6 +2093,8 @@
20872093
children = (
20882094
F34BDB3B2F574A58007A222C /* BidiSafeFilenameTests.swift */,
20892095
AA52EB452D42AC5A0089C348 /* Placeholder.swift */,
2096+
B543154B2DA690B700981E7E /* NCNotificationText.swift */,
2097+
AF8ED1FB2757821000B8DBC4 /* NextcloudUnitTests.swift */,
20902098
);
20912099
path = NextcloudUnitTests;
20922100
sourceTree = "<group>";
@@ -4220,6 +4228,8 @@
42204228
F34BDB3C2F574A58007A222C /* BidiSafeFilenameTests.swift in Sources */,
42214229
F372087D2BAB4C0F006B5430 /* TestConstants.swift in Sources */,
42224230
F78E2D6C29AF02DB0024D4F3 /* Database.swift in Sources */,
4231+
B543154C2DA690B700981E7E /* NCNotificationText.swift in Sources */,
4232+
F7817CFE29801A3500FFBC65 /* Data+Extension.swift in Sources */,
42234233
);
42244234
runOnlyForDeploymentPostprocessing = 0;
42254235
};

iOSClient/Notification/NCNotification.swift

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ import UIKit
2626
import NextcloudKit
2727
import SwiftyJSON
2828

29-
class NCNotification: UITableViewController, NCNotificationCellDelegate {
29+
class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmptyDataSetDelegate {
3030
let utilityFileSystem = NCUtilityFileSystem()
3131
let utility = NCUtility()
3232
var notifications: [NKNotifications] = []
3333
var session: NCSession.Session!
34+
private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
35+
var emptyDataSet: NCEmptyDataSet?
3436

3537
@MainActor
3638
var controller: NCMainTabBarController? {
@@ -51,6 +53,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
5153
view.backgroundColor = .systemBackground
5254

5355
navigationController?.setNavigationBarAppearance()
56+
self.session = NCSession.shared.getSession(controller: controller)
5457

5558
tableView.tableFooterView = UIView()
5659
tableView.rowHeight = UITableView.automaticDimension
@@ -67,8 +70,17 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
6770
let close = UIBarButtonItem(title: NSLocalizedString("_close_", comment: ""), style: .plain) {
6871
self.dismiss(animated: true)
6972
}
73+
// Empty
74+
let offset = (self.navigationController?.navigationBar.bounds.height ?? 0) - 20
75+
emptyDataSet = NCEmptyDataSet(view: tableView, offset: -offset, delegate: self)
76+
77+
}
7078

71-
self.navigationItem.leftBarButtonItems = [close]
79+
override func viewWillAppear(_ animated: Bool) {
80+
super.viewWillAppear(animated)
81+
appDelegate.activeViewController = self
82+
navigationController?.setNavigationBarAppearance()
83+
AnalyticsHelper.shared.trackEvent(eventName: .SCREEN_EVENT__NOTIFICATIONS)
7284
}
7385

7486
override func viewDidAppear(_ animated: Bool) {
@@ -93,18 +105,43 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
93105

94106
// MARK: - NotificationCenter
95107
@objc func initialize() {
96-
getNetwokingNotification()
108+
getNetwokingNotification(nil)
97109
}
98110

111+
// MARK: - Empty
112+
113+
func emptyDataSetView(_ view: NCEmptyView) {
114+
115+
if self.dataSourceTask?.state == .running {
116+
view.emptyImage.image = UIImage(named: "networkInProgress")?.image(color: .gray, size: UIScreen.main.bounds.width)
117+
view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
118+
view.emptyDescription.text = ""
119+
} else {
120+
view.emptyImage.image = utility.loadImage(named: "bell", colors: [.gray], size: UIScreen.main.bounds.width)
121+
view.emptyTitle.text = NSLocalizedString("_no_notification_", comment: "")
122+
view.emptyDescription.text = ""
123+
}
124+
}
125+
99126
// MARK: - Table
100127

101128
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
129+
emptyDataSet?.numberOfItemsInSection(notifications.count, section: section)
102130
return notifications.count
103131
}
104132

105133
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
134+
// let notification = notifications[indexPath.row]
135+
106136
let notification = notifications[indexPath.row]
107137

138+
if notification.app == "files_sharing" {
139+
NCActionCenter.shared.viewerFile(account: session.account, fileId: notification.objectId, viewController: self)
140+
} else {
141+
NCApplicationHandle().didSelectNotification(notification, viewController: self)
142+
}
143+
guard let notification = NCApplicationHandle().didSelectNotification(notifications[indexPath.row], viewController: self) else { return }
144+
108145
do {
109146
if let subjectRichParameters = notification.subjectRichParameters,
110147
let json = try JSONSerialization.jsonObject(with: subjectRichParameters, options: .mutableContainers) as? [String: Any],
@@ -138,9 +175,9 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
138175
}
139176

140177
if let image = image {
141-
cell.icon.image = image.withTintColor(NCBrandColor.shared.getElement(account: session.account), renderingMode: .alwaysOriginal)
178+
cell.icon.image = image.withTintColor(NCBrandColor.shared.iconColor, renderingMode: .alwaysOriginal)
142179
} else {
143-
cell.icon.image = utility.loadImage(named: "bell", color: NCBrandColor.shared.iconColor)
180+
cell.icon.image = utility.loadImage(named: "bell", colors: [NCBrandColor.shared.iconColor])
144181
}
145182

146183
// Avatar
@@ -169,14 +206,14 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
169206

170207
cell.date.text = DateFormatter.localizedString(from: notification.date as Date, dateStyle: .medium, timeStyle: .medium)
171208
cell.notification = notification
172-
cell.date.text = utility.getRelativeDateTitle(notification.date as Date)
173-
cell.date.textColor = NCBrandColor.shared.iconImageColor2
209+
cell.date.text = utility.dateDiff(notification.date as Date)
210+
cell.date.textColor = .gray
174211
cell.subject.text = notification.subject
175212
cell.subject.textColor = NCBrandColor.shared.textColor
176213
cell.message.text = notification.message.replacingOccurrences(of: "<br />", with: "\n")
177-
cell.message.textColor = NCBrandColor.shared.textColor2
214+
cell.message.textColor = .gray
178215

179-
cell.remove.setImage(utility.loadImage(named: "xmark", colors: [NCBrandColor.shared.iconImageColor]), for: .normal)
216+
cell.remove.setImage(UIImage(named: "xmark")!.image(color: .gray, size: 20), for: .normal)
180217

181218
cell.primary.isEnabled = false
182219
cell.primary.isHidden = true
@@ -192,9 +229,9 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
192229
cell.secondary.layer.cornerRadius = 10
193230
cell.secondary.layer.masksToBounds = true
194231
cell.secondary.layer.borderWidth = 1
195-
cell.secondary.layer.borderColor = NCBrandColor.shared.iconImageColor2.cgColor
196-
cell.secondary.layer.backgroundColor = UIColor.secondarySystemBackground.cgColor
197-
cell.secondary.setTitleColor(NCBrandColor.shared.iconImageColor2, for: .normal)
232+
cell.secondary.layer.borderColor = NCBrandColor.shared.notificationAction.cgColor
233+
cell.secondary.layer.backgroundColor = UIColor.clear.cgColor
234+
cell.secondary.setTitleColor(NCBrandColor.shared.notificationAction, for: .normal)
198235

199236
// Action
200237
if let actions = notification.actions,

0 commit comments

Comments
 (0)