forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceAuthenticationUI.swift
More file actions
34 lines (26 loc) · 915 Bytes
/
ServiceAuthenticationUI.swift
File metadata and controls
34 lines (26 loc) · 915 Bytes
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
//
// ServiceAuthenticationUI.swift
// LoopKitUI
//
// Copyright © 2018 LoopKit Authors. All rights reserved.
//
import LoopKit
public protocol ServiceAuthenticationUI: ServiceAuthentication {
// The indexed credentials (e.g. username, password) used to authenticate
var credentialFormFields: [ServiceCredential] { get }
//Form field helper text displayed when completing form
var credentialFormFieldHelperMessage: String? { get }
}
public extension ServiceAuthenticationUI {
var credentials: [(field: ServiceCredential, value: String?)] {
return zip(credentialFormFields, credentialValues).map { (field, value) in
return (field: field, value: value)
}
}
func resetCredentials() {
for (index, field) in credentialFormFields.enumerated() {
credentialValues[index] = field.options?.first?.value
}
reset()
}
}