From 77b7a5929edf6bdfd7f0ede6cdcce3942ace9e88 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Thu, 8 Sep 2022 19:23:25 +0200 Subject: [PATCH 1/7] =?UTF-8?q?=E2=9C=A8::=20Add=20support=20for=20iOS=201?= =?UTF-8?q?4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotchGradientLoadingBarController.swift | 2 +- .../NotchGradientLoadingBarViewModel.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift index fa9cc7f..ab534bb 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift @@ -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..233e071 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift @@ -29,12 +29,14 @@ final class NotchGradientLoadingBarViewModel { case iPhone13 case iPhone13Pro case iPhone13ProMax + case iPhone14 + case iPhone14Plus } // MARK: - Public properties /// The current safe area device. - let safeAreaDevice: SafeAreaDevice + let safeAreaDevice: SafeAreaDevice? // MARK: - Instance Lifecycle @@ -98,6 +100,12 @@ private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { case "iPhone14,3": self = .iPhone13ProMax + case "iPhone14,7": + self = .iPhone14 + + case "iPhone14,8": + self = .iPhone14Plus + default: self = .unknown } From 4521bc86227ad601013ef8a542fb1dbf2bf83872 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Thu, 8 Sep 2022 19:23:42 +0200 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9C=85=20::=20Adapt=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotchGradientLoadingBarViewModelTestCase.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift b/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift index be0ce5e..43f5fd4 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 From 2b19e431ecaf333a929849ac7d04d599a1b1e6ed Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Thu, 8 Sep 2022 19:24:13 +0200 Subject: [PATCH 3/7] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Prefer=20`nil`=20?= =?UTF-8?q?over=20`.unknown`=20enum=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotchGradientLoadingBarController.swift | 12 ++++++------ .../NotchGradientLoadingBarViewModel.swift | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift index ab534bb..3df9c48 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 { + guard let safeAreaDevice = viewModel.safeAreaDevice else { // No special masking required for non safe area devices. 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(safeAreaDevice: safeAreaDevice) let notchBezierPath = notchBezierPath(for: screenWidth, notchConfig: notchConfig) let viewHeight = notchBezierPath.bounds.height + 1 @@ -207,11 +210,8 @@ 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) { + init(safeAreaDevice: NotchGradientLoadingBarViewModel.SafeAreaDevice) { switch safeAreaDevice { - case .unknown: - return nil - case .iPhoneX, .iPhoneXS, .iPhoneXSMax: /// The default configuration for the iPhone X. /// Values are based on . diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift index 233e071..3660750 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift @@ -13,7 +13,6 @@ final class NotchGradientLoadingBarViewModel { // MARK: - Types enum SafeAreaDevice { - case unknown case iPhoneX case iPhoneXS case iPhoneXSMax @@ -52,7 +51,7 @@ private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { /// 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": @@ -107,7 +106,7 @@ private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { self = .iPhone14Plus default: - self = .unknown + return nil } } } From 707793be133d40b7f4d2e3912d3a46566779c658 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Thu, 8 Sep 2022 19:25:17 +0200 Subject: [PATCH 4/7] =?UTF-8?q?=E2=9C=85=20::=20Adapt=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotchGradientLoadingBarViewModelTestCase.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift b/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift index 43f5fd4..8ed740d 100644 --- a/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift +++ b/Example/ExampleTests/NotchGradientLoadingBar/NotchGradientLoadingBarViewModelTestCase.swift @@ -45,7 +45,7 @@ final class NotchGradientLoadingBarViewModelTestCase: XCTestCase { } } - func test_initializer_shouldSetSafeAreaDevice_toUnknown() { + func test_initializer_shouldSetSafeAreaDevice_toNil() { // Given let deviceIdentifier = "Foo-Bar-🤡" @@ -53,6 +53,6 @@ final class NotchGradientLoadingBarViewModelTestCase: XCTestCase { let viewModel = NotchGradientLoadingBarViewModel(deviceIdentifier: deviceIdentifier) // Then - XCTAssertEqual(viewModel.safeAreaDevice, .unknown) + XCTAssertNil(viewModel.safeAreaDevice) } } From 47166ac314af0efa212963a55dcd38028d555188 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Thu, 8 Sep 2022 19:41:10 +0200 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=94=96=20::=20Bump=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 ++++++- Example/Podfile.lock | 4 ++-- .../Pods/Local Podspecs/GradientLoadingBar.podspec.json | 4 ++-- Example/Pods/Manifest.lock | 4 ++-- .../GradientLoadingBar/GradientLoadingBar-Info.plist | 2 +- GradientLoadingBar.podspec | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cefdbf..757ed64 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" or "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/Podfile.lock b/Example/Podfile.lock index 5efd847..1df07ba 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 5efd847..1df07ba 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. From 345a874a0461d4b37f0a0640a8f1b1bf8f81bbed Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Thu, 8 Sep 2022 22:29:58 +0200 Subject: [PATCH 6/7] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20::=20Fix=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 757ed64..86d15b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [2.3.3] - 2022-08-09 ### Changed - - Added specific Bézier Path for `NotchGradientLoadingBar` for "iPhone 14" or "iPhone 14 Plus" + - Added specific Bézier Path for `NotchGradientLoadingBar` for "iPhone 14" and "iPhone 14 Plus" ## [2.3.2] - 2022-08-09 ### Changed From e58c15c381e774a19e1c8d4a15284836038db830 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Fri, 9 Sep 2022 13:42:12 +0200 Subject: [PATCH 7/7] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Rename=20`SafeAre?= =?UTF-8?q?aDevice`=20to=20`NotchDevice`=20as=20the=20iPhone=2014=20Pro=20?= =?UTF-8?q?(Max)=20has=20a=20safe=20area=20without=20a=20notch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotchGradientLoadingBarController.swift | 14 +++++++------- .../NotchGradientLoadingBarViewModel.swift | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift index 3df9c48..df33f76 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift @@ -20,8 +20,8 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { // MARK: - Public methods override open func setupConstraints(superview: UIView) { - guard let 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 } @@ -30,7 +30,7 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { // and therefore can safely use `bounds.size.width` here. let screenWidth = superview.bounds.size.width - let notchConfig = NotchConfig(safeAreaDevice: safeAreaDevice) + let notchConfig = NotchConfig(notchDevice: notchDevice) let notchBezierPath = notchBezierPath(for: screenWidth, notchConfig: notchConfig) let viewHeight = notchBezierPath.bounds.height + 1 @@ -210,15 +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 { + 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: diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift index 3660750..4d94dc3 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift @@ -12,7 +12,7 @@ final class NotchGradientLoadingBarViewModel { // MARK: - Types - enum SafeAreaDevice { + enum NotchDevice { case iPhoneX case iPhoneXS case iPhoneXSMax @@ -34,19 +34,19 @@ final class NotchGradientLoadingBarViewModel { // 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`). ///