-
Notifications
You must be signed in to change notification settings - Fork 114
/
Style.swift
185 lines (136 loc) · 6.53 KB
/
Style.swift
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Style.swift
//
// Copyright (c) 2016 Auth0 (http://auth0.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation
import UIKit
/**
* Define Auth0 Lock style and allows to customise it.
*/
public struct Style {
/// Title used in Header
public var title = "Auth0".i18n(key: "com.auth0.lock.header.default_title", comment: "Header Title")
/// Primary color of Lock used in the principal components like the Primary Button
public var primaryColor = UIColor.a0_orange
/// Lock background color
public var backgroundColor = UIColor.white
/// Lock background image
public var backgroundImage: UIImage?
/// Lock disabled component color
public var disabledColor = UIColor(red: 0.8902, green: 0.898, blue: 0.9059, alpha: 1.0)
/// Lock disabled component text color
public var disabledTextColor = UIColor(red: 0.5725, green: 0.5804, blue: 0.5843, alpha: 1.0) // #929495
/// Primary button tint color
public var buttonTintColor = UIColor.white
/// Header background color. By default it has no color but a blur
public var headerColor: UIColor?
/// Blur effect style used. It can be any value defined in `UIBlurEffectStyle`
public var headerBlur: A0BlurEffectStyle = .light
/// Header close button image
public var headerCloseIcon: UIImage? = UIImage(named: "ic_close", in: bundleForLock())
/// Header back button image
public var headerBackIcon: UIImage? = UIImage(named: "ic_back", in: bundleForLock())
/// Header title color
public var titleColor = UIColor.black
/// Hide header title (show only logo). By default is false
public var hideTitle = false {
didSet {
hideButtonTitle = false
}
}
/// Main body text color
public var textColor = UIColor.black
/// Hide primary button title (show only icon). By default is false
public var hideButtonTitle = false
/// Header logo image
public var logo: UIImage? = UIImage(named: "ic_auth0", in: bundleForLock())
/// OAuth2 custom connection styles by mapping a connection name with an `AuthStyle`
public var oauth2: [String: AuthStyle] = [:]
/// Social seperator label
public var seperatorTextColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.54)
/// Input field text color
public var inputTextColor = UIColor.black
/// Input field placeholder text color
public var inputPlaceholderTextColor = UIColor(red: 0.780, green: 0.780, blue: 0.804, alpha: 1.00) // #C7C7CD
/// Input field border color default
public var inputBorderColor = UIColor(red: 0.9333, green: 0.9333, blue: 0.9333, alpha: 1.0)
/// Input field border color invalid
public var inputBorderColorError = UIColor.red
/// Input field background color
public var inputBackgroundColor = UIColor.white
/// Input field icon background color
public var inputIconBackgroundColor = UIColor(red: 0.9333, green: 0.9333, blue: 0.9333, alpha: 1.0)
/// Input field icon color
public var inputIconColor = UIColor(red: 0.5725, green: 0.5804, blue: 0.5843, alpha: 1.0) // #929495
/// Password rule text color default
public var ruleTextColor = UIColor(red: 0.016, green: 0.016, blue: 0.016, alpha: 1.0)
/// Password rule text color valid
public var ruleTextColorSuccess = UIColor(red: 0.502, green: 0.820, blue: 0.208, alpha: 1.0)
/// Password rule text color invalid
public var ruleTextColorError = UIColor(red: 0.745, green: 0.271, blue: 0.153, alpha: 1.0)
/// Secondary button color
public var secondaryButtonColor = UIColor.black
/// Terms of Use and Privacy Policy button color
public var termsButtonColor = UIColor(red: 0.9333, green: 0.9333, blue: 0.9333, alpha: 1.0)
/// Terms of Use and Privacy Policy button title color
public var termsButtonTitleColor = UIColor.black
/// Database login Tab Text Color
public var tabTextColor = UIColor(red: 0.5725, green: 0.5804, blue: 0.5843, alpha: 1.0) // #929495
/// Database login selected Tab Text Color
public var selectedTabTextColor = UIColor.black
/// Database login Tab Tint Color
public var tabTintColor = UIColor.black
/// Lock Controller Status bar update animation
public var statusBarUpdateAnimation: UIStatusBarAnimation = .none
/// Lock Controller Status bar hidden
public var statusBarHidden = false
/// Lock Controller Status bar style
public var statusBarStyle: UIStatusBarStyle = .default
/// Passwordless search bar style
public var searchBarStyle: A0SearchBarStyle = .default
/// iPad Modal Presentation Style
public var modalPopup = true
var headerMask: UIImage? {
let image = self.logo
if Style.Auth0.logo == image {
return image?.withRenderingMode(.alwaysTemplate)
}
return image
}
func primaryButtonColor(forState state: A0ControlState) -> UIColor {
if state.contains(.highlighted) {
return self.primaryColor.a0_darker(0.20)
}
if state.contains(.disabled) {
return self.disabledColor
}
return self.primaryColor
}
func primaryButtonTintColor(forState state: A0ControlState) -> UIColor {
if state.contains(.disabled) {
return self.disabledTextColor
}
return self.buttonTintColor
}
static let Auth0 = Style()
}
protocol Stylable {
func apply(style: Style)
}