@@ -20,6 +20,7 @@ class RouteTableViewCell: UITableViewCell {
2020
2121 static let identifier : String = " routeCell "
2222 private let fileName : String = " RouteTableViewCell "
23+
2324 var route : Route ?
2425
2526 // MARK: Log vars
@@ -28,6 +29,8 @@ class RouteTableViewCell: UITableViewCell {
2829
2930 // MARK: View vars
3031
32+ let containerView = UIView ( )
33+
3134 var timesStackView : UIStackView
3235 var travelTimeLabel : UILabel
3336
@@ -41,11 +44,7 @@ class RouteTableViewCell: UITableViewCell {
4144 var stretchyFillerView : UIView
4245
4346 var verticalStackView : UIStackView
44- var topBorder : UIView
4547 var routeDiagram : RouteDiagram
46- var funMessage : UILabel
47- var bottomBorder : UIView
48- var cellSeparator : UIView
4948
5049 // MARK: Spacing vars
5150
@@ -54,8 +53,10 @@ class RouteTableViewCell: UITableViewCell {
5453 let bottomMargin : CGFloat = 16
5554 let rightMargin : CGFloat = 12
5655
57- let cellBorderHeight : CGFloat = 0.75
58- let cellSeparatorHeight : CGFloat = 6.0
56+ let cellMargin : CGFloat = 12
57+
58+ let cornerRadius : CGFloat = 16
59+ let cellSeparatorHeight : CGFloat = 12
5960
6061 let spaceBtnDepartureElements : CGFloat = 4
6162 let arrowImageViewHeight : CGFloat = 11.5
@@ -78,24 +79,16 @@ class RouteTableViewCell: UITableViewCell {
7879 stretchyFillerView = UIView ( )
7980 liveStackView = UIStackView ( arrangedSubviews: [ liveLabel, liveIndicatorView, stretchyFillerView] )
8081
81- topBorder = UIView ( )
8282 routeDiagram = RouteDiagram ( )
83- funMessage = UILabel ( )
84- bottomBorder = UIView ( )
85- cellSeparator = UIView ( )
8683 verticalStackView = UIStackView ( arrangedSubviews: [ timesStackView, liveStackView, routeDiagram] )
8784
8885 super. init ( style: style, reuseIdentifier: reuseIdentifier)
8986
90- styleTopBorder ( )
87+ styleCellBackground ( )
9188 styleVerticalStackView ( )
92- styleBottomBorder ( )
93- styleCellSeparator ( )
9489
95- contentView. addSubview ( topBorder)
96- contentView. addSubview ( verticalStackView)
97- contentView. addSubview ( bottomBorder)
98- contentView. addSubview ( cellSeparator)
90+ contentView. addSubview ( containerView)
91+ containerView. addSubview ( verticalStackView)
9992
10093 activateConstraints ( )
10194 }
@@ -104,21 +97,37 @@ class RouteTableViewCell: UITableViewCell {
10497 fatalError ( " init(coder:) has not been implemented " )
10598 }
10699
100+ override func layoutSubviews( ) {
101+ super. layoutSubviews ( )
102+ let padding = UIEdgeInsets ( top: 0 , left: 0 , bottom: cellMargin, right: 0 )
103+ contentView. frame = contentView. frame. inset ( by: padding)
104+ }
105+
107106 // MARK: Style
108107
108+ private func styleCellBackground( ) {
109+ layer. backgroundColor = UIColor . clear. cgColor
110+ contentView. backgroundColor = . clear
111+ backgroundColor = . clear
112+
113+ containerView. backgroundColor = Colors . white
114+ containerView. layer. cornerRadius = cornerRadius
115+ containerView. layer. masksToBounds = true
116+ }
117+
109118 private func styleVerticalStackView( ) {
110119 verticalStackView. axis = . vertical
120+ verticalStackView. spacing = 8
111121 verticalStackView. layoutMargins = UIEdgeInsets . init ( top: topMargin, left: leftMargin, bottom: bottomMargin, right: rightMargin)
112122 verticalStackView. isLayoutMarginsRelativeArrangement = true
113123
114124 styleTimesStackView ( )
115125 styleLiveStackView ( )
116- // styleFunMessage()
117126 }
118127
119128 private func styleTimesStackView( ) {
120129 timesStackView. axis = . horizontal
121- timesStackView. alignment = . center
130+ timesStackView. alignment = . firstBaseline
122131
123132 travelTimeLabel. font = . getFont( . semibold, size: 16 )
124133 travelTimeLabel. textColor = Colors . primaryText
@@ -140,29 +149,13 @@ class RouteTableViewCell: UITableViewCell {
140149 stretchyFillerView. setContentHuggingPriority ( liveLabel. contentHuggingPriority ( for: . horizontal) - 1 , for: . horizontal)
141150
142151 liveStackView. axis = . horizontal
143- liveStackView. alignment = . lastBaseline
152+ liveStackView. alignment = . center
144153 liveStackView. spacing = spaceBtnLiveElements
154+ liveStackView. frame = liveStackView. frame. inset ( by: UIEdgeInsets ( top: - 4 , left: 0 , bottom: - 4 , right: 0 ) )
145155
146156 liveLabel. font = . getFont( . semibold, size: 14 )
147157 }
148158
149- private func styleFunMessage( ) {
150- funMessage. font = . getFont( . semibold, size: 12 )
151- funMessage. textColor = . lightGray
152- }
153-
154- private func styleTopBorder( ) {
155- topBorder. backgroundColor = Colors . dividerTextField
156- }
157-
158- private func styleBottomBorder( ) {
159- bottomBorder. backgroundColor = Colors . dividerTextField
160- }
161-
162- private func styleCellSeparator( ) {
163- cellSeparator. backgroundColor = Colors . backgroundWash
164- }
165-
166159 // MARK: Add subviews
167160
168161 func addRouteDiagramSubviews( ) {
@@ -180,46 +173,32 @@ class RouteTableViewCell: UITableViewCell {
180173 setDebugIdentifiers ( )
181174
182175 NSLayoutConstraint . activate ( [
183- topBorder. topAnchor. constraint ( equalTo: contentView. topAnchor) ,
184- topBorder. leadingAnchor. constraint ( equalTo: contentView. leadingAnchor) ,
185- topBorder. trailingAnchor. constraint ( equalTo: contentView. trailingAnchor) ,
186- topBorder. heightAnchor. constraint ( equalToConstant: cellBorderHeight) ,
187- topBorder. bottomAnchor. constraint ( equalTo: verticalStackView. topAnchor)
188- ] )
189-
190- NSLayoutConstraint . activate ( [
191- verticalStackView. leadingAnchor. constraint ( equalTo: contentView. leadingAnchor) ,
192- verticalStackView. trailingAnchor. constraint ( equalTo: contentView. trailingAnchor) ,
193- verticalStackView. bottomAnchor. constraint ( equalTo: bottomBorder. topAnchor)
194- ] )
195-
196- NSLayoutConstraint . activate ( [
197- bottomBorder. leadingAnchor. constraint ( equalTo: contentView. leadingAnchor) ,
198- bottomBorder. trailingAnchor. constraint ( equalTo: contentView. trailingAnchor) ,
199- bottomBorder. heightAnchor. constraint ( equalToConstant: cellBorderHeight) ,
200- bottomBorder. bottomAnchor. constraint ( equalTo: cellSeparator. topAnchor)
176+ containerView. leadingAnchor. constraint ( equalTo: contentView. leadingAnchor, constant: cellMargin) ,
177+ containerView. trailingAnchor. constraint ( equalTo: contentView. trailingAnchor, constant: - cellMargin) ,
178+ containerView. topAnchor. constraint ( equalTo: contentView. topAnchor) ,
179+ containerView. bottomAnchor. constraint ( equalTo: contentView. bottomAnchor)
201180 ] )
202181
203182 NSLayoutConstraint . activate ( [
204- cellSeparator . leadingAnchor. constraint ( equalTo: contentView . leadingAnchor) ,
205- cellSeparator . trailingAnchor. constraint ( equalTo: contentView . trailingAnchor) ,
206- cellSeparator . heightAnchor . constraint ( equalToConstant : cellSeparatorHeight ) ,
207- cellSeparator . bottomAnchor. constraint ( equalTo: contentView . bottomAnchor)
183+ verticalStackView . leadingAnchor. constraint ( equalTo: containerView . leadingAnchor) ,
184+ verticalStackView . trailingAnchor. constraint ( equalTo: containerView . trailingAnchor) ,
185+ verticalStackView . topAnchor . constraint ( equalTo : containerView . topAnchor ) ,
186+ verticalStackView . bottomAnchor. constraint ( equalTo: containerView . bottomAnchor)
208187 ] )
209188
210189 NSLayoutConstraint . activate ( [
211190 arrowImageView. heightAnchor. constraint ( equalToConstant: arrowImageViewHeight) ,
212191 arrowImageView. widthAnchor. constraint ( equalToConstant: arrowImageViewWidth) ,
213192 arrowImageView. centerYAnchor. constraint ( equalTo: departureTimeLabel. centerYAnchor)
214193 ] )
194+
215195 }
216196
217197 private func setTranslatesAutoresizingMaskIntoConstraints( ) {
218198 let subviews = [ timesStackView, travelTimeLabel,
219199 departureStackView, departureTimeLabel, arrowImageView,
220200 liveStackView, liveLabel, liveIndicatorView, stretchyFillerView,
221- verticalStackView, topBorder, routeDiagram, funMessage, bottomBorder, cellSeparator]
222-
201+ verticalStackView, routeDiagram, containerView]
223202 subviews. forEach { $0. translatesAutoresizingMaskIntoConstraints = false }
224203 }
225204
@@ -238,10 +217,7 @@ class RouteTableViewCell: UITableViewCell {
238217 stretchyFillerView. accessibilityIdentifier = " stretchyFillerView "
239218
240219 verticalStackView. accessibilityIdentifier = " verticalStackView "
241- topBorder. accessibilityIdentifier = " topBorder "
242220 routeDiagram. accessibilityIdentifier = " routeDiagram "
243- bottomBorder. accessibilityIdentifier = " bottomBorder "
244- cellSeparator. accessibilityIdentifier = " cellSeparator "
245221 }
246222
247223 // MARK: Get Data
@@ -267,10 +243,9 @@ class RouteTableViewCell: UITableViewCell {
267243 if ( delayedDepartTime >= Date ( ) || delay >= 120 ) {
268244 return . late( date: delayedDepartTime)
269245 } else { // delay < 120
270- return . onTime( date: departTime)
246+ return . onTime( date: departTime)
271247 }
272- }
273- else { // bus is not delayed
248+ } else { // bus is not delayed
274249 return . onTime( date: departTime)
275250 }
276251
@@ -306,8 +281,6 @@ class RouteTableViewCell: UITableViewCell {
306281 setDepartureTimeAndLiveElements ( withRoute: route)
307282
308283 routeDiagram. setData ( withDirections: route. rawDirections, withTravelDistance: route. travelDistance, withWalkingRoute: route. isRawWalkingRoute ( ) )
309-
310- // setFunMessage()
311284 }
312285
313286 private func setDepartureTimeAndLiveElements( withRoute route: Route ) {
@@ -323,10 +296,6 @@ class RouteTableViewCell: UITableViewCell {
323296 setLiveElements ( withDelayState: delayState)
324297 }
325298
326- private func setFunMessage( ) {
327- funMessage. text = " Howdy! Here's a fun message! :) "
328- }
329-
330299 @objc func updateLiveElementsWithDelay( ) {
331300 if let route = route,
332301 let direction = route. getFirstDepartRawDirection ( ) ,
0 commit comments