ServiceUI.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // ServiceUI.swift
  3. // LoopKitUI
  4. //
  5. // Created by Darin Krauss on 5/17/19.
  6. // Copyright © 2019 LoopKit Authors. All rights reserved.
  7. //
  8. import LoopKit
  9. import SwiftUI
  10. import HealthKit
  11. public protocol SupportInfoProvider {
  12. var pumpStatus: PumpManagerStatus? { get }
  13. var cgmDevice: HKDevice? { get }
  14. var localizedAppNameAndVersion: String { get }
  15. func generateIssueReport(completion: @escaping (String) -> Void)
  16. }
  17. public protocol ServiceUI: Service {
  18. /// The image for this type of service.
  19. static var image: UIImage? { get }
  20. /// Indicates whether this service provides onboarding (configuring therapy settings)
  21. static var providesOnboarding: Bool { get }
  22. /// Provides a view controller to create and configure a new service, if needed.
  23. ///
  24. /// - Returns: A view controller to create and configure a new service.
  25. static func setupViewController(currentTherapySettings: TherapySettings, preferredGlucoseUnit: HKUnit, chartColors: ChartColorPalette, carbTintColor: Color, glucoseTintColor: Color, guidanceColors: GuidanceColors, insulinTintColor: Color) -> (UIViewController & ServiceSetupNotifying & CompletionNotifying)?
  26. /// Provides a view controller to configure an existing service.
  27. ///
  28. /// - Returns: A view controller to configure an existing service.
  29. func settingsViewController(currentTherapySettings: TherapySettings, preferredGlucoseUnit: HKUnit, chartColors: ChartColorPalette, carbTintColor: Color, glucoseTintColor: Color, guidanceColors: GuidanceColors, insulinTintColor: Color) -> (UIViewController & ServiceSettingsNotifying & CompletionNotifying)
  30. /// Provides a view controller to configure an existing service.
  31. ///
  32. /// - Returns: A view that will be used in a support menu for providing user support
  33. func supportMenuItem(supportInfoProvider: SupportInfoProvider, urlHandler: @escaping (URL) -> Void) -> AnyView?
  34. }
  35. public extension ServiceUI {
  36. var image: UIImage? { return type(of: self).image }
  37. }