Skip to content

Commit 490b279

Browse files
NMC 1935 - Notification screen customisation changes
1 parent e5d6f80 commit 490b279

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

iOSClient/Notification/NCNotification.swift

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,18 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
7373
override func viewDidAppear(_ animated: Bool) {
7474
super.viewDidAppear(animated)
7575

76+
// Re-evaluate in-app messages after viewDidAppear
77+
MoEngageAnalytics.shared.displayInAppNotificationSafely(reason: "viewDidAppear")
78+
7679
Task {
7780
await getNetwokingNotification()
7881
}
7982
}
83+
84+
override func viewWillAppear(_ animated: Bool) {
85+
super.viewWillAppear(animated)
86+
AnalyticsHelper.shared.trackEvent(eventName: .SCREEN_EVENT__NOTIFICATIONS)
87+
}
8088

8189
override func viewWillDisappear(_ animated: Bool) {
8290
super.viewWillDisappear(animated)
@@ -97,15 +105,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
97105
}
98106

99107
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
100-
// let notification = notifications[indexPath.row]
101-
102-
let notification = notifications[indexPath.row]
103-
104-
if notification.app == "files_sharing" {
105-
NCActionCenter.shared.viewerFile(account: session.account, fileId: notification.objectId, viewController: self)
106-
} else {
107-
NCApplicationHandle().didSelectNotification(notification, viewController: self)
108-
}
109108
guard let notification = NCApplicationHandle().didSelectNotification(notifications[indexPath.row], viewController: self) else { return }
110109

111110
do {
@@ -129,7 +128,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
129128
guard let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? NCNotificationCell else { return UITableViewCell() }
130129
cell.delegate = self
131130
cell.selectionStyle = .none
132-
cell.index = indexPath
131+
cell.indexPath = indexPath
133132

134133
let notification = notifications[indexPath.row]
135134
let urlIcon = URL(string: notification.icon)
@@ -157,9 +156,9 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
157156
let results = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName)
158157

159158
if results.image == nil {
160-
cell.avatar?.image = utility.loadUserImage(for: user, displayName: json["user"]?["name"].string, urlBase: session.urlBase)
159+
cell.avatarImageView?.image = utility.loadUserImage(for: user, displayName: json["user"]?["name"].string, urlBase: session.urlBase)
161160
} else {
162-
cell.avatar?.image = results.image
161+
cell.avatarImageView?.image = results.image
163162
}
164163

165164
if !(results.tblAvatar?.loaded ?? false),
@@ -239,13 +238,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
239238
cell.more.isEnabled = true
240239
cell.more.isHidden = false
241240
cell.more.setTitle("", for: .normal)
242-
243-
let contextMenu = NCContextMenuNotification(
244-
notification: notification,
245-
delegate: self
246-
)
247-
cell.more.menu = contextMenu.viewMenu()
248-
cell.more.showsMenuAsPrimaryAction = true
249241
}
250242

251243
var buttonWidth = max(cell.primary.intrinsicContentSize.width, cell.secondary.intrinsicContentSize.width)
@@ -359,7 +351,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
359351
let sortedNotifications = notifications.sorted { $0.date > $1.date }
360352
for notification in sortedNotifications {
361353
if let icon = notification.icon {
362-
if await self.utility.convertSVGtoPNGWriteToUserData(serverUrl: icon, rewrite: false, account: session.account).image != nil {
354+
self.utility.convertSVGtoPNGWriteToUserData(svgUrlString: icon, width: 25, rewrite: false, account: session.account) { _, _ in
363355
self.tableView.reloadData()
364356
}
365357
}
@@ -372,7 +364,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
372364

373365
// MARK: -
374366

375-
class NCNotificationCell: UITableViewCell {
367+
class NCNotificationCell: UITableViewCell, NCCellProtocol {
376368

377369
@IBOutlet weak var icon: UIImageView!
378370
@IBOutlet weak var avatar: UIImageView!
@@ -387,12 +379,24 @@ class NCNotificationCell: UITableViewCell {
387379
@IBOutlet weak var primaryWidth: NSLayoutConstraint!
388380
@IBOutlet weak var secondaryWidth: NSLayoutConstraint!
389381

390-
var user = ""
391-
var index = IndexPath()
382+
private var user = ""
383+
private var index = IndexPath()
392384

393385
weak var delegate: NCNotificationCellDelegate?
394386
var notification: NKNotifications?
395387

388+
var indexPath: IndexPath {
389+
get { return index }
390+
set { index = newValue }
391+
}
392+
var avatarImageView: UIImageView? {
393+
return avatar
394+
}
395+
var fileUser: String? {
396+
get { return user }
397+
set { user = newValue ?? "" }
398+
}
399+
396400
@IBAction func touchUpInsideRemove(_ sender: Any) {
397401
guard let notification = notification else { return }
398402
delegate?.tapRemove(with: notification, sender: sender)

0 commit comments

Comments
 (0)