diff --git a/.travis.yml b/.travis.yml index 35dd0d8..44a3e94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode9.2 +osx_image: xcode10.1 gemfile: Gemfile bundler_args: "--without documentation --path bundle" # Don't download documentation for gems. cache: diff --git a/Gemfile b/Gemfile index e024b7e..40fec55 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,9 @@ source "https://rubygems.org" # Needed for Fastlane & Danger -gem 'fastlane', '~>2.86.2' +gem 'fastlane' gem 'danger' -gem 'danger-swiftlint', '~>0.13.1' +gem 'danger-swiftlint' gem 'danger-xcov' gem 'danger-xcode_summary' gem 'xcpretty' diff --git a/Sources/UINotification.swift b/Sources/UINotification.swift index 6a61de6..a879bc6 100644 --- a/Sources/UINotification.swift +++ b/Sources/UINotification.swift @@ -23,7 +23,7 @@ public protocol UINotificationStyle { var backgroundColor: UIColor { get } /// The height of the notification which applies on the notification view. - var height: UINotificationHeight { get } + var height: UINotification.Height { get } /// When `true`, the notification is swipeable and tappable. var interactive: Bool { get } @@ -32,24 +32,6 @@ public protocol UINotificationStyle { var chevronImage: UIImage? { get } } -/// Defines the height which will be applied on the notification view. -public enum UINotificationHeight { - case statusBar - case navigationBar - case custom(height: CGFloat) - - internal var value: CGFloat { - switch self { - case .statusBar: - return UIApplication.shared.statusBarFrame.height - case .navigationBar: - return UIApplication.shared.statusBarFrame.height + 44 - case .custom(let height): - return height - } - } -} - /// Handles changes in UINotification protocol UINotificationDelegate: class { // Called when Notification is updated @@ -58,7 +40,25 @@ protocol UINotificationDelegate: class { /// An UINotification which can be showed on top of the `UINavigationBar` and `UIStatusBar` public final class UINotification: Equatable { - + + /// Defines the height which will be applied on the notification view. + public enum Height { + case statusBar + case navigationBar + case custom(height: CGFloat) + + internal var value: CGFloat { + switch self { + case .statusBar: + return UIApplication.shared.statusBarFrame.height + case .navigationBar: + return UIApplication.shared.statusBarFrame.height + 44 + case .custom(let height): + return height + } + } + } + /// The content of the notification. public var content: UINotificationContent diff --git a/Sources/UINotificationCenter.swift b/Sources/UINotificationCenter.swift index 92bc17b..b1606f9 100644 --- a/Sources/UINotificationCenter.swift +++ b/Sources/UINotificationCenter.swift @@ -23,7 +23,7 @@ public final class UINotificationCenter { /// The window level that notification should appear at. The default level is over the status bar. /// Changing the window level while a notification is displayed might give some issues. - public var windowLevel: UIWindowLevel = UIWindowLevelStatusBar + public var windowLevel: UIWindow.Level = UIWindow.Level.statusBar /// If `true`, the same notifications can be queued. This can result in duplicate notifications being presented after each other. public var isDuplicateQueueingAllowed: Bool = false diff --git a/Sources/UINotificationDismissTrigger.swift b/Sources/UINotificationDismissTrigger.swift index 2f45e67..ebe5e94 100644 --- a/Sources/UINotificationDismissTrigger.swift +++ b/Sources/UINotificationDismissTrigger.swift @@ -17,7 +17,7 @@ public protocol Dismissable: class { /// A trigger which can be used to dismiss an `UINotificationView`. public protocol UINotificationDismissTrigger: class { /// The target to dismiss. - weak var target: Dismissable? { get set } + var target: Dismissable? { get set } } /// A trigger which is schedulable and therefor cancelable. diff --git a/Sources/UINotificationPresentationContext.swift b/Sources/UINotificationPresentationContext.swift index 6cba01f..da04810 100644 --- a/Sources/UINotificationPresentationContext.swift +++ b/Sources/UINotificationPresentationContext.swift @@ -15,7 +15,7 @@ public final class UINotificationPresentationContext { public let containerWindow: UIWindow /// The level the container window should be on when presenting the notification - private let windowLevel: UIWindowLevel + private let windowLevel: UIWindow.Level /// The `UINotificationView` containing the visual representation of the `UINotification`. public let notificationView: UINotificationView @@ -28,7 +28,7 @@ public final class UINotificationPresentationContext { return request.notification } - internal init(request: UINotificationRequest, containerWindow: UIWindow, windowLevel: UIWindowLevel, notificationView: UINotificationView) { + internal init(request: UINotificationRequest, containerWindow: UIWindow, windowLevel: UIWindow.Level, notificationView: UINotificationView) { self.request = request self.containerWindow = containerWindow self.notificationView = notificationView @@ -86,7 +86,7 @@ public final class UINotificationPresentationContext { private func resetContainerWindow() { /// Move the window behind the key application window. - containerWindow.windowLevel = UIWindowLevelNormal - 1 + containerWindow.windowLevel = UIWindow.Level.normal - 1 containerWindow.rootViewController = nil /// Make sure the key window of the app is visible again. diff --git a/Sources/UINotificationPresenters/UINotificationEaseInOutPresenter.swift b/Sources/UINotificationPresenters/UINotificationEaseInOutPresenter.swift index b406ada..de95817 100644 --- a/Sources/UINotificationPresenters/UINotificationEaseInOutPresenter.swift +++ b/Sources/UINotificationPresenters/UINotificationEaseInOutPresenter.swift @@ -35,7 +35,7 @@ public final class UINotificationEaseOutEaseInPresenter: UINotificationPresenter presentationContext.notificationView.topConstraint?.constant = presentationContext.notificationView.layoutMargins.top + UIApplication.shared.statusBarFrame.size.height } - UIView.animate(withDuration: inDuration, delay: 0.0, options: UIViewAnimationOptions.curveEaseOut, animations: { + UIView.animate(withDuration: inDuration, delay: 0.0, options: UIView.AnimationOptions.curveEaseOut, animations: { self.presentationContext.containerWindow.layoutIfNeeded() }, completion: { (_) in self.state = .presented @@ -53,7 +53,7 @@ public final class UINotificationEaseOutEaseInPresenter: UINotificationPresenter presentationContext.notificationView.topConstraint?.constant = -presentationContext.notification.style.height.value - UIView.animate(withDuration: outDuration, delay: 0, options: UIViewAnimationOptions.curveEaseIn, animations: { + UIView.animate(withDuration: outDuration, delay: 0, options: UIView.AnimationOptions.curveEaseIn, animations: { self.presentationContext.containerWindow.layoutIfNeeded() }, completion: { (_) in self.state = .idle diff --git a/Sources/UINotificationQueue.swift b/Sources/UINotificationQueue.swift index d1fd37f..72029bb 100644 --- a/Sources/UINotificationQueue.swift +++ b/Sources/UINotificationQueue.swift @@ -59,8 +59,7 @@ internal final class UINotificationQueue { internal func remove(_ request: UINotificationRequest) { lockQueue.sync { - guard let index = requests.index(where: { $0 == request }) else { return } - requests.remove(at: index) + requests.removeAll(where: { $0 == request }) } updateRunningRequest() } @@ -81,7 +80,7 @@ internal final class UINotificationQueue { } extension UINotificationQueue: UINotificationRequestDelegate { - func notificationRequest(_ request: UINotificationRequest, didChangeStateTo state: UINotificationRequest.UINotificationRequestState) { + func notificationRequest(_ request: UINotificationRequest, didChangeStateTo state: UINotificationRequest.State) { switch state { case .finished, .cancelled: remove(request) diff --git a/Sources/UINotificationRequest.swift b/Sources/UINotificationRequest.swift index c1d843b..733362f 100644 --- a/Sources/UINotificationRequest.swift +++ b/Sources/UINotificationRequest.swift @@ -15,7 +15,7 @@ protocol UINotificationRequestDelegate: class { /// - Parameters: /// - request: The `UINotificationRequest` of which the state is changed. /// - state: The new state of the passed `UINotificationRequest`. - func notificationRequest(_ request: UINotificationRequest, didChangeStateTo state: UINotificationRequest.UINotificationRequestState) + func notificationRequest(_ request: UINotificationRequest, didChangeStateTo state: UINotificationRequest.State) } /// Defines the request of a notification presentation. @@ -26,7 +26,7 @@ public final class UINotificationRequest: Equatable { weak var target: UINotificationRequestDelegate? } - public enum UINotificationRequestState { + public enum State { /// Waiting to run case idle @@ -53,7 +53,7 @@ public final class UINotificationRequest: Equatable { private let identifier: UUID /// The current state of the request. - private(set) public var state: UINotificationRequestState = .idle { + private(set) public var state: UINotificationRequest.State = .idle { didSet { delegates.forEach { $0.target?.notificationRequest(self, didChangeStateTo: state) } } diff --git a/Sources/UINotificationStyles/UINotificationSystemStyle.swift b/Sources/UINotificationStyles/UINotificationSystemStyle.swift index 907c66e..f502627 100644 --- a/Sources/UINotificationStyles/UINotificationSystemStyle.swift +++ b/Sources/UINotificationStyles/UINotificationSystemStyle.swift @@ -15,7 +15,7 @@ public struct UINotificationSystemStyle: UINotificationStyle { public var backgroundColor: UIColor = UIColor.white public var titleTextColor: UIColor = UIColor.black public var subtitleTextColor: UIColor = UIColor.darkGray - public var height: UINotificationHeight = .navigationBar + public var height: UINotification.Height = .navigationBar public var interactive: Bool = true public var chevronImage: UIImage? diff --git a/Sources/UINotificationView.swift b/Sources/UINotificationView.swift index 268a40a..8e7ce35 100644 --- a/Sources/UINotificationView.swift +++ b/Sources/UINotificationView.swift @@ -165,7 +165,7 @@ open class UINotificationView: UIView { handlePanGestureState(panGestureRecognizer.state, translation: translation) } - internal func handlePanGestureState(_ state: UIGestureRecognizerState, translation: CGPoint) { + internal func handlePanGestureState(_ state: UIGestureRecognizer.State, translation: CGPoint) { guard let presenter = presenter, let topConstraint = topConstraint else { return } if state == .began { diff --git a/Submodules/WeTransfer-iOS-CI b/Submodules/WeTransfer-iOS-CI index de7710f..3e21320 160000 --- a/Submodules/WeTransfer-iOS-CI +++ b/Submodules/WeTransfer-iOS-CI @@ -1 +1 @@ -Subproject commit de7710f6f26ea4268fe35d4373ebdb22663dc7eb +Subproject commit 3e213205a929b54f5c94ccbaebb8047cf49e2296 diff --git a/UINotifications.xcodeproj/project.pbxproj b/UINotifications.xcodeproj/project.pbxproj index aea7f9e..44b432a 100644 --- a/UINotifications.xcodeproj/project.pbxproj +++ b/UINotifications.xcodeproj/project.pbxproj @@ -256,7 +256,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = WeTransfer; TargetAttributes = { 502C139F206E5F230082CE37 = { @@ -365,6 +365,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -372,6 +373,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -425,6 +427,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -432,6 +435,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -481,7 +485,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.wetransfer.UINotifications; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -503,7 +507,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.wetransfer.UINotifications; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -520,7 +524,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.wetransfer.UINotificationsTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -536,7 +540,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.wetransfer.UINotificationsTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -555,6 +559,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -562,6 +567,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -618,7 +624,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.wetransfer.UINotifications; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Test; @@ -635,7 +641,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.wetransfer.UINotificationsTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Test; diff --git a/UINotifications.xcodeproj/xcshareddata/xcschemes/UINotifications.xcscheme b/UINotifications.xcodeproj/xcshareddata/xcschemes/UINotifications.xcscheme index c74c49f..af772d2 100644 --- a/UINotifications.xcodeproj/xcshareddata/xcschemes/UINotifications.xcscheme +++ b/UINotifications.xcodeproj/xcshareddata/xcschemes/UINotifications.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> + skipped = "NO" + testExecutionOrdering = "random">