@@ -26,11 +26,13 @@ import UIKit
2626import NextcloudKit
2727import 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