Skip to content

Commit

Permalink
Release/0.2.0 (#63)
Browse files Browse the repository at this point in the history
* Fix the first suspension time

* Fix bolus indicator

* Fix authorization logic

* weakAssign

* tmp remove logout button

* Accept uppercased remote commands

* Fix CR range

* Fix bolus auth

* Fix pump settings placeholders

* carbsReq badge

* Bump version

* README update

* Clean signing
  • Loading branch information
ivalkou committed May 31, 2021
1 parent 647f99f commit 60f1e7a
Show file tree
Hide file tree
Showing 32 changed files with 212 additions and 100 deletions.
38 changes: 19 additions & 19 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
3811DE4125C9D4A100A708ED /* SettingsRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE3C25C9D4A100A708ED /* SettingsRootView.swift */; };
3811DE4225C9D4A100A708ED /* SettingsDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE3D25C9D4A100A708ED /* SettingsDataFlow.swift */; };
3811DE4325C9D4A100A708ED /* SettingsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE3E25C9D4A100A708ED /* SettingsProvider.swift */; };
3811DE4C25C9D4B800A708ED /* AuthotizedRootBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4625C9D4B800A708ED /* AuthotizedRootBuilder.swift */; };
3811DE4D25C9D4B800A708ED /* AuthotizedRootViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4725C9D4B800A708ED /* AuthotizedRootViewModel.swift */; };
3811DE4C25C9D4B800A708ED /* AuthorizedRootBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4625C9D4B800A708ED /* AuthorizedRootBuilder.swift */; };
3811DE4D25C9D4B800A708ED /* AuthorizedRootViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4725C9D4B800A708ED /* AuthorizedRootViewModel.swift */; };
3811DE4E25C9D4B800A708ED /* AuthotizedRootRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4925C9D4B800A708ED /* AuthotizedRootRootView.swift */; };
3811DE4F25C9D4B800A708ED /* AuthotizedRootDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4A25C9D4B800A708ED /* AuthotizedRootDataFlow.swift */; };
3811DE5025C9D4B800A708ED /* AuthotizedRootProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4B25C9D4B800A708ED /* AuthotizedRootProvider.swift */; };
3811DE4F25C9D4B800A708ED /* AuthorizedRootDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4A25C9D4B800A708ED /* AuthorizedRootDataFlow.swift */; };
3811DE5025C9D4B800A708ED /* AuthorizedRootProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE4B25C9D4B800A708ED /* AuthorizedRootProvider.swift */; };
3811DE5C25C9D4D500A708ED /* Formatters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE5425C9D4D500A708ED /* Formatters.swift */; };
3811DE5D25C9D4D500A708ED /* Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE5525C9D4D500A708ED /* Publisher.swift */; };
3811DE5F25C9D4D500A708ED /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE5725C9D4D500A708ED /* ProgressBar.swift */; };
Expand Down Expand Up @@ -341,11 +341,11 @@
3811DE3C25C9D4A100A708ED /* SettingsRootView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsRootView.swift; sourceTree = "<group>"; };
3811DE3D25C9D4A100A708ED /* SettingsDataFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsDataFlow.swift; sourceTree = "<group>"; };
3811DE3E25C9D4A100A708ED /* SettingsProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsProvider.swift; sourceTree = "<group>"; };
3811DE4625C9D4B800A708ED /* AuthotizedRootBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthotizedRootBuilder.swift; sourceTree = "<group>"; };
3811DE4725C9D4B800A708ED /* AuthotizedRootViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthotizedRootViewModel.swift; sourceTree = "<group>"; };
3811DE4625C9D4B800A708ED /* AuthorizedRootBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorizedRootBuilder.swift; sourceTree = "<group>"; };
3811DE4725C9D4B800A708ED /* AuthorizedRootViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorizedRootViewModel.swift; sourceTree = "<group>"; };
3811DE4925C9D4B800A708ED /* AuthotizedRootRootView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthotizedRootRootView.swift; sourceTree = "<group>"; };
3811DE4A25C9D4B800A708ED /* AuthotizedRootDataFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthotizedRootDataFlow.swift; sourceTree = "<group>"; };
3811DE4B25C9D4B800A708ED /* AuthotizedRootProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthotizedRootProvider.swift; sourceTree = "<group>"; };
3811DE4A25C9D4B800A708ED /* AuthorizedRootDataFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorizedRootDataFlow.swift; sourceTree = "<group>"; };
3811DE4B25C9D4B800A708ED /* AuthorizedRootProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorizedRootProvider.swift; sourceTree = "<group>"; };
3811DE5425C9D4D500A708ED /* Formatters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Formatters.swift; sourceTree = "<group>"; };
3811DE5525C9D4D500A708ED /* Publisher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Publisher.swift; sourceTree = "<group>"; };
3811DE5725C9D4D500A708ED /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -637,7 +637,7 @@
children = (
6DC5D590658EF8B8DF94F9F5 /* AddCarbs */,
A9A4C88374496B3C89058A89 /* AddTempTarget */,
3811DE4525C9D4B800A708ED /* AuthotizedRoot */,
3811DE4525C9D4B800A708ED /* AuthorizedRoot */,
672F63EEAE27400625E14BAD /* AutotuneConfig */,
A42F1FEDFFD0DDE00AAD54D3 /* BasalProfileEditor */,
3811DE0425C9D32E00A708ED /* Base */,
Expand Down Expand Up @@ -762,16 +762,16 @@
path = View;
sourceTree = "<group>";
};
3811DE4525C9D4B800A708ED /* AuthotizedRoot */ = {
3811DE4525C9D4B800A708ED /* AuthorizedRoot */ = {
isa = PBXGroup;
children = (
3811DE4625C9D4B800A708ED /* AuthotizedRootBuilder.swift */,
3811DE4A25C9D4B800A708ED /* AuthotizedRootDataFlow.swift */,
3811DE4B25C9D4B800A708ED /* AuthotizedRootProvider.swift */,
3811DE4725C9D4B800A708ED /* AuthotizedRootViewModel.swift */,
3811DE4625C9D4B800A708ED /* AuthorizedRootBuilder.swift */,
3811DE4A25C9D4B800A708ED /* AuthorizedRootDataFlow.swift */,
3811DE4B25C9D4B800A708ED /* AuthorizedRootProvider.swift */,
3811DE4725C9D4B800A708ED /* AuthorizedRootViewModel.swift */,
3811DE4825C9D4B800A708ED /* View */,
);
path = AuthotizedRoot;
path = AuthorizedRoot;
sourceTree = "<group>";
};
3811DE4825C9D4B800A708ED /* View */ = {
Expand Down Expand Up @@ -1625,7 +1625,7 @@
3811DEEB25CA063400A708ED /* PersistedProperty.swift in Sources */,
388E5A6025B6F2310019842D /* Autosens.swift in Sources */,
3811DE8B25C9D6DD00A708ED /* RequestPermissionsBuilder.swift in Sources */,
3811DE4C25C9D4B800A708ED /* AuthotizedRootBuilder.swift in Sources */,
3811DE4C25C9D4B800A708ED /* AuthorizedRootBuilder.swift in Sources */,
3811DE8F25C9D80400A708ED /* User.swift in Sources */,
3811DEB225C9D88300A708ED /* KeychainItemAccessibility.swift in Sources */,
385CEAC425F2F154002D6D5B /* AnnouncementsStorage.swift in Sources */,
Expand Down Expand Up @@ -1727,9 +1727,9 @@
38BF021D25E7E3AF00579895 /* Reservoir.swift in Sources */,
38BF021B25E7D06400579895 /* PumpSettingsView.swift in Sources */,
3811DEEA25CA063400A708ED /* SyncAccess.swift in Sources */,
3811DE4F25C9D4B800A708ED /* AuthotizedRootDataFlow.swift in Sources */,
3811DE4F25C9D4B800A708ED /* AuthorizedRootDataFlow.swift in Sources */,
38BF021F25E7F0DE00579895 /* DeviceDataManager.swift in Sources */,
3811DE5025C9D4B800A708ED /* AuthotizedRootProvider.swift in Sources */,
3811DE5025C9D4B800A708ED /* AuthorizedRootProvider.swift in Sources */,
38A504A425DD9C4000C5B9E8 /* UserDefaultsExtensions.swift in Sources */,
38FE826A25CC82DB001FF17A /* NetworkService.swift in Sources */,
3883581C25EE79BB00E024B2 /* DecimalTextField.swift in Sources */,
Expand All @@ -1744,7 +1744,7 @@
38E98A2525F52C9300C0CED0 /* IssueReporter.swift in Sources */,
3811DF0825CAAA4700A708ED /* ServiceContainer.swift in Sources */,
3811DEB025C9D88300A708ED /* BaseKeychain.swift in Sources */,
3811DE4D25C9D4B800A708ED /* AuthotizedRootViewModel.swift in Sources */,
3811DE4D25C9D4B800A708ED /* AuthorizedRootViewModel.swift in Sources */,
3811DE6A25C9D62600A708ED /* OnboardingBuilder.swift in Sources */,
3811DEC425C9D99900A708ED /* NetworkContainer.swift in Sources */,
3811DE4325C9D4A100A708ED /* SettingsProvider.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Resources/Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_VERSION = 0.1.23
BUILD_VERSION = 0.2.0
2 changes: 2 additions & 0 deletions FreeAPS/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(BUILD_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>dexcomg6</string>
Expand Down
15 changes: 11 additions & 4 deletions FreeAPS/Sources/APS/APSManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,14 @@ final class BaseAPSManager: APSManager, Injectable {
if !isSMB {
self.determineBasal().sink { _ in }.store(in: &self.lifetime)
}
self.bolusProgress.send(0)
}
} receiveValue: { _ in }
.store(in: &lifetime)
}

func cancelBolus() {
guard let pump = pumpManager else { return }
guard let pump = pumpManager, pump.status.pumpStatus.bolusing else { return }
debug(.apsManager, "Cancel bolus")
pump.cancelBolus().sink { completion in
if case let .failure(error) = completion {
Expand Down Expand Up @@ -391,6 +392,7 @@ final class BaseAPSManager: APSManager, Injectable {
case .success:
debug(.apsManager, "Announcement Bolus succeeded")
self.announcementsStorage.storeAnnouncements([announcement], enacted: true)
self.bolusProgress.send(0)
case let .failure(error):
warning(.apsManager, "Announcement Bolus failed with error: \(error.localizedDescription)")
}
Expand Down Expand Up @@ -507,8 +509,11 @@ final class BaseAPSManager: APSManager, Injectable {
return Just(()).setFailureType(to: Error.self)
.eraseToAnyPublisher()
}
return pump.enactBolus(units: Double(units), automatic: true).map { _ in () }
.eraseToAnyPublisher()
return pump.enactBolus(units: Double(units), automatic: true).map { _ in
self.bolusProgress.send(0)
return ()
}
.eraseToAnyPublisher()
}()

basalPublisher
Expand Down Expand Up @@ -558,7 +563,9 @@ final class BaseAPSManager: APSManager, Injectable {
private func clearBolusReporter() {
bolusReporter?.removeObserver(self)
bolusReporter = nil
bolusProgress.send(nil)
processQueue.asyncAfter(deadline: .now() + 1) {
self.bolusProgress.send(nil)
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions FreeAPS/Sources/Helpers/Publisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ extension Publisher where Failure == Never {
}

typealias Lifetime = Set<AnyCancellable>

extension Publisher where Failure == Never {
func weakAssign<T: AnyObject>(
to keyPath: ReferenceWritableKeyPath<T, Output>,
on object: T
) -> AnyCancellable {
sink { [weak object] value in
object?[keyPath: keyPath] = value
}
}
}
4 changes: 2 additions & 2 deletions FreeAPS/Sources/Models/Announcement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ struct Announcement: JSON {
guard components.count == 2 else {
return nil
}
let command = String(components[0])
let arguments = String(components[1])
let command = String(components[0]).lowercased()
let arguments = String(components[1]).lowercased()
switch command {
case "bolus":
guard let amount = Decimal(from: arguments) else { return nil }
Expand Down
4 changes: 3 additions & 1 deletion FreeAPS/Sources/Modules/AddCarbs/AddCarbsDataFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ enum AddCarbs {
enum Config {}
}

protocol AddCarbsProvider: Provider {}
protocol AddCarbsProvider: Provider {
var suggestion: Suggestion? { get }
}
6 changes: 5 additions & 1 deletion FreeAPS/Sources/Modules/AddCarbs/AddCarbsProvider.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
extension AddCarbs {
final class Provider: BaseProvider, AddCarbsProvider {}
final class Provider: BaseProvider, AddCarbsProvider {
var suggestion: Suggestion? {
storage.retrieve(OpenAPS.Enact.suggested, as: Suggestion.self)
}
}
}
5 changes: 4 additions & 1 deletion FreeAPS/Sources/Modules/AddCarbs/AddCarbsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ extension AddCarbs {
@Injected() var apsManager: APSManager!
@Published var carbs: Decimal = 0
@Published var date = Date()
@Published var carbsRequired: Decimal?

override func subscribe() {}
override func subscribe() {
carbsRequired = provider.suggestion?.carbsReq
}

func add() {
guard carbs > 0 else {
Expand Down
9 changes: 9 additions & 0 deletions FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ extension AddCarbs {

var body: some View {
Form {
if let carbsReq = viewModel.carbsRequired {
Section {
HStack {
Text("Carbs required")
Spacer()
Text(formatter.string(from: carbsReq as NSNumber)! + " g")
}
}
}
Section {
HStack {
Text("Amount")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
extension AuthotizedRoot {
extension AuthorizedRoot {
final class Builder: BaseModuleBuilder<RootView, ViewModel<Provider>, Provider> {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import SwiftUI

enum AuthorizedRoot {
enum Config {}
}

protocol AuthorizedRootProvider: Provider {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extension AuthorizedRoot {
final class Provider: BaseProvider, AuthorizedRootProvider {}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SwiftUI
import Swinject

extension AuthotizedRoot {
class ViewModel<Provider>: BaseViewModel<Provider>, ObservableObject where Provider: AuthotizedRootProvider {
extension AuthorizedRoot {
class ViewModel<Provider>: BaseViewModel<Provider>, ObservableObject where Provider: AuthorizedRootProvider {
override func subscribe() {}

var rootView: some View {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

extension AuthotizedRoot {
extension AuthorizedRoot {
struct RootView: BaseView {
@EnvironmentObject var viewModel: ViewModel<Provider>

Expand Down

This file was deleted.

This file was deleted.

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

let timeValues = stride(from: 0.0, to: 1.days.timeInterval, by: 30.minutes.timeInterval).map { $0 }

let rateValues = stride(from: 2, to: 50.01, by: 0.1).map { $0 }
let rateValues = stride(from: 3, to: 50.01, by: 0.1).map { $0 }

var canAdd: Bool {
guard let lastItem = items.last else { return true }
Expand Down
16 changes: 9 additions & 7 deletions FreeAPS/Sources/Modules/Home/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension Home {
@Published var errorDate: Date? = nil
@Published var bolusProgress: Decimal?
@Published var eventualBG: Int?

@Published var carbsRequired: Decimal?
@Published var allowManualTemp = false
@Published var units: GlucoseUnits = .mmolL

Expand All @@ -63,6 +63,7 @@ extension Home {
allowManualTemp = !settingsManager.settings.closedLoop
closedLoop = settingsManager.settings.closedLoop
lastLoopDate = apsManager.lastLoopDate
carbsRequired = suggestion?.carbsReq

setStatusTitle()
setupCurrentTempTarget()
Expand All @@ -89,22 +90,22 @@ extension Home {

apsManager.isLooping
.receive(on: DispatchQueue.main)
.assign(to: \.isLooping, on: self)
.weakAssign(to: \.isLooping, on: self)
.store(in: &lifetime)

apsManager.lastLoopDateSubject
.receive(on: DispatchQueue.main)
.assign(to: \.lastLoopDate, on: self)
.weakAssign(to: \.lastLoopDate, on: self)
.store(in: &lifetime)

apsManager.pumpName
.receive(on: DispatchQueue.main)
.assign(to: \.pumpName, on: self)
.weakAssign(to: \.pumpName, on: self)
.store(in: &lifetime)

apsManager.pumpExpiresAtDate
.receive(on: DispatchQueue.main)
.assign(to: \.pumpExpiresAtDate, on: self)
.weakAssign(to: \.pumpExpiresAtDate, on: self)
.store(in: &lifetime)

apsManager.lastError
Expand All @@ -113,12 +114,12 @@ extension Home {
self.errorDate = error == nil ? nil : Date()
return error?.localizedDescription
}
.assign(to: \.errorMessage, on: self)
.weakAssign(to: \.errorMessage, on: self)
.store(in: &lifetime)

apsManager.bolusProgress
.receive(on: DispatchQueue.main)
.assign(to: \.bolusProgress, on: self)
.weakAssign(to: \.bolusProgress, on: self)
.store(in: &lifetime)
}

Expand Down Expand Up @@ -289,6 +290,7 @@ extension Home.ViewModel:

func suggestionDidUpdate(_ suggestion: Suggestion) {
self.suggestion = suggestion
carbsRequired = suggestion.carbsReq
setStatusTitle()
}

Expand Down
14 changes: 12 additions & 2 deletions FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,18 @@ extension MainChartView {

let firstRec = self.suspensions.first.flatMap { event -> CGRect? in
guard event.type == .pumpResume else { return nil }
let width = self.timeToXCoordinate(event.timestamp.timeIntervalSince1970, fullSize: fullSize)
return CGRect(x: 0, y: 0, width: width, height: Config.basalHeight)
let tbrTime = self.tempBasals.last { $0.timestamp < event.timestamp }
.map { $0.timestamp.timeIntervalSince1970 + TimeInterval($0.durationMin ?? 0) * 60 } ?? Date()
.addingTimeInterval(-1.days.timeInterval).timeIntervalSince1970

let x0 = self.timeToXCoordinate(tbrTime, fullSize: fullSize)
let x1 = self.timeToXCoordinate(event.timestamp.timeIntervalSince1970, fullSize: fullSize)
return CGRect(
x: x0,
y: 0,
width: x1 - x0,
height: Config.basalHeight
)
}

let lastRec = self.suspensions.last.flatMap { event -> CGRect? in
Expand Down
Loading

0 comments on commit 60f1e7a

Please sign in to comment.