Skip to content

Commit 7314473

Browse files
committed
RoundedGradientActivityIndicatorView added
1 parent 54159ca commit 7314473

File tree

7 files changed

+315
-51
lines changed

7 files changed

+315
-51
lines changed

Example/GradientLoadingBar.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
64E7F4252293E16B00BE5095 /* GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64E7F4242293E16B00BE5095 /* GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift */; };
2222
77357BD34CFF2778341F80E8 /* Pods_GradientLoadingBar_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03CD5D69D7C3FBBDBF5FABBB /* Pods_GradientLoadingBar_Example.framework */; };
2323
8020C040972E902A8CCAA9E7 /* Pods_GradientLoadingBar_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 434E3C8A6E245A38C2831E73 /* Pods_GradientLoadingBar_Tests.framework */; };
24+
94BAEE6D25612847007BA27E /* CircleBorderedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94BAEE6C25612846007BA27E /* CircleBorderedButton.swift */; };
2425
972CFBCC2138849A006F14C9 /* SafeAreaExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972CFBCB2138849A006F14C9 /* SafeAreaExampleViewController.swift */; };
2526
97464E6721372BCD0097183A /* AdvancedExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97464E6621372BCD0097183A /* AdvancedExampleViewController.swift */; };
2627
97464E6921372C010097183A /* NavigationBarExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97464E6821372C010097183A /* NavigationBarExampleViewController.swift */; };
@@ -73,6 +74,7 @@
7374
64C596EB2351D7FF00A6CC97 /* InterfaceBuilderExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InterfaceBuilderExampleViewController.swift; sourceTree = "<group>"; };
7475
64E0F5BB2211B7D20066D00D /* GradientLoadingBarViewModelTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientLoadingBarViewModelTestCase.swift; sourceTree = "<group>"; };
7576
64E7F4242293E16B00BE5095 /* GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GradientActivityIndicatorView+AnimateIsHiddenTestCase.swift"; sourceTree = "<group>"; };
77+
94BAEE6C25612846007BA27E /* CircleBorderedButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleBorderedButton.swift; sourceTree = "<group>"; };
7678
972CFBCB2138849A006F14C9 /* SafeAreaExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafeAreaExampleViewController.swift; sourceTree = "<group>"; };
7779
97464E6621372BCD0097183A /* AdvancedExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedExampleViewController.swift; sourceTree = "<group>"; };
7880
97464E6821372C010097183A /* NavigationBarExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarExampleViewController.swift; sourceTree = "<group>"; };
@@ -81,7 +83,7 @@
8183
97B6F5FD2143F31F008CFEA5 /* BlueBorderedButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueBorderedButton.swift; sourceTree = "<group>"; };
8284
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 = "<group>"; };
8385
ABA9B1EF5F3928BA6E31D3EA /* Pods_GradientLoadingBar_SnapshotTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GradientLoadingBar_SnapshotTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
84-
C06CA4DFA1DCB931095ABD3D /* GradientLoadingBar.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GradientLoadingBar.podspec; path = ../GradientLoadingBar.podspec; sourceTree = "<group>"; };
86+
C06CA4DFA1DCB931095ABD3D /* GradientLoadingBar.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GradientLoadingBar.podspec; path = ../GradientLoadingBar.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
8587
DC190F602496A24F0069E2B0 /* NotchGradientLoadingBarControllerTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotchGradientLoadingBarControllerTestCase.swift; sourceTree = "<group>"; };
8688
DCE3AB11249761AB00889FFA /* Snapshotting+WindowedImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Snapshotting+WindowedImage.swift"; sourceTree = "<group>"; };
8789
DCE3AB14249764A000889FFA /* GradientLoadingBarControllerTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientLoadingBarControllerTestCase.swift; sourceTree = "<group>"; };
@@ -237,6 +239,7 @@
237239
97B6F5FB2143F31F008CFEA5 /* Views */ = {
238240
isa = PBXGroup;
239241
children = (
242+
94BAEE6C25612846007BA27E /* CircleBorderedButton.swift */,
240243
97B6F5FC2143F31F008CFEA5 /* BlueFilledButton.swift */,
241244
97B6F5FD2143F31F008CFEA5 /* BlueBorderedButton.swift */,
242245
6430C3A22338F1CA001F4A33 /* LargeNavigationBarHeaderView.swift */,
@@ -600,6 +603,7 @@
600603
97B6F5FE2143F31F008CFEA5 /* UIColor+CustomColors.swift in Sources */,
601604
97B6F6002143F31F008CFEA5 /* BlueBorderedButton.swift in Sources */,
602605
97464E6921372C010097183A /* NavigationBarExampleViewController.swift in Sources */,
606+
94BAEE6D25612847007BA27E /* CircleBorderedButton.swift in Sources */,
603607
);
604608
runOnlyForDeploymentPostprocessing = 0;
605609
};

