forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceUI.swift
More file actions
65 lines (54 loc) · 2.16 KB
/
ServiceUI.swift
File metadata and controls
65 lines (54 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// ServiceUI.swift
// LoopKitUI
//
// Created by Darin Krauss on 5/17/19.
// Copyright © 2019 LoopKit Authors. All rights reserved.
//
import SwiftUI
import LoopKit
public struct ServiceDescriptor {
public let identifier: String
public let localizedTitle: String
public init(identifier: String, localizedTitle: String) {
self.identifier = identifier
self.localizedTitle = localizedTitle
}
}
public typealias ServiceViewController = (UIViewController & ServiceOnboarding & CompletionNotifying)
public protocol ServiceUI: Service {
/// The image for this type of service.
static var image: UIImage? { get }
/// Create and onboard a new service.
///
/// - Parameters:
/// - colorPalette: Color palette to use for any UI.
/// - pluginHost: Object that provides namd and version information about host to the service plugin.
/// - Returns: Either a conforming view controller to create and onboard the service or a newly created and onboarded service.
static func setupViewController(colorPalette: LoopUIColorPalette, pluginHost: PluginHost) -> SetupUIResult<ServiceViewController, ServiceUI>
/// Configure settings for an existing service.
///
/// - Parameters:
/// - colorPalette: Color palette to use for any UI.
/// - Returns: A view controller to configure an existing service.
func settingsViewController(colorPalette: LoopUIColorPalette) -> ServiceViewController
}
public extension ServiceUI {
var image: UIImage? { return type(of: self).image }
}
public protocol ServiceOnboardingDelegate: AnyObject {
/// Informs the delegate that the specified service was created.
///
/// - Parameters:
/// - service: The service created.
func serviceOnboarding(didCreateService service: Service)
/// Informs the delegate that the specified service was onboarded.
///
/// - Parameters:
/// - service: The service onboarded.
func serviceOnboarding(didOnboardService service: Service)
}
public protocol ServiceOnboarding {
/// Delegate to notify about service onboarding.
var serviceOnboardingDelegate: ServiceOnboardingDelegate? { get set }
}