Skip to content

Commit

Permalink
Merge pull request #1 from Merkaffe/onboardingView
Browse files Browse the repository at this point in the history
Onboarding
  • Loading branch information
scrappy authored Jul 1, 2024
2 parents f1879c7 + 075e26c commit bcdd9f9
Show file tree
Hide file tree
Showing 23 changed files with 1,059 additions and 140 deletions.
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_DISPLAY_NAME = iAPS
APP_VERSION = 4.5.0
APP_VERSION = 4.6.0
APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
Expand Down
6 changes: 5 additions & 1 deletion Core_Data.xcdatamodeld/Core_Data.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22758" systemVersion="23E224" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22758" systemVersion="23F79" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<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 Expand Up @@ -71,6 +71,10 @@
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="number" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
</entity>
<entity name="Onboarding" representedClassName="Onboarding" syncable="YES" codeGenerationType="class">
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="firstRun" optional="YES" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
</entity>
<entity name="Override" representedClassName="Override" syncable="YES" codeGenerationType="class">
<attribute name="advancedSettings" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="cr" optional="YES" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
Expand Down
4 changes: 4 additions & 0 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
191F62682AD6B05A004D7911 /* NightscoutSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191F62672AD6B05A004D7911 /* NightscoutSettings.swift */; };
1920BF5D2B9DF53200E861FE /* BolusShortcut.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1920BF5C2B9DF53200E861FE /* BolusShortcut.swift */; };
19229B962AFBB84800CD91CA /* Predictions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19229B952AFBB84800CD91CA /* Predictions.swift */; };
1922ACBD2C30B25300B28CF3 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1922ACBC2C30B25300B28CF3 /* Database.swift */; };
192424CB2B7A64E70063CBF0 /* NIghtscoutExercise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192424CA2B7A64E70063CBF0 /* NIghtscoutExercise.swift */; };
1924F72C2BA35AE5006644EE /* TotalDailyDose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1924F72B2BA35AE5006644EE /* TotalDailyDose.swift */; };
1927C8E62744606D00347C69 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1927C8E82744606D00347C69 /* InfoPlist.strings */; };
Expand Down Expand Up @@ -575,6 +576,7 @@
1920BF5C2B9DF53200E861FE /* BolusShortcut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BolusShortcut.swift; sourceTree = "<group>"; };
192202902BAB567800B95BE8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
19229B952AFBB84800CD91CA /* Predictions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Predictions.swift; sourceTree = "<group>"; };
1922ACBC2C30B25300B28CF3 /* Database.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = "<group>"; };
192424CA2B7A64E70063CBF0 /* NIghtscoutExercise.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NIghtscoutExercise.swift; sourceTree = "<group>"; };
1924F72B2BA35AE5006644EE /* TotalDailyDose.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TotalDailyDose.swift; sourceTree = "<group>"; };
1927C8E92744611700347C69 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1585,6 +1587,7 @@
3811DE9725C9D88300A708ED /* NightscoutManager.swift */,
38FE826925CC82DB001FF17A /* NetworkService.swift */,
38FE826C25CC8461001FF17A /* NightscoutAPI.swift */,
1922ACBC2C30B25300B28CF3 /* Database.swift */,
);
path = Network;
sourceTree = "<group>";
Expand Down Expand Up @@ -3137,6 +3140,7 @@
FA630397F76B582C8D8681A7 /* BasalProfileEditorProvider.swift in Sources */,
63E890B4D951EAA91C071D5C /* BasalProfileEditorStateModel.swift in Sources */,
CE398D16297C9D1D00DF218F /* dexcomSourceG7.swift in Sources */,
1922ACBD2C30B25300B28CF3 /* Database.swift in Sources */,
38FEF3FA2737E42000574A46 /* BaseStateModel.swift in Sources */,
CC6C406E2ACDD69E009B8058 /* RawFetchedProfile.swift in Sources */,
385CEA8225F23DFD002D6D5B /* NightscoutStatus.swift in Sources */,
Expand Down
12 changes: 6 additions & 6 deletions FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift",
"state": {
"branch": null,
"revision": "19b3c3ceed117c5cc883517c4e658548315ba70b",
"version": "1.6.0"
"revision": "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0",
"version": "1.8.2"
}
},
{
Expand Down Expand Up @@ -60,17 +60,17 @@
"repositoryURL": "https://github.com/SwiftKickMobile/SwiftMessages",
"state": {
"branch": null,
"revision": "b29dd21090b708aa0ae9ecbaf6e2d0487028dc3f",
"version": "9.0.6"
"revision": "62e12e138fc3eedf88c7553dd5d98712aa119f40",
"version": "9.0.9"
}
},
{
"package": "Swinject",
"repositoryURL": "https://github.com/Swinject/Swinject",
"state": {
"branch": null,
"revision": "8bc503e60965298984fb58cf47b71c541449fe2a",
"version": "2.8.3"
"revision": "be9dbcc7b86811bc131539a20c6f9c2d3e56919f",
"version": "2.9.1"
}
}
]
Expand Down
124 changes: 63 additions & 61 deletions FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
{
"units" : "mmol/L",
"closedLoop" : false,
"allowAnnouncements" : false,
"useAutotune" : false,
"isUploadEnabled" : false,
"useLocalGlucoseSource" : false,
"localGlucosePort" : 8080,
"debugOptions" : false,
"insulinReqPercentage" : 70,
"skipBolusScreenAfterCarbs" : false,
"displayHR" : false,
"cgm" : "nightscout",
"uploadGlucose" : true,
"useCalendar" : false,
"displayCalendarEmojis" : false,
"displayCalendarIOBandCOB" : false,
"glucoseBadge" : false,
"glucoseNotificationsAlways" : false,
"useAlarmSound" : false,
"addSourceInfoToGlucoseNotifications" : false,
"lowGlucose" : 72,
"highGlucose" : 270,
"carbsRequiredThreshold" : 10,
"animatedBackground" : false,
"useFPUconversion" : true,
"individualAdjustmentFactor" : 0.5,
"timeCap" : 8,
"minuteInterval" : 30,
"delay" : 60,
"useAppleHealth" : false,
"smoothGlucose" : false,
"displayOnWatch" : "BGTarget",
"overrideHbA1cUnit" : false,
"high" : 145,
"low" : 70,
"uploadStats" : false,
"hours" : 6,
"xGridLines" : true,
"yGridLines" : true,
"oneDimensionalGraph" : false,
"rulerMarks" : false,
"maxCarbs" : 1000,
"displayFatAndProteinOnWatch" : false,
"confirmBolusFaster" : false,
"onlyAutotuneBasals" : false,
"overrideFactor" : 0.8,
"useCalc" : true,
"fattyMeals" : false,
"fattyMealFactor" : 0.7,
"displayPredictions" : true,
"useLiveActivity" : false,
"useTargetButton" : false,
"alwaysUseColors" : true,
"timeSettings" : true,
"disableCGMError" : true,
"allowBolusShortcut": false,
"profilesOrTempTargets": true,
"allowedRemoteBolusAmount": 0.0,
"cgm": "nightscout",
"low": 70,
"high": 145,
"delay": 60,
"hours": 6,
"units": "mmol/L",
"timeCap": 8,
"useCalc": true,
"maxCarbs": 500,
"birthDate": "0001-01-01T23:00:00.000Z",
"displayHR": true,
"closedLoop": true,
"eventualBG": true,
"minumimPrediction": true,
"fattyMeals": true,
"lowGlucose": 66.66666666666666,
"minimumSMB": 0.3,
"useInsulinBars": false,
"rulerMarks": true,
"sexSetting": 3,
"xGridLines": true,
"yGridLines": true,
"highGlucose": 270,
"uploadStats": true,
"useAutotune": false,
"useCalendar": false,
"debugOptions": false,
"glucoseBadge": true,
"timeSettings": true,
"smoothGlucose": false,
"uploadGlucose": true,
"uploadVersion": true,
"birthDate": Date.distantPast
"useAlarmSound": false,
"displayOnWatch": "BGTarget",
"minuteInterval": 30,
"overrideFactor": 1.0,
"useAppleHealth": false,
"useInsulinBars": true,
"alwaysUseColors": false,
"disableCGMError": true,
"fattyMealFactor": 0.7,
"isUploadEnabled": false,
"useLiveActivity": false,
"useTargetButton": false,
"localGlucosePort": 8080,
"skipGlucoseChart": false,
"useFPUconversion": true,
"minumimPrediction": true,
"overrideHbA1cUnit": false,
"allowAnnouncements": false,
"allowBolusShortcut": false,
"animatedBackground": false,
"confirmBolusFaster": false,
"displayPredictions": true,
"onlyAutotuneBasals": false,
"oneDimensionalGraph": false,
"insulinReqPercentage": 70,
"displayCalendarEmojis": false,
"profilesOrTempTargets": false,
"useLocalGlucoseSource": false,
"carbsRequiredThreshold": 25,
"allowedRemoteBolusAmount": 0,
"displayCalendarIOBandCOB": false,
"skipBolusScreenAfterCarbs": false,
"glucoseNotificationsAlways": false,
"individualAdjustmentFactor": 0.5,
"displayFatAndProteinOnWatch": true,
"addSourceInfoToGlucoseNotifications": false
}
101 changes: 50 additions & 51 deletions FreeAPS/Resources/json/defaults/preferences.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
{
"max_iob" : 0,
"max_daily_safety_multiplier" : 3,
"current_basal_safety_multiplier" : 4,
"autosens_max" : 1.2,
"autosens_min" : 0.7,
"smb_delivery_ratio" : 0.5,
"rewind_resets_autosens" : true,
"high_temptarget_raises_sensitivity" : false,
"low_temptarget_lowers_sensitivity" : false,
"sensitivity_raises_target" : false,
"resistance_lowers_target" : false,
"adv_target_adjustments" : false,
"exercise_mode" : false,
"half_basal_exercise_target" : 160,
"maxCOB" : 120,
"wide_bg_target_range" : false,
"skip_neutral_temps" : false,
"unsuspend_if_no_temp" : false,
"min_5m_carbimpact" : 8,
"autotune_isf_adjustmentFraction" : 1,
"remainingCarbsCap" : 90,
"remainingCarbsFraction" : 1,
"enableUAM" : false,
"A52_risk_enable" : false,
"enableSMB_with_COB" : false,
"enableSMB_with_temptarget" : false,
"enableSMB_always" : false,
"enableSMB_after_carbs" : false,
"allowSMB_with_high_temptarget" : false,
"maxSMBBasalMinutes" : 30,
"maxUAMSMBBasalMinutes" : 30,
"SMBInterval" : 3,
"bolus_increment" : 0.1,
"curve" : "rapid-acting",
"useCustomPeakTime" : false,
"insulinPeakTime" : 75,
"carbsReqThreshold" : 1,
"noisyCGMTargetMultiplier" : 1.3,
"suspend_zeros_iob" : false,
"maxDelta_bg_threshold" : 0.2,
"curve": "rapid-acting",
"adjustmentFactor" : 0.5,
"sigmoid" : true,
"enableDynamicCR" : false,
"useNewFormula" : false,
"useWeightedAverage" : true,
"weightPercentage" : 0.65,
"tddAdjBasal" : false,
"enableSMB_high_bg" : false,
"enableSMB_high_bg_target" : 110,
"threshold_setting" : 65,
"updateInterval" : 20
"maxCOB": 350,
"max_iob": 10,
"sigmoid": true,
"enableUAM": true,
"SMBInterval": 3,
"tddAdjBasal": false,
"autosens_max": 1.3,
"autosens_min": 0.7,
"exercise_mode": false,
"useNewFormula": false,
"updateInterval": 20,
"A52_risk_enable": false,
"bolus_increment": 0.1,
"enableDynamicCR": false,
"insulinPeakTime": 75,
"adjustmentFactor": 0.5,
"enableSMB_always": true,
"weightPercentage": 0.65,
"carbsReqThreshold": 1,
"enableSMB_high_bg": false,
"min_5m_carbimpact": 8,
"remainingCarbsCap": 90,
"suspend_zeros_iob": false,
"threshold_setting": 67.56756756756755,
"useCustomPeakTime": false,
"enableSMB_with_COB": false,
"maxSMBBasalMinutes": 150,
"skip_neutral_temps": false,
"smb_delivery_ratio": 0.5,
"useWeightedAverage": false,
"unsuspend_if_no_temp": false,
"wide_bg_target_range": false,
"enableSMB_after_carbs": false,
"maxDelta_bg_threshold": 0.25,
"maxUAMSMBBasalMinutes": 80,
"adv_target_adjustments": false,
"remainingCarbsFraction": 1,
"resistanceLowersTarget": false,
"rewind_resets_autosens": false,
"enableSMB_high_bg_target": 110,
"noisyCGMTargetMultiplier": 1.3,
"enableSMB_with_temptarget": false,
"sensitivity_raises_target": false,
"half_basal_exercise_target": 160,
"max_daily_safety_multiplier": 3,
"allowSMB_with_high_temptarget": false,
"autotune_isf_adjustmentFraction": 1,
"current_basal_safety_multiplier": 4,
"low_temptarget_lowers_sensitivity": true,
"high_temptarget_raises_sensitivity": true
}
2 changes: 1 addition & 1 deletion FreeAPS/Sources/APS/OpenAPS/OpenAPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ final class OpenAPS {
if let total = tdd {
let round = round(Double((total.bolus + total.basal) * 10)) / 10
let bolus = Int(total.bolus * 100 / ((total.bolus + total.basal) != 0 ? total.bolus + total.basal : 1))
tddString = ", TDD: \(round) U, \(bolus) % Bolus, "
tddString = ", Insulin past 24h: \(round) U, \(bolus) % Bolus, "
} else {
tddString = ", "
}
Expand Down
6 changes: 6 additions & 0 deletions FreeAPS/Sources/APS/OpenAPS/TotalDailyDose.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ final class TotalDailyDose {
} else { return 0 }
}

