diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cefdbf..86d15b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +## [2.3.3] - 2022-08-09 +### Changed + - Added specific Bézier Path for `NotchGradientLoadingBar` for "iPhone 14" and "iPhone 14 Plus" + ## [2.3.2] - 2022-08-09 ### Changed - Improved Bézier Path of `NotchGradientLoadingBar` @@ -184,7 +188,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - Initial release -[Unreleased]: https://github.com/fxm90/GradientLoadingBar/compare/2.3.2...main +[Unreleased]: https://github.com/fxm90/GradientLoadingBar/compare/2.3.3...main +[2.3.3]: https://github.com/fxm90/GradientLoadingBar/compare/2.3.2...2.3.3 [2.3.2]: https://github.com/fxm90/GradientLoadingBar/compare/2.3.1...2.3.2 [2.3.1]: https://github.com/fxm90/GradientLoadingBar/compare/2.3.0...2.3.1 [2.3.0]: https://github.com/fxm90/GradientLoadingBar/compare/2.2.5...2.3.0 diff --git a/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift b/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift index be0ce5e..8ed740d 100644 --- a/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift +++ b/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift @@ -32,6 +32,8 @@ final class NotchGradientLoadingBarViewModelTestCase: XCTestCase { "iPhone14,5": .iPhone13, "iPhone14,2": .iPhone13Pro, "iPhone14,3": .iPhone13ProMax, + "iPhone14,7": .iPhone14, + "iPhone14,8": .iPhone14Plus, ] identifiersToSafeAreaDeviceMap.forEach { deviceIdentifier, safeAreaDevice in @@ -43,7 +45,7 @@ final class NotchGradientLoadingBarViewModelTestCase: XCTestCase { } } - func test_initializer_shouldSetSafeAreaDevice_toUnknown() { + func test_initializer_shouldSetSafeAreaDevice_toNil() { // Given let deviceIdentifier = "Foo-Bar-🤡" @@ -51,6 +53,6 @@ final class NotchGradientLoadingBarViewModelTestCase: XCTestCase { let viewModel = NotchGradientLoadingBarViewModel(deviceIdentifier: deviceIdentifier) // Then - XCTAssertEqual(viewModel.safeAreaDevice, .unknown) + XCTAssertNil(viewModel.safeAreaDevice) } } diff --git a/Example/Podfile.lock b/Example/Podfile.lock index e755cd0..eb124b8 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - GradientLoadingBar (2.3.2): + - GradientLoadingBar (2.3.3): - LightweightObservable (~> 2.1) - LightweightObservable (2.2.1) - SnapshotTesting (1.9.0) @@ -33,7 +33,7 @@ CHECKOUT OPTIONS: :git: https://github.com/fxm90/SwiftConfigurationFiles.git SPEC CHECKSUMS: - GradientLoadingBar: 0fb63c35e73bb8c56689e9ffd7a46e754fea8a15 + GradientLoadingBar: e4a564b70529c1378fed08cf5b0bd77d4b1b4fab LightweightObservable: 64d0f623a4eec857e2680476380a08f3117a1a92 SnapshotTesting: 6141c48b6aa76ead61431ca665c14ab9a066c53b SwiftConfigurationFiles: 1cf2228a911ebed9f42f8dec077bb634f04ca6c8 diff --git a/Example/Pods/Local Podspecs/GradientLoadingBar.podspec.json b/Example/Pods/Local Podspecs/GradientLoadingBar.podspec.json index 744a6ff..62c61b0 100644 --- a/Example/Pods/Local Podspecs/GradientLoadingBar.podspec.json +++ b/Example/Pods/Local Podspecs/GradientLoadingBar.podspec.json @@ -1,6 +1,6 @@ { "name": "GradientLoadingBar", - "version": "2.3.2", + "version": "2.3.3", "summary": "A customizable animated gradient loading bar.", "description": "A customizable animated gradient loading bar.\nInspired by https://codepen.io/marcobiedermann/pen/LExXWW", "homepage": "https://github.com/fxm90/GradientLoadingBar", @@ -14,7 +14,7 @@ }, "source": { "git": "https://github.com/fxm90/GradientLoadingBar.git", - "tag": "2.3.2" + "tag": "2.3.3" }, "swift_versions": "5.5", "platforms": { diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index e755cd0..eb124b8 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,5 +1,5 @@ PODS: - - GradientLoadingBar (2.3.2): + - GradientLoadingBar (2.3.3): - LightweightObservable (~> 2.1) - LightweightObservable (2.2.1) - SnapshotTesting (1.9.0) @@ -33,7 +33,7 @@ CHECKOUT OPTIONS: :git: https://github.com/fxm90/SwiftConfigurationFiles.git SPEC CHECKSUMS: - GradientLoadingBar: 0fb63c35e73bb8c56689e9ffd7a46e754fea8a15 + GradientLoadingBar: e4a564b70529c1378fed08cf5b0bd77d4b1b4fab LightweightObservable: 64d0f623a4eec857e2680476380a08f3117a1a92 SnapshotTesting: 6141c48b6aa76ead61431ca665c14ab9a066c53b SwiftConfigurationFiles: 1cf2228a911ebed9f42f8dec077bb634f04ca6c8 diff --git a/Example/Pods/Target Support Files/GradientLoadingBar/GradientLoadingBar-Info.plist b/Example/Pods/Target Support Files/GradientLoadingBar/GradientLoadingBar-Info.plist index ecb8f03..24c04e7 100644 --- a/Example/Pods/Target Support Files/GradientLoadingBar/GradientLoadingBar-Info.plist +++ b/Example/Pods/Target Support Files/GradientLoadingBar/GradientLoadingBar-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.3.2 + 2.3.3 CFBundleSignature ???? CFBundleVersion diff --git a/GradientLoadingBar.podspec b/GradientLoadingBar.podspec index faa0f27..66e4cdc 100644 --- a/GradientLoadingBar.podspec +++ b/GradientLoadingBar.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'GradientLoadingBar' - s.version = '2.3.2' + s.version = '2.3.3' s.summary = 'A customizable animated gradient loading bar.' # This description is used to generate tags and improve search results. diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift index fa9cc7f..df33f76 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift @@ -20,14 +20,17 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { // MARK: - Public methods override open func setupConstraints(superview: UIView) { - guard let notchConfig = NotchConfig(safeAreaDevice: viewModel.safeAreaDevice) else { - // No special masking required for non safe area devices. + guard let notchDevice = viewModel.notchDevice else { + // No special masking required for devices without a notch. super.setupConstraints(superview: superview) return } - // As we currently only support portrait mode (and no device rotation), we can safely use `bounds.size.width` here. + // We currently only support portrait mode (without device rotation), + // and therefore can safely use `bounds.size.width` here. let screenWidth = superview.bounds.size.width + + let notchConfig = NotchConfig(notchDevice: notchDevice) let notchBezierPath = notchBezierPath(for: screenWidth, notchConfig: notchConfig) let viewHeight = notchBezierPath.bounds.height + 1 @@ -207,18 +210,15 @@ private extension NotchConfig { /// Initializes the notch specific configuration for the current safe area device. /// /// - Note: We define this in an extension to keep the memberwise initializer. - init?(safeAreaDevice: NotchGradientLoadingBarViewModel.SafeAreaDevice) { - switch safeAreaDevice { - case .unknown: - return nil - + init(notchDevice: NotchGradientLoadingBarViewModel.NotchDevice) { + switch notchDevice { case .iPhoneX, .iPhoneXS, .iPhoneXSMax: /// The default configuration for the iPhone X. /// Values are based on . self.init(notchWidth: 209, largeCircleRadius: 22.5, largeCircleVerticalOffset: -4.75, - transform: safeAreaDevice == .iPhoneXSMax ? .identity : CGAffineTransform(translationX: 0.33, y: 0)) + transform: notchDevice == .iPhoneXSMax ? .identity : CGAffineTransform(translationX: 0.33, y: 0)) case .iPhoneXR, .iPhone11: self.init(notchWidth: 230, @@ -231,7 +231,7 @@ private extension NotchConfig { self.init(notchWidth: 209, largeCircleRadius: 21, largeCircleVerticalOffset: -3.5, - transform: safeAreaDevice == .iPhone11ProMax ? .identity : CGAffineTransform(translationX: 0.33, y: 0)) + transform: notchDevice == .iPhone11ProMax ? .identity : CGAffineTransform(translationX: 0.33, y: 0)) // The "iPhone 12 Mini" has a larger notch than the "iPhone 12". case .iPhone12Mini: @@ -253,7 +253,7 @@ private extension NotchConfig { largeCircleVerticalOffset: 0.5, transform: .identity) - case .iPhone13, .iPhone13Pro, .iPhone13ProMax: + case .iPhone13, .iPhone13Pro, .iPhone13ProMax, .iPhone14, .iPhone14Plus: // The iPhone 13 specific configuration: ‟iPhone 13 notch is 20% smaller in width, but it is also a little taller in height‟. // Source: . self.init(notchWidth: 161, diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift index 269ee68..4d94dc3 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift @@ -12,8 +12,7 @@ final class NotchGradientLoadingBarViewModel { // MARK: - Types - enum SafeAreaDevice { - case unknown + enum NotchDevice { case iPhoneX case iPhoneXS case iPhoneXSMax @@ -29,28 +28,30 @@ final class NotchGradientLoadingBarViewModel { case iPhone13 case iPhone13Pro case iPhone13ProMax + case iPhone14 + case iPhone14Plus } // MARK: - Public properties - /// The current safe area device. - let safeAreaDevice: SafeAreaDevice + /// The current device if it has a notch / otherwise `nil`. + let notchDevice: NotchDevice? // MARK: - Instance Lifecycle init(deviceIdentifier: String = UIDevice.identifier) { - safeAreaDevice = SafeAreaDevice(deviceIdentifier: deviceIdentifier) + notchDevice = NotchDevice(deviceIdentifier: deviceIdentifier) } } // MARK: - Helper -private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { +private extension NotchGradientLoadingBarViewModel.NotchDevice { /// Creates a new instance from a given `deviceIdentifier` (value returned by `UIDevice.identifier`). /// /// - Note: This is taken from - init(deviceIdentifier: String) { + init?(deviceIdentifier: String) { // swiftlint:disable:previous cyclomatic_complexity switch deviceIdentifier { case "iPhone10,3", "iPhone10,6": @@ -98,8 +99,14 @@ private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { case "iPhone14,3": self = .iPhone13ProMax + case "iPhone14,7": + self = .iPhone14 + + case "iPhone14,8": + self = .iPhone14Plus + default: - self = .unknown + return nil } } }