Skip to content

Commit c4e92d6

Browse files
authored
Merge pull request #312 from mohssenfathi/uber-button
Remove UberButton_DEPRECATED
2 parents d91ca25 + 2a76999 commit c4e92d6

File tree

12 files changed

+462
-597
lines changed

12 files changed

+462
-597
lines changed

Sources/UberAuth/Authorize/AuthenticationSession.swift

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class AuthenticationSession: AuthenticationSessioning {
3838
completion(.failure(UberAuthError.invalidAuthCode))
3939
case (.some(let url), _):
4040
guard let code = Self.parse(url: url) else {
41-
completion(.failure(UberAuthError.invalidAuthCode))
41+
completion(.failure(Self.parseError(url: url)))
4242
return
4343
}
4444
completion(.success(.init(authorizationCode: code)))
@@ -68,6 +68,19 @@ final class AuthenticationSession: AuthenticationSessioning {
6868
}
6969
return codeParameter.value
7070
}
71+
72+
private static func parseError(url: URL) -> UberAuthError {
73+
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
74+
let errorParameter = components.queryItems?.first(where: { $0.name == "error" })?.value else {
75+
return .invalidAuthCode
76+
}
77+
switch OAuthError(rawValue: errorParameter) {
78+
case .some(let error):
79+
return UberAuthError.oAuth(error)
80+
case .none:
81+
return .invalidAuthCode
82+
}
83+
}
7184
}
7285

7386
final class AuthPresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {

Sources/UberAuth/Button/LoginButton.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public final class LoginButton: UberButton {
8787

8888
// MARK: UberButton
8989

90-
override public var title: String {
91-
buttonState.title
90+
public override var title: NSAttributedString? {
91+
NSAttributedString(string: buttonState.title)
9292
}
9393

9494
override public var image: UIImage? {

Sources/UberCore/Colors.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55

66
import UIKit
77

8-
extension UIColor {
8+
public extension UIColor {
99

1010
static let uberButtonBackground: UIColor = UIColor(
1111
named: "UberButtonBackground",
1212
in: .resource(for: UberButton.self),
1313
compatibleWith: nil
1414
) ?? UIColor.darkText
1515

16-
static let uberButtonHighlightedBackground: UIColor = UIColor(
17-
named: "UberButtonHighlightedBackground",
18-
in: .resource(for: UberButton.self),
16+
static let uberButtonHighlightedDarkBackground: UIColor = UIColor(
17+
named: "UberButtonHighlightedDarkBackground",
18+
in: .module,
19+
compatibleWith: nil
20+
) ?? UIColor.darkText
21+
22+
static let uberButtonHighlightedLightBackground: UIColor = UIColor(
23+
named: "UberButtonHighlightedLightBackground",
24+
in: .module,
1925
compatibleWith: nil
2026
) ?? UIColor.darkText
2127

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0xE4",
9+
"green" : "0xE5",
10+
"red" : "0xE5"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x27",
27+
"green" : "0x27",
28+
"red" : "0x28"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}

0 commit comments

Comments
 (0)