Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Application/FreeAPSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import Swinject

var body: some Scene {
WindowGroup {
Main.RootView(resolver: resolver)
rootView
.onOpenURL(perform: handleURL)
}
.onChange(of: scenePhase) { newScenePhase in
Expand Down
14 changes: 14 additions & 0 deletions FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,23 @@

/* Add carbs screen */
"Add Carbs" = "Add Carbs";
"Add without bolus" = "Add without bolus";

/* Add carbs header and button in Watch app. You can skip the last " " space. It's just for differentiation */
"Add Carbs " = "Add Carbs ";
"Without bolus" = "Without bolus";

/* Fast Add carbs button */
"Fast Add" = "Fast Add";

/* Fast Add carbs button description */
"Carbs will add and FreeAPX X will update forecasts without bolus" = "Carbs will add and FreeAPX X will update forecasts without bolus";

/* Simple Add carbs button */
"Simple Add" = "Simple Add";

/* Simple Add carbs button description*/
"Carbs will add without bolus" = "Carbs will add without bolus";

/* */
"Amount Carbs" = "Amount Carbs";
Expand Down
14 changes: 14 additions & 0 deletions FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,23 @@

/* Add carbs screen */
"Add Carbs" = "Ввод углеводов";
"Add without bolus" = "Ввод без болюса";

/* Add carbs header and button in Watch app. You can skip the last " " space. It's just for differentiation */
"Add Carbs " = "Ввод углеводов";
"Without bolus" = "Без болюса";

/* Fast Add carbs button */
"Fast Add" = "Добавить быстро";

/* Fast Add carbs button description */
"Carbs will add and FreeAPX X will update forecasts without bolus" = "Углеводы будут добавлены без ввода болюса, FreeAPS X автоматически обновит прогнозы";

/* Simple Add carbs button */
"Simple Add" = "Просто добавить";

/* Simple Add carbs button description*/
"Carbs will add without bolus" = "Углеводы будут добавлены без ввода болюса";

/* */
"Amount Carbs" = "Кол-во углеводов";
Expand Down
5 changes: 0 additions & 5 deletions FreeAPS/Sources/Models/FreeAPSSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ struct FreeAPSSettings: JSON, Equatable {
var localGlucosePort: Int = 8080
var debugOptions: Bool = false
var insulinReqFraction: Decimal = 0.7
var skipBolusScreenAfterCarbs: Bool = false
var cgm: CGMType = .nightscout
var uploadGlucose: Bool = false
var useCalendar: Bool = false
Expand Down Expand Up @@ -67,10 +66,6 @@ extension FreeAPSSettings: Decodable {
settings.insulinReqFraction = insulinReqFraction
}

if let skipBolusScreenAfterCarbs = try? container.decode(Bool.self, forKey: .skipBolusScreenAfterCarbs) {
settings.skipBolusScreenAfterCarbs = skipBolusScreenAfterCarbs
}

if let cgm = try? container.decode(CGMType.self, forKey: .cgm) {
settings.cgm = cgm
}
Expand Down
19 changes: 14 additions & 5 deletions FreeAPS/Sources/Modules/AddCarbs/AddCarbsStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension AddCarbs {
carbsRequired = provider.suggestion?.carbsReq
}

func add() {
func addCarbs() {
guard carbs > 0 else {
showModal(for: nil)
return
Expand All @@ -22,12 +22,21 @@ extension AddCarbs {
CarbsEntry(createdAt: date, carbs: carbs, enteredBy: CarbsEntry.manual)
])

if settingsManager.settings.skipBolusScreenAfterCarbs {
apsManager.determineBasalSync()
showModal(for: .bolus(waitForSuggestion: true))
}

func addCarbsWitoutBolus() {
guard carbs > 0 else {
showModal(for: nil)
} else {
showModal(for: .bolus(waitForSuggestion: true))
return
}

carbsStorage.storeCarbs([
CarbsEntry(createdAt: date, carbs: carbs, enteredBy: CarbsEntry.manual)
])

apsManager.determineBasalSync()
showModal(for: nil)
}
}
}
5 changes: 4 additions & 1 deletion FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ extension AddCarbs {
}

Section {
Button { state.add() }
Button { state.addCarbs() }
label: { Text("Add") }
.disabled(state.carbs <= 0)
Button { state.addCarbsWitoutBolus() }
label: { Text("Add without bolus") }
.disabled(state.carbs <= 0)
}
}
.onAppear(perform: configureView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension Migration {
Publishers
.getMigrationPublisher(fromMigrationManager: manager)
// .migrate(startAtVersion: "0.2.6", MigrationWorkExample())
.migrate(startAtVersion: "0.2.6", MigrationWorkCarbsWithoutBolus())
.sink { _ in
debug(.businessLogic, "Migration did finish")
// fake pause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extension PreferencesEditor {

subscribeSetting(\.allowAnnouncements, on: $allowAnnouncements) { allowAnnouncements = $0 }
subscribeSetting(\.insulinReqFraction, on: $insulinReqFraction) { insulinReqFraction = $0 }
subscribeSetting(\.skipBolusScreenAfterCarbs, on: $skipBolusScreenAfterCarbs) { skipBolusScreenAfterCarbs = $0 }

subscribeSetting(\.units, on: $unitsIndex.map { $0 == 0 ? GlucoseUnits.mgdL : .mmolL }) {
unitsIndex = $0 == .mgdL ? 0 : 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ extension PreferencesEditor {
Text("Recommended Insulin Fraction")
DecimalTextField("", value: $state.insulinReqFraction, formatter: formatter)
}

Toggle("Skip Bolus screen after carbs", isOn: $state.skipBolusScreenAfterCarbs)
}

ForEach(state.sections.indexed(), id: \.1.id) { sectionIndex, section in
Expand Down
13 changes: 13 additions & 0 deletions FreeAPS/Sources/Services/Migration/MigrationWorkItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ class MigrationWorkExample: MigrationWorkItem {
debug(.businessLogic, "Migration MigrationWorkExample will start")
}
}

// Remove skipBolusScreenAfterCarbs setting
class MigrationWorkCarbsWithoutBolus: MigrationWorkItem {
private(set) var repeatEachTime: Bool = false
private(set) var uniqueIdentifier: String = "Migration.MigrationWorkCarbsWithoutBolus"
func migrationHandler(_: AppInfo) {
debug(.businessLogic, "Migration MigrationWorkCarbsWithoutBolus will start")
guard let settingManager = FreeAPSApp.resolver.resolve(SettingsManager.self) else { return }
// Just resave settings to remove not used setting
settingManager.settings.animatedBackground.toggle()
settingManager.settings.animatedBackground.toggle()
}
}
19 changes: 6 additions & 13 deletions FreeAPS/Sources/Services/WatchManager/WatchManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ final class BaseWatchManager: NSObject, WatchManager, Injectable {
until: untilDate
)
}
self.state.bolusAfterCarbs = !self.settingsManager.settings.skipBolusScreenAfterCarbs
let eBG = self.evetualBGStraing()
self.state.eventualBG = eBG.map { "⇢ " + $0 }
self.state.eventualBGRaw = eBG
Expand Down Expand Up @@ -240,18 +239,12 @@ extension BaseWatchManager: WCSessionDelegate {
CarbsEntry(createdAt: Date(), carbs: Decimal(carbs), enteredBy: CarbsEntry.manual)
])

if settingsManager.settings.skipBolusScreenAfterCarbs {
apsManager.determineBasalSync()
replyHandler(["confirmation": true])
return
} else {
apsManager.determineBasal()
.sink { _ in
replyHandler(["confirmation": true])
}
.store(in: &lifetime)
return
}
apsManager.determineBasal()
.sink { _ in
replyHandler(["confirmation": true])
}
.store(in: &lifetime)
return
}

if let tempTargetID = message["tempTarget"] as? String {
Expand Down
1 change: 0 additions & 1 deletion FreeAPSWatch WatchKit Extension/DataFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct WatchState: Codable {
var iob: Decimal?
var cob: Decimal?
var tempTargets: [TempTargetWatchPreset] = []
var bolusAfterCarbs: Bool?
var eventualBG: String?
var eventualBGRaw: String?
}
Expand Down
19 changes: 19 additions & 0 deletions FreeAPSWatch WatchKit Extension/Views/CarbsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct CarbsView: View {
WKInterfaceDevice.current().play(.click)
// Get amount from displayed string
let amount = Int(numberFormatter.string(from: amount as NSNumber)!) ?? Int(amount.rounded())
state.bolusAfterCarbs = true
state.addCarbs(amount)
}
label: {
Expand All @@ -65,6 +66,24 @@ struct CarbsView: View {
}
}
.disabled(amount <= 0)
Button {
WKInterfaceDevice.current().play(.click)
// Get amount from displayed string
let amount = Int(numberFormatter.string(from: amount as NSNumber)!) ?? Int(amount.rounded())
state.bolusAfterCarbs = false
state.addCarbs(amount)
}
label: {
HStack {
Image("carbs", bundle: nil)
.renderingMode(.template)
.resizable()
.frame(width: 24, height: 24)
.foregroundColor(.loopGreen)
Text("Without bolus")
}
}
.disabled(amount <= 0)
}.frame(maxHeight: .infinity)
}
.navigationTitle("Add Carbs ")
Expand Down
1 change: 0 additions & 1 deletion FreeAPSWatch WatchKit Extension/WatchStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class WatchStateModel: NSObject, ObservableObject {
iob = state.iob
cob = state.cob
tempTargets = state.tempTargets
bolusAfterCarbs = state.bolusAfterCarbs ?? true
eventualBG = state.eventualBG ?? ""
lastUpdate = Date()
}
Expand Down