diff --git a/.swiftlint.yml b/.swiftlint.yml index 40faf67..deefb79 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -17,6 +17,7 @@ included: # paths to include during linting. `--path` is ignored if present. excluded: # paths to ignore during linting. Takes precedence over `included`. - Carthage - Pods + - GitTime/Sources/Utils/PropertyWrappers/BundleInfoWrapper.swift analyzer_rules: # Rules run by `swiftlint analyze` (experimental) - explicit_self diff --git a/GitTime/Sources/Services/AuthService.swift b/GitTime/Sources/Services/AuthService.swift index cf8bac5..4941155 100644 --- a/GitTime/Sources/Services/AuthService.swift +++ b/GitTime/Sources/Services/AuthService.swift @@ -62,7 +62,7 @@ final class AuthService: AuthServiceType { } }) if #available(iOS 13.0, *) { - if let loginVC = UIApplication.shared.keyWindow?.rootViewController as? LoginViewController { + if let loginVC = UIApplication.keyWindow?.rootViewController as? LoginViewController { self.session?.presentationContextProvider = loginVC } } diff --git a/GitTime/Sources/Utils/Extensions/UIApplication+Extensions.swift b/GitTime/Sources/Utils/Extensions/UIApplication+Extensions.swift new file mode 100644 index 0000000..5920507 --- /dev/null +++ b/GitTime/Sources/Utils/Extensions/UIApplication+Extensions.swift @@ -0,0 +1,22 @@ +// +// UIApplication+Extensions.swift +// GitTime +// +// Created by Kanz on 2022/04/26. +// + +import UIKit + +extension UIApplication { + static var keyWindow: UIWindow? { + if #available(iOS 15.0, *) { + return UIApplication.shared.connectedScenes + .filter { $0.activationState == .foregroundActive } + .first(where: { $0 is UIWindowScene }) + .flatMap { $0 as? UIWindowScene }?.windows + .first(where: \.isKeyWindow) + } else { + return UIApplication.shared.windows.first(where: { $0.isKeyWindow }) + } + } +} diff --git a/GitTime/Sources/Utils/Extensions/UIColor+Extensions.swift b/GitTime/Sources/Utils/Extensions/UIColor+Extensions.swift index 2edd460..4809111 100644 --- a/GitTime/Sources/Utils/Extensions/UIColor+Extensions.swift +++ b/GitTime/Sources/Utils/Extensions/UIColor+Extensions.swift @@ -9,22 +9,22 @@ import UIKit extension UIColor { - convenience init(hexString: String) { - let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) - var int = UInt32() - Scanner(string: hex).scanHexInt32(&int) - let a, r, g, b: UInt32 - switch hex.count { - case 3: // RGB (12-bit) - (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) - case 6: // RGB (24-bit) - (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) - case 8: // ARGB (32-bit) - (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) - default: - (a, r, g, b) = (255, 0, 0, 0) - } - self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) + convenience init(hexString: String, alpha: CGFloat = 1.0) { + var hexFormatted: String = hexString.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased() + + if hexFormatted.hasPrefix("#") { + hexFormatted = String(hexFormatted.dropFirst()) + } + + assert(hexFormatted.count == 6, "Invalid hex code used.") + + var rgbValue: UInt64 = 0 + Scanner(string: hexFormatted).scanHexInt64(&rgbValue) + + self.init(red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, + green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, + blue: CGFloat(rgbValue & 0x0000FF) / 255.0, + alpha: alpha) } } diff --git a/Podfile b/Podfile index f085ca6..1f8787f 100644 --- a/Podfile +++ b/Podfile @@ -75,4 +75,10 @@ target 'GitTime' do end - +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' + end + end +end diff --git a/Podfile.lock b/Podfile.lock index 09e3573..1c42c34 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -330,6 +330,6 @@ SPEC CHECKSUMS: URLNavigator: 2593c0e2d293732ec5c44503cf54dceba1a68085 WeakMapTable: 05c694ce8439a7a9ebabb56187287a63c57673d6 -PODFILE CHECKSUM: ecfb47752adb4f2669fe0fbed01e71aadb792c5e +PODFILE CHECKSUM: 889e35fd688c78c4e6f036a683a2aed3bbd554c6 COCOAPODS: 1.11.2