func insulinToday(_ data: [PumpHistoryEvent], increment: Double) -> (bolus: Decimal, basal: Decimal, hours: Double) {
let filtered = data.filter({ $0.timestamp > Calendar.current.startOfDay(for: Date()) })

return totalDailyDose(filtered, increment: increment)
}

// All delivered boli (manual, external and SMBs)
private func bolus(_ data: [PumpHistoryEvent]) -> Decimal {
data.compactMap(\.amount).reduce(0, +)
Expand Down
21 changes: 21 additions & 0 deletions FreeAPS/Sources/APS/Storage/CoreDataStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,25 @@ final class CoreDataStorage {
}
return presetsArray
}

func fetchOnbarding() -> Bool {
var firstRun = true
coredataContext.performAndWait {
let requestBool = Onboarding.fetchRequest() as NSFetchRequest<Onboarding>
let sort = NSSortDescriptor(key: "date", ascending: false)
requestBool.sortDescriptors = [sort]
requestBool.fetchLimit = 1
try? firstRun = self.coredataContext.fetch(requestBool).first?.firstRun ?? true
}
return firstRun
}

func saveOnbarding() {
coredataContext.performAndWait { [self] in
let save = Onboarding(context: self.coredataContext)
save.firstRun = false
save.date = Date.now
try? self.coredataContext.save()
}
}
}
1 change: 0 additions & 1 deletion FreeAPS/Sources/Models/FreeAPSSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct FreeAPSSettings: JSON, Equatable {
var uploadVersion: Bool = true
var skipGlucoseChart: Bool = false
var birthDate = Date.distantPast
// var sex: Sex = .secret
var sexSetting: Int = 3
}

Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/NightscoutStatistics.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

struct NightscoutStatistics: JSON {
let report = "statistics"
var report = "statistics"
let dailystats: Statistics?
let justVersion: BareMinimum?
}
6 changes: 6 additions & 0 deletions FreeAPS/Sources/Models/RawFetchedProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ struct FetchedNightscoutProfile: JSON {
let carbratio: [NightscoutTimevalue]
let units: String
}

struct DatabaseProfileStore: JSON {
let units: String
let enteredBy: String
let store: [String: ScheduledNightscoutProfile]
}
Loading

0 comments on commit bcdd9f9

Please sign in to comment.