Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RC #497

Merged
merged 110 commits into from
Jan 16, 2023
Merged

RC #497

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
016cdae
New translations Localizable.strings (Spanish)
creepymonster Jan 10, 2023
3e16355
New translations Localizable.strings (Spanish)
creepymonster Jan 10, 2023
00a4a6b
New translations Localizable.strings (Italian)
creepymonster Jan 10, 2023
d0a954d
Merge pull request #476 from creepymonster/crowdin_users
creepymonster Jan 10, 2023
b06321a
New translations InfoPlist.strings (Polish)
creepymonster Jan 10, 2023
f3796fa
New translations Localizable.strings (Polish)
creepymonster Jan 10, 2023
497c2c7
Merge branch 'main' into crowdin
creepymonster Jan 10, 2023
d39984e
New Crowdin updates (#478)
creepymonster Jan 10, 2023
0440a3a
New translations Localizable.strings (Portuguese)
creepymonster Jan 10, 2023
f1f9105
New translations Localizable.strings (French)
creepymonster Jan 10, 2023
b37f87c
New translations Localizable.strings (Spanish)
creepymonster Jan 10, 2023
6746398
New translations Localizable.strings (German)
creepymonster Jan 10, 2023
cc60c6d
New translations Localizable.strings (Finnish)
creepymonster Jan 10, 2023
a0c8d05
New translations Localizable.strings (Italian)
creepymonster Jan 10, 2023
78ac82b
New translations Localizable.strings (Dutch)
creepymonster Jan 10, 2023
8e47646
New translations Localizable.strings (Russian)
creepymonster Jan 10, 2023
3ff52d0
New translations Localizable.strings (Swedish)
creepymonster Jan 10, 2023
4a5bb59
New translations Localizable.strings (Turkish)
creepymonster Jan 10, 2023
e916e4d
New translations Localizable.strings (Ukrainian)
creepymonster Jan 10, 2023
e0a33b2
New translations Localizable.strings (Chinese Simplified)
creepymonster Jan 10, 2023
8c8746b
New translations Localizable.strings (Chinese Traditional)
creepymonster Jan 10, 2023
f636b09
New translations Localizable.strings (Polish)
creepymonster Jan 10, 2023
ad2c3b9
New translations Localizable.strings (Arabic)
creepymonster Jan 10, 2023
206a348
New translations Localizable.strings (Bulgarian)
creepymonster Jan 10, 2023
4d8fb80
New translations Localizable.strings (German)
creepymonster Jan 10, 2023
a45113d
Merge branch 'crowdin' into crowdin_users
creepymonster Jan 10, 2023
6a394ac
New Crowdin updates (#480)
creepymonster Jan 10, 2023
5fd908b
Merge branch 'main' into crowdin
creepymonster Jan 10, 2023
8831cd0
New translations Localizable.strings (Ukrainian)
creepymonster Jan 10, 2023
9f83416
Merge branch 'crowdin' into crowdin_users
creepymonster Jan 10, 2023
6c3fe5b
New Crowdin updates (#484)
creepymonster Jan 10, 2023
9957157
New translations InfoPlist.strings (Polish)
creepymonster Jan 11, 2023
c76c506
New translations Localizable.strings (Polish)
creepymonster Jan 11, 2023
9b2d481
New translations Localizable.strings (Turkish)
creepymonster Jan 12, 2023
865fdc5
New translations Localizable.strings (Turkish)
creepymonster Jan 12, 2023
3212904
New Crowdin updates (#485)
creepymonster Jan 14, 2023
a535c97
Merge branch 'main' into crowdin
creepymonster Jan 14, 2023
a9cf298
Merge branch 'main' into crowdin
creepymonster Jan 14, 2023
f731e66
New translations Localizable.strings (Portuguese)
creepymonster Jan 14, 2023
586a049
New translations Localizable.strings (French)
creepymonster Jan 14, 2023
3c7be8d
New translations Localizable.strings (Spanish)
creepymonster Jan 14, 2023
cfdfeb8
New translations Localizable.strings (German)
creepymonster Jan 14, 2023
b0aff8e
New translations Localizable.strings (Finnish)
creepymonster Jan 14, 2023
1f8d2e5
New translations Localizable.strings (Italian)
creepymonster Jan 14, 2023
1e7f3ed
New translations Localizable.strings (Dutch)
creepymonster Jan 14, 2023
635ad07
New translations Localizable.strings (Russian)
creepymonster Jan 14, 2023
7288b0c
New translations Localizable.strings (Swedish)
creepymonster Jan 14, 2023
6c96b65
New translations Localizable.strings (Turkish)
creepymonster Jan 14, 2023
410246a
New translations Localizable.strings (Ukrainian)
creepymonster Jan 14, 2023
82b2df5
New translations Localizable.strings (Chinese Simplified)
creepymonster Jan 14, 2023
ded9880
New translations Localizable.strings (Chinese Traditional)
creepymonster Jan 14, 2023
4c121fd
New translations Localizable.strings (Polish)
creepymonster Jan 14, 2023
bad244e
New translations Localizable.strings (Arabic)
creepymonster Jan 14, 2023
2385f35
New translations Localizable.strings (Bulgarian)
creepymonster Jan 14, 2023
8268f48
Merge branch 'main' into crowdin
creepymonster Jan 14, 2023
cbbf07a
New Crowdin updates (#488)
creepymonster Jan 14, 2023
b92807d
Create GlucoseDirectOverride.xcconfig
creepymonster Jan 14, 2023
ca5f06f
Delete GlucoseDirectOverride.xcconfig
creepymonster Jan 14, 2023
347b68c
New translations Localizable.strings (Portuguese)
creepymonster Jan 14, 2023
944d911
New translations Localizable.strings (French)
creepymonster Jan 14, 2023
0d8d4b7
New translations Localizable.strings (Spanish)
creepymonster Jan 14, 2023
835a82c
New translations Localizable.strings (German)
creepymonster Jan 14, 2023
16bd657
New translations Localizable.strings (Finnish)
creepymonster Jan 14, 2023
670b37c
New translations Localizable.strings (Italian)
creepymonster Jan 14, 2023
8262c5d
New translations Localizable.strings (Dutch)
creepymonster Jan 14, 2023
ec94bb0
New translations Localizable.strings (Russian)
creepymonster Jan 14, 2023
b21f735
New translations Localizable.strings (Swedish)
creepymonster Jan 14, 2023
9554f98
New translations Localizable.strings (Turkish)
creepymonster Jan 14, 2023
907900e
New translations Localizable.strings (Ukrainian)
creepymonster Jan 14, 2023
8104523
New translations Localizable.strings (Chinese Simplified)
creepymonster Jan 14, 2023
d54a6c4
New translations Localizable.strings (Chinese Traditional)
creepymonster Jan 14, 2023
67a0946
New translations Localizable.strings (Polish)
creepymonster Jan 14, 2023
65d5c50
New translations Localizable.strings (Arabic)
creepymonster Jan 14, 2023
bb88b0d
New translations Localizable.strings (Bulgarian)
creepymonster Jan 14, 2023
2c7b176
New translations Localizable.strings (Polish)
creepymonster Jan 14, 2023
4e25f13
New translations Localizable.strings (Portuguese)
creepymonster Jan 14, 2023
aca87bd
New translations Localizable.strings (French)
creepymonster Jan 14, 2023
84a2020
New translations Localizable.strings (Spanish)
creepymonster Jan 14, 2023
efdccca
New translations Localizable.strings (German)
creepymonster Jan 14, 2023
f32df4f
New translations Localizable.strings (Italian)
creepymonster Jan 14, 2023
0135fe9
New translations Localizable.strings (Turkish)
creepymonster Jan 14, 2023
9249961
New translations Localizable.strings (Chinese Simplified)
creepymonster Jan 14, 2023
ca17779
New translations Localizable.strings (Bulgarian)
creepymonster Jan 14, 2023
1594f4b
Merge branch 'crowdin' into crowdin_users
creepymonster Jan 15, 2023
4681b55
Merge pull request #491 from creepymonster/crowdin_users
creepymonster Jan 15, 2023
43b4751
Merge branch 'main' into crowdin
creepymonster Jan 15, 2023
362b75f
Merge pull request #494 from creepymonster/crowdin
creepymonster Jan 15, 2023
d2a4003
New translations Localizable.strings (Bulgarian)
creepymonster Jan 16, 2023
f27ef06
change translation keys
creepymonster Jan 16, 2023
6e5026d
New translations Localizable.strings (Portuguese)
creepymonster Jan 16, 2023
3210bc6
New translations Localizable.strings (French)
creepymonster Jan 16, 2023
872a822
New translations Localizable.strings (Spanish)
creepymonster Jan 16, 2023
8330a27
New translations Localizable.strings (German)
creepymonster Jan 16, 2023
2303be2
New translations Localizable.strings (Finnish)
creepymonster Jan 16, 2023
b240df1
New translations Localizable.strings (Italian)
creepymonster Jan 16, 2023
36bbb80
New translations Localizable.strings (Dutch)
creepymonster Jan 16, 2023
3486701
New translations Localizable.strings (Russian)
creepymonster Jan 16, 2023
1d00855
New translations Localizable.strings (Swedish)
creepymonster Jan 16, 2023
b3b01b4
New translations Localizable.strings (Turkish)
creepymonster Jan 16, 2023
62d2e05
New translations Localizable.strings (Ukrainian)
creepymonster Jan 16, 2023
3c6615d
New translations Localizable.strings (Chinese Simplified)
creepymonster Jan 16, 2023
1815864
New translations Localizable.strings (Chinese Traditional)
creepymonster Jan 16, 2023
7437edb
New translations InfoPlist.strings (Chinese Traditional)
creepymonster Jan 16, 2023
e89e588
New translations Localizable.strings (Polish)
creepymonster Jan 16, 2023
3a70ddd
New translations Localizable.strings (Bulgarian)
creepymonster Jan 16, 2023
d102aa7
New translations InfoPlist.strings (Finnish)
creepymonster Jan 16, 2023
1de10dd
Merge pull request #495 from creepymonster/crowdin_users
creepymonster Jan 16, 2023
2ee536f
Merge pull request #496 from creepymonster/crowdin
creepymonster Jan 16, 2023
6467214
cleanup settings, add alarm volume control, fixes
creepymonster Jan 16, 2023
7831255
Merge branch 'main' of https://github.com/creepymonster/GlucoseDirect
creepymonster Jan 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions App/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ struct AppState: DirectState {
UserDefaults.shared.transmitter = transmitter
}

self.alarmHigh = UserDefaults.standard.alarmHigh ?? 180
self.alarmLow = UserDefaults.standard.alarmLow ?? 80
self.alarmHigh = UserDefaults.standard.alarmHigh
self.alarmLow = UserDefaults.standard.alarmLow
self.alarmVolume = UserDefaults.standard.alarmVolume
self.appleCalendarExport = UserDefaults.standard.appleCalendarExport
self.appleHealthExport = UserDefaults.standard.appleHealthExport
self.bellmanAlarm = UserDefaults.standard.bellmanAlarm
Expand Down Expand Up @@ -75,7 +76,8 @@ struct AppState: DirectState {
self.sensorInterval = UserDefaults.standard.sensorInterval
self.showAnnotations = UserDefaults.standard.showAnnotations
self.transmitter = UserDefaults.shared.transmitter
self.smoothChartValues = UserDefaults.standard.smoothChartValues
self.showSmoothedGlucose = UserDefaults.standard.showSmoothedGlucose
self.showInsulinInput = UserDefaults.standard.showInsulinInput
}

// MARK: Internal
Expand Down Expand Up @@ -111,6 +113,7 @@ struct AppState: DirectState {

var alarmHigh: Int { didSet { UserDefaults.standard.alarmHigh = alarmHigh } }
var alarmLow: Int { didSet { UserDefaults.standard.alarmLow = alarmLow } }
var alarmVolume: Float { didSet { UserDefaults.standard.alarmVolume = alarmVolume } }
var appleCalendarExport: Bool { didSet { UserDefaults.standard.appleCalendarExport = appleCalendarExport } }
var appleHealthExport: Bool { didSet { UserDefaults.standard.appleHealthExport = appleHealthExport } }
var bellmanAlarm: Bool { didSet { UserDefaults.standard.bellmanAlarm = bellmanAlarm } }
Expand Down Expand Up @@ -142,5 +145,6 @@ struct AppState: DirectState {
var sensorInterval: Int { didSet { UserDefaults.standard.sensorInterval = sensorInterval } }
var showAnnotations: Bool { didSet { UserDefaults.standard.showAnnotations = showAnnotations } }
var transmitter: Transmitter? { didSet { UserDefaults.shared.transmitter = transmitter } }
var smoothChartValues: Bool { didSet { UserDefaults.standard.smoothChartValues = smoothChartValues } }
var showSmoothedGlucose: Bool { didSet { UserDefaults.standard.showSmoothedGlucose = showSmoothedGlucose } }
var showInsulinInput: Bool { didSet { UserDefaults.standard.showInsulinInput = showInsulinInput } }
}
6 changes: 3 additions & 3 deletions App/Modules/Debug/Debug.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private func debugMiddleware(service: LazyService<DebugService>) -> Middleware<D
return { state, action, _ in
switch action {
case .debugAlarm:
service.value.debugAlarm(sound: state.expiringAlarmSound, ignoreMute: state.ignoreMute)
service.value.debugAlarm(sound: state.expiringAlarmSound, volume: state.alarmVolume, ignoreMute: state.ignoreMute)

case .debugNotification:
service.value.debugNotification(sound: state.expiringAlarmSound, ignoreMute: state.ignoreMute)
Expand Down Expand Up @@ -49,13 +49,13 @@ private class DebugService {
DirectNotifications.shared.removeNotification(identifier: Identifier.debugAlarm.rawValue)
}

func debugAlarm(sound: NotificationSound, ignoreMute: Bool) {
func debugAlarm(sound: NotificationSound, volume: Float, ignoreMute: Bool) {
DirectNotifications.shared.ensureCanSendNotification { state in
guard state == .sound else {
return
}

DirectNotifications.shared.playSound(sound: sound, ignoreMute: ignoreMute)
DirectNotifications.shared.playSound(sound: sound, volume: volume, ignoreMute: ignoreMute)
}
}

Expand Down
12 changes: 6 additions & 6 deletions App/Modules/ExpiringNotification/ExpiringNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ private func expiringNotificationMiddelware(service: LazyService<ExpiringNotific
if sensor.state == .expired { // expired
DirectLog.info("Sensor is expired")

service.value.setSensorExpiredAlarm(sound: state.expiringAlarmSound, ignoreMute: state.ignoreMute)
service.value.setSensorExpiredAlarm(sound: state.expiringAlarmSound, volume: state.alarmVolume, ignoreMute: state.ignoreMute)

} else if sensor.remainingLifetime <= (24 * 60) { // less than 24 hours
DirectLog.info("Sensor is expiring in less than 24 hours")

service.value.setSensorExpiringAlarm(body: String(format: LocalizedString("Your sensor is about to expire. Replace sensor in %1$@."), sensor.remainingLifetime.inTimeSummary), sound: .none, ignoreMute: state.ignoreMute)
service.value.setSensorExpiringAlarm(body: String(format: LocalizedString("Your sensor is about to expire. Replace sensor in %1$@."), sensor.remainingLifetime.inTimeSummary), sound: .none, volume: state.alarmVolume, ignoreMute: state.ignoreMute)
}

default:
Expand Down Expand Up @@ -75,7 +75,7 @@ private class ExpiringNotificationService {
DirectNotifications.shared.removeNotification(identifier: Identifier.sensorExpiringAlarm.rawValue)
}

func setSensorExpiredAlarm(sound: NotificationSound, ignoreMute: Bool) {
func setSensorExpiredAlarm(sound: NotificationSound, volume: Float, ignoreMute: Bool) {
guard nextExpiredAlert == nil || Date() >= nextExpiredAlert! else {
return
}
Expand All @@ -96,14 +96,14 @@ private class ExpiringNotificationService {
notification.body = LocalizedString("Your sensor has expired and needs to be replaced as soon as possible")

if state == .sound {
DirectNotifications.shared.playSound(sound: sound, ignoreMute: ignoreMute)
DirectNotifications.shared.playSound(sound: sound, volume: volume, ignoreMute: ignoreMute)
}

DirectNotifications.shared.addNotification(identifier: Identifier.sensorExpiringAlarm.rawValue, content: notification)
}
}

func setSensorExpiringAlarm(body: String, sound: NotificationSound, ignoreMute: Bool) {
func setSensorExpiringAlarm(body: String, sound: NotificationSound, volume: Float, ignoreMute: Bool) {
guard lastExpiringAlert != body else {
return
}
Expand All @@ -128,7 +128,7 @@ private class ExpiringNotificationService {
notification.body = body

if state == .sound {
DirectNotifications.shared.playSound(sound: sound, ignoreMute: ignoreMute)
DirectNotifications.shared.playSound(sound: sound, volume: volume, ignoreMute: ignoreMute)
}

DirectNotifications.shared.addNotification(identifier: Identifier.sensorExpiringAlarm.rawValue, content: notification)
Expand Down
12 changes: 6 additions & 6 deletions App/Modules/GlucoseNotification/GlucoseNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private func glucoseNotificationMiddelware(service: LazyService<GlucoseNotificat

if !isSnoozed {
if state.hasLowGlucoseAlarm {
service.value.setLowGlucoseAlarm(sound: state.lowGlucoseAlarmSound, ignoreMute: state.ignoreMute)
service.value.setLowGlucoseAlarm(sound: state.lowGlucoseAlarmSound, volume: state.alarmVolume, ignoreMute: state.ignoreMute)
}

return Just(.setAlarmSnoozeUntil(untilDate: Date().addingTimeInterval(5 * 60).toRounded(on: 1, .minute), autosnooze: true))
Expand All @@ -61,7 +61,7 @@ private func glucoseNotificationMiddelware(service: LazyService<GlucoseNotificat

if !isSnoozed {
if state.hasHighGlucoseAlarm {
service.value.setHighGlucoseAlarm(sound: state.highGlucoseAlarmSound, ignoreMute: state.ignoreMute)
service.value.setHighGlucoseAlarm(sound: state.highGlucoseAlarmSound, volume: state.alarmVolume, ignoreMute: state.ignoreMute)
}

return Just(.setAlarmSnoozeUntil(untilDate: Date().addingTimeInterval(5 * 60).toRounded(on: 1, .minute), autosnooze: true))
Expand Down Expand Up @@ -131,8 +131,8 @@ private class GlucoseNotificationService {
}
}

func setLowGlucoseAlarm(sound: NotificationSound, ignoreMute: Bool) {
DirectNotifications.shared.playSound(sound: sound, ignoreMute: ignoreMute)
func setLowGlucoseAlarm(sound: NotificationSound, volume: Float, ignoreMute: Bool) {
DirectNotifications.shared.playSound(sound: sound, volume: volume, ignoreMute: ignoreMute)
}

func setLowGlucoseNotification(glucose: SensorGlucose, glucoseUnit: GlucoseUnit, isSnoozed: Bool) {
Expand Down Expand Up @@ -164,8 +164,8 @@ private class GlucoseNotificationService {
}
}

func setHighGlucoseAlarm(sound: NotificationSound, ignoreMute: Bool) {
DirectNotifications.shared.playSound(sound: sound, ignoreMute: ignoreMute)
func setHighGlucoseAlarm(sound: NotificationSound, volume: Float, ignoreMute: Bool) {
DirectNotifications.shared.playSound(sound: sound, volume: volume, ignoreMute: ignoreMute)
}

func setHighGlucoseNotification(glucose: SensorGlucose, glucoseUnit: GlucoseUnit, isSnoozed: Bool) {
Expand Down
2 changes: 1 addition & 1 deletion App/Views/Lists/SensorGlucoseListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct SensorGlucoseListView: View {

Spacer()

if let glucoseValue = sensorGlucose.smoothGlucoseValue?.toInteger(), sensorGlucose.timestamp < store.state.smoothThreshold, DirectConfig.smoothSensorGlucoseValues {
if let glucoseValue = sensorGlucose.smoothGlucoseValue?.toInteger(), sensorGlucose.timestamp < store.state.smoothThreshold, DirectConfig.showSmoothedGlucose {
Text(verbatim: glucoseValue.asGlucose(glucoseUnit: store.state.glucoseUnit, withUnit: true))
.monospacedDigit()
.if(store.state.isAlarm(glucoseValue: glucoseValue) != .none) { text in
Expand Down
20 changes: 11 additions & 9 deletions App/Views/ListsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ struct ListsView: View {

var body: some View {
List {
Button("Add insulin", action: {
showingAddInsulinView = true
}).sheet(isPresented: $showingAddInsulinView, onDismiss: {
showingAddInsulinView = false
}) {
AddInsulinView { start, end, units, insulinType in
let insulinDelivery = InsulinDelivery(id: UUID(), starts: start, ends: end, units: units, type: insulinType)
store.dispatch(.addInsulinDelivery(insulinDeliveryValues: [insulinDelivery]))
if DirectConfig.showInsulinInput, store.state.showInsulinInput {
Button("Add insulin", action: {
showingAddInsulinView = true
}).sheet(isPresented: $showingAddInsulinView, onDismiss: {
showingAddInsulinView = false
}) {
AddInsulinView { start, end, units, insulinType in
let insulinDelivery = InsulinDelivery(id: UUID(), starts: start, ends: end, units: units, type: insulinType)
store.dispatch(.addInsulinDelivery(insulinDeliveryValues: [insulinDelivery]))
}
}
}

Expand All @@ -42,7 +44,7 @@ struct ListsView: View {
BloodGlucoseListView()
}

if DirectConfig.insulinDeliveryInput {
if DirectConfig.showInsulinInput, store.state.showInsulinInput {
InsulinDeliveryListView()
}

Expand Down
20 changes: 14 additions & 6 deletions App/Views/Overview/ChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct ChartView: View {
.cornerRadius(5)
}

if let selectedRawPoint = selectedRawSensorPoint, showUnsmoothedValues, store.state.smoothChartValues {
if let selectedRawPoint = selectedRawSensorPoint, showUnsmoothedValues, store.state.showSmoothedGlucose {
VStack(alignment: .leading) {
Text(selectedRawPoint.time.toLocalDateTime())
Text(selectedRawPoint.info).bold()
Expand Down Expand Up @@ -257,7 +257,7 @@ struct ChartView: View {
}
}

if showUnsmoothedValues, store.state.smoothChartValues {
if showUnsmoothedValues, store.state.showSmoothedGlucose {
if !rawSensorGlucoseSeries.isEmpty {
ForEach(rawSensorGlucoseSeries) { value in
LineMark(
Expand Down Expand Up @@ -335,7 +335,15 @@ struct ChartView: View {
}
}
.id(Config.chartID)
.onChange(of: store.state.sensorGlucoseValues) { _ in
.onChange(of: store.state.showSmoothedGlucose) { _ in
if shouldRefresh {
DirectLog.info("onChange: sensorGlucoseValues")

updateSeriesMetadata()
updateSensorSeries()
}

}.onChange(of: store.state.sensorGlucoseValues) { _ in
if shouldRefresh {
DirectLog.info("onChange: sensorGlucoseValues")

Expand Down Expand Up @@ -366,7 +374,7 @@ struct ChartView: View {
updateSeriesMetadata()
}

}.onChange(of: store.state.smoothChartValues) { _ in
}.onChange(of: store.state.showSmoothedGlucose) { _ in
showUnsmoothedValues = false

}.onChange(of: store.state.selectedDate) { _ in
Expand Down Expand Up @@ -617,7 +625,7 @@ struct ChartView: View {
var smoothSensorPointInfos: [Date: GlucoseDatapoint] = [:]
var rawSensorPointInfos: [Date: GlucoseDatapoint] = [:]

let smoothSensorGlucoseSeries = DirectConfig.smoothSensorGlucoseValues && store.state.smoothChartValues
let smoothSensorGlucoseSeries = DirectConfig.showSmoothedGlucose && store.state.showSmoothedGlucose
? populateSmoothValues(glucoseValues: store.state.sensorGlucoseValues)
: populateValues(glucoseValues: store.state.sensorGlucoseValues)
smoothSensorGlucoseSeries.forEach { value in
Expand All @@ -626,7 +634,7 @@ struct ChartView: View {
}
}

let rawSensorGlucoseSeries = store.state.smoothChartValues
let rawSensorGlucoseSeries = store.state.showSmoothedGlucose
? populateValues(glucoseValues: store.state.sensorGlucoseValues.filter {
$0.timestamp < store.state.smoothThreshold
})
Expand Down
43 changes: 43 additions & 0 deletions App/Views/Settings/AdditionalSettingsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// AdditionalSettings.swift
// GlucoseDirectApp
//
// Created by Reimar Metzen on 16.01.23.
//

import SwiftUI

struct AdditionalSettingsView: View {
@EnvironmentObject var store: DirectStore

var body: some View {
Section(
content: {
if DirectConfig.showSmoothedGlucose {
Toggle("Show smoothed glucose", isOn: showSmoothedGlucose).toggleStyle(SwitchToggleStyle(tint: Color.ui.accent))
}

if DirectConfig.showInsulinInput {
Toggle("Show insulin input", isOn: showInsulinInput).toggleStyle(SwitchToggleStyle(tint: Color.ui.accent))
}
},
header: {
Label("Additional settings", systemImage: "gearshape")
}
)
}

private var showSmoothedGlucose: Binding<Bool> {
Binding(
get: { store.state.showSmoothedGlucose },
set: { store.dispatch(.setShowSmoothedGlucose(enabled: $0)) }
)
}

private var showInsulinInput: Binding<Bool> {
Binding(
get: { store.state.showInsulinInput },
set: { store.dispatch(.setShowInsulinInput(enabled: $0)) }
)
}
}
33 changes: 29 additions & 4 deletions App/Views/Settings/AlarmSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ struct AlarmSettingsView: View {
Text(info.localizedDescription)
}
}.pickerStyle(.menu)

VStack(alignment: .leading) {
HStack {
Text("Alarm volume")
Spacer()
Text((store.state.alarmVolume * 100).asPercent())
}

Slider(value: alarmVolume, in: 0...1, step: 0.05)
}

Toggle("Ignore mute", isOn: ignoreMute).toggleStyle(SwitchToggleStyle(tint: Color.ui.accent))
},
Expand All @@ -55,6 +65,21 @@ struct AlarmSettingsView: View {
set: { store.dispatch(.setIgnoreMute(enabled: $0)) }
)
}

private var alarmVolume: Binding<Float> {
Binding(
get: { store.state.alarmVolume },
set: {
store.dispatch(.setAlarmVolume(volume: $0))

if DirectNotifications.shared.isPlaying() {
DirectNotifications.shared.setVolume(volume: $0)
} else {
DirectNotifications.shared.testSound(sound: .alarm, volume: $0)
}
}
)
}

private var selectedLowGlucoseAlarmSound: Binding<String> {
Binding(
Expand All @@ -63,7 +88,7 @@ struct AlarmSettingsView: View {
let sound = NotificationSound(rawValue: $0)!

store.dispatch(.setLowGlucoseAlarmSound(sound: sound))
DirectNotifications.shared.testSound(sound: sound)
DirectNotifications.shared.testSound(sound: sound, volume: store.state.alarmVolume)
}
)
}
Expand All @@ -75,7 +100,7 @@ struct AlarmSettingsView: View {
let sound = NotificationSound(rawValue: $0)!

store.dispatch(.setHighGlucoseAlarmSound(sound: sound))
DirectNotifications.shared.testSound(sound: sound)
DirectNotifications.shared.testSound(sound: sound, volume: store.state.alarmVolume)
}
)
}
Expand All @@ -87,7 +112,7 @@ struct AlarmSettingsView: View {
let sound = NotificationSound(rawValue: $0)!

store.dispatch(.setConnectionAlarmSound(sound: sound))
DirectNotifications.shared.testSound(sound: sound)
DirectNotifications.shared.testSound(sound: sound, volume: store.state.alarmVolume)
}
)
}
Expand All @@ -99,7 +124,7 @@ struct AlarmSettingsView: View {
let sound = NotificationSound(rawValue: $0)!

store.dispatch(.setExpiringAlarmSound(sound: sound))
DirectNotifications.shared.testSound(sound: sound)
DirectNotifications.shared.testSound(sound: sound, volume: store.state.alarmVolume)
}
)
}
Expand Down
Loading