mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-02-16 21:02:04 +00:00
Move platform-specific extensions around
This commit is contained in:
parent
f2723c475d
commit
42e2c83eb5
@ -73,3 +73,40 @@ extension UIAlertController {
|
|||||||
return action
|
return action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension UIView {
|
||||||
|
static func get<T: UIView>() -> T {
|
||||||
|
let name = String(describing: T.self)
|
||||||
|
let nib = UINib(nibName: name, bundle: nil)
|
||||||
|
let objects = nib.instantiate(withOwner: nil)
|
||||||
|
for o in objects {
|
||||||
|
if let view = o as? T {
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UITableView {
|
||||||
|
func scrollToRowAsync(at indexPath: IndexPath) {
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
self?.scrollToRow(at: indexPath, at: .middle, animated: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectRowAsync(at indexPath: IndexPath) {
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
self?.selectRow(at: indexPath, animated: false, scrollPosition: .middle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UIColor {
|
||||||
|
convenience init(rgb: UInt32, alpha: CGFloat) {
|
||||||
|
let r = CGFloat((rgb & 0xff0000) >> 16) / 255.0
|
||||||
|
let g = CGFloat((rgb & 0xff00) >> 8) / 255.0
|
||||||
|
let b = CGFloat(rgb & 0xff) / 255.0
|
||||||
|
self.init(red: r, green: g, blue: b, alpha: alpha)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,15 +28,6 @@ import MessageUI
|
|||||||
import StoreKit
|
import StoreKit
|
||||||
import PassepartoutCore
|
import PassepartoutCore
|
||||||
|
|
||||||
extension UIColor {
|
|
||||||
convenience init(rgb: UInt32, alpha: CGFloat) {
|
|
||||||
let r = CGFloat((rgb & 0xff0000) >> 16) / 255.0
|
|
||||||
let g = CGFloat((rgb & 0xff00) >> 8) / 255.0
|
|
||||||
let b = CGFloat(rgb & 0xff) / 255.0
|
|
||||||
self.init(red: r, green: g, blue: b, alpha: alpha)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Theme {
|
struct Theme {
|
||||||
struct Palette {
|
struct Palette {
|
||||||
var primaryBackground = UIColor(rgb: 0x515d71, alpha: 1.0)
|
var primaryBackground = UIColor(rgb: 0x515d71, alpha: 1.0)
|
||||||
@ -174,12 +165,3 @@ extension PoolGroup {
|
|||||||
return ImageAsset(name: country.lowercased()).image
|
return ImageAsset(name: country.lowercased()).image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SKProduct {
|
|
||||||
var localizedPrice: String? {
|
|
||||||
let fmt = NumberFormatter()
|
|
||||||
fmt.numberStyle = .currency
|
|
||||||
fmt.locale = priceLocale
|
|
||||||
return fmt.string(from: price)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user