diff --git a/LoopOnboardingKitUI/LoopOnboardingUI.swift b/LoopOnboardingKitUI/LoopOnboardingUI.swift index b2fe4b2..fc89fcf 100644 --- a/LoopOnboardingKitUI/LoopOnboardingUI.swift +++ b/LoopOnboardingKitUI/LoopOnboardingUI.swift @@ -13,13 +13,14 @@ import LoopKitUI import LoopOnboardingKit public final class LoopOnboardingUI: OnboardingUI { + public static func createOnboarding() -> OnboardingUI { return Self() } public weak var onboardingDelegate: OnboardingDelegate? - public static let pluginIdentifier = "LoopOnboarding" + public let pluginIdentifier = "LoopOnboarding" public var isOnboarded: Bool { didSet { @@ -53,7 +54,7 @@ public final class LoopOnboardingUI: OnboardingUI { ] } - public func onboardingViewController(onboardingProvider: OnboardingProvider, displayGlucosePreference: DisplayGlucosePreference, colorPalette: LoopUIColorPalette) -> (UIViewController & OnboardingViewController) { + public func onboardingViewController(onboardingProvider: OnboardingProvider, displayGlucosePreference: DisplayGlucosePreference, colorPalette: LoopUIColorPalette, adultChildInsulinModelSelectionEnabled: Bool) -> (UIViewController & OnboardingViewController) { return OnboardingUICoordinator(onboarding: self, onboardingProvider: onboardingProvider, initialTherapySettings: onboardingProvider.onboardingTherapySettings, displayGlucosePreference: displayGlucosePreference, colorPalette: colorPalette) } diff --git a/LoopOnboardingKitUI/View Controllers/OnboardingUICoordinator.swift b/LoopOnboardingKitUI/View Controllers/OnboardingUICoordinator.swift index cc61f2d..a80eaf5 100644 --- a/LoopOnboardingKitUI/View Controllers/OnboardingUICoordinator.swift +++ b/LoopOnboardingKitUI/View Controllers/OnboardingUICoordinator.swift @@ -13,7 +13,9 @@ import SwiftUI import LoopKit import LoopKitUI import NightscoutServiceKit +import NightscoutServiceKitUI import LoopSupportKitUI +import LoopAlgorithm enum OnboardingScreen: CaseIterable { case welcome @@ -271,20 +273,16 @@ class OnboardingUICoordinator: UINavigationController, CGMManagerOnboarding, Pum private func setupWithNightscout() { LoopKitAnalytics.shared.recordAnalyticsEvent("Onboarding With Nightscout", withProperties: nil, outOfSession: false) - switch onboardingProvider.onboardService(withIdentifier: OnboardingUICoordinator.serviceIdentifier) { - case .failure(let error): - log.debug("Failure to create and setup service with identifier '%{public}@': %{public}@", OnboardingUICoordinator.serviceIdentifier, String(describing: error)) - case .success(let success): - switch success { - case .userInteractionRequired(var setupViewController): - nightscoutOnboardingViewController = setupViewController - setupViewController.serviceOnboardingDelegate = self - setupViewController.completionDelegate = self - show(setupViewController, sender: self) - case .createdAndOnboarded(let service): - self.service = service - checkForAvailableSettingsImport() - } + let result = NightscoutService.setupViewController(colorPalette: colorPalette, pluginHost: onboardingProvider, allowDebugFeatures: onboardingProvider.allowDebugFeatures) + switch result { + case .userInteractionRequired(var setupViewController): + nightscoutOnboardingViewController = setupViewController + setupViewController.serviceOnboardingDelegate = self + setupViewController.completionDelegate = self + show(setupViewController, sender: self) + case .createdAndOnboarded(let service): + self.service = service + checkForAvailableSettingsImport() } } @@ -349,16 +347,18 @@ class OnboardingUICoordinator: UINavigationController, CGMManagerOnboarding, Pum } extension OnboardingUICoordinator: TherapySettingsViewModelDelegate { + func syncBasalRateSchedule(items: [RepeatingScheduleValue], completion: @escaping (Result) -> Void) { // Since pump isn't set up, this syncing shouldn't do anything assertionFailure() } - func syncDeliveryLimits(deliveryLimits: DeliveryLimits, completion: @escaping (Result) -> Void) { + func syncDeliveryLimits(deliveryLimits: LoopKit.DeliveryLimits) async throws -> LoopKit.DeliveryLimits { // Since pump isn't set up, this syncing shouldn't do anything assertionFailure() + return deliveryLimits } - + func saveCompletion(therapySettings: TherapySettings) { stepFinished() } diff --git a/LoopOnboardingKitUI/Views/WelcomeView.swift b/LoopOnboardingKitUI/Views/WelcomeView.swift index 4c2d89f..5936d8b 100644 --- a/LoopOnboardingKitUI/Views/WelcomeView.swift +++ b/LoopOnboardingKitUI/Views/WelcomeView.swift @@ -19,10 +19,13 @@ struct WelcomeView: View { Text(LocalizedString("Welcome to Loop", comment: "Title on WelcomeView")) .font(.largeTitle) .fontWeight(.semibold) + Image(frameworkImage: "Loop", decorative: true) .onLongPressGesture(minimumDuration: 2) { didLongPressOnLogo?() } + .accessibilityHidden(false) + .accessibilityIdentifier("loopLogo") Text(LocalizedString("Before using Loop you need to configure a few settings. These settings should be entered with precision and care; they are a critical part of how Loop determines the right amount of insulin to deliver.\n\nIf you are new to Loop, work with your diabetes support team to determine the settings that work best for you.", comment: "Descriptive text on WelcomeView")) .foregroundColor(.secondary)