Skip to content

Commit

Permalink
Merge pull request #309 from mohssenfathi/min-os
Browse files Browse the repository at this point in the history
Drop min OS version to iOS 14
  • Loading branch information
mohssenfathi authored Jul 23, 2024
2 parents 815673f + fa41f92 commit 455f578
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
name: "rides-ios-sdk",
defaultLocalization: "en",
platforms: [
.iOS(.v15)
.iOS(.v14)
],
products: [
.library(
Expand Down
43 changes: 37 additions & 6 deletions Sources/UberCore/UberButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,46 @@ open class UberButton: UIButton {

public func update() {
DispatchQueue.main.async { [self] in
configuration = .uber(
title: title,
image: image,
isHighlighted: isHighlighted
)
updateConfiguration()
if #available(iOS 15, *) {
configuration = .uber(
title: title,
image: image,
isHighlighted: isHighlighted
)
updateConfiguration()
}
else {
clipsToBounds = true
layer.cornerRadius = Constants.cornerRadius

setImage(
image?.withRenderingMode(.alwaysTemplate),
for: .normal
)
imageView?.tintColor = .uberButtonForeground
imageView?.contentMode = .left

setTitle(title, for: .normal)
titleLabel?.textAlignment = .right

setTitleColor(.uberButtonForeground, for: .normal)
backgroundColor = isHighlighted ? .uberButtonHighlightedBackground : .uberButtonBackground

contentEdgeInsets = Constants.contentInsets
}
}
}

private enum Constants {
static let cornerRadius: CGFloat = 8
static let horizontalPadding: CGFloat = 16
static let verticalPadding: CGFloat = 10
static let contentInsets: UIEdgeInsets = .init(top: 0, left: 16, bottom: 0, right: 16)
}
}


@available(iOS 15, *)
extension UIButton.Configuration {

static func uber(title: String? = nil,
Expand All @@ -94,6 +124,7 @@ extension UIButton.Configuration {
return style
}
}


/// Base class for Uber buttons that sets up colors and some constraints.
open class UberButton_DEPRECATED: UIButton {
Expand Down

0 comments on commit 455f578

Please sign in to comment.