From 731447306512a9e9ca67686ba06cea5792ed7c59 Mon Sep 17 00:00:00 2001 From: Aleksei Cherepanov Date: Sun, 15 Nov 2020 13:15:04 +0300 Subject: [PATCH] RoundedGradientActivityIndicatorView added --- .../project.pbxproj | 6 +- .../AdvancedExampleViewController.swift | 55 +++++++ .../Base.lproj/Main.storyboard | 152 ++++++++++++++---- .../Views/CircleBorderedButton.swift | 47 ++++++ Example/Pods/Pods.xcodeproj/project.pbxproj | 33 ++-- .../Views/GradientActivityIndicatorView.swift | 2 +- ...RoundedGradientActivityIndicatorView.swift | 71 ++++++++ 7 files changed, 315 insertions(+), 51 deletions(-) create mode 100644 Example/GradientLoadingBar/Views/CircleBorderedButton.swift create mode 100644 GradientLoadingBar/Classes/Views/RoundedGradientActivityIndicatorView.swift diff --git a/Example/GradientLoadingBar.xcodeproj/project.pbxproj b/Example/GradientLoadingBar.xcodeproj/project.pbxproj index 7f2f24d..98ffbf9 100644 --- a/Example/GradientLoadingBar.xcodeproj/project.pbxproj +++ b/Example/GradientLoadingBar.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 64E7F4252293E16B00BE5095 /* GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64E7F4242293E16B00BE5095 /* GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift */; }; 77357BD34CFF2778341F80E8 /* Pods_GradientLoadingBar_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03CD5D69D7C3FBBDBF5FABBB /* Pods_GradientLoadingBar_Example.framework */; }; 8020C040972E902A8CCAA9E7 /* Pods_GradientLoadingBar_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 434E3C8A6E245A38C2831E73 /* Pods_GradientLoadingBar_Tests.framework */; }; + 94BAEE6D25612847007BA27E /* CircleBorderedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94BAEE6C25612846007BA27E /* CircleBorderedButton.swift */; }; 972CFBCC2138849A006F14C9 /* SafeAreaExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972CFBCB2138849A006F14C9 /* SafeAreaExampleViewController.swift */; }; 97464E6721372BCD0097183A /* AdvancedExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97464E6621372BCD0097183A /* AdvancedExampleViewController.swift */; }; 97464E6921372C010097183A /* NavigationBarExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97464E6821372C010097183A /* NavigationBarExampleViewController.swift */; }; @@ -73,6 +74,7 @@ 64C596EB2351D7FF00A6CC97 /* InterfaceBuilderExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InterfaceBuilderExampleViewController.swift; sourceTree = ""; }; 64E0F5BB2211B7D20066D00D /* GradientLoadingBarViewModelTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientLoadingBarViewModelTestCase.swift; sourceTree = ""; }; 64E7F4242293E16B00BE5095 /* GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift"; sourceTree = ""; }; + 94BAEE6C25612846007BA27E /* CircleBorderedButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleBorderedButton.swift; sourceTree = ""; }; 972CFBCB2138849A006F14C9 /* SafeAreaExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafeAreaExampleViewController.swift; sourceTree = ""; }; 97464E6621372BCD0097183A /* AdvancedExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedExampleViewController.swift; sourceTree = ""; }; 97464E6821372C010097183A /* NavigationBarExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarExampleViewController.swift; sourceTree = ""; }; @@ -81,7 +83,7 @@ 97B6F5FD2143F31F008CFEA5 /* BlueBorderedButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueBorderedButton.swift; sourceTree = ""; }; A98CA9F1B0C1BD6864C14E01 /* Pods-GradientLoadingBar_SnapshotTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GradientLoadingBar_SnapshotTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-GradientLoadingBar_SnapshotTests/Pods-GradientLoadingBar_SnapshotTests.release.xcconfig"; sourceTree = ""; }; ABA9B1EF5F3928BA6E31D3EA /* Pods_GradientLoadingBar_SnapshotTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GradientLoadingBar_SnapshotTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - C06CA4DFA1DCB931095ABD3D /* GradientLoadingBar.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GradientLoadingBar.podspec; path = ../GradientLoadingBar.podspec; sourceTree = ""; }; + C06CA4DFA1DCB931095ABD3D /* GradientLoadingBar.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GradientLoadingBar.podspec; path = ../GradientLoadingBar.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; DC190F602496A24F0069E2B0 /* NotchGradientLoadingBarControllerTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotchGradientLoadingBarControllerTestCase.swift; sourceTree = ""; }; DCE3AB11249761AB00889FFA /* Snapshotting+WindowedImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Snapshotting+WindowedImage.swift"; sourceTree = ""; }; DCE3AB14249764A000889FFA /* GradientLoadingBarControllerTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientLoadingBarControllerTestCase.swift; sourceTree = ""; }; @@ -237,6 +239,7 @@ 97B6F5FB2143F31F008CFEA5 /* Views */ = { isa = PBXGroup; children = ( + 94BAEE6C25612846007BA27E /* CircleBorderedButton.swift */, 97B6F5FC2143F31F008CFEA5 /* BlueFilledButton.swift */, 97B6F5FD2143F31F008CFEA5 /* BlueBorderedButton.swift */, 6430C3A22338F1CA001F4A33 /* LargeNavigationBarHeaderView.swift */, @@ -600,6 +603,7 @@ 97B6F5FE2143F31F008CFEA5 /* UIColor+CustomColors.swift in Sources */, 97B6F6002143F31F008CFEA5 /* BlueBorderedButton.swift in Sources */, 97464E6921372C010097183A /* NavigationBarExampleViewController.swift in Sources */, + 94BAEE6D25612847007BA27E /* CircleBorderedButton.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/GradientLoadingBar/AdvancedExampleViewController.swift b/Example/GradientLoadingBar/AdvancedExampleViewController.swift index 2e42d36..7502302 100644 --- a/Example/GradientLoadingBar/AdvancedExampleViewController.swift +++ b/Example/GradientLoadingBar/AdvancedExampleViewController.swift @@ -21,6 +21,8 @@ class AdvancedExampleViewController: UIViewController { @IBOutlet private var programmaticallyButton: BlueBorderedButton! @IBOutlet private var customColorsButton: BlueBorderedButton! + @IBOutlet private var roundedButton: BlueBorderedButton! + @IBOutlet private var circleButton: UIButton! // MARK: - Private properties @@ -39,6 +41,9 @@ class AdvancedExampleViewController: UIViewController { return gradientActivityIndicatorView }() + private let cirlceGradientActivityIndicatorView = RoundedGradientActivityIndicatorView() + private let roundedGradientActivityIndicatorView = RoundedGradientActivityIndicatorView() + // MARK: - Public methods override func viewDidLoad() { @@ -46,6 +51,8 @@ class AdvancedExampleViewController: UIViewController { setupProgrammaticallyGradientActivityIndicatorView() setupCustomColorsGradientActivityIndicatorView() + setupCircleGradientActivityIndicatorView() + setupRoundedGradientActivityIndicatorView() } override func viewWillDisappear(_ animated: Bool) { @@ -71,6 +78,22 @@ class AdvancedExampleViewController: UIViewController { } } + @IBAction func toggleCircleButtonTouchUpInside(_: Any) { + if cirlceGradientActivityIndicatorView.isHidden { + cirlceGradientActivityIndicatorView.fadeIn() + } else { + cirlceGradientActivityIndicatorView.fadeOut() + } + } + + @IBAction func toggleRoundedButtonTouchUpInside(_: Any) { + if roundedGradientActivityIndicatorView.isHidden { + roundedGradientActivityIndicatorView.fadeIn() + } else { + roundedGradientActivityIndicatorView.fadeOut() + } + } + // MARK: - Private methods private func setupProgrammaticallyGradientActivityIndicatorView() { @@ -102,4 +125,36 @@ class AdvancedExampleViewController: UIViewController { customColorsGradientActivityIndicatorView.heightAnchor.constraint(equalToConstant: Config.height) ]) } + + private func setupCircleGradientActivityIndicatorView() { + circleButton.contentEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) + cirlceGradientActivityIndicatorView.fadeOut(duration: 0) + + cirlceGradientActivityIndicatorView.translatesAutoresizingMaskIntoConstraints = false + circleButton.addSubview(cirlceGradientActivityIndicatorView) + + NSLayoutConstraint.activate([ + cirlceGradientActivityIndicatorView.leadingAnchor.constraint(equalTo: circleButton.leadingAnchor), + cirlceGradientActivityIndicatorView.trailingAnchor.constraint(equalTo: circleButton.trailingAnchor), + + cirlceGradientActivityIndicatorView.topAnchor.constraint(equalTo: circleButton.topAnchor), + cirlceGradientActivityIndicatorView.bottomAnchor.constraint(equalTo: circleButton.bottomAnchor) + ]) + } + + private func setupRoundedGradientActivityIndicatorView() { + roundedButton.layer.cornerRadius = 20 + roundedGradientActivityIndicatorView.fadeOut(duration: 0) + + roundedGradientActivityIndicatorView.translatesAutoresizingMaskIntoConstraints = false + roundedButton.addSubview(roundedGradientActivityIndicatorView) + + NSLayoutConstraint.activate([ + roundedGradientActivityIndicatorView.leadingAnchor.constraint(equalTo: roundedButton.leadingAnchor), + roundedGradientActivityIndicatorView.trailingAnchor.constraint(equalTo: roundedButton.trailingAnchor), + + roundedGradientActivityIndicatorView.topAnchor.constraint(equalTo: roundedButton.topAnchor), + roundedGradientActivityIndicatorView.bottomAnchor.constraint(equalTo: roundedButton.bottomAnchor) + ]) + } } diff --git a/Example/GradientLoadingBar/Base.lproj/Main.storyboard b/Example/GradientLoadingBar/Base.lproj/Main.storyboard index 6a8cae1..6a82031 100644 --- a/Example/GradientLoadingBar/Base.lproj/Main.storyboard +++ b/Example/GradientLoadingBar/Base.lproj/Main.storyboard @@ -1,8 +1,10 @@ - + - + + + @@ -34,7 +36,7 @@ - - - - - - + + + + + + + + + + + + -