Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update progress function #18

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assets/progress-example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1160"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
33 changes: 29 additions & 4 deletions Example/GradientLoadingBar/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="31S-8b-Niv">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="31S-8b-Niv">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
Expand Down Expand Up @@ -32,7 +32,7 @@
<rect key="frame" x="0.0" y="138" width="375" height="480"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="Hrq-tB-Sk3">
<rect key="frame" x="16" y="220" width="343" height="40"/>
<rect key="frame" x="16" y="20" width="343" height="40"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W6V-cT-b8Q" customClass="BlueFilledButton" customModule="GradientLoadingBar_Example" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="163.5" height="40"/>
Expand All @@ -58,12 +58,21 @@
</button>
</subviews>
</stackView>
<slider hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="bi1-og-G8F">
<rect key="frame" x="14" y="80" width="347" height="31"/>
<connections>
<action selector="chnageSliderValue:" destination="vXZ-lx-hvc" eventType="valueChanged" id="yjf-Jm-ylT"/>
</connections>
</slider>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="Hrq-tB-Sk3" firstAttribute="leading" secondItem="vCz-UL-eay" secondAttribute="leading" constant="16" id="Er7-gx-Ray"/>
<constraint firstItem="Hrq-tB-Sk3" firstAttribute="centerY" secondItem="vCz-UL-eay" secondAttribute="centerY" id="MB9-lc-dAX"/>
<constraint firstItem="bi1-og-G8F" firstAttribute="leading" secondItem="vCz-UL-eay" secondAttribute="leading" constant="16" id="GRD-QQ-hGx"/>
<constraint firstItem="Hrq-tB-Sk3" firstAttribute="top" secondItem="vCz-UL-eay" secondAttribute="top" constant="20" id="K7t-rg-G0j"/>
<constraint firstAttribute="trailing" secondItem="Hrq-tB-Sk3" secondAttribute="trailing" constant="16" id="ao9-tR-lfs"/>
<constraint firstItem="bi1-og-G8F" firstAttribute="top" secondItem="Hrq-tB-Sk3" secondAttribute="bottom" constant="20" id="hLh-II-KpU"/>
<constraint firstAttribute="trailing" secondItem="bi1-og-G8F" secondAttribute="trailing" constant="16" id="mc0-5P-zjX"/>
</constraints>
</view>
</subviews>
Expand All @@ -80,6 +89,9 @@
</view>
<tabBarItem key="tabBarItem" title="Basic Example" image="house" catalog="system" id="QbQ-0M-Q7f"/>
<navigationItem key="navigationItem" title="Basic Example" prompt="Gradient Loading Bar" largeTitleDisplayMode="always" id="Rdw-Bd-vul"/>
<connections>
<outlet property="slider" destination="bi1-og-G8F" id="ZFa-di-COw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
Expand Down Expand Up @@ -230,14 +242,24 @@
</button>
</subviews>
</stackView>
<slider hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="6iB-XA-1FD">
<rect key="frame" x="14" y="308" width="347" height="31"/>
<connections>
<action selector="chnageSlider:" destination="G0W-Ta-C7r" eventType="valueChanged" id="feD-wL-hVl"/>
<action selector="chnageSliderValue:" destination="vXZ-lx-hvc" eventType="valueChanged" id="QQW-w5-r1L"/>
</connections>
</slider>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="oWt-EZ-h2R" firstAttribute="bottom" secondItem="cQz-wE-hV5" secondAttribute="centerY" constant="-8" id="77C-lL-1fS"/>
<constraint firstItem="oWt-EZ-h2R" firstAttribute="leading" secondItem="cQz-wE-hV5" secondAttribute="leading" constant="16" id="Hjd-XM-aek"/>
<constraint firstItem="6iB-XA-1FD" firstAttribute="top" secondItem="eno-YK-fo8" secondAttribute="bottom" constant="20" id="dsW-xK-bqv"/>
<constraint firstAttribute="trailing" secondItem="oWt-EZ-h2R" secondAttribute="trailing" constant="16" id="ifg-oy-eiV"/>
<constraint firstItem="6iB-XA-1FD" firstAttribute="leading" secondItem="cQz-wE-hV5" secondAttribute="leading" constant="16" id="jSO-Hc-I5d"/>
<constraint firstAttribute="trailing" secondItem="eno-YK-fo8" secondAttribute="trailing" constant="16" id="o3h-uA-jbM"/>
<constraint firstItem="eno-YK-fo8" firstAttribute="top" secondItem="cQz-wE-hV5" secondAttribute="centerY" constant="8" id="rVX-yO-z4X"/>
<constraint firstAttribute="trailing" secondItem="6iB-XA-1FD" secondAttribute="trailing" constant="16" id="tgh-XK-aqf"/>
<constraint firstItem="eno-YK-fo8" firstAttribute="leading" secondItem="cQz-wE-hV5" secondAttribute="leading" constant="16" id="zaJ-tE-bCY"/>
</constraints>
</view>
Expand All @@ -255,6 +277,9 @@
</view>
<tabBarItem key="tabBarItem" title="Safe Area Example" image="rectangle.and.arrow.up.right.and.arrow.down.left" catalog="system" id="VBS-L1-AHW"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="slider" destination="6iB-XA-1FD" id="5kc-MV-J5F"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="oYv-dl-Yai" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down Expand Up @@ -466,7 +491,7 @@
<tabBarItem key="tabBarItem" title="Nav Bar Example" image="lightbulb.fill" catalog="system" id="r91-al-1Rr"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="zAv-AH-IlN">
<rect key="frame" x="0.0" y="0.0" width="375" height="96"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="104.5"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
11 changes: 11 additions & 0 deletions Example/GradientLoadingBar/BasicExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,28 @@ import GradientLoadingBar
class BasicExampleViewController: UIViewController {
// MARK: - Public methods

@IBOutlet private var slider: UISlider!

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

slider.isHidden = true
GradientLoadingBar.shared.fadeOut()
}

@IBAction func showButtonTouchUpInside(_: Any) {
GradientLoadingBar.shared.fadeIn()

slider.isHidden = false
GradientLoadingBar.shared.setProgress(CGFloat(slider.value))
}

@IBAction func hideButtonTouchUpInside(_: Any) {
slider.isHidden = true
GradientLoadingBar.shared.fadeOut()
}

@IBAction func chnageSliderValue(_ sender: UISlider) {
GradientLoadingBar.shared.setProgress(CGFloat(sender.value))
}
}
10 changes: 10 additions & 0 deletions Example/GradientLoadingBar/SafeAreaExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import GradientLoadingBar
class SafeAreaExampleViewController: UIViewController {
// MARK: - Private properties

@IBOutlet private var slider: UISlider!

private let gradientLoadingBar = GradientLoadingBar(isRelativeToSafeArea: false)

private let notchGradientLoadingBar = NotchGradientLoadingBar(isRelativeToSafeArea: false)
Expand All @@ -21,6 +23,7 @@ class SafeAreaExampleViewController: UIViewController {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

slider.isHidden = true
gradientLoadingBar.fadeOut()
notchGradientLoadingBar.fadeOut()
}
Expand All @@ -34,10 +37,17 @@ class SafeAreaExampleViewController: UIViewController {
}

@IBAction func showNotchBarButtonTouchUpInside(_: Any) {
slider.isHidden = false
notchGradientLoadingBar.fadeIn()
notchGradientLoadingBar.setProgress(CGFloat(slider.value))
}

@IBAction func hideNotchBarButtonTouchUpInside(_: Any) {
slider.isHidden = true
notchGradientLoadingBar.fadeOut()
}

@IBAction func chnageSlider(_ sender: UISlider) {
notchGradientLoadingBar.setProgress(CGFloat(sender.value))
}
}
Loading