@@ -137,7 +137,7 @@ class WorkoutsViewController: EntireTableViewController {
137137 if lastSyncDate != nil && data. count > 0 {
138138 updateStatusLabel ( " GitHub last updated on \n \( formatter. string ( from: lastSyncDate!) ) . " )
139139 } else {
140- updateStatusLabel ( " " )
140+ updateStatusLabel ( " No update yet. " )
141141 }
142142 }
143143
@@ -207,21 +207,43 @@ class WorkoutsViewController: EntireTableViewController {
207207 }
208208
209209 func loadStatusView( ) {
210- statusLabel = UILabel ( frame: CGRect . init ( x: 0 , y: 0 , width: 200 , height: 34 ) )
211- statusLabel? . text = " "
212- statusLabel? . textAlignment = NSTextAlignment . center
210+ statusLabel = PaddingLabel ( )
211+ statusLabel? . translatesAutoresizingMaskIntoConstraints = false
212+ statusLabel? . text = " No update yet. "
213+ statusLabel? . textAlignment = . center
213214 statusLabel? . textColor = UIColor . secondaryLabel
214215 statusLabel? . font = UIFont . preferredFont ( forTextStyle: . footnote)
215216 statusLabel? . lineBreakMode = . byWordWrapping
216217 statusLabel? . numberOfLines = 2
218+ statusLabel? . preferredMaxLayoutWidth = 300
219+
220+ let statusContainer = UIView ( )
221+ statusContainer. translatesAutoresizingMaskIntoConstraints = false
222+ statusContainer. addSubview ( statusLabel!)
223+
224+ NSLayoutConstraint . activate ( [
225+ statusLabel!. leadingAnchor. constraint ( equalTo: statusContainer. leadingAnchor, constant: 8 ) ,
226+ statusLabel!. trailingAnchor. constraint ( equalTo: statusContainer. trailingAnchor, constant: - 8 ) ,
227+ statusLabel!. topAnchor. constraint ( equalTo: statusContainer. topAnchor) ,
228+ statusLabel!. bottomAnchor. constraint ( equalTo: statusContainer. bottomAnchor)
229+ ] )
230+
231+ let widthConstraint = statusContainer. widthAnchor. constraint ( equalToConstant: 200 )
232+ widthConstraint. priority = . defaultLow
233+ widthConstraint. isActive = true
234+
235+ let statusItem = UIBarButtonItem ( customView: statusContainer)
236+ statusItem. customView? . setContentHuggingPriority ( . defaultLow, for: . horizontal)
237+ statusItem. customView? . setContentCompressionResistancePriority ( . defaultLow, for: . horizontal)
217238
218- let statusItem = UIBarButtonItem ( customView: statusLabel!)
219239 filterButton = UIBarButtonItem ( image: UIImage ( systemName: " line.horizontal.3.decrease.circle " ) , style: . plain, target: self , action: #selector( showFilter ( sender: ) ) )
220240 filterButton? . tintColor = ( self . filter. isEmpty ? UIColor . secondaryLabel : UIColor . systemBlue)
221241 let rightButtonItem = UIBarButtonItem ( image: UIImage ( systemName: " safari " ) , style: . plain, target: self , action: #selector( openSafari ( sender: ) ) )
222242 rightButtonItem. tintColor = UIColor . secondaryLabel
243+
223244 let leftSpaceItem = UIBarButtonItem ( barButtonSystemItem: . flexibleSpace, target: nil , action: nil )
224245 let rightSpaceItem = UIBarButtonItem ( barButtonSystemItem: . flexibleSpace, target: nil , action: nil )
246+
225247 self . toolbarItems = [ filterButton!, leftSpaceItem, statusItem, rightSpaceItem, rightButtonItem]
226248 }
227249
0 commit comments