Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed errors and warnings in Xcode 12 #3

Merged
merged 2 commits into from
Feb 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Sources/PhotoLibraryPicker/PhotoLibraryPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AudioToolbox

extension UIApplication {

class func topViewController(_ viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
class func topViewController(_ viewController: UIViewController? = UIApplication.shared.windows.first?.rootViewController) -> UIViewController? {
if let nav = viewController as? UINavigationController {
return topViewController(nav.visibleViewController)
}
Expand Down Expand Up @@ -193,10 +193,10 @@ public extension UIColor {
let scanner = Scanner(string: hexString as String)

if hexString.hasPrefix("#") {
scanner.scanLocation = 1
scanner.currentIndex = scanner.string.startIndex
}
var color: UInt32 = 0
scanner.scanHexInt32(&color)
var color: UInt64 = 0
scanner.scanHexInt64(&color)

let mask = 0x000000FF
let r = Int(color >> 16) & mask
Expand All @@ -216,7 +216,7 @@ public extension UIColor {
/// - green: green component.
/// - blue: blue component.
/// - transparency: optional transparency value (default is 1)
public convenience init(red: Int, green: Int, blue: Int, transparency: CGFloat = 1) {
convenience init(red: Int, green: Int, blue: Int, transparency: CGFloat = 1) {
assert(red >= 0 && red <= 255, "Invalid red component")
assert(green >= 0 && green <= 255, "Invalid green component")
assert(blue >= 0 && blue <= 255, "Invalid blue component")
Expand All @@ -237,7 +237,7 @@ public extension UIColor {
public extension UIView {

/// Size of view.
public var size: CGSize {
var size: CGSize {
get {
return self.frame.size
}
Expand All @@ -248,7 +248,7 @@ public extension UIView {
}

/// Width of view.
public var width: CGFloat {
var width: CGFloat {
get {
return self.frame.size.width
}
Expand All @@ -258,7 +258,7 @@ public extension UIView {
}

/// Height of view.
public var height: CGFloat {
var height: CGFloat {
get {
return self.frame.size.height
}
Expand Down Expand Up @@ -600,7 +600,7 @@ extension UIAlertController {

// TODO: for iPad or other views
let isPad: Bool = UIDevice.current.userInterfaceIdiom == .pad
let root = UIApplication.shared.keyWindow?.rootViewController?.view
let root = UIApplication.shared.windows.first?.rootViewController?.view

//self.responds(to: #selector(getter: popoverPresentationController))
if let source = source {
Expand Down Expand Up @@ -641,7 +641,7 @@ extension UIAlertController {
}

DispatchQueue.main.async {
UIApplication.shared.keyWindow?.rootViewController?.present(self, animated: animated, completion: completion)
UIApplication.shared.windows.first?.rootViewController?.present(self, animated: animated, completion: completion)
if vibrate {
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
}
Expand Down Expand Up @@ -904,6 +904,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
switch layout.scrollDirection {
case .vertical: return UIDevice.current.userInterfaceIdiom == .pad ? 3 : 2
case .horizontal: return 1
default:
return UIDevice.current.userInterfaceIdiom == .pad ? 3 : 2
}
}

Expand All @@ -913,6 +915,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
return CGSize(width: view.bounds.width / columns, height: view.bounds.width / columns)
case .horizontal:
return CGSize(width: view.bounds.width, height: view.bounds.height / columns)
default:
return CGSize(width: view.bounds.width / columns, height: view.bounds.width / columns)
}
}

Expand Down Expand Up @@ -1016,6 +1020,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
self.alertController?.dismiss(animated: true)
}
alert.show()
default:
break
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final class PhotoLibraryPickerTests: XCTestCase {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertEqual(PhotoLibraryPicker().text, "Hello, World!")
// XCTAssertEqual(PhotoLibraryPicker(<#Binding<[Picture]>#>).text, "Hello, World!")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete it :)

all right

}

static var allTests = [
Expand Down