Example/GradientLoadingBar/AdvancedExampleViewController.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class AdvancedExampleViewController: UIViewController {
2121

2222
@IBOutlet private var programmaticallyButton: BlueBorderedButton!
2323
@IBOutlet private var customColorsButton: BlueBorderedButton!
24+
@IBOutlet private var roundedButton: BlueBorderedButton!
25+
@IBOutlet private var circleButton: UIButton!
2426

2527
// MARK: - Private properties
2628

@@ -39,13 +41,18 @@ class AdvancedExampleViewController: UIViewController {
3941
return gradientActivityIndicatorView
4042
}()
4143

44+
private let cirlceGradientActivityIndicatorView = RoundedGradientActivityIndicatorView()
45+
private let roundedGradientActivityIndicatorView = RoundedGradientActivityIndicatorView()
46+
4247
// MARK: - Public methods
4348

4449
override func viewDidLoad() {
4550
super.viewDidLoad()
4651

4752
setupProgrammaticallyGradientActivityIndicatorView()
4853
setupCustomColorsGradientActivityIndicatorView()
54+
setupCircleGradientActivityIndicatorView()
55+
setupRoundedGradientActivityIndicatorView()
4956
}
5057

5158
override func viewWillDisappear(_ animated: Bool) {
@@ -71,6 +78,22 @@ class AdvancedExampleViewController: UIViewController {
7178
}
7279
}
7380

81+
@IBAction func toggleCircleButtonTouchUpInside(_: Any) {
82+
if cirlceGradientActivityIndicatorView.isHidden {
83+
cirlceGradientActivityIndicatorView.fadeIn()
84+
} else {
85+
cirlceGradientActivityIndicatorView.fadeOut()
86+
}
87+
}
88+
89+
@IBAction func toggleRoundedButtonTouchUpInside(_: Any) {
90+
if roundedGradientActivityIndicatorView.isHidden {
91+
roundedGradientActivityIndicatorView.fadeIn()
92+
} else {
93+
roundedGradientActivityIndicatorView.fadeOut()
94+
}
95+
}
96+
7497
// MARK: - Private methods
7598

7699
private func setupProgrammaticallyGradientActivityIndicatorView() {
@@ -102,4 +125,36 @@ class AdvancedExampleViewController: UIViewController {
102125
customColorsGradientActivityIndicatorView.heightAnchor.constraint(equalToConstant: Config.height)
103126
])
104127
}
128+
129+
private func setupCircleGradientActivityIndicatorView() {
130+
circleButton.contentEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
131+
cirlceGradientActivityIndicatorView.fadeOut(duration: 0)
132+
133+
cirlceGradientActivityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
134+
circleButton.addSubview(cirlceGradientActivityIndicatorView)
135+
136+
NSLayoutConstraint.activate([
137+
cirlceGradientActivityIndicatorView.leadingAnchor.constraint(equalTo: circleButton.leadingAnchor),
138+
cirlceGradientActivityIndicatorView.trailingAnchor.constraint(equalTo: circleButton.trailingAnchor),
139+
140+
cirlceGradientActivityIndicatorView.topAnchor.constraint(equalTo: circleButton.topAnchor),
141+
cirlceGradientActivityIndicatorView.bottomAnchor.constraint(equalTo: circleButton.bottomAnchor)
142+
])
143+
}
144+
145+
private func setupRoundedGradientActivityIndicatorView() {
146+
roundedButton.layer.cornerRadius = 20
147+
roundedGradientActivityIndicatorView.fadeOut(duration: 0)
148+
149+
roundedGradientActivityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
150+
roundedButton.addSubview(roundedGradientActivityIndicatorView)
151+
152+
NSLayoutConstraint.activate([
153+
roundedGradientActivityIndicatorView.leadingAnchor.constraint(equalTo: roundedButton.leadingAnchor),
154+
roundedGradientActivityIndicatorView.trailingAnchor.constraint(equalTo: roundedButton.trailingAnchor),
155+
156+
roundedGradientActivityIndicatorView.topAnchor.constraint(equalTo: roundedButton.topAnchor),
157+
roundedGradientActivityIndicatorView.bottomAnchor.constraint(equalTo: roundedButton.bottomAnchor)
158+
])
159+
}
105160
}

0 commit comments

Comments
 (0)