@@ -49,6 +49,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
49
49
50
50
tableView. register ( BolusProgressTableViewCell . nib ( ) , forCellReuseIdentifier: BolusProgressTableViewCell . className)
51
51
tableView. register ( AlertPermissionsDisabledWarningCell . self, forCellReuseIdentifier: AlertPermissionsDisabledWarningCell . className)
52
+ tableView. register ( MuteAlertsWarningCell . self, forCellReuseIdentifier: MuteAlertsWarningCell . className)
52
53
53
54
if FeatureFlags . predictedGlucoseChartClampEnabled {
54
55
statusCharts. glucose. glucoseDisplayRange = LoopConstants . glucoseChartDefaultDisplayBoundClamped
@@ -633,7 +634,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
633
634
}
634
635
635
636
private enum Section : Int , CaseIterable {
636
- case alertPermissionsDisabledWarning
637
+ case alertWarning
637
638
case hud
638
639
case status
639
640
case charts
@@ -679,7 +680,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
679
680
case pumpSuspended( resuming: Bool )
680
681
case onboardingSuspended
681
682
case recommendManualGlucoseEntry
682
- case tempMuteAlerts
683
683
684
684
var hasRow : Bool {
685
685
switch self {
@@ -718,22 +718,25 @@ final class StatusTableViewController: LoopChartsTableViewController {
718
718
!premealOverride. hasFinished ( )
719
719
{
720
720
statusRowMode = . scheduleOverrideEnabled( premealOverride)
721
- } else if alertMuter. shouldMuteAlert ( ) {
722
- statusRowMode = . tempMuteAlerts
723
721
} else {
724
722
statusRowMode = . hidden
725
723
}
726
724
727
725
return statusRowMode
728
726
}
729
-
727
+
728
+ private var shouldShowBannerWarning : Bool {
729
+ alertPermissionsChecker. showWarning || alertMuter. configuration. shouldMute
730
+ }
731
+
730
732
private func updateBannerRow( animated: Bool ) {
731
- let warningWasVisible = tableView. numberOfRows ( inSection: Section . alertPermissionsDisabledWarning. rawValue) != 0
732
- let showWarning = alertPermissionsChecker. showWarning
733
- if !showWarning && warningWasVisible {
734
- tableView. deleteRows ( at: [ IndexPath ( row: 0 , section: Section . alertPermissionsDisabledWarning. rawValue) ] , with: animated ? . top : . none)
735
- } else if showWarning && !warningWasVisible {
736
- tableView. insertRows ( at: [ IndexPath ( row: 0 , section: Section . alertPermissionsDisabledWarning. rawValue) ] , with: animated ? . top : . none)
733
+ let warningWasVisible = tableView. numberOfRows ( inSection: Section . alertWarning. rawValue) != 0
734
+ if !shouldShowBannerWarning && warningWasVisible {
735
+ tableView. deleteRows ( at: [ IndexPath ( row: 0 , section: Section . alertWarning. rawValue) ] , with: animated ? . top : . none)
736
+ } else if shouldShowBannerWarning && !warningWasVisible {
737
+ tableView. insertRows ( at: [ IndexPath ( row: 0 , section: Section . alertWarning. rawValue) ] , with: animated ? . top : . none)
738
+ } else {
739
+ tableView. reloadRows ( at: [ IndexPath ( row: 0 , section: Section . alertWarning. rawValue) ] , with: . none)
737
740
}
738
741
}
739
742
@@ -850,8 +853,8 @@ final class StatusTableViewController: LoopChartsTableViewController {
850
853
851
854
override func tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
852
855
switch Section ( rawValue: section) ! {
853
- case . alertPermissionsDisabledWarning :
854
- return alertPermissionsChecker . showWarning ? 1 : 0
856
+ case . alertWarning :
857
+ return shouldShowBannerWarning ? 1 : 0
855
858
case . hud:
856
859
return shouldShowHUD ? 1 : 0
857
860
case . charts:
@@ -862,7 +865,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
862
865
}
863
866
864
867
private class AlertPermissionsDisabledWarningCell : UITableViewCell {
865
-
866
868
override func updateConfiguration( using state: UICellConfigurationState ) {
867
869
super. updateConfiguration ( using: state)
868
870
@@ -878,7 +880,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
878
880
contentConfig. textProperties. color = . white
879
881
contentConfig. textProperties. font = . systemFont( ofSize: adjustViewForNarrowDisplay ? 16 : 18 , weight: . bold)
880
882
contentConfig. textProperties. adjustsFontSizeToFitWidth = true
881
- contentConfig. secondaryText = " Fix now by turning Notifications, Critical Alerts and Time Sensitive Notifications ON. "
883
+ contentConfig. secondaryText = NSLocalizedString ( " Fix now by turning Notifications, Critical Alerts and Time Sensitive Notifications ON. " , comment : " instructions on how to fix alert permission warning " )
882
884
contentConfig. secondaryTextProperties. color = . white
883
885
contentConfig. secondaryTextProperties. font = . systemFont( ofSize: adjustViewForNarrowDisplay ? 13 : 15 )
884
886
contentConfiguration = contentConfig
@@ -897,12 +899,55 @@ final class StatusTableViewController: LoopChartsTableViewController {
897
899
contentView. directionalLayoutMargins = NSDirectionalEdgeInsets ( top: 6 , leading: 0 , bottom: 13 , trailing: 0 )
898
900
}
899
901
}
902
+
903
+ private class MuteAlertsWarningCell : UITableViewCell {
904
+ var formattedAlertMuteEndTime : String = NSLocalizedString ( " Unknown " , comment: " label for when the alert mute end time is unknown " )
905
+
906
+ override func updateConfiguration( using state: UICellConfigurationState ) {
907
+ super. updateConfiguration ( using: state)
908
+
909
+ let adjustViewForNarrowDisplay = bounds. width < 350
910
+
911
+ var contentConfig = defaultContentConfiguration ( ) . updated ( for: state)
912
+ let title = NSMutableAttributedString ( string: NSLocalizedString ( " All Alerts Muted " , comment: " Warning text for when alerts are muted " ) )
913
+ contentConfig. image = UIImage ( systemName: " speaker.slash.fill " )
914
+ contentConfig. imageProperties. tintColor = . white
915
+ contentConfig. attributedText = title
916
+ contentConfig. textProperties. color = . white
917
+ contentConfig. textProperties. font = . systemFont( ofSize: adjustViewForNarrowDisplay ? 16 : 18 , weight: . bold)
918
+ contentConfig. textProperties. adjustsFontSizeToFitWidth = true
919
+ contentConfig. secondaryText = String ( format: NSLocalizedString ( " Until %1$@ " , comment: " indication of when alerts will be unmuted (1: time when alerts unmute) " ) , formattedAlertMuteEndTime)
920
+ contentConfig. secondaryTextProperties. color = . white
921
+ contentConfig. secondaryTextProperties. font = . systemFont( ofSize: adjustViewForNarrowDisplay ? 13 : 15 )
922
+ contentConfiguration = contentConfig
923
+
924
+ var backgroundConfig = backgroundConfiguration? . updated ( for: state)
925
+ backgroundConfig? . backgroundColor = . warning. withAlphaComponent ( 0.8 )
926
+ backgroundConfiguration = backgroundConfig
927
+ backgroundConfiguration? . backgroundInsets = NSDirectionalEdgeInsets ( top: 0 , leading: 10 , bottom: 5 , trailing: 10 )
928
+ backgroundConfiguration? . cornerRadius = 10
929
+
930
+ let unmuteIndicator = UIImage ( systemName: " stop.circle " ) ? . withTintColor ( . white)
931
+ let imageView = UIImageView ( image: unmuteIndicator)
932
+ imageView. tintColor = . white
933
+ imageView. frame. size = CGSize ( width: 30 , height: 30 )
934
+ accessoryView = imageView
935
+
936
+ contentView. directionalLayoutMargins = NSDirectionalEdgeInsets ( top: 6 , leading: 0 , bottom: 13 , trailing: 0 )
937
+ }
938
+ }
900
939
901
940
override func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
902
941
switch Section ( rawValue: indexPath. section) ! {
903
- case . alertPermissionsDisabledWarning:
904
- let cell = tableView. dequeueReusableCell ( withIdentifier: AlertPermissionsDisabledWarningCell . className, for: indexPath) as! AlertPermissionsDisabledWarningCell
905
- return cell
942
+ case . alertWarning:
943
+ if alertPermissionsChecker. showWarning {
944
+ let cell = tableView. dequeueReusableCell ( withIdentifier: AlertPermissionsDisabledWarningCell . className, for: indexPath) as! AlertPermissionsDisabledWarningCell
945
+ return cell
946
+ } else {
947
+ let cell = tableView. dequeueReusableCell ( withIdentifier: MuteAlertsWarningCell . className, for: indexPath) as! MuteAlertsWarningCell
948
+ cell. formattedAlertMuteEndTime = alertMuter. formattedEndTime
949
+ return cell
950
+ }
906
951
case . hud:
907
952
let cell = tableView. dequeueReusableCell ( withIdentifier: HUDViewTableViewCell . className, for: indexPath) as! HUDViewTableViewCell
908
953
hudView = cell. hudView
@@ -958,11 +1003,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
958
1003
switch StatusRow ( rawValue: indexPath. row) ! {
959
1004
case . status:
960
1005
switch statusRowMode {
961
- case . tempMuteAlerts:
962
- //TODO testing (need design to make the correct status row)
963
- let cell = getTitleSubtitleCell ( )
964
- cell. titleLabel. text = NSLocalizedString ( " Temp Mute Alerts " , comment: " The title of the cell indicating alerts are temporarily muted " )
965
- return cell
966
1006
case . hidden:
967
1007
let cell = getTitleSubtitleCell ( )
968
1008
return cell
@@ -1101,7 +1141,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
1101
1141
cell. setSubtitleLabel ( label: nil )
1102
1142
}
1103
1143
}
1104
- case . hud, . status, . alertPermissionsDisabledWarning :
1144
+ case . hud, . status, . alertWarning :
1105
1145
break
1106
1146
}
1107
1147
}
@@ -1122,16 +1162,21 @@ final class StatusTableViewController: LoopChartsTableViewController {
1122
1162
case . iob, . dose, . cob:
1123
1163
return max ( 106 , 0.21 * availableSize)
1124
1164
}
1125
- case . hud, . status, . alertPermissionsDisabledWarning :
1165
+ case . hud, . status, . alertWarning :
1126
1166
return UITableView . automaticDimension
1127
1167
}
1128
1168
}
1129
1169
1130
1170
override func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
1131
1171
switch Section ( rawValue: indexPath. section) ! {
1132
- case . alertPermissionsDisabledWarning:
1133
- tableView. deselectRow ( at: indexPath, animated: true )
1134
- AlertPermissionsChecker . gotoSettings ( )
1172
+ case . alertWarning:
1173
+ if alertPermissionsChecker. showWarning {
1174
+ tableView. deselectRow ( at: indexPath, animated: true )
1175
+ AlertPermissionsChecker . gotoSettings ( )
1176
+ } else {
1177
+ tableView. deselectRow ( at: indexPath, animated: true )
1178
+ presentUnmuteAlertConfirmation ( )
1179
+ }
1135
1180
case . hud:
1136
1181
break
1137
1182
case . status:
@@ -1208,6 +1253,20 @@ final class StatusTableViewController: LoopChartsTableViewController {
1208
1253
}
1209
1254
}
1210
1255
1256
+ private func presentUnmuteAlertConfirmation( ) {
1257
+ let title = NSLocalizedString ( " Unmute Alerts? " , comment: " The alert title for unmute alert confirmation " )
1258
+ let body = NSLocalizedString ( " Tap Unmute to resume sound for your alerts and alarms. " , comment: " The alert body for unmute alert confirmation " )
1259
+ let action = UIAlertAction (
1260
+ title: NSLocalizedString ( " Unmute " , comment: " The title of the action used to unmute alerts " ) ,
1261
+ style: . default) { _ in
1262
+ self . alertMuter. unmuteAlerts ( )
1263
+ }
1264
+ let alert = UIAlertController ( title: title, message: body, preferredStyle: . alert)
1265
+ alert. addAction ( action)
1266
+ alert. addCancelAction { _ in }
1267
+ present ( alert, animated: true , completion: nil )
1268
+ }
1269
+
1211
1270
private func presentErrorCancelingBolus( _ error: ( Error ) ) {
1212
1271
log. error ( " Error Canceling Bolus: %@ " , error. localizedDescription)
1213
1272
let title = NSLocalizedString ( " Error Canceling Bolus " , comment: " The alert title for an error while canceling a bolus " )
0 commit comments