@@ -46,6 +46,43 @@ extension MainViewController {
4646 self . startDeviceStatusTimer ( time: 10 )
4747 }
4848 }
49+
50+ func evaluateNotLooping( lastLoopTime: TimeInterval ) {
51+ if let statusStackView = LoopStatusLabel . superview as? UIStackView {
52+ if ( ( TimeInterval ( Date ( ) . timeIntervalSince1970) - lastLoopTime) / 60 ) > 15 {
53+ IsNotLooping = true
54+ // Change the distribution to 'fill' to allow manual resizing of arranged subviews
55+ statusStackView. distribution = . fill
56+
57+ // Hide PredictionLabel and expand LoopStatusLabel to fill the entire stack view
58+ PredictionLabel . isHidden = true
59+ LoopStatusLabel . frame = CGRect ( x: 0 , y: 0 , width: statusStackView. frame. width, height: statusStackView. frame. height)
60+
61+ // Update LoopStatusLabel's properties to display Not Looping
62+ LoopStatusLabel . textAlignment = . center
63+ LoopStatusLabel . text = " ⚠️ Not Looping! "
64+ LoopStatusLabel . textColor = UIColor . systemYellow
65+ LoopStatusLabel . font = UIFont . boldSystemFont ( ofSize: 18 )
66+
67+ } else {
68+ IsNotLooping = false
69+ // Restore the original distribution and visibility of labels
70+ statusStackView. distribution = . fillEqually
71+ PredictionLabel . isHidden = false
72+
73+ // Reset LoopStatusLabel's properties
74+ LoopStatusLabel . textAlignment = . right
75+ LoopStatusLabel . font = UIFont . systemFont ( ofSize: 17 )
76+
77+ if UserDefaultsRepository . forceDarkMode. value {
78+ LoopStatusLabel . textColor = UIColor . white
79+ } else {
80+ LoopStatusLabel . textColor = UIColor . black
81+ }
82+ }
83+ }
84+ latestLoopTime = lastLoopTime
85+ }
4986
5087 // NS Device Status Response Processor
5188 func updateDeviceStatusDisplay( jsonDeviceStatus: [ [ String : AnyObject ] ] ) {
@@ -171,12 +208,8 @@ extension MainViewController {
171208 }
172209
173210 }
174-
175- if ( ( TimeInterval ( Date ( ) . timeIntervalSince1970) - lastLoopTime) / 60 ) > 15 {
176- LoopStatusLabel . text = " ⚠ "
177- latestLoopStatusString = " ⚠ "
178- }
179- latestLoopTime = lastLoopTime
211+
212+ evaluateNotLooping ( lastLoopTime: lastLoopTime)
180213 } // end lastLoopTime
181214 } // end lastLoop Record
182215
@@ -305,11 +338,8 @@ extension MainViewController {
305338 }
306339
307340 }
308- if ( ( TimeInterval ( Date ( ) . timeIntervalSince1970) - lastLoopTime) / 60 ) > 15 {
309- LoopStatusLabel . text = " ⚠ "
310- latestLoopStatusString = " ⚠ "
311- }
312- latestLoopTime = lastLoopTime
341+
342+ evaluateNotLooping ( lastLoopTime: lastLoopTime)
313343 }
314344 }
315345
0 commit comments