@@ -26,47 +26,47 @@ import Classy
26
26
27
27
28
28
@objc protocol ConversationListViewControllerDelegate {
29
- optional func conversationList( conversationList: ConversationListViewController , didSelectConversation conversation: Conversation )
29
+ optional func conversationList( _ conversationList: ConversationListViewController , didSelectConversation conversation: Conversation )
30
30
}
31
31
32
32
33
33
34
34
class ConversationListViewController : UITableViewController {
35
35
36
- @IBOutlet private weak var backButton : IconButton !
37
- @IBOutlet private weak var cancelButton : IconButton !
36
+ @IBOutlet fileprivate weak var backButton : IconButton !
37
+ @IBOutlet fileprivate weak var cancelButton : IconButton !
38
38
39
39
override func viewDidLoad( ) {
40
40
super. viewDidLoad ( )
41
41
42
42
self . tableView. estimatedRowHeight = 52.0
43
43
self . tableView. rowHeight = UITableViewAutomaticDimension
44
44
45
- let image = UIImage ( forLogoWithColor : UIColor . accentColor, iconSize: . Medium )
45
+ let image = UIImage ( forLogoWith : UIColor . accentColor, iconSize: . medium )
46
46
self . navigationItem. titleView = UIImageView ( image: image)
47
47
48
- self . cancelButton. setIcon ( . X, withSize : . Tiny , forState : . Normal )
49
- self . backButton. setIcon ( . ChevronLeft , withSize : . Tiny , forState : . Normal )
48
+ self . cancelButton. setIcon ( . X, with : . tiny , for : UIControlState ( ) )
49
+ self . backButton. setIcon ( . chevronLeft , with : . tiny , for : UIControlState ( ) )
50
50
51
- let barButtonOffset : CGFloat = ( self . traitCollection. userInterfaceIdiom == . Phone ) ? 8 : 4
51
+ let barButtonOffset : CGFloat = ( self . traitCollection. userInterfaceIdiom == . phone ) ? 8 : 4
52
52
if let leftItem = self . navigationItem. leftBarButtonItem {
53
- let leftSpacer = UIBarButtonItem ( barButtonSystemItem: UIBarButtonSystemItem . FixedSpace , target: nil , action: nil )
53
+ let leftSpacer = UIBarButtonItem ( barButtonSystemItem: UIBarButtonSystemItem . fixedSpace , target: nil , action: nil )
54
54
leftSpacer. width = barButtonOffset
55
55
self . navigationItem. leftBarButtonItems = [ leftSpacer, leftItem]
56
56
}
57
57
58
58
if let rightItem = self . navigationItem. rightBarButtonItem {
59
- let rightSpacer = UIBarButtonItem ( barButtonSystemItem: UIBarButtonSystemItem . FixedSpace , target: nil , action: nil )
59
+ let rightSpacer = UIBarButtonItem ( barButtonSystemItem: UIBarButtonSystemItem . fixedSpace , target: nil , action: nil )
60
60
rightSpacer. width = barButtonOffset
61
61
self . navigationItem. rightBarButtonItems = [ rightSpacer, rightItem]
62
62
}
63
63
}
64
64
65
- override func viewWillAppear( animated: Bool ) {
65
+ override func viewWillAppear( _ animated: Bool ) {
66
66
super. viewWillAppear ( animated)
67
67
}
68
68
69
- override func viewDidAppear( animated: Bool ) {
69
+ override func viewDidAppear( _ animated: Bool ) {
70
70
super. viewDidAppear ( animated)
71
71
72
72
// Following manual Classy update is a workarround for a bug:
@@ -89,29 +89,29 @@ class ConversationListViewController: UITableViewController {
89
89
var searchTerm : String = " " {
90
90
didSet {
91
91
self . tableView. reloadData ( )
92
- if ( self . tableView. numberOfRowsInSection ( 0 ) > 0 ) {
93
- self . tableView. scrollToRowAtIndexPath ( NSIndexPath ( forRow : 0 , inSection : 0 ) , atScrollPosition : . Top , animated: false )
92
+ if ( self . tableView. numberOfRows ( inSection : 0 ) > 0 ) {
93
+ self . tableView. scrollToRow ( at : IndexPath ( row : 0 , section : 0 ) , at : . top , animated: false )
94
94
}
95
95
}
96
96
}
97
97
98
98
var excludedConversations : Array < Conversation > = [ ] {
99
99
didSet {
100
100
self . tableView. reloadData ( )
101
- if ( self . tableView. numberOfRowsInSection ( 0 ) > 0 ) {
102
- self . tableView. scrollToRowAtIndexPath ( NSIndexPath ( forRow : 0 , inSection : 0 ) , atScrollPosition : . Top , animated: false )
101
+ if ( self . tableView. numberOfRows ( inSection : 0 ) > 0 ) {
102
+ self . tableView. scrollToRow ( at : IndexPath ( row : 0 , section : 0 ) , at : . top , animated: false )
103
103
}
104
104
}
105
105
}
106
106
107
107
// MARK: - Actions
108
108
109
- @IBAction func backButtonPressed( sender: AnyObject ) {
110
- self . navigationController? . popViewControllerAnimated ( true )
109
+ @IBAction func backButtonPressed( _ sender: AnyObject ) {
110
+ self . navigationController? . popViewController ( animated : true )
111
111
}
112
112
113
- @IBAction func cancelPressed( sender: AnyObject ) {
114
- self . extensionContext!. cancelRequestWithError ( NSError ( domain: NSCocoaErrorDomain, code: NSUserCancelledError, userInfo: nil ) )
113
+ @IBAction func cancelPressed( _ sender: AnyObject ) {
114
+ self . extensionContext!. cancelRequest ( withError : NSError ( domain: NSCocoaErrorDomain, code: NSUserCancelledError, userInfo: nil ) )
115
115
}
116
116
117
117
// MARK: - API
@@ -158,16 +158,16 @@ class ConversationListViewController: UITableViewController {
158
158
159
159
// MARK: - Table view data source
160
160
161
- override func numberOfSectionsInTableView ( tableView: UITableView ) -> Int {
161
+ override func numberOfSections ( in tableView: UITableView ) -> Int {
162
162
return 1
163
163
}
164
164
165
- override func tableView( tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
165
+ override func tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
166
166
return self . filteredModel. count
167
167
}
168
168
169
- override func tableView( tableView: UITableView , cellForRowAtIndexPath indexPath: NSIndexPath ) -> UITableViewCell {
170
- let cell = tableView. dequeueReusableCellWithIdentifier ( " ConversationListCell " , forIndexPath : indexPath) as! ConversationListCell
169
+ override func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
170
+ let cell = tableView. dequeueReusableCell ( withIdentifier : " ConversationListCell " , for : indexPath) as! ConversationListCell
171
171
172
172
let conversation = self . filteredModel [ indexPath. row]
173
173
cell. conversation = conversation
@@ -182,7 +182,7 @@ class ConversationListViewController: UITableViewController {
182
182
183
183
// MARK: - Table view delegate
184
184
185
- override func tableView( tableView: UITableView , didSelectRowAtIndexPath indexPath: NSIndexPath ) {
185
+ override func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
186
186
self . delegate? . conversationList ? ( self , didSelectConversation: self . filteredModel [ indexPath. row] )
187
187
}
188
188
0 commit comments