Skip to content

Commit

Permalink
Merge pull request #312 from mohssenfathi/uber-button
Browse files Browse the repository at this point in the history
Remove UberButton_DEPRECATED
  • Loading branch information
mohssenfathi authored Aug 27, 2024
2 parents d91ca25 + 2a76999 commit c4e92d6
Show file tree
Hide file tree
Showing 12 changed files with 462 additions and 597 deletions.
15 changes: 14 additions & 1 deletion Sources/UberAuth/Authorize/AuthenticationSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class AuthenticationSession: AuthenticationSessioning {
completion(.failure(UberAuthError.invalidAuthCode))
case (.some(let url), _):
guard let code = Self.parse(url: url) else {
completion(.failure(UberAuthError.invalidAuthCode))
completion(.failure(Self.parseError(url: url)))
return
}
completion(.success(.init(authorizationCode: code)))
Expand Down Expand Up @@ -68,6 +68,19 @@ final class AuthenticationSession: AuthenticationSessioning {
}
return codeParameter.value
}

private static func parseError(url: URL) -> UberAuthError {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let errorParameter = components.queryItems?.first(where: { $0.name == "error" })?.value else {
return .invalidAuthCode
}
switch OAuthError(rawValue: errorParameter) {
case .some(let error):
return UberAuthError.oAuth(error)
case .none:
return .invalidAuthCode
}
}
}

final class AuthPresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {
Expand Down
4 changes: 2 additions & 2 deletions Sources/UberAuth/Button/LoginButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public final class LoginButton: UberButton {

// MARK: UberButton

override public var title: String {
buttonState.title
public override var title: NSAttributedString? {
NSAttributedString(string: buttonState.title)
}

override public var image: UIImage? {
Expand Down
14 changes: 10 additions & 4 deletions Sources/UberCore/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@

import UIKit

extension UIColor {
public extension UIColor {

static let uberButtonBackground: UIColor = UIColor(
named: "UberButtonBackground",
in: .resource(for: UberButton.self),
compatibleWith: nil
) ?? UIColor.darkText

static let uberButtonHighlightedBackground: UIColor = UIColor(
named: "UberButtonHighlightedBackground",
in: .resource(for: UberButton.self),
static let uberButtonHighlightedDarkBackground: UIColor = UIColor(
named: "UberButtonHighlightedDarkBackground",
in: .module,
compatibleWith: nil
) ?? UIColor.darkText

static let uberButtonHighlightedLightBackground: UIColor = UIColor(
named: "UberButtonHighlightedLightBackground",
in: .module,
compatibleWith: nil
) ?? UIColor.darkText

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xE4",
"green" : "0xE5",
"red" : "0xE5"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x27",
"green" : "0x27",
"red" : "0x28"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit c4e92d6

Please sign in to comment.