Skip to content
Merged
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
27 changes: 27 additions & 0 deletions OmniKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
275A98C02AE456EA0097F476 /* SlideButton in Frameworks */ = {isa = PBXBuildFile; productRef = 275A98BF2AE456EA0097F476 /* SlideButton */; };
C1229C1A29C7E5BC0066A89C /* RileyLinkBLEKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1229C1729C7E5BC0066A89C /* RileyLinkBLEKit.framework */; };
C1229C1B29C7E5BC0066A89C /* RileyLinkBLEKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C1229C1729C7E5BC0066A89C /* RileyLinkBLEKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C1229C1C29C7E5BC0066A89C /* RileyLinkKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1229C1829C7E5BC0066A89C /* RileyLinkKit.framework */; };
Expand Down Expand Up @@ -454,6 +455,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
275A98C02AE456EA0097F476 /* SlideButton in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -885,6 +887,9 @@
dependencies = (
);
name = OmniKitUI;
packageProductDependencies = (
275A98BF2AE456EA0097F476 /* SlideButton */,
);
productName = OmniKitUI;
productReference = C124020B29C7D92700B32844 /* OmniKitUI.framework */;
productType = "com.apple.product-type.framework";
Expand Down Expand Up @@ -989,6 +994,9 @@
hi,
);
mainGroup = C124016229C7D87A00B32844;
packageReferences = (
275A98BE2AE456EA0097F476 /* XCRemoteSwiftPackageReference "SlideButton" */,
);
productRefGroup = C124016D29C7D87A00B32844 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -1782,6 +1790,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
275A98BE2AE456EA0097F476 /* XCRemoteSwiftPackageReference "SlideButton" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/no-comment/SlideButton";
requirement = {
branch = main;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
275A98BF2AE456EA0097F476 /* SlideButton */ = {
isa = XCSwiftPackageProductDependency;
package = 275A98BE2AE456EA0097F476 /* XCRemoteSwiftPackageReference "SlideButton" */;
productName = SlideButton;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = C124016329C7D87A00B32844 /* Project object */;
}
12 changes: 10 additions & 2 deletions OmniKitUI/ViewModels/InsertCannulaViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InsertCannulaViewModel: ObservableObject, Identifiable {
var actionButtonAccessibilityLabel: String {
switch self {
case .ready, .startingInsertion:
return LocalizedString("Insert Cannula", comment: "Insert cannula action button accessibility label while ready to pair")
return LocalizedString("Slide Button to insert Cannula", comment: "Insert cannula slider button accessibility label while ready to pair")
case .inserting:
return LocalizedString("Inserting. Please wait.", comment: "Insert cannula action button accessibility label while pairing")
case .checkingInsertion:
Expand All @@ -54,7 +54,7 @@ class InsertCannulaViewModel: ObservableObject, Identifiable {
var nextActionButtonDescription: String {
switch self {
case .ready:
return LocalizedString("Insert Cannula", comment: "Cannula insertion button text while ready to insert")
return LocalizedString("Slide to Insert Cannula", comment: "Cannula insertion button text while ready to insert")
case .error:
return LocalizedString("Retry", comment: "Cannula insertion button text while showing error")
case .inserting, .startingInsertion:
Expand Down Expand Up @@ -125,6 +125,14 @@ class InsertCannulaViewModel: ObservableObject, Identifiable {
}

@Published var state: InsertCannulaViewModelState = .ready
public var stateNeedsDeliberateUserAcceptance : Bool {
switch state {
case .ready:
true
default:
false
}
}

var didFinish: (() -> Void)?

Expand Down
68 changes: 59 additions & 9 deletions OmniKitUI/Views/InsertCannulaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import SwiftUI
import LoopKitUI
import SlideButton
import OmniKit

struct InsertCannulaView: View {

Expand All @@ -24,7 +26,7 @@ struct InsertCannulaView: View {

HStack {
InstructionList(instructions: [
LocalizedString("Tap below to start cannula insertion.", comment: "Label text for step one of insert cannula instructions"),
LocalizedString("Slide the switch below to start cannula insertion.", comment: "Label text for step one of insert cannula instructions"),
LocalizedString("Wait until insertion is completed.", comment: "Label text for step two of insert cannula instructions"),
])
.disabled(viewModel.state.instructionsDisabled)
Expand Down Expand Up @@ -65,14 +67,7 @@ struct InsertCannulaView: View {
}

if (self.viewModel.error == nil || self.viewModel.error?.recoverable == true) {
Button(action: {
self.viewModel.continueButtonTapped()
}) {
Text(self.viewModel.state.nextActionButtonDescription)
.accessibility(identifier: "button_next_action")
.accessibility(label: Text(self.viewModel.state.actionButtonAccessibilityLabel))
.actionButtonStyle(.primary)
}
actionButton
.disabled(self.viewModel.state.isProcessing)
.zIndex(1)
}
Expand All @@ -85,6 +80,37 @@ struct InsertCannulaView: View {
.navigationBarBackButtonHidden(true)
.navigationBarItems(trailing: cancelButton)
}
var actionText : some View {
Text(self.viewModel.state.nextActionButtonDescription)
.accessibility(identifier: "button_next_action")
.accessibility(label: Text(self.viewModel.state.actionButtonAccessibilityLabel))
.font(.headline)

}


@ViewBuilder
var actionButton: some View {
if self.viewModel.stateNeedsDeliberateUserAcceptance {
SlideButton(action: {
self.viewModel.continueButtonTapped()
}) {
actionText
}

} else {
Button(action: {
self.viewModel.continueButtonTapped()
}) {
actionText
.actionButtonStyle(.primary)
}

}


}


var cancelButton: some View {
Button(LocalizedString("Cancel", comment: "Cancel button text in navigation bar on insert cannula screen")) {
Expand All @@ -103,3 +129,27 @@ struct InsertCannulaView: View {
}

}

class MockCannulaInserter: CannulaInserter {
public func insertCannula(completion: @escaping (Result<TimeInterval,OmnipodPumpManagerError>) -> Void) {
let mockDelay = TimeInterval(seconds: 3)
let result :Result<TimeInterval, OmnipodPumpManagerError> = .success(mockDelay)
completion(result)
}

func checkCannulaInsertionFinished(completion: @escaping (OmnipodPumpManagerError?) -> Void) {
completion(nil)
}


}
struct InsertCannulaView_Previews: PreviewProvider {
static var mockInserter = MockCannulaInserter()
static var model = InsertCannulaViewModel(cannulaInserter: mockInserter)
static var previews: some View {
InsertCannulaView(viewModel: model)



}
}