mirror of
https://github.com/fxm90/GradientLoadingBar.git
synced 2026-06-16 12:24:31 +00:00
Merge branch 'main' into task/dependency-update
This commit is contained in:
+6
-1
@@ -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
|
||||
|
||||
+4
-2
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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": {
|
||||
|
||||
Generated
+2
-2
@@ -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
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.3.2</string>
|
||||
<string>2.3.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -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.
|
||||
|
||||
+11
-11
@@ -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 <https://www.paintcodeapp.com/news/iphone-x-screen-demystified>.
|
||||
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: <https://9to5mac.com/2021/09/14/iphone-13-notch-smaller-but-bigger>.
|
||||
self.init(notchWidth: 161,
|
||||
|
||||
+15
-8
@@ -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 <https://stackoverflow.com/a/26962452/3532505>
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user