diff --git a/Example/Example/Helper/StoryboardView.swift b/Example/Example/Helper/StoryboardView.swift index d88818b..64a8d2c 100644 --- a/Example/Example/Helper/StoryboardView.swift +++ b/Example/Example/Helper/StoryboardView.swift @@ -9,11 +9,12 @@ import SwiftUI struct StoryboardView: UIViewControllerRepresentable { + // MARK: - Public properties let name: String - // MARK: - Public properties + // MARK: - Public methods func makeUIViewController(context _: Context) -> UIViewController { let storyboard = UIStoryboard(name: name, bundle: nil) diff --git a/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift b/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift index e4448ba..f4df383 100644 --- a/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift +++ b/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift @@ -11,6 +11,7 @@ import SwiftUI import GradientLoadingBar final class AdvancedExampleTableViewController: UITableViewController { + // MARK: - Config private enum Config { diff --git a/Example/Example/Scenes/AdvancedExample/Cells/CustomColorsTableViewCell.swift b/Example/Example/Scenes/AdvancedExample/Cells/CustomColorsTableViewCell.swift index 7a6880a..61a5343 100644 --- a/Example/Example/Scenes/AdvancedExample/Cells/CustomColorsTableViewCell.swift +++ b/Example/Example/Scenes/AdvancedExample/Cells/CustomColorsTableViewCell.swift @@ -9,6 +9,7 @@ import UIKit final class CustomColorsTableViewCell: UITableViewCell { + // MARK: - Public properties static let reuseIdentifier = "CustomColorsTableViewCell" diff --git a/Example/Example/Scenes/AdvancedExample/Cells/CustomSuperviewTableViewCell.swift b/Example/Example/Scenes/AdvancedExample/Cells/CustomSuperviewTableViewCell.swift index c2333f6..47543b9 100644 --- a/Example/Example/Scenes/AdvancedExample/Cells/CustomSuperviewTableViewCell.swift +++ b/Example/Example/Scenes/AdvancedExample/Cells/CustomSuperviewTableViewCell.swift @@ -10,6 +10,7 @@ import UIKit import GradientLoadingBar final class CustomSuperviewTableViewCell: UITableViewCell { + // MARK: - Config private enum Config { diff --git a/Example/Example/Scenes/AdvancedExample/Cells/InterfaceBuilderSetupTableViewCell.swift b/Example/Example/Scenes/AdvancedExample/Cells/InterfaceBuilderSetupTableViewCell.swift index ae4f5f0..dfc0702 100644 --- a/Example/Example/Scenes/AdvancedExample/Cells/InterfaceBuilderSetupTableViewCell.swift +++ b/Example/Example/Scenes/AdvancedExample/Cells/InterfaceBuilderSetupTableViewCell.swift @@ -10,6 +10,7 @@ import UIKit import GradientLoadingBar final class InterfaceBuilderSetupTableViewCell: UITableViewCell { + // MARK: - Config private enum Config { diff --git a/Example/Example/Scenes/AdvancedExample/Views/BorderedButton.swift b/Example/Example/Scenes/AdvancedExample/Views/BorderedButton.swift index 31a180f..fba8592 100644 --- a/Example/Example/Scenes/AdvancedExample/Views/BorderedButton.swift +++ b/Example/Example/Scenes/AdvancedExample/Views/BorderedButton.swift @@ -10,6 +10,7 @@ import UIKit @IBDesignable final class BorderedButton: UIButton { + // MARK: - Config private enum Config { @@ -18,7 +19,7 @@ final class BorderedButton: UIButton { static let cornerRadius: CGFloat = 4 } - // MARK: - Initializer + // MARK: - Instance Lifecycle override init(frame: CGRect) { super.init(frame: frame) diff --git a/Example/Example/Scenes/BasicExample/BasicExampleViewController.swift b/Example/Example/Scenes/BasicExample/BasicExampleViewController.swift index a7fae8a..289ed17 100644 --- a/Example/Example/Scenes/BasicExample/BasicExampleViewController.swift +++ b/Example/Example/Scenes/BasicExample/BasicExampleViewController.swift @@ -11,6 +11,7 @@ import SwiftUI import GradientLoadingBar final class BasicExampleViewController: UIViewController { + // MARK: - Public methods override func viewWillDisappear(_ animated: Bool) { @@ -31,7 +32,7 @@ final class BasicExampleViewController: UIViewController { } } -// MARK: - Helpers +// MARK: - Helper struct BasicExampleView: View { var body: some View { diff --git a/Example/Example/Scenes/EntryPointView.swift b/Example/Example/Scenes/EntryPointView.swift index 6f7928b..604f169 100644 --- a/Example/Example/Scenes/EntryPointView.swift +++ b/Example/Example/Scenes/EntryPointView.swift @@ -9,6 +9,7 @@ import SwiftUI struct EntryPointView: View { + // MARK: - Private properties @State @@ -62,7 +63,7 @@ struct EntryPointView: View { // Unfortunately setting the title here results in constraint warnings. // I couldn't find a possible fix yet, even `.navigationViewStyle(.stack)` doesn't seem to work. // https://stackoverflow.com/q/65316497 - .navigationTitle("GradientProgressBar") + .navigationTitle("GradientLoadingBar") .navigationBarTitleDisplayMode(.large) } } diff --git a/Example/Example/Scenes/NavigationBarExample/NavigationBarExampleViewController.swift b/Example/Example/Scenes/NavigationBarExample/NavigationBarExampleViewController.swift index 200cbb4..4ed3a44 100644 --- a/Example/Example/Scenes/NavigationBarExample/NavigationBarExampleViewController.swift +++ b/Example/Example/Scenes/NavigationBarExample/NavigationBarExampleViewController.swift @@ -11,6 +11,7 @@ import SwiftUI import GradientLoadingBar final class NavigationBarExampleViewController: UIViewController { + // MARK: - Config private enum Config { @@ -70,7 +71,7 @@ final class NavigationBarExampleViewController: UIViewController { } } -// MARK: - Helpers +// MARK: - Helper struct NavigationBarExampleView: View { var body: some View { diff --git a/Example/Example/Scenes/SafeAreaExample/SafeAreaExampleViewController.swift b/Example/Example/Scenes/SafeAreaExample/SafeAreaExampleViewController.swift index ce54bdb..c4d6be7 100644 --- a/Example/Example/Scenes/SafeAreaExample/SafeAreaExampleViewController.swift +++ b/Example/Example/Scenes/SafeAreaExample/SafeAreaExampleViewController.swift @@ -11,6 +11,7 @@ import SwiftUI import GradientLoadingBar final class SafeAreaExampleViewController: UIViewController { + // MARK: - Private properties private let gradientLoadingBar = GradientLoadingBar(isRelativeToSafeArea: false) @@ -45,7 +46,7 @@ final class SafeAreaExampleViewController: UIViewController { } } -// MARK: - Helpers +// MARK: - Helper struct SafeAreaExampleView: View { var body: some View { diff --git a/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift b/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift index a91709f..6784229 100644 --- a/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift +++ b/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift @@ -10,6 +10,7 @@ import SwiftUI import GradientLoadingBar struct SwiftUIExampleView: View { + // MARK: - Render var body: some View { diff --git a/Example/ExampleSnapshotTests/GradientActivityIndicatorView/GradientActivityIndicatorViewTestCase.swift b/Example/ExampleSnapshotTests/GradientActivityIndicatorView/GradientActivityIndicatorViewTestCase.swift index 8617c5f..2e55a5b 100644 --- a/Example/ExampleSnapshotTests/GradientActivityIndicatorView/GradientActivityIndicatorViewTestCase.swift +++ b/Example/ExampleSnapshotTests/GradientActivityIndicatorView/GradientActivityIndicatorViewTestCase.swift @@ -12,6 +12,7 @@ import SnapshotTesting @testable import GradientLoadingBar final class GradientActivityIndicatorViewTestCase: XCTestCase { + // MARK: - Config private enum Config { diff --git a/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift b/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift index 8ab8aaf..dd0a0a2 100644 --- a/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift +++ b/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift @@ -12,6 +12,7 @@ import SnapshotTesting @testable import GradientLoadingBar final class GradientLoadingBarControllerTestCase: XCTestCase { + // MARK: - Config private enum Config { diff --git a/Example/ExampleSnapshotTests/GradientLoadingBarView/GradientLoadingBarViewTestCase.swift b/Example/ExampleSnapshotTests/GradientLoadingBarView/GradientLoadingBarViewTestCase.swift index dbe028a..a58e783 100644 --- a/Example/ExampleSnapshotTests/GradientLoadingBarView/GradientLoadingBarViewTestCase.swift +++ b/Example/ExampleSnapshotTests/GradientLoadingBarView/GradientLoadingBarViewTestCase.swift @@ -13,6 +13,7 @@ import SnapshotTesting @testable import GradientLoadingBar final class GradientLoadingBarViewTestCase: XCTestCase { + // MARK: - Config private enum Config { @@ -25,10 +26,6 @@ final class GradientLoadingBarViewTestCase: XCTestCase { static let gradientColors = [ #colorLiteral(red: 0.9490196078, green: 0.3215686275, blue: 0.431372549, alpha: 1), #colorLiteral(red: 0.9450980392, green: 0.4784313725, blue: 0.5921568627, alpha: 1), #colorLiteral(red: 0.9529411765, green: 0.737254902, blue: 0.7843137255, alpha: 1), #colorLiteral(red: 0.4274509804, green: 0.8666666667, blue: 0.9490196078, alpha: 1), #colorLiteral(red: 0.7568627451, green: 0.9411764706, blue: 0.9568627451, alpha: 1), ].map(Color.init) - - /// The percentage of pixels that must match. - /// We explicitly reduce the precision for the custom colors test case here, to avoid flaky tests. - static let customColorsPrecision: Float = 0.99 } // MARK: - Test cases @@ -48,6 +45,6 @@ final class GradientLoadingBarViewTestCase: XCTestCase { .frame(width: Config.frame.width, height: Config.frame.height) // Then - assertSnapshot(matching: gradientLoadingBarView, as: .image(precision: Config.customColorsPrecision)) + assertSnapshot(matching: gradientLoadingBarView, as: .image) } } diff --git a/Example/ExampleTests/ViewModel/GradientActivityIndicatorViewModelTestCase.swift b/Example/ExampleTests/ViewModel/GradientActivityIndicatorViewModelTestCase.swift index ae2ab59..406624b 100644 --- a/Example/ExampleTests/ViewModel/GradientActivityIndicatorViewModelTestCase.swift +++ b/Example/ExampleTests/ViewModel/GradientActivityIndicatorViewModelTestCase.swift @@ -13,6 +13,7 @@ import LightweightObservable // swiftlint:disable:next type_name final class GradientActivityIndicatorViewModelTestCase: XCTestCase { + // MARK: - Private properties private var viewModel: GradientActivityIndicatorViewModel! diff --git a/Example/ExampleTests/ViewModel/GradientLoadingBarView+ViewModelTestCase.swift b/Example/ExampleTests/ViewModel/GradientLoadingBarView+ViewModelTestCase.swift index 0ce7431..849b546 100644 --- a/Example/ExampleTests/ViewModel/GradientLoadingBarView+ViewModelTestCase.swift +++ b/Example/ExampleTests/ViewModel/GradientLoadingBarView+ViewModelTestCase.swift @@ -13,6 +13,7 @@ import SwiftUI // swiftlint:disable:next type_name final class GradientLoadingBarView_ViewModelTestCase: XCTestCase { + // MARK: - Test property `gradientColors` func test_initialGradientColors_shouldIncludeReversedGradientColors() { diff --git a/Example/ExampleTests/ViewModel/GradientLoadingBarViewModelTestCase.swift b/Example/ExampleTests/ViewModel/GradientLoadingBarViewModelTestCase.swift index 2b923e0..b5c1bfa 100644 --- a/Example/ExampleTests/ViewModel/GradientLoadingBarViewModelTestCase.swift +++ b/Example/ExampleTests/ViewModel/GradientLoadingBarViewModelTestCase.swift @@ -12,6 +12,7 @@ import LightweightObservable @testable import GradientLoadingBar final class GradientLoadingBarViewModelTestCase: XCTestCase { + // MARK: - Private properties private var sharedApplicationMock: SharedApplicationMock! diff --git a/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift b/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift index c289d88..1ab78ad 100644 --- a/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift +++ b/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift @@ -12,6 +12,7 @@ import XCTest // swiftlint:disable:next type_name final class GradientActivityIndicatorViewAnimateIsHiddenTestCase: XCTestCase { + // MARK: - Private properties private var window: UIWindow! diff --git a/Example/Pods/LightweightObservable/LightweightObservable/Disposable.swift b/Example/Pods/LightweightObservable/LightweightObservable/Disposable.swift index 9864946..661dd6d 100644 --- a/Example/Pods/LightweightObservable/LightweightObservable/Disposable.swift +++ b/Example/Pods/LightweightObservable/LightweightObservable/Disposable.swift @@ -13,6 +13,7 @@ public typealias DisposeBag = [Disposable] /// Calls a closure on when this instance is deallocated. public final class Disposable { + // MARK: - Types /// Type for the closure to be called on deallocation. @@ -23,7 +24,7 @@ public final class Disposable { /// The closure to be called on deallocation. private let dispose: Dispose - // MARK: - Initializer + // MARK: - Instance Lifecycle /// Creates a new instance. /// diff --git a/Example/Pods/SwiftConfigurationFiles/.swiftformat b/Example/Pods/SwiftConfigurationFiles/.swiftformat index ed26699..4e7f300 100644 --- a/Example/Pods/SwiftConfigurationFiles/.swiftformat +++ b/Example/Pods/SwiftConfigurationFiles/.swiftformat @@ -22,6 +22,7 @@ # Rules # --disable andOperator +--disable blankLinesAtStartOfScope --disable sortedImports --disable wrapMultilineStatementBraces diff --git a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView+AnimateIsHidden.swift b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView+AnimateIsHidden.swift index 0a5ce3f..7abcdb8 100644 --- a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView+AnimateIsHidden.swift +++ b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView+AnimateIsHidden.swift @@ -16,7 +16,6 @@ import UIKit /// /// - SeeAlso: [Github Gist – UIView+AnimateIsHidden.swift](https://gist.github.com/fxm90/723b5def31b46035cd92a641e3b184f6) public extension GradientActivityIndicatorView { - // MARK: - Public methods /// Updates the view visibility. /// diff --git a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView.swift b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView.swift index 5928f26..b6618d0 100644 --- a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView.swift +++ b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorView.swift @@ -11,6 +11,7 @@ import LightweightObservable @IBDesignable open class GradientActivityIndicatorView: UIView { + // MARK: - Config /// Animation-Key for the progress animation. @@ -71,7 +72,7 @@ open class GradientActivityIndicatorView: UIView { /// The dispose bag for the observables. private var disposeBag = DisposeBag() - // MARK: - Initializers + // MARK: - Instance Lifecycle override public init(frame: CGRect) { super.init(frame: frame) diff --git a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift index 4c260cd..6fae179 100644 --- a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift +++ b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift @@ -11,6 +11,7 @@ import LightweightObservable /// This view model contains all logic related to the `GradientActivityIndicatorView`. final class GradientActivityIndicatorViewModel { + // MARK: - Types struct SizeUpdate: Equatable { @@ -88,7 +89,7 @@ final class GradientActivityIndicatorViewModel { private var disposeBag = DisposeBag() - // MARK: - Initializer + // MARK: - Instance Lifecycle init() { gradientLayerColorsSubject = Variable(gradientColors.infiniteLayerColors()) diff --git a/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarController.swift b/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarController.swift index 6e1b1e8..545b4e7 100644 --- a/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarController.swift +++ b/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarController.swift @@ -14,6 +14,7 @@ public typealias GradientLoadingBar = GradientLoadingBarController /// The `GradientLoadingBarController` mediates between the `GradientLoadingBarViewModel` and the corresponding `GradientActivityIndicatorView`. open class GradientLoadingBarController { + // MARK: - Public properties /// The height of the gradient bar. @@ -58,7 +59,7 @@ open class GradientLoadingBarController { /// The dispose bag for the observables. private var disposeBag = DisposeBag() - // MARK: - Initializers + // MARK: - Instance Lifecycle /// Creates a new gradient loading bar instance. /// diff --git a/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarViewModel.swift b/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarViewModel.swift index 5d4e740..b384d9b 100644 --- a/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarViewModel.swift +++ b/GradientLoadingBar/Feature/GradientLoadingBar/GradientLoadingBarViewModel.swift @@ -12,6 +12,7 @@ import LightweightObservable /// This view model checks for the availability of the key-window, /// and adds it as a superview to the gradient-view. final class GradientLoadingBarViewModel { + // MARK: - Public properties /// Observable for the superview of the gradient-view. @@ -28,7 +29,7 @@ final class GradientLoadingBarViewModel { private let sharedApplication: UIApplicationProtocol private let notificationCenter: NotificationCenter - // MARK: - Constructor + // MARK: - Instance Lifecycle init(sharedApplication: UIApplicationProtocol = UIApplication.shared, notificationCenter: NotificationCenter = .default) { self.sharedApplication = sharedApplication diff --git a/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView+ViewModel.swift b/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView+ViewModel.swift index 6af3187..6c6330e 100644 --- a/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView+ViewModel.swift +++ b/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView+ViewModel.swift @@ -14,6 +14,7 @@ extension GradientLoadingBarView { /// This view model contains all logic related to the `GradientLoadingBarView` /// and the corresponding progress animation. final class ViewModel: ObservableObject { + // MARK: - Public properties /// The gradient colors used for the progress animation (including the reversed colors). @@ -51,7 +52,7 @@ extension GradientLoadingBarView { private var progressDuration: TimeInterval - // MARK: - Public methods + // MARK: - Instance Lifecycle init(gradientColors: [Color], progressDuration: TimeInterval) { // Simulate infinite animation - Therefore we'll reverse the colors and remove the first and last item diff --git a/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift b/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift index 6a68342..38440ce 100644 --- a/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift +++ b/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift @@ -11,6 +11,7 @@ import SwiftUI // For some reason the animation looks broken on iOS versions <= 15.0. @available(iOS 15.0, *) public struct GradientLoadingBarView: View { + // MARK: - Config public enum Config { @@ -26,7 +27,7 @@ public struct GradientLoadingBarView: View { @StateObject private var viewModel: ViewModel - // MARK: - Initializer + // MARK: - Instance Lifecycle public init(gradientColors: [Color] = Config.gradientColors, progressDuration: TimeInterval = Config.progressDuration) { diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift index 41bf674..16e06b5 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarController.swift @@ -36,6 +36,7 @@ private struct NotchConfig { public typealias NotchGradientLoadingBar = NotchGradientLoadingBarController open class NotchGradientLoadingBarController: GradientLoadingBarController { + // MARK: - Private properties private let viewModel = NotchGradientLoadingBarViewModel() @@ -209,7 +210,7 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { } } -// MARK: - Helpers +// MARK: - Helper private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { /// The notch specific configuration for the current device. diff --git a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift index e35b3b9..69e531a 100644 --- a/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift +++ b/GradientLoadingBar/Feature/NotchGradientLoadingBar/NotchGradientLoadingBarViewModel.swift @@ -9,6 +9,7 @@ import UIKit final class NotchGradientLoadingBarViewModel { + // MARK: - Types enum SafeAreaDevice { @@ -25,14 +26,14 @@ final class NotchGradientLoadingBarViewModel { /// The current safe area device. let safeAreaDevice: SafeAreaDevice - // MARK: - Initializer + // MARK: - Instance Lifecycle init(deviceIdentifier: String = UIDevice.identifier) { safeAreaDevice = SafeAreaDevice(deviceIdentifier: deviceIdentifier) } } -// MARK: - Helpers +// MARK: - Helper private extension NotchGradientLoadingBarViewModel.SafeAreaDevice { /// Creates a new instance from a given `deviceIdentifier` (value returned by `UIDevice.identifier`).