Skip to content

Commit

Permalink
Merge branch 'dev' into Crowdin
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-b-m committed Nov 9, 2023
2 parents d7849a1 + d6f8175 commit 49da8ed
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 63 deletions.
11 changes: 11 additions & 0 deletions Core_Data.xcdatamodeld/Core_Data.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22225" systemVersion="22G120" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Autosens_" representedClassName="Autosens_" syncable="YES" codeGenerationType="class">
<attribute name="newisf" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="ratio" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
</entity>
<entity name="Autotune_" representedClassName="Autotune_" syncable="YES" codeGenerationType="class">
<attribute name="basalProfile" optional="YES" attributeType="Transformable"/>
<attribute name="carbRatio" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="createdAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="sensitivity" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
</entity>
<entity name="BGaverages" representedClassName="BGaverages" syncable="YES" codeGenerationType="class">
<attribute name="average" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="average_1" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
Expand Down
4 changes: 2 additions & 2 deletions FreeAPS/Sources/Modules/AddCarbs/AddCarbsStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension AddCarbs {
useFPUconversion = settingsManager.settings.useFPUconversion
}

func add() {
func add(_ continue_: Bool, fetch: Bool) {
guard carbs > 0 || fat > 0 || protein > 0 else {
showModal(for: nil)
return
Expand All @@ -51,7 +51,7 @@ extension AddCarbs {
)]
carbsStorage.storeCarbs(carbsToStore)

if skipBolus {
if skipBolus, !continue_, !fetch {
apsManager.determineBasalSync()
showModal(for: nil)
} else if carbs > 0 {
Expand Down
7 changes: 4 additions & 3 deletions FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extension AddCarbs {
struct RootView: BaseView {
let resolver: Resolver
let editMode: Bool
let override: Bool
@StateObject var state = StateModel()
@State var dish: String = ""
@State var isPromptPresented = false
Expand Down Expand Up @@ -115,9 +116,9 @@ extension AddCarbs {
}

Section {
Button { state.add() }
label: { Text(state.skipBolus ? "Save" : "Continue") }
.disabled(state.carbs <= 0 && state.fat <= 0 && state.protein <= 0)
Button { state.add(override, fetch: editMode) }
label: { Text((state.skipBolus && !override && !editMode) ? "Save" : "Continue") }
.disabled(empty)
.frame(maxWidth: .infinity, alignment: .center)
}.listRowBackground(!empty ? Color(.systemBlue) : Color(.systemGray4))
.tint(.white)
Expand Down
4 changes: 2 additions & 2 deletions FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ extension Bolus {
}
}

func backToCarbsView(complexEntry: Bool, _ id: String) {
func backToCarbsView(complexEntry: Bool, _ id: String, override: Bool) {
delete(deleteTwice: complexEntry, id: id)
showModal(for: .addCarbs(editMode: complexEntry))
showModal(for: .addCarbs(editMode: complexEntry, override: override))
}

func delete(deleteTwice: Bool, id: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,26 @@ extension Bolus {
.onTapGesture { state.amount = state.insulinCalculated }
}

if !state.waitForSuggestion {
HStack {
Text("Bolus")
Spacer()
DecimalTextField(
"0",
value: $state.amount,
formatter: formatter,
autofocus: false,
cleanInput: true
)
Text(exceededMaxBolus ? "😵" : " U").foregroundColor(.secondary)
}
.onChange(of: state.amount) { newValue in
if newValue > state.maxBolus {
exceededMaxBolus = true
} else {
exceededMaxBolus = false
}
HStack {
Text("Bolus")
Spacer()
DecimalTextField(
"0",
value: $state.amount,
formatter: formatter,
autofocus: false,
cleanInput: true
)
Text(exceededMaxBolus ? "😵" : " U").foregroundColor(.secondary)
}
.onChange(of: state.amount) { newValue in
if newValue > state.maxBolus {
exceededMaxBolus = true
} else {
exceededMaxBolus = false
}
}

} header: { Text("Bolus") }

if state.amount > 0 {
Expand Down Expand Up @@ -169,7 +168,7 @@ extension Bolus {
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(
leading: Button {
carbssView()
carbsView()
}
label: { Text(fetch ? "Back" : "Meal") },

Expand Down Expand Up @@ -278,13 +277,13 @@ extension Bolus {
((meal.first?.fat ?? 0) > 0) || ((meal.first?.protein ?? 0) > 0)
}

func carbssView() {
func carbsView() {
let id_ = meal.first?.id ?? ""
if fetch {
keepForNextWiew = true
state.backToCarbsView(complexEntry: fetch, id_)
state.backToCarbsView(complexEntry: fetch, id_, override: false)
} else {
state.showModal(for: .addCarbs(editMode: false))
state.backToCarbsView(complexEntry: false, id_, override: true)
}
}

Expand Down
56 changes: 28 additions & 28 deletions FreeAPS/Sources/Modules/Bolus/View/DefaultBolusCalcRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,37 @@ extension Bolus {
else { state.amount = state.insulinRecommended }
}
}.contentShape(Rectangle())
}

HStack {
Text("Amount")
Spacer()
DecimalTextField(
"0",
value: $state.amount,
formatter: formatter,
autofocus: true,
cleanInput: true
)
Text(!(state.amount > state.maxBolus) ? "U" : "😵").foregroundColor(.secondary)
}
HStack {
Text("Amount")
Spacer()
DecimalTextField(
"0",
value: $state.amount,
formatter: formatter,
autofocus: true,
cleanInput: true
)
Text(!(state.amount > state.maxBolus) ? "U" : "😵").foregroundColor(.secondary)
}

} header: { Text("Bolus") }

if !state.waitForSuggestion {
if state.amount > 0 {
Section {
Button {
keepForNextWiew = true
state.add()
}
label: { Text(!(state.amount > state.maxBolus) ? "Enact bolus" : "Max Bolus exceeded!") }
.frame(maxWidth: .infinity, alignment: .center)
.disabled(disabled)
.listRowBackground(!disabled ? Color(.systemBlue) : Color(.systemGray4))
.tint(.white)
if state.amount > 0 {
Section {
Button {
keepForNextWiew = true
state.add()
}
label: { Text(!(state.amount > state.maxBolus) ? "Enact bolus" : "Max Bolus exceeded!") }
.frame(maxWidth: .infinity, alignment: .center)
.disabled(disabled)
.listRowBackground(!disabled ? Color(.systemBlue) : Color(.systemGray4))
.tint(.white)
}
}

if state.amount <= 0 {
Section {
Button {
Expand Down Expand Up @@ -153,7 +153,7 @@ extension Bolus {
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(
leading: Button {
carbssView()
carbsView()
}
label: { Text(fetch ? "Back" : "Meal") },

Expand Down Expand Up @@ -185,13 +185,13 @@ extension Bolus {
((meal.first?.fat ?? 0) > 0) || ((meal.first?.protein ?? 0) > 0)
}

func carbssView() {
func carbsView() {
let id_ = meal.first?.id ?? ""
if fetch {
keepForNextWiew = true
state.backToCarbsView(complexEntry: fetch, id_)
state.backToCarbsView(complexEntry: fetch, id_, override: false)
} else {
state.showModal(for: .addCarbs(editMode: false))
state.backToCarbsView(complexEntry: false, id_, override: true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Modules/Home/HomeStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ extension Home {
}

func addCarbs() {
showModal(for: .addCarbs(editMode: false))
showModal(for: .addCarbs(editMode: false, override: false))
}

func runLoop() {
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Modules/Home/View/HomeRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ extension Home {
Rectangle().fill(Color.gray.opacity(0.3)).frame(height: 50 + geo.safeAreaInsets.bottom)

HStack {
Button { state.showModal(for: .addCarbs(editMode: false)) }
Button { state.showModal(for: .addCarbs(editMode: false, override: false)) }
label: {
ZStack(alignment: Alignment(horizontal: .trailing, vertical: .bottom)) {
Image("carbs")
Expand Down
6 changes: 3 additions & 3 deletions FreeAPS/Sources/Router/Screen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum Screen: Identifiable, Hashable {
case crEditor
case targetsEditor
case preferencesEditor
case addCarbs(editMode: Bool)
case addCarbs(editMode: Bool, override: Bool)
case addTempTarget
case bolus(waitForSuggestion: Bool, fetch: Bool)
case manualTempBasal
Expand Down Expand Up @@ -65,8 +65,8 @@ extension Screen {
TargetsEditor.RootView(resolver: resolver)
case .preferencesEditor:
PreferencesEditor.RootView(resolver: resolver)
case let .addCarbs(editMode):
AddCarbs.RootView(resolver: resolver, editMode: editMode)
case let .addCarbs(editMode, override):
AddCarbs.RootView(resolver: resolver, editMode: editMode, override: override)
case .addTempTarget:
AddTempTarget.RootView(resolver: resolver)
case let .bolus(waitForSuggestion, fetch):
Expand Down

0 comments on commit 49da8ed

Please sign in to comment.