diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d50571..a404ebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -167,7 +167,7 @@ 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.2.5...master +[Unreleased]: https://github.com/fxm90/GradientLoadingBar/compare/2.2.5...main [2.2.5]: https://github.com/fxm90/GradientLoadingBar/compare/2.2.4...2.2.5 [2.2.4]: https://github.com/fxm90/GradientLoadingBar/compare/2.2.3...2.2.4 [2.2.3]: https://github.com/fxm90/GradientLoadingBar/compare/2.2.2...2.2.3 diff --git a/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift b/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift index f4df383..70dabb8 100644 --- a/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift +++ b/Example/Example/Scenes/AdvancedExample/AdvancedExampleTableViewController.swift @@ -21,10 +21,7 @@ final class AdvancedExampleTableViewController: UITableViewController { #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), ] - /// static let firstSectionHeaderHeight: CGFloat = 48 - - /// static let defaultSectionHeaderHeight: CGFloat = 32 } diff --git a/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift b/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift index 6784229..925cf30 100644 --- a/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift +++ b/Example/Example/Scenes/SwiftUIExample/SwiftUIExampleView.swift @@ -34,6 +34,7 @@ struct SwiftUIExampleView: View { // MARK: - Subviews private struct DefaultExampleView: View { + @State private var isVisible = true @@ -69,6 +70,7 @@ private struct DefaultExampleView: View { } private struct CustomColorsExampleView: View { + private enum Config { /// The custom gradient colors we use. /// Source: https://color.adobe.com/Pink-Flamingo-color-theme-10343714/ @@ -112,6 +114,7 @@ private struct CustomColorsExampleView: View { } private struct CustomProgressDurationExampleView: View { + private enum Config { /// The custom progress duration to use. static let progressDuration: TimeInterval = 10 @@ -154,6 +157,7 @@ private struct CustomProgressDurationExampleView: View { // MARK: - Helper private struct RoundedRectangleButtonStyle: ButtonStyle { + func makeBody(configuration: Configuration) -> some View { configuration.label .padding(12) diff --git a/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift b/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift index 1ab78ad..26ce641 100644 --- a/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift +++ b/Example/ExampleTests/Views/GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift @@ -60,7 +60,7 @@ final class GradientActivityIndicatorViewAnimateIsHiddenTestCase: XCTestCase { wait(for: [expectation], timeout: 1) XCTAssertFalse(gradientActivityIndicatorView.isHidden) - XCTAssertEqual(gradientActivityIndicatorView.alpha, 1.0, accuracy: CGFloat.ulpOfOne) + XCTAssertEqual(gradientActivityIndicatorView.alpha, 1, accuracy: CGFloat.ulpOfOne) } func test_animateIsHidden_withInterruption_shouldShowView_andCallCompletionHandler() { @@ -142,7 +142,7 @@ final class GradientActivityIndicatorViewAnimateIsHiddenTestCase: XCTestCase { wait(for: [expectation], timeout: 1) XCTAssertFalse(gradientActivityIndicatorView.isHidden) - XCTAssertEqual(gradientActivityIndicatorView.alpha, 1.0, accuracy: CGFloat.ulpOfOne) + XCTAssertEqual(gradientActivityIndicatorView.alpha, 1, accuracy: CGFloat.ulpOfOne) } func test_fadeIn_withInterruption_shouldShowView_andCallCompletionHandler() { diff --git a/Example/Gemfile.lock b/Example/Gemfile.lock index f57a108..83e7438 100644 --- a/Example/Gemfile.lock +++ b/Example/Gemfile.lock @@ -3,7 +3,7 @@ GEM specs: CFPropertyList (3.0.5) rexml - activesupport (6.1.5) + activesupport (6.1.5.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -17,20 +17,20 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.567.0) - aws-sdk-core (3.130.0) + aws-partitions (1.581.0) + aws-sdk-core (3.130.2) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.55.0) + aws-sdk-kms (1.56.0) aws-sdk-core (~> 3, >= 3.127.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.113.0) + aws-sdk-s3 (1.113.2) aws-sdk-core (~> 3, >= 3.127.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) - aws-sigv4 (1.4.0) + aws-sigv4 (1.5.0) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) claide (1.1.0) @@ -63,7 +63,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.5.1) + cocoapods-downloader (1.6.3) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -75,7 +75,7 @@ GEM colored2 (3.1.2) commander (4.6.0) highline (~> 2.0.0) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) declarative (0.0.20) digest-crc (0.6.4) rake (>= 12.0.0, < 14.0.0) @@ -86,7 +86,7 @@ GEM escape (0.0.4) ethon (0.15.0) ffi (>= 1.15.0) - excon (0.92.0) + excon (0.92.3) faraday (1.10.0) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) @@ -116,7 +116,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.6) - fastlane (2.204.3) + fastlane (2.205.2) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -160,7 +160,7 @@ GEM fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.16.0) + google-apis-androidpublisher_v3 (0.19.0) google-apis-core (>= 0.4, < 2.a) google-apis-core (0.4.2) addressable (~> 2.5, >= 2.5.1) @@ -175,15 +175,15 @@ GEM google-apis-core (>= 0.4, < 2.a) google-apis-playcustomapp_v1 (0.7.0) google-apis-core (>= 0.4, < 2.a) - google-apis-storage_v1 (0.11.0) + google-apis-storage_v1 (0.13.0) google-apis-core (>= 0.4, < 2.a) google-cloud-core (1.6.0) google-cloud-env (~> 1.0) google-cloud-errors (~> 1.0) - google-cloud-env (1.5.0) - faraday (>= 0.17.3, < 2.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) google-cloud-errors (1.2.0) - google-cloud-storage (1.36.1) + google-cloud-storage (1.36.2) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) @@ -191,7 +191,7 @@ GEM google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (1.1.2) + googleauth (1.1.3) faraday (>= 0.17.3, < 3.a) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -221,7 +221,7 @@ GEM optparse (0.1.1) os (1.1.4) plist (3.6.0) - public_suffix (4.0.6) + public_suffix (4.0.7) rake (13.0.6) representable (3.1.1) declarative (< 0.1.0) diff --git a/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift b/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift index 38440ce..f663190 100644 --- a/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift +++ b/GradientLoadingBar/Feature/GradientLoadingBarView/GradientLoadingBarView.swift @@ -50,10 +50,11 @@ public struct GradientLoadingBarView: View { viewModel.size = $0 } // Using an `overlay` here makes sure that the parent view won't change it's frame. - .overlay(// + .overlay( LinearGradient(colors: viewModel.gradientColors, startPoint: .leading, endPoint: .trailing) .frame(width: viewModel.gradientWidth) - .offset(x: viewModel.horizontalOffset, y: 0)) + .offset(x: viewModel.horizontalOffset, y: 0) + ) } } diff --git a/readme.md b/readme.md index f49f71b..67232e7 100644 --- a/readme.md +++ b/readme.md @@ -50,7 +50,7 @@ This framework provides four classes: - **GradientLoadingBar**: A controller, managing the visibility of the `GradientActivityIndicatorView` on the current key window. - **NotchGradientLoadingBar**: A subclass of `GradientLoadingBar`, wrapping the `GradientActivityIndicatorView` around the notch of the iPhone. - **GradientActivityIndicatorView**: A `UIView` containing the gradient with the animation. It can be added as a subview to another view either inside the interface builder or programmatically. Both ways are shown inside the example application. - - **GradientLoadingBarView**: A `View` for SwiftUI containing the gradient with the animation. The view can be added to any other SwiftUI view. The example application also contains same sample code for this use case. + - **GradientLoadingBarView**: A `View` for SwiftUI containing the gradient with the animation. The view can be added to any other SwiftUI view. The example application also contains sample code for this use case. #### GradientLoadingBar To get started, import the module `GradientLoadingBar` into your file and save an instance of `GradientLoadingBar()` on a property of your view-controller. To show the loading bar, simply call the `fadeIn(duration:completion)` method and after your async operations have finished call the `fadeOut(duration:completion)` method. @@ -171,12 +171,12 @@ This property adjusts the duration of the animation moving the gradient from lef #### GradientLoadingBarView -This is the SwiftUI variant for the `GradientActivityIndicatorView`. The view can be configured via the two parameters `gradientColors: [Color]` and `progressAnimation: Animation` passed to the initializer. +This is the SwiftUI variant for the `GradientActivityIndicatorView`. The view can be configured via the two parameters `gradientColors: [Color]` and `progressDuration: TimeInterval` passed to the initializer. ##### – `gradientColors: [Color]` : This parameter adjusts the gradient colors shown on the loading bar. -##### – `progressAnimation: Animation` : +##### – `progressDuration: TimeInterval` : This parameter adjusts the duration of the animation moving the gradient from left to right. The visibility of the view can be updated with the view modifier [`opacity()`](https://developer.apple.com/documentation/swiftui/view/opacity(_:)) or [`hidden()`](https://developer.apple.com/documentation/swiftui/view/hidden()).