├── .gitignore ├── .travis.yml ├── Example ├── Loady.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── Loady-Example.xcscheme ├── Loady.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Loady │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── image.imageset │ │ │ ├── Contents.json │ │ │ └── image.png │ │ ├── locked.imageset │ │ │ ├── 002-locked-padlock.pdf │ │ │ └── Contents.json │ │ ├── new.imageset │ │ │ ├── Contents.json │ │ │ └── new-product.pdf │ │ ├── pause-button.imageset │ │ │ ├── Contents.json │ │ │ └── pause-button.pdf │ │ └── unlocked.imageset │ │ │ ├── 001-unlock.pdf │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── Podfile ├── Podfile.lock ├── Pods │ ├── Local Podspecs │ │ └── Loady.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ └── Target Support Files │ │ ├── Loady │ │ ├── Loady-Info.plist │ │ ├── Loady-dummy.m │ │ ├── Loady-prefix.pch │ │ ├── Loady-umbrella.h │ │ ├── Loady.modulemap │ │ └── Loady.xcconfig │ │ ├── Pods-Loady_Example │ │ ├── Pods-Loady_Example-Info.plist │ │ ├── Pods-Loady_Example-acknowledgements.markdown │ │ ├── Pods-Loady_Example-acknowledgements.plist │ │ ├── Pods-Loady_Example-dummy.m │ │ ├── Pods-Loady_Example-frameworks.sh │ │ ├── Pods-Loady_Example-umbrella.h │ │ ├── Pods-Loady_Example.debug.xcconfig │ │ ├── Pods-Loady_Example.modulemap │ │ └── Pods-Loady_Example.release.xcconfig │ │ └── Pods-Loady_Tests │ │ ├── Pods-Loady_Tests-Info.plist │ │ ├── Pods-Loady_Tests-acknowledgements.markdown │ │ ├── Pods-Loady_Tests-acknowledgements.plist │ │ ├── Pods-Loady_Tests-dummy.m │ │ ├── Pods-Loady_Tests-umbrella.h │ │ ├── Pods-Loady_Tests.debug.xcconfig │ │ ├── Pods-Loady_Tests.modulemap │ │ └── Pods-Loady_Tests.release.xcconfig └── Tests │ ├── Info.plist │ └── Tests.swift ├── LICENSE ├── Loady.podspec ├── Loady ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── Animations │ ├── LoadyAndroidAnimation.swift │ ├── LoadyAppStoreAnimation.swift │ ├── LoadyBackgroundHighlighter.swift │ ├── LoadyCircleAndThickAnimation.swift │ ├── LoadyDownloadingAnimation.swift │ ├── LoadyFourPhaseAnimation.swift │ ├── LoadyIndicatorAnimation.swift │ └── LoadyTopLineAnimation.swift │ ├── Loadible.swift │ ├── Loady+NVActivityIndicatorView.swift │ ├── LoadyAnimation.swift │ ├── LoadyAnimationOptions.swift │ ├── LoadyAnimationType.swift │ ├── LoadyButton │ ├── Loady.swift │ └── LoadyFourPhaseButton.swift │ └── LoadyCore.swift ├── Package.swift ├── README.md ├── _Pods.xcodeproj └── examples ├── _cancelPhase.gif ├── _download.gif ├── _errorPhasee.gif ├── _gif.gif ├── _nvacctivityindicator1.gif ├── _nvacctivityindicator2.gif ├── _properties.png ├── _setClass.png ├── _specs.jpeg ├── _successPhase.gif └── logo.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | .DS_Store 70 | .DS_Store 71 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 72 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/Loady.xcworkspace -scheme Loady-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/Loady.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 03831E3D8EAD6FBDBE0259B5 /* Pods_Loady_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA4D64FD036EB8417A2CCA6 /* Pods_Loady_Tests.framework */; }; 11 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 12 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 13 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 14 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 15 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 16 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 17 | C7BA4BD39CFD63DE60941D72 /* Pods_Loady_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554E19C6A77F95BC4BA3B042 /* Pods_Loady_Example.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 26 | remoteInfo = Loady; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 2E1559D1868D719D22F64CFB /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 32 | 351F8751ADEA51E65538AE16 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 33 | 438B458B2CF3360AAD57CEA6 /* Pods-Loady_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Loady_Tests.release.xcconfig"; path = "Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests.release.xcconfig"; sourceTree = ""; }; 34 | 554E19C6A77F95BC4BA3B042 /* Pods_Loady_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Loady_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 5C07EA9ACB191E931288B6CE /* Pods-Loady_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Loady_Example.debug.xcconfig"; path = "Target Support Files/Pods-Loady_Example/Pods-Loady_Example.debug.xcconfig"; sourceTree = ""; }; 36 | 607FACD01AFB9204008FA782 /* Loady_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Loady_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 42 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 43 | 607FACE51AFB9204008FA782 /* Loady_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Loady_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 46 | 6CA4D64FD036EB8417A2CCA6 /* Pods_Loady_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Loady_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 7C5CE2A3A8AD2BB74E28E436 /* Pods-Loady_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Loady_Example.release.xcconfig"; path = "Target Support Files/Pods-Loady_Example/Pods-Loady_Example.release.xcconfig"; sourceTree = ""; }; 48 | 9BACE2EE18954819E374C950 /* Loady.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Loady.podspec; path = ../Loady.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 49 | CF8A97AAF625D7EF236EAD92 /* Pods-Loady_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Loady_Tests.debug.xcconfig"; path = "Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests.debug.xcconfig"; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | C7BA4BD39CFD63DE60941D72 /* Pods_Loady_Example.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 03831E3D8EAD6FBDBE0259B5 /* Pods_Loady_Tests.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 335D7512B1FA5A0DE0BD25F1 /* Frameworks */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 554E19C6A77F95BC4BA3B042 /* Pods_Loady_Example.framework */, 76 | 6CA4D64FD036EB8417A2CCA6 /* Pods_Loady_Tests.framework */, 77 | ); 78 | name = Frameworks; 79 | sourceTree = ""; 80 | }; 81 | 607FACC71AFB9204008FA782 = { 82 | isa = PBXGroup; 83 | children = ( 84 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 85 | 607FACD21AFB9204008FA782 /* Example for Loady */, 86 | 607FACE81AFB9204008FA782 /* Tests */, 87 | 607FACD11AFB9204008FA782 /* Products */, 88 | 6270CB83C92B9E264FAD5993 /* Pods */, 89 | 335D7512B1FA5A0DE0BD25F1 /* Frameworks */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | 607FACD11AFB9204008FA782 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 607FACD01AFB9204008FA782 /* Loady_Example.app */, 97 | 607FACE51AFB9204008FA782 /* Loady_Tests.xctest */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 607FACD21AFB9204008FA782 /* Example for Loady */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 106 | 607FACD71AFB9204008FA782 /* ViewController.swift */, 107 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 108 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 109 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 110 | 607FACD31AFB9204008FA782 /* Supporting Files */, 111 | ); 112 | name = "Example for Loady"; 113 | path = Loady; 114 | sourceTree = ""; 115 | }; 116 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 607FACD41AFB9204008FA782 /* Info.plist */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | 607FACE81AFB9204008FA782 /* Tests */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 128 | 607FACE91AFB9204008FA782 /* Supporting Files */, 129 | ); 130 | path = Tests; 131 | sourceTree = ""; 132 | }; 133 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 607FACEA1AFB9204008FA782 /* Info.plist */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 9BACE2EE18954819E374C950 /* Loady.podspec */, 145 | 351F8751ADEA51E65538AE16 /* README.md */, 146 | 2E1559D1868D719D22F64CFB /* LICENSE */, 147 | ); 148 | name = "Podspec Metadata"; 149 | sourceTree = ""; 150 | }; 151 | 6270CB83C92B9E264FAD5993 /* Pods */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 5C07EA9ACB191E931288B6CE /* Pods-Loady_Example.debug.xcconfig */, 155 | 7C5CE2A3A8AD2BB74E28E436 /* Pods-Loady_Example.release.xcconfig */, 156 | CF8A97AAF625D7EF236EAD92 /* Pods-Loady_Tests.debug.xcconfig */, 157 | 438B458B2CF3360AAD57CEA6 /* Pods-Loady_Tests.release.xcconfig */, 158 | ); 159 | path = Pods; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXGroup section */ 163 | 164 | /* Begin PBXNativeTarget section */ 165 | 607FACCF1AFB9204008FA782 /* Loady_Example */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Loady_Example" */; 168 | buildPhases = ( 169 | 301400E461C2D7EA37D52123 /* [CP] Check Pods Manifest.lock */, 170 | 607FACCC1AFB9204008FA782 /* Sources */, 171 | 607FACCD1AFB9204008FA782 /* Frameworks */, 172 | 607FACCE1AFB9204008FA782 /* Resources */, 173 | BD33DAB473DBBD083BD479B4 /* [CP] Embed Pods Frameworks */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | ); 179 | name = Loady_Example; 180 | productName = Loady; 181 | productReference = 607FACD01AFB9204008FA782 /* Loady_Example.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | 607FACE41AFB9204008FA782 /* Loady_Tests */ = { 185 | isa = PBXNativeTarget; 186 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Loady_Tests" */; 187 | buildPhases = ( 188 | 1A9F2AD8D2391254C9A2B656 /* [CP] Check Pods Manifest.lock */, 189 | 607FACE11AFB9204008FA782 /* Sources */, 190 | 607FACE21AFB9204008FA782 /* Frameworks */, 191 | 607FACE31AFB9204008FA782 /* Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 197 | ); 198 | name = Loady_Tests; 199 | productName = Tests; 200 | productReference = 607FACE51AFB9204008FA782 /* Loady_Tests.xctest */; 201 | productType = "com.apple.product-type.bundle.unit-test"; 202 | }; 203 | /* End PBXNativeTarget section */ 204 | 205 | /* Begin PBXProject section */ 206 | 607FACC81AFB9204008FA782 /* Project object */ = { 207 | isa = PBXProject; 208 | attributes = { 209 | LastSwiftUpdateCheck = 0830; 210 | LastUpgradeCheck = 0830; 211 | ORGANIZATIONNAME = CocoaPods; 212 | TargetAttributes = { 213 | 607FACCF1AFB9204008FA782 = { 214 | CreatedOnToolsVersion = 6.3.1; 215 | LastSwiftMigration = 0900; 216 | }; 217 | 607FACE41AFB9204008FA782 = { 218 | CreatedOnToolsVersion = 6.3.1; 219 | LastSwiftMigration = 0900; 220 | TestTargetID = 607FACCF1AFB9204008FA782; 221 | }; 222 | }; 223 | }; 224 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Loady" */; 225 | compatibilityVersion = "Xcode 3.2"; 226 | developmentRegion = English; 227 | hasScannedForEncodings = 0; 228 | knownRegions = ( 229 | English, 230 | en, 231 | Base, 232 | ); 233 | mainGroup = 607FACC71AFB9204008FA782; 234 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 235 | projectDirPath = ""; 236 | projectRoot = ""; 237 | targets = ( 238 | 607FACCF1AFB9204008FA782 /* Loady_Example */, 239 | 607FACE41AFB9204008FA782 /* Loady_Tests */, 240 | ); 241 | }; 242 | /* End PBXProject section */ 243 | 244 | /* Begin PBXResourcesBuildPhase section */ 245 | 607FACCE1AFB9204008FA782 /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 250 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 251 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | 607FACE31AFB9204008FA782 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | /* End PBXResourcesBuildPhase section */ 263 | 264 | /* Begin PBXShellScriptBuildPhase section */ 265 | 1A9F2AD8D2391254C9A2B656 /* [CP] Check Pods Manifest.lock */ = { 266 | isa = PBXShellScriptBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | ); 270 | inputFileListPaths = ( 271 | ); 272 | inputPaths = ( 273 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 274 | "${PODS_ROOT}/Manifest.lock", 275 | ); 276 | name = "[CP] Check Pods Manifest.lock"; 277 | outputFileListPaths = ( 278 | ); 279 | outputPaths = ( 280 | "$(DERIVED_FILE_DIR)/Pods-Loady_Tests-checkManifestLockResult.txt", 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | shellPath = /bin/sh; 284 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 285 | showEnvVarsInLog = 0; 286 | }; 287 | 301400E461C2D7EA37D52123 /* [CP] Check Pods Manifest.lock */ = { 288 | isa = PBXShellScriptBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | ); 292 | inputFileListPaths = ( 293 | ); 294 | inputPaths = ( 295 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 296 | "${PODS_ROOT}/Manifest.lock", 297 | ); 298 | name = "[CP] Check Pods Manifest.lock"; 299 | outputFileListPaths = ( 300 | ); 301 | outputPaths = ( 302 | "$(DERIVED_FILE_DIR)/Pods-Loady_Example-checkManifestLockResult.txt", 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | shellPath = /bin/sh; 306 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 307 | showEnvVarsInLog = 0; 308 | }; 309 | BD33DAB473DBBD083BD479B4 /* [CP] Embed Pods Frameworks */ = { 310 | isa = PBXShellScriptBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | ); 314 | inputPaths = ( 315 | "${PODS_ROOT}/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-frameworks.sh", 316 | "${BUILT_PRODUCTS_DIR}/Loady/Loady.framework", 317 | ); 318 | name = "[CP] Embed Pods Frameworks"; 319 | outputPaths = ( 320 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Loady.framework", 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | shellPath = /bin/sh; 324 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-frameworks.sh\"\n"; 325 | showEnvVarsInLog = 0; 326 | }; 327 | /* End PBXShellScriptBuildPhase section */ 328 | 329 | /* Begin PBXSourcesBuildPhase section */ 330 | 607FACCC1AFB9204008FA782 /* Sources */ = { 331 | isa = PBXSourcesBuildPhase; 332 | buildActionMask = 2147483647; 333 | files = ( 334 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, 335 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | }; 339 | 607FACE11AFB9204008FA782 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | }; 347 | /* End PBXSourcesBuildPhase section */ 348 | 349 | /* Begin PBXTargetDependency section */ 350 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 351 | isa = PBXTargetDependency; 352 | target = 607FACCF1AFB9204008FA782 /* Loady_Example */; 353 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 354 | }; 355 | /* End PBXTargetDependency section */ 356 | 357 | /* Begin PBXVariantGroup section */ 358 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 359 | isa = PBXVariantGroup; 360 | children = ( 361 | 607FACDA1AFB9204008FA782 /* Base */, 362 | ); 363 | name = Main.storyboard; 364 | sourceTree = ""; 365 | }; 366 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 367 | isa = PBXVariantGroup; 368 | children = ( 369 | 607FACDF1AFB9204008FA782 /* Base */, 370 | ); 371 | name = LaunchScreen.xib; 372 | sourceTree = ""; 373 | }; 374 | /* End PBXVariantGroup section */ 375 | 376 | /* Begin XCBuildConfiguration section */ 377 | 607FACED1AFB9204008FA782 /* Debug */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ALWAYS_SEARCH_USER_PATHS = NO; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_COMMA = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_EMPTY_BODY = YES; 391 | CLANG_WARN_ENUM_CONVERSION = YES; 392 | CLANG_WARN_INFINITE_RECURSION = YES; 393 | CLANG_WARN_INT_CONVERSION = YES; 394 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 395 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 397 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 398 | CLANG_WARN_STRICT_PROTOTYPES = YES; 399 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 400 | CLANG_WARN_UNREACHABLE_CODE = YES; 401 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 402 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 403 | COPY_PHASE_STRIP = NO; 404 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 405 | ENABLE_STRICT_OBJC_MSGSEND = YES; 406 | ENABLE_TESTABILITY = YES; 407 | GCC_C_LANGUAGE_STANDARD = gnu99; 408 | GCC_DYNAMIC_NO_PIC = NO; 409 | GCC_NO_COMMON_BLOCKS = YES; 410 | GCC_OPTIMIZATION_LEVEL = 0; 411 | GCC_PREPROCESSOR_DEFINITIONS = ( 412 | "DEBUG=1", 413 | "$(inherited)", 414 | ); 415 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 418 | GCC_WARN_UNDECLARED_SELECTOR = YES; 419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 | GCC_WARN_UNUSED_FUNCTION = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 423 | MTL_ENABLE_DEBUG_INFO = YES; 424 | ONLY_ACTIVE_ARCH = YES; 425 | SDKROOT = iphoneos; 426 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 427 | }; 428 | name = Debug; 429 | }; 430 | 607FACEE1AFB9204008FA782 /* Release */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | ALWAYS_SEARCH_USER_PATHS = NO; 434 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 435 | CLANG_CXX_LIBRARY = "libc++"; 436 | CLANG_ENABLE_MODULES = YES; 437 | CLANG_ENABLE_OBJC_ARC = YES; 438 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 439 | CLANG_WARN_BOOL_CONVERSION = YES; 440 | CLANG_WARN_COMMA = YES; 441 | CLANG_WARN_CONSTANT_CONVERSION = YES; 442 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 443 | CLANG_WARN_EMPTY_BODY = YES; 444 | CLANG_WARN_ENUM_CONVERSION = YES; 445 | CLANG_WARN_INFINITE_RECURSION = YES; 446 | CLANG_WARN_INT_CONVERSION = YES; 447 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 448 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 449 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 450 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 451 | CLANG_WARN_STRICT_PROTOTYPES = YES; 452 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 453 | CLANG_WARN_UNREACHABLE_CODE = YES; 454 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 455 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 456 | COPY_PHASE_STRIP = NO; 457 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 458 | ENABLE_NS_ASSERTIONS = NO; 459 | ENABLE_STRICT_OBJC_MSGSEND = YES; 460 | GCC_C_LANGUAGE_STANDARD = gnu99; 461 | GCC_NO_COMMON_BLOCKS = YES; 462 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 463 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 464 | GCC_WARN_UNDECLARED_SELECTOR = YES; 465 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 466 | GCC_WARN_UNUSED_FUNCTION = YES; 467 | GCC_WARN_UNUSED_VARIABLE = YES; 468 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 469 | MTL_ENABLE_DEBUG_INFO = NO; 470 | SDKROOT = iphoneos; 471 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 472 | VALIDATE_PRODUCT = YES; 473 | }; 474 | name = Release; 475 | }; 476 | 607FACF01AFB9204008FA782 /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | baseConfigurationReference = 5C07EA9ACB191E931288B6CE /* Pods-Loady_Example.debug.xcconfig */; 479 | buildSettings = { 480 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 481 | INFOPLIST_FILE = Loady/Info.plist; 482 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 483 | MODULE_NAME = ExampleApp; 484 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 487 | SWIFT_VERSION = 4.0; 488 | }; 489 | name = Debug; 490 | }; 491 | 607FACF11AFB9204008FA782 /* Release */ = { 492 | isa = XCBuildConfiguration; 493 | baseConfigurationReference = 7C5CE2A3A8AD2BB74E28E436 /* Pods-Loady_Example.release.xcconfig */; 494 | buildSettings = { 495 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 496 | INFOPLIST_FILE = Loady/Info.plist; 497 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 498 | MODULE_NAME = ExampleApp; 499 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 502 | SWIFT_VERSION = 4.0; 503 | }; 504 | name = Release; 505 | }; 506 | 607FACF31AFB9204008FA782 /* Debug */ = { 507 | isa = XCBuildConfiguration; 508 | baseConfigurationReference = CF8A97AAF625D7EF236EAD92 /* Pods-Loady_Tests.debug.xcconfig */; 509 | buildSettings = { 510 | FRAMEWORK_SEARCH_PATHS = ( 511 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 512 | "$(inherited)", 513 | ); 514 | GCC_PREPROCESSOR_DEFINITIONS = ( 515 | "DEBUG=1", 516 | "$(inherited)", 517 | ); 518 | INFOPLIST_FILE = Tests/Info.plist; 519 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 520 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 521 | PRODUCT_NAME = "$(TARGET_NAME)"; 522 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 523 | SWIFT_VERSION = 4.0; 524 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Loady_Example.app/Loady_Example"; 525 | }; 526 | name = Debug; 527 | }; 528 | 607FACF41AFB9204008FA782 /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | baseConfigurationReference = 438B458B2CF3360AAD57CEA6 /* Pods-Loady_Tests.release.xcconfig */; 531 | buildSettings = { 532 | FRAMEWORK_SEARCH_PATHS = ( 533 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 534 | "$(inherited)", 535 | ); 536 | INFOPLIST_FILE = Tests/Info.plist; 537 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 538 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 539 | PRODUCT_NAME = "$(TARGET_NAME)"; 540 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 541 | SWIFT_VERSION = 4.0; 542 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Loady_Example.app/Loady_Example"; 543 | }; 544 | name = Release; 545 | }; 546 | /* End XCBuildConfiguration section */ 547 | 548 | /* Begin XCConfigurationList section */ 549 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Loady" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | 607FACED1AFB9204008FA782 /* Debug */, 553 | 607FACEE1AFB9204008FA782 /* Release */, 554 | ); 555 | defaultConfigurationIsVisible = 0; 556 | defaultConfigurationName = Release; 557 | }; 558 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Loady_Example" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | 607FACF01AFB9204008FA782 /* Debug */, 562 | 607FACF11AFB9204008FA782 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Loady_Tests" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | 607FACF31AFB9204008FA782 /* Debug */, 571 | 607FACF41AFB9204008FA782 /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | /* End XCConfigurationList section */ 577 | }; 578 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 579 | } 580 | -------------------------------------------------------------------------------- /Example/Loady.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Loady.xcodeproj/xcshareddata/xcschemes/Loady-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 65 | 66 | 67 | 68 | 70 | 76 | 77 | 78 | 79 | 80 | 90 | 92 | 98 | 99 | 100 | 101 | 107 | 109 | 115 | 116 | 117 | 118 | 120 | 121 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /Example/Loady.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/Loady.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Loady/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Loady 4 | // 5 | // Created by farshadjahanmanesh on 11/07/2019. 6 | // Copyright (c) 2019 farshadjahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/Loady/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/Loady/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 37 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 174 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 260 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 298 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 334 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "image.png" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "original" 14 | } 15 | } -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/image.imageset/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Example/Loady/Images.xcassets/image.imageset/image.png -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/locked.imageset/002-locked-padlock.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Example/Loady/Images.xcassets/locked.imageset/002-locked-padlock.pdf -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/locked.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "002-locked-padlock.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "template", 14 | "preserves-vector-representation" : true 15 | } 16 | } -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/new.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "new-product.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "template", 14 | "preserves-vector-representation" : true 15 | } 16 | } -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/new.imageset/new-product.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Example/Loady/Images.xcassets/new.imageset/new-product.pdf -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/pause-button.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "pause-button.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "compression-type" : "automatic", 14 | "template-rendering-intent" : "template", 15 | "preserves-vector-representation" : true 16 | } 17 | } -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/pause-button.imageset/pause-button.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Example/Loady/Images.xcassets/pause-button.imageset/pause-button.pdf -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/unlocked.imageset/001-unlock.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Example/Loady/Images.xcassets/unlocked.imageset/001-unlock.pdf -------------------------------------------------------------------------------- /Example/Loady/Images.xcassets/unlocked.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "001-unlock.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "template", 14 | "preserves-vector-representation" : true 15 | } 16 | } -------------------------------------------------------------------------------- /Example/Loady/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/Loady/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Loady 4 | // 5 | // Created by farshadjahanmanesh on 11/07/2019. 6 | // Copyright (c) 2019 farshadjahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Loady 11 | class ViewController: UIViewController { 12 | var tempTimer1 : Timer? 13 | var tempTimer2 : Timer? 14 | var tempTimer3 : Timer? 15 | var tempTimer4 : Timer? 16 | var fourPhaseTempTimer : Timer? 17 | @IBOutlet var circleView : LoadyButton! 18 | @IBOutlet var uberLikeView : LoadyButton! 19 | @IBOutlet var fillingView : LoadyButton! 20 | @IBOutlet var indicatorViewLike : LoadyButton! 21 | @IBOutlet var appstore : LoadyButton! 22 | @IBOutlet var androidLoading : LoadyButton! 23 | @IBOutlet var downloading : LoadyButton! 24 | @IBOutlet var fourPhases : LoadyFourPhaseButton! 25 | 26 | override func viewDidLoad() { 27 | super.viewDidLoad() 28 | 29 | // start and stop animating on user touch 30 | self.circleView.addTarget(self, action: #selector(animateView(_:)), for: .touchUpInside) 31 | self.uberLikeView.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 32 | self.fillingView.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 33 | self.indicatorViewLike.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 34 | self.appstore.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 35 | self.fourPhases.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 36 | self.androidLoading.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 37 | self.downloading.addTarget(self, action:#selector(animateView(_:)), for:.touchUpInside) 38 | 39 | self.circleView.setAnimation(LoadyAnimationType.circleAndTick()) 40 | self.uberLikeView.setAnimation(LoadyAnimationType.topLine()) 41 | self.fillingView.setAnimation(LoadyAnimationType.backgroundHighlighter()) 42 | self.indicatorViewLike.setAnimation(LoadyAnimationType.indicator(with: .init(indicatorViewStyle: .light))) 43 | self.androidLoading.setAnimation(LoadyAnimationType.android()) 44 | self.downloading.setAnimation(LoadyAnimationType.downloading(with: .init( 45 | downloadingLabel: (title: "Copying Data...", font: UIFont.boldSystemFont(ofSize: 18), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)), 46 | percentageLabel: (font: UIFont.boldSystemFont(ofSize: 14), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)), 47 | downloadedLabel: (title: "Completed.", font: UIFont.boldSystemFont(ofSize: 20), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)) 48 | ) 49 | )) 50 | 51 | self.appstore.setAnimation(LoadyAnimationType.appstore(with: .init(shrinkFrom: .fromRight))) 52 | self.appstore?.pauseImage = UIImage(named: "pause-button") 53 | self.appstore?.backgroundFillColor = UIColor.lightGray.withAlphaComponent(0.4) 54 | 55 | // starts loading animation 56 | // self.allInOneview?.startLoading() 57 | 58 | // some animations have filling background, or change the circle stroke, this sets the filling percent, number is something between 0 to 100 59 | self.fourPhases.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0) 60 | self.fourPhases.setPhases(phases: .init(normalPhase: 61 | (title: "Lock", image: UIImage(named: "unlocked"), background: UIColor(red:0.00, green:0.49, blue:0.90, alpha:1.0)), loadingPhase: 62 | (title: "Waiting...", image: nil, background: UIColor(red:0.17, green:0.24, blue:0.31, alpha:1.0)), successPhase: 63 | (title: "Activated", image: UIImage(named: "locked"), background: UIColor(red:0.15, green:0.68, blue:0.38, alpha:1.0)), errorPhase: 64 | (title: "Error", image: UIImage(named: "unlocked"), background: UIColor(red:0.64, green:0.00, blue:0.15, alpha:1.0)))) 65 | } 66 | 67 | @IBAction func animateView(_ sender : UIButton){ 68 | if let button = sender as? LoadyFourPhaseButton { 69 | if button.loadingIsShowing() { 70 | button.stopLoading() 71 | return 72 | } 73 | button.startLoading() 74 | self.fourPhaseTempTimer?.invalidate() 75 | self.fourPhaseTempTimer = nil 76 | self.fourPhases.loadingPhase() 77 | if #available(iOS 10.0, *) { 78 | self.fourPhaseTempTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true){(t) in 79 | if self.fourPhases.tag == 0 { 80 | self.fourPhases.errorPhase() 81 | self.fourPhases.tag = 1 82 | }else if self.fourPhases?.tag == 1{ 83 | self.fourPhases.successPhase() 84 | self.fourPhases.tag = 2 85 | } else{ 86 | self.fourPhases.normalPhase() 87 | self.fourPhases.tag = 0 88 | } 89 | } 90 | } 91 | DispatchQueue.main.asyncAfter(deadline: .now() + 3) { 92 | self.fourPhaseTempTimer?.fire() 93 | } 94 | return 95 | } 96 | 97 | guard let button = sender as? LoadyButton else { 98 | return 99 | } 100 | if button.loadingIsShowing() { 101 | button.stopLoading() 102 | return 103 | } 104 | button.startLoading() 105 | var percent : CGFloat = 0 106 | switch button.animationType { 107 | case LoadyBackgroundHighlighterAnimation.animationTypeKey: 108 | self.tempTimer1?.invalidate() 109 | self.tempTimer1 = nil 110 | if #available(iOS 10.0, *) { 111 | self.tempTimer1 = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { (t) in 112 | percent += CGFloat.random(in: 0...10) 113 | button.update(percent: percent) 114 | if percent > 105 { 115 | percent = 100 116 | self.tempTimer1?.invalidate() 117 | } 118 | } 119 | } 120 | self.tempTimer1?.fire() 121 | case LoadyCircleAndTickAnimation.animationTypeKey: 122 | self.tempTimer2?.invalidate() 123 | self.tempTimer2 = nil 124 | if #available(iOS 10.0, *) { 125 | self.tempTimer2 = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { (t) in 126 | percent += CGFloat.random(in: 0...10) 127 | button.update(percent: percent) 128 | if percent > 105 { 129 | percent = 100 130 | self.tempTimer2?.invalidate() 131 | } 132 | } 133 | } 134 | self.tempTimer2?.fire() 135 | case LoadyAppStoreAnimation.animationTypeKey: 136 | self.tempTimer3?.invalidate() 137 | self.tempTimer3 = nil 138 | if #available(iOS 10.0, *) { 139 | self.tempTimer3 = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { (t) in 140 | percent += CGFloat.random(in: 0...10) 141 | button.update(percent: percent) 142 | 143 | if percent > 105 { 144 | percent = 100 145 | self.tempTimer3?.invalidate() 146 | } 147 | 148 | } 149 | } 150 | self.tempTimer3?.fire() 151 | case LoadyDownloadingAnimation.animationTypeKey: 152 | self.tempTimer4?.invalidate() 153 | self.tempTimer4 = nil 154 | if #available(iOS 10.0, *) { 155 | self.tempTimer4 = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true){(t) in 156 | percent += CGFloat.random(in: 5...10) 157 | 158 | button.update(percent: percent) 159 | if percent > 105 { 160 | percent = 100 161 | self.tempTimer4?.invalidate() 162 | } 163 | } 164 | } 165 | self.tempTimer4?.fire() 166 | default: 167 | break; 168 | } 169 | } 170 | 171 | 172 | } 173 | 174 | 175 | // YOU CAN USE NVActivityIndicatorView VERY EASY LIKE THIS 176 | // 177 | // extension NVActivityIndicatorView : LoadyActivityIndicator { 178 | // 179 | // } 180 | // 181 | // let av2 = NVActivityIndicatorView(frame: .zero) 182 | // av2.type = .orbit 183 | // av2.color = UIColor(red:0, green:0.71, blue:0.8, alpha:1) 184 | // av2.padding = 12 185 | // self.allInOneview?.activiyIndicator = av2 186 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'Loady_Example' do 4 | pod 'Loady', :path => '../' 5 | 6 | target 'Loady_Tests' do 7 | inherit! :search_paths 8 | 9 | 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Loady (0.1.0) 3 | 4 | DEPENDENCIES: 5 | - Loady (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | Loady: 9 | :path: "../" 10 | 11 | SPEC CHECKSUMS: 12 | Loady: dde064eb73fa744124f0128c8404dba34974a2aa 13 | 14 | PODFILE CHECKSUM: 604ccd27563e81578a155159721ab9adfa038a35 15 | 16 | COCOAPODS: 1.7.5 17 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/Loady.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Loady", 3 | "version": "0.1.0", 4 | "summary": "A short description of Loady.", 5 | "description": "TODO: Add long description of the pod here.", 6 | "homepage": "https://github.com/farshadjahanmanesh/Loady", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENSE" 10 | }, 11 | "authors": { 12 | "farshadjahanmanesh": "farshadjahanmanesh@gmail.com" 13 | }, 14 | "source": { 15 | "git": "https://github.com/farshadjahanmanesh/Loady.git", 16 | "tag": "0.1.0" 17 | }, 18 | "platforms": { 19 | "ios": "8.0" 20 | }, 21 | "source_files": "Loady/Classes/**/*" 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Loady (0.1.0) 3 | 4 | DEPENDENCIES: 5 | - Loady (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | Loady: 9 | :path: "../" 10 | 11 | SPEC CHECKSUMS: 12 | Loady: dde064eb73fa744124f0128c8404dba34974a2aa 13 | 14 | PODFILE CHECKSUM: 604ccd27563e81578a155159721ab9adfa038a35 15 | 16 | COCOAPODS: 1.7.5 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Loady/Loady-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Loady/Loady-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Loady : NSObject 3 | @end 4 | @implementation PodsDummy_Loady 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Loady/Loady-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Loady/Loady-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double LoadyVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char LoadyVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Loady/Loady.modulemap: -------------------------------------------------------------------------------- 1 | framework module Loady { 2 | umbrella header "Loady-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Loady/Loady.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Loady 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Loady 5 | 6 | Copyright (c) 2019 farshadjahanmanesh 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2019 farshadjahanmanesh <farshadjahanmanesh@gmail.com> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | Loady 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Generated by CocoaPods - https://cocoapods.org 47 | Title 48 | 49 | Type 50 | PSGroupSpecifier 51 | 52 | 53 | StringsTable 54 | Acknowledgements 55 | Title 56 | Acknowledgements 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Loady_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Loady_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | set -u 4 | set -o pipefail 5 | 6 | function on_error { 7 | echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" 8 | } 9 | trap 'on_error $LINENO' ERR 10 | 11 | if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then 12 | # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy 13 | # frameworks to, so exit 0 (signalling the script phase was successful). 14 | exit 0 15 | fi 16 | 17 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 18 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 19 | 20 | COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" 21 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 22 | 23 | # Used as a return value for each invocation of `strip_invalid_archs` function. 24 | STRIP_BINARY_RETVAL=0 25 | 26 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 27 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 28 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 29 | 30 | # Copies and strips a vendored framework 31 | install_framework() 32 | { 33 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 34 | local source="${BUILT_PRODUCTS_DIR}/$1" 35 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 36 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 37 | elif [ -r "$1" ]; then 38 | local source="$1" 39 | fi 40 | 41 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 42 | 43 | if [ -L "${source}" ]; then 44 | echo "Symlinked..." 45 | source="$(readlink "${source}")" 46 | fi 47 | 48 | # Use filter instead of exclude so missing patterns don't throw errors. 49 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 50 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 51 | 52 | local basename 53 | basename="$(basename -s .framework "$1")" 54 | binary="${destination}/${basename}.framework/${basename}" 55 | 56 | if ! [ -r "$binary" ]; then 57 | binary="${destination}/${basename}" 58 | elif [ -L "${binary}" ]; then 59 | echo "Destination binary is symlinked..." 60 | dirname="$(dirname "${binary}")" 61 | binary="${dirname}/$(readlink "${binary}")" 62 | fi 63 | 64 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 65 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 66 | strip_invalid_archs "$binary" 67 | fi 68 | 69 | # Resign the code if required by the build settings to avoid unstable apps 70 | code_sign_if_enabled "${destination}/$(basename "$1")" 71 | 72 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 73 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 74 | local swift_runtime_libs 75 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) 76 | for lib in $swift_runtime_libs; do 77 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 78 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 79 | code_sign_if_enabled "${destination}/${lib}" 80 | done 81 | fi 82 | } 83 | 84 | # Copies and strips a vendored dSYM 85 | install_dsym() { 86 | local source="$1" 87 | if [ -r "$source" ]; then 88 | # Copy the dSYM into a the targets temp dir. 89 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" 90 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" 91 | 92 | local basename 93 | basename="$(basename -s .framework.dSYM "$source")" 94 | binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" 95 | 96 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 97 | if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then 98 | strip_invalid_archs "$binary" 99 | fi 100 | 101 | if [[ $STRIP_BINARY_RETVAL == 1 ]]; then 102 | # Move the stripped file into its final destination. 103 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 104 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 105 | else 106 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. 107 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" 108 | fi 109 | fi 110 | } 111 | 112 | # Copies the bcsymbolmap files of a vendored framework 113 | install_bcsymbolmap() { 114 | local bcsymbolmap_path="$1" 115 | local destination="${BUILT_PRODUCTS_DIR}" 116 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"" 117 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" 118 | } 119 | 120 | # Signs a framework with the provided identity 121 | code_sign_if_enabled() { 122 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 123 | # Use the current code_sign_identity 124 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 125 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" 126 | 127 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 128 | code_sign_cmd="$code_sign_cmd &" 129 | fi 130 | echo "$code_sign_cmd" 131 | eval "$code_sign_cmd" 132 | fi 133 | } 134 | 135 | # Strip invalid architectures 136 | strip_invalid_archs() { 137 | binary="$1" 138 | # Get architectures for current target binary 139 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 140 | # Intersect them with the architectures we are building for 141 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 142 | # If there are no archs supported by this binary then warn the user 143 | if [[ -z "$intersected_archs" ]]; then 144 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 145 | STRIP_BINARY_RETVAL=0 146 | return 147 | fi 148 | stripped="" 149 | for arch in $binary_archs; do 150 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 151 | # Strip non-valid architectures in-place 152 | lipo -remove "$arch" -output "$binary" "$binary" 153 | stripped="$stripped $arch" 154 | fi 155 | done 156 | if [[ "$stripped" ]]; then 157 | echo "Stripped $binary of architectures:$stripped" 158 | fi 159 | STRIP_BINARY_RETVAL=1 160 | } 161 | 162 | 163 | if [[ "$CONFIGURATION" == "Debug" ]]; then 164 | install_framework "${BUILT_PRODUCTS_DIR}/Loady/Loady.framework" 165 | fi 166 | if [[ "$CONFIGURATION" == "Release" ]]; then 167 | install_framework "${BUILT_PRODUCTS_DIR}/Loady/Loady.framework" 168 | fi 169 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 170 | wait 171 | fi 172 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_Loady_ExampleVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_Loady_ExampleVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady/Loady.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "Loady" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_Loady_Example { 2 | umbrella header "Pods-Loady_Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Example/Pods-Loady_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady/Loady.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "Loady" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Loady_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Loady_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_Loady_TestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_Loady_TestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady/Loady.framework/Headers" 4 | OTHER_LDFLAGS = $(inherited) -framework "Loady" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_Loady_Tests { 2 | umbrella header "Pods-Loady_Tests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Loady_Tests/Pods-Loady_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Loady/Loady.framework/Headers" 4 | OTHER_LDFLAGS = $(inherited) -framework "Loady" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Loady 3 | 4 | class Tests: XCTestCase { 5 | 6 | override func setUp() { 7 | super.setUp() 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | } 10 | 11 | override func tearDown() { 12 | // Put teardown code here. This method is called after the invocation of each test method in the class. 13 | super.tearDown() 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | XCTAssert(true, "Pass") 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure() { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 farshad jahanmanesh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Loady.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.platform = :ios 3 | s.ios.deployment_target = '9.0' 4 | s.name = "loady" 5 | s.module_name = "Loady" 6 | s.summary = "fully customizable loading button with 8 different styles." 7 | s.requires_arc = true 8 | s.version = "1.0.8" 9 | s.license = { :type => "MIT", :file => "LICENSE" } 10 | s.author = { "farshad jahanmanesh" => "farshadjahanmanesh@gmail.com" } 11 | s.homepage = "https://github.com/farshadjahanmanesh/loady" 12 | s.source = { :git => "https://github.com/farshadjahanmanesh/loady.git", 13 | :tag => "#{s.version}" } 14 | s.framework = "UIKit" 15 | s.source_files = "Loady/Classes/**/*" 16 | #s.resources = "RWPickFlavor/**/*.{png,jpeg,jpg,storyboard,xib,xcassets}" 17 | s.swift_version = "5.0" 18 | 19 | end 20 | -------------------------------------------------------------------------------- /Loady/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Loady/Assets/.gitkeep -------------------------------------------------------------------------------- /Loady/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/Loady/Classes/.gitkeep -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyAndroidAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyAndroidAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | public extension LoadyAnimationType { 11 | static func android()->LoadyAndroidAnimation{ 12 | return LoadyAndroidAnimation() 13 | } 14 | } 15 | public class LoadyAndroidAnimation { 16 | private var loading: Bool = false 17 | public func isLoading() -> Bool { 18 | return loading 19 | } 20 | 21 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "circleAndTick") 22 | private unowned var loady: Loadiable! 23 | private var strokeFillerLayer: CAShapeLayer? 24 | private func startCircluarLoadingAnimation(_ layer : CAShapeLayer) { 25 | var time: CFTimeInterval = 0 26 | var times = [CFTimeInterval]() 27 | var start: CGFloat = 0 28 | var rotations = [CGFloat]() 29 | var strokeEnds = [CGFloat]() 30 | let poses = LoadyCore.poses 31 | let totalSeconds = poses.reduce(0) { $0 + $1.secondsSincePriorPose } 32 | 33 | for pose in poses { 34 | time += pose.secondsSincePriorPose 35 | times.append(time / totalSeconds) 36 | start = pose.start 37 | rotations.append(start * 2 * .pi) 38 | strokeEnds.append(pose.length) 39 | } 40 | 41 | times.append(times.last!) 42 | rotations.append(rotations[0]) 43 | strokeEnds.append(strokeEnds[0]) 44 | 45 | LoadyCore.animateKeyPath(layer,keyPath: "strokeEnd", duration: totalSeconds, times: times, values: strokeEnds) 46 | LoadyCore.animateKeyPath(layer,keyPath: "transform.rotation", duration: totalSeconds, times: times, values: rotations) 47 | 48 | animateStrokeHueWithDuration(layer ,duration: totalSeconds * 5) 49 | } 50 | 51 | private func animateStrokeHueWithDuration(_ layer : CAShapeLayer, duration: CFTimeInterval) { 52 | let count = 200 53 | let animation = CAKeyframeAnimation(keyPath: "strokeColor") 54 | animation.keyTimes = (0 ... count).map { NSNumber(value: CFTimeInterval($0) / CFTimeInterval(count)) } 55 | let loadingColor = self.loady.loadingColor 56 | animation.values = (0 ... count).map {num in 57 | if num <= 3 && animation.accessibilityHint == nil{ 58 | return loadingColor.withAlphaComponent(CGFloat(num) / 3.0).cgColor 59 | }else{ 60 | return loadingColor.cgColor 61 | } 62 | } 63 | animation.duration = duration 64 | animation.calculationMode = .linear 65 | animation.autoreverses = true 66 | 67 | animation.repeatCount = Float.infinity 68 | layer.add(animation, forKey: animation.keyPath) 69 | } 70 | } 71 | 72 | extension LoadyAndroidAnimation: LoadyAnimation, LoadyPercentageObserver { 73 | public func inject(loady: Loadiable) { 74 | self.loady = loady 75 | } 76 | 77 | public func stop() { 78 | loading = false 79 | strokeFillerLayer?.removeAllAnimations() 80 | strokeFillerLayer?.removeFromSuperlayer() 81 | loady.reloadDefaultState(duration: 0.5) { [weak strokeFillerLayer] in 82 | strokeFillerLayer?.removeFromSuperlayer() 83 | strokeFillerLayer = nil; 84 | } 85 | } 86 | 87 | public func run() { 88 | loading = true 89 | let center = self.loady.center 90 | self.loady.cleanCanvas() 91 | let radius = min(self.loady.bounds.width, self.loady.bounds.height) 92 | 93 | UIView.animate(withDuration: 0.3, animations: { 94 | self.loady.center = center 95 | self.loady.layer.bounds = CGRect(x: self.loady.center.x, y: self.loady.center.y, width: radius, height: radius) 96 | self.loady.layer.cornerRadius = radius / 2 97 | self.loady.backgroundColor = self.loady.backgroundFillColor 98 | self.loady.layoutIfNeeded() 99 | }, completion: { (finished) in 100 | if(finished){ 101 | self.strokeFillerLayer = LoadyCore.createCircleInside(bounds: self.loady.bounds.insetBy(dx: -4, dy: -4), strokeColor: self.loady.loadingColor) 102 | self.loady.addSublayer(self.strokeFillerLayer!) 103 | self.startCircluarLoadingAnimation(self.strokeFillerLayer!) 104 | } 105 | }) 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyAppStoreAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyAppStoreAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/5/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension LoadyAnimationType { 12 | static func appstore(with options: LoadyAppStoreAnimation.AnimationOption)->LoadyAppStoreAnimation{ 13 | return LoadyAppStoreAnimation(options: options) 14 | } 15 | } 16 | 17 | // MARK: - Creates the AppStore 18 | public class LoadyAppStoreAnimation { 19 | private var loading: Bool = false 20 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "appstore") 21 | public struct AnimationOption { 22 | public enum ShrinkStyle { 23 | case fromLeft 24 | case fromRight 25 | } 26 | public var shrinkFrom: ShrinkStyle = .fromLeft 27 | public init(shrinkFrom: ShrinkStyle) { 28 | self.shrinkFrom = shrinkFrom 29 | } 30 | } 31 | init(options: AnimationOption) { 32 | self.options = options 33 | } 34 | 35 | init(loady: Loadiable, options: AnimationOption) { 36 | self.loady = loady 37 | self.options = options 38 | } 39 | private unowned var loady: Loadiable! 40 | private let options: AnimationOption 41 | private var circleContainer: CAShapeLayer? 42 | private var strokeFillerLayer: CAShapeLayer? 43 | 44 | public func change(from: CGFloat, to: CGFloat) { 45 | let animation = LoadyCore.createBasicAnimation(keypath: "strokeEnd", from: NSNumber(floatLiteral: Double(from / 100)), to: NSNumber(floatLiteral: Double(to / 100)),duration : 0.2) 46 | animation.isRemovedOnCompletion = false; 47 | animation.fillMode = .forwards; 48 | self.strokeFillerLayer?.add(animation, forKey: nil) 49 | } 50 | 51 | private func createAppstoreLoadingLayer(){ 52 | guard let loady = self.loady else { 53 | assertionFailure("loady is not passed, please use init(loady, options)") 54 | return 55 | } 56 | let strokeFillerLayer = LoadyCore.createCircleInside(bounds: self.loady.bounds.insetBy(dx: -4, dy: -4), strokeColor: self.loady.loadingColor, centerX: self.loady.bounds.height / 2) 57 | loady.addSublayer(strokeFillerLayer) 58 | self.strokeFillerLayer = strokeFillerLayer 59 | let circleContainer = LoadyCore.copy(layer: strokeFillerLayer) 60 | circleContainer.strokeColor = UIColor.lightGray.withAlphaComponent(0.3).cgColor 61 | circleContainer.strokeStart = 0 62 | circleContainer.strokeEnd = 1 63 | circleContainer.opacity = 1 64 | // check if user specifies an image for pause 65 | if let image = self.loady.pauseImage { 66 | let imageLayer = CAShapeLayer() 67 | imageLayer.bounds = CGRect(x:0,y: 0,width: 15,height: 15); 68 | imageLayer.position = CGPoint(x: circleContainer.bounds.midX,y: circleContainer.bounds.midY); 69 | imageLayer.anchorPoint = CGPoint(x:0.5,y: 0.5); 70 | imageLayer.contents = image.cgImage 71 | circleContainer.addSublayer(imageLayer) 72 | } 73 | self.circleContainer = circleContainer 74 | loady.addSublayer(circleContainer) 75 | 76 | circleContainer.add(LoadyCore.createBasicAnimation(keypath: "opacity", from: 0.0, to: 1.0, duration: 0.2), forKey: "fade") 77 | 78 | } 79 | } 80 | 81 | extension LoadyAppStoreAnimation: LoadyAnimation, LoadyPercentageObserver { 82 | public func isLoading() -> Bool { 83 | return loading 84 | } 85 | public func inject(loady: Loadiable) { 86 | self.loady = loady 87 | } 88 | 89 | public func run() { 90 | loading = true 91 | let radius = min(self.loady.frame.size.width, self.loady.frame.size.height) * 0.7 92 | let xPosition = self.options.shrinkFrom == .fromRight ? 0 : self.loady.bounds.width - radius 93 | self.loady.cleanCanvas() 94 | UIView.animate(withDuration: 0.3, animations: { 95 | self.loady.layer.cornerRadius = radius / 2 96 | self.loady.layer.bounds = CGRect(x: 0,y: self.loady.center.y,width: radius,height: radius) 97 | self.loady.frame.origin.x = xPosition 98 | self.loady.alpha = 1 99 | self.loady.backgroundColor = self.loady.backgroundFillColor 100 | self.loady.layoutIfNeeded() 101 | }) {done in 102 | self.createAppstoreLoadingLayer() 103 | } 104 | } 105 | 106 | public func stop() { 107 | loading = false 108 | circleContainer?.removeFromSuperlayer() 109 | strokeFillerLayer?.removeAllAnimations() 110 | strokeFillerLayer?.removeFromSuperlayer() 111 | loady.reloadDefaultState(duration: 0.5) { [weak strokeFillerLayer] in 112 | strokeFillerLayer?.removeFromSuperlayer() 113 | strokeFillerLayer = nil; 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyBackgroundHighlighter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyBackgroundHighlighter.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | public extension LoadyAnimationType { 11 | static func backgroundHighlighter()->LoadyBackgroundHighlighterAnimation{ 12 | return LoadyBackgroundHighlighterAnimation() 13 | } 14 | } 15 | 16 | public class LoadyBackgroundHighlighterAnimation: LoadyAnimation, LoadyPercentageObserver { 17 | var fillingLayer: CAShapeLayer? 18 | var containerLayer: CAShapeLayer? 19 | private func createFillingLoading(){ 20 | //a shape for filling the button 21 | let fillingLayer = CAShapeLayer(); 22 | fillingLayer.backgroundColor = self.loady.backgroundFillColor.cgColor 23 | fillingLayer.bounds = CGRect(x:0,y:0, width: 0,height: self.loady.frame.size.height); 24 | fillingLayer.anchorPoint = CGPoint(x:0,y:0.5); 25 | fillingLayer.position = CGPoint(x:0,y: self.loady.frame.size.height / 2); 26 | fillingLayer.masksToBounds = true 27 | self.fillingLayer = fillingLayer 28 | //create aniamtion 29 | let containerLayer = CAShapeLayer() 30 | containerLayer.bounds = CGRect(x:0,y:0,width: self.loady.frame.size.width,height: self.loady.frame.size.height) 31 | containerLayer.position = CGPoint(x:self.loady.frame.size.width / 2, y: self.loady.frame.size.height / 2) 32 | containerLayer.masksToBounds = true 33 | containerLayer.cornerRadius = self.loady.layer.cornerRadius 34 | containerLayer.insertSublayer(fillingLayer,at:0) 35 | self.containerLayer = containerLayer 36 | 37 | self.loady.addSublayer(self.containerLayer!, at: 0); 38 | } 39 | 40 | private var loading: Bool = false 41 | public func isLoading() -> Bool { 42 | return loading 43 | } 44 | 45 | public func inject(loady: Loadiable) { 46 | self.loady = loady 47 | } 48 | 49 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "backgroundHighlighter") 50 | private unowned var loady: Loadiable! 51 | private var strokeFillerLayer: CAShapeLayer? 52 | 53 | public func change(from: CGFloat, to: CGFloat) { 54 | 55 | self.fillingLayer?.bounds = CGRect(x : 0, y: (self.loady.frame.size.height / 2), width: (self.loady.frame.size.width * (to / 100)), height: self.loady.frame.size.height) 56 | } 57 | 58 | public func run() { 59 | loading = true 60 | createFillingLoading() 61 | 62 | } 63 | 64 | public func stop() { 65 | loading = false 66 | self.containerLayer?.removeFromSuperlayer() 67 | self.containerLayer = nil 68 | self.fillingLayer?.removeFromSuperlayer() 69 | self.fillingLayer = nil 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyCircleAndThickAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyCircleAndThickAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/5/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | public extension LoadyAnimationType { 11 | static func circleAndTick()->LoadyCircleAndTickAnimation{ 12 | return LoadyCircleAndTickAnimation() 13 | } 14 | } 15 | public class LoadyCircleAndTickAnimation: LoadyAnimation, LoadyPercentageObserver { 16 | private var loading: Bool = false 17 | public func isLoading() -> Bool { 18 | return loading 19 | } 20 | 21 | public func inject(loady: Loadiable) { 22 | self.loady = loady 23 | } 24 | 25 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "circleAndTick") 26 | private unowned var loady: Loadiable! 27 | private var strokeFillerLayer: CAShapeLayer? 28 | 29 | public func change(from: CGFloat, to: CGFloat) { 30 | let animation = LoadyCore.createBasicAnimation(keypath: "strokeEnd", from: NSNumber(floatLiteral: Double(from / 100)), to: NSNumber(floatLiteral: Double(to / 100)),duration : 0.2) 31 | animation.isRemovedOnCompletion = false; 32 | animation.fillMode = .forwards; 33 | self.strokeFillerLayer?.add(animation, forKey: nil) 34 | } 35 | 36 | public func run() { 37 | loading = true 38 | let center = self.loady.center 39 | self.loady.cleanCanvas() 40 | let radius = min(self.loady.bounds.width, self.loady.bounds.height) 41 | 42 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { 43 | UIView.animate(withDuration: 0.5, animations: { 44 | self.loady.center = center 45 | self.loady.transform = CGAffineTransform(scaleX: -1,y: 1) 46 | self.loady.bounds = CGRect(x:self.loady.center.x,y: self.loady.center.y,width: radius,height: radius) 47 | self.loady.layer.cornerRadius = radius / 2 48 | self.loady.backgroundColor = self.loady.backgroundFillColor 49 | self.loady.layoutIfNeeded() 50 | }, completion: { (finished) in 51 | if(finished){ 52 | self.strokeFillerLayer = LoadyCore.createCircleInside(bounds: self.loady.bounds, strokeColor: self.loady.loadingColor) 53 | self.loady.addSublayer(self.strokeFillerLayer!) 54 | } 55 | }) 56 | } 57 | } 58 | 59 | public func stop() { 60 | loading = false 61 | strokeFillerLayer?.removeAllAnimations() 62 | strokeFillerLayer?.removeFromSuperlayer() 63 | loady.reloadDefaultState(duration: 0.5) { [weak strokeFillerLayer] in 64 | strokeFillerLayer?.removeFromSuperlayer() 65 | strokeFillerLayer = nil; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyDownloadingAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyDownloadingAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension LoadyAnimationType { 12 | static func downloading(with options: LoadyDownloadingAnimation.AnimationOption)->LoadyDownloadingAnimation{ 13 | return LoadyDownloadingAnimation(options: options) 14 | } 15 | } 16 | 17 | public class LoadyDownloadingAnimation { 18 | public struct AnimationOption { 19 | public typealias Label = (title:String,font : UIFont, textColor : UIColor) 20 | var downloadingLabel : Label? 21 | var percentageLabel: (font : UIFont, textColor : UIColor)? 22 | var downloadedLabel : Label? 23 | public init(downloadingLabel : Label?,percentageLabel: (font : UIFont, textColor : UIColor)?,downloadedLabel : Label?) { 24 | self.downloadingLabel = downloadingLabel 25 | self.percentageLabel = percentageLabel 26 | self.downloadedLabel = downloadedLabel 27 | } 28 | } 29 | private let options: AnimationOption 30 | init(options: AnimationOption) { 31 | self.options = options 32 | } 33 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "indicator") 34 | lazy var activiyIndicator : LoadyActivityIndicator = { UIActivityIndicatorView() }() 35 | private unowned var loady: (Loadiable & UIButton)! 36 | private var loading: Bool = false 37 | var fillingLayer: CAShapeLayer? 38 | var containerLayer: CAShapeLayer? 39 | private func createFillingLoading(){ 40 | //a shape for filling the button 41 | let fillingLayer = CAShapeLayer(); 42 | fillingLayer.backgroundColor = self.loady.backgroundFillColor.cgColor 43 | fillingLayer.bounds = CGRect(x:0,y:0, width: 0,height: 4); 44 | fillingLayer.anchorPoint = CGPoint(x:0,y:0.5); 45 | fillingLayer.position = CGPoint(x:0,y: self.loady.frame.size.height / 2); 46 | fillingLayer.masksToBounds = true 47 | self.fillingLayer = fillingLayer 48 | //create aniamtion 49 | let containerLayer = CAShapeLayer() 50 | containerLayer.bounds = CGRect(x:0,y:0,width: self.loady.frame.size.width,height: 4) 51 | containerLayer.position = CGPoint(x:self.loady.frame.size.width / 2, y: self.loady.frame.size.height / 2) 52 | containerLayer.masksToBounds = true 53 | containerLayer.cornerRadius = self.loady.layer.cornerRadius 54 | containerLayer.insertSublayer(fillingLayer,at:0) 55 | self.containerLayer = containerLayer 56 | self.loady.addSublayer(self.containerLayer!, at: 0); 57 | } 58 | private func createDownloadingLayer(){ 59 | let center = self.loady.center 60 | self.loady.cleanCanvas() 61 | UIView.animate(withDuration: 0.25, animations: { 62 | self.loady.center = center; 63 | self.loady.layer.bounds.size.height = 5 64 | self.loady.layer.cornerRadius = 5 / 2; 65 | self.loady.layoutIfNeeded() 66 | }, completion: { (finished) in 67 | if(finished){ 68 | //filling animation 69 | self.createFillingLoading() 70 | if let _ = self.options.downloadingLabel { 71 | self.createDownloadingLabelLayer() 72 | } 73 | if let _ = self.options.percentageLabel { 74 | self.createPercentageLabelLayer() 75 | } 76 | } 77 | }) 78 | 79 | } 80 | var labelLayer: CATextLayer? 81 | var percentageLayer: CATextLayer? 82 | 83 | 84 | private func createDownloadingLabelLayer(){ 85 | // create a temp layer to hide animation behide it 86 | let containerLayer = CAShapeLayer() 87 | let size = CGSize(width: self.loady.bounds.width, height: 30) 88 | containerLayer.bounds = CGRect(x: 0, y: 0, width: size.width, height: size.height) 89 | containerLayer.position.x = containerLayer.bounds.midX 90 | containerLayer.position.y = size.height / -2 91 | let text = LoadyCore.createTextLayers(layer:containerLayer,string: options.downloadingLabel!.title, font: options.downloadingLabel!.font) 92 | text.foregroundColor = options.downloadingLabel!.textColor.cgColor 93 | containerLayer.addSublayer(text) 94 | labelLayer = text 95 | 96 | // add animation 97 | UIView.beginAnimations("changeTextTransition", context: nil) 98 | let animation = LoadyCore.createTextPushAnimation(type: .fromTop, duration: 0.3) 99 | text.add(animation, forKey:"changeTextTransition") 100 | containerLayer.masksToBounds = true 101 | self.loady.addSublayer(containerLayer, at: 0) 102 | UIView.commitAnimations() 103 | } 104 | 105 | private func finishDownloading(){ 106 | guard let downloadLabel = labelLayer, let downloadedOption = options.downloadedLabel else { 107 | return 108 | } 109 | // add animation 110 | UIView.beginAnimations("changeTextTransition", context: nil) 111 | downloadLabel.string = downloadedOption.title 112 | downloadLabel.foregroundColor = downloadedOption.textColor.cgColor 113 | downloadLabel.font = downloadedOption.font 114 | downloadLabel.position.x = self.loady.layer.position.x 115 | downloadLabel.fontSize = downloadedOption.font.pointSize 116 | let animation = LoadyCore.createTextPushAnimation(type: .fromTop, duration: 0.3) 117 | downloadLabel.add(animation, forKey:"changeTextTransition") 118 | UIView.commitAnimations() 119 | } 120 | 121 | private func createPercentageLabelLayer(){ 122 | // create a temp layer to hide animation behide it 123 | let containerLayer = CAShapeLayer() 124 | let size = CGSize(width: self.loady.bounds.width, height: 30) 125 | containerLayer.bounds = CGRect(x: 0, y: 0, width: size.width, height: size.height) 126 | containerLayer.position.x = containerLayer.bounds.midX 127 | containerLayer.position.y = (self.loady.bounds.height + size.height / 2) + 8 128 | //layer.backgroundColor = UIColor.green.cgColor 129 | let text = LoadyCore.createTextLayers(layer:containerLayer,string: "0%", font: options.percentageLabel!.font) 130 | text.foregroundColor = options.percentageLabel!.textColor.cgColor 131 | containerLayer.addSublayer(text) 132 | percentageLayer = text 133 | 134 | // add animation 135 | UIView.beginAnimations("changeTextTransition", context: nil) 136 | let animation = LoadyCore.createTextPushAnimation(type: .fromBottom, duration: 0.3) 137 | text.add(animation, forKey:"changeTextTransitionPercent") 138 | containerLayer.masksToBounds = true 139 | self.loady.addSublayer(containerLayer, at: 1) 140 | UIView.commitAnimations() 141 | } 142 | } 143 | 144 | extension LoadyDownloadingAnimation: LoadyAnimation, LoadyPercentageObserver { 145 | public func inject(loady: Loadiable) { 146 | guard let loady = loady as? Loadiable & UIButton else { 147 | assertionFailure("this animation will apply only on UIbutton") 148 | return 149 | } 150 | self.loady = loady 151 | } 152 | public func completed(lastetValue: CGFloat) { 153 | finishDownloading() 154 | } 155 | public func change(from: CGFloat, to: CGFloat) { 156 | self.fillingLayer?.bounds = CGRect(x : 0, y: (self.loady.frame.size.height / 2), width: (self.loady.frame.size.width * (to / 100)), height: self.loady.frame.size.height) 157 | percentageLayer?.string = String(format:"%.1f%%", to) 158 | } 159 | public func isLoading() -> Bool { 160 | return loading 161 | } 162 | 163 | public func run() { 164 | loading = true 165 | createDownloadingLayer() 166 | } 167 | 168 | public func stop() { 169 | loading = false 170 | self.containerLayer?.removeFromSuperlayer() 171 | labelLayer?.removeFromSuperlayer() 172 | percentageLayer?.removeFromSuperlayer() 173 | loady.reloadDefaultState(duration: 0.5, done: nil) 174 | } 175 | } 176 | 177 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyFourPhaseAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyFourPhaseAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension LoadyAnimationType.Key { 12 | static func phasy(phases: LoadyAnimationOptions.FourPhases)->LoadyFourPhaseAnimation{ 13 | return LoadyFourPhaseAnimation(phases: phases) 14 | } 15 | } 16 | 17 | // MARK: - Creates the Four Phases 18 | public class LoadyFourPhaseAnimation { 19 | private var loading: Bool = false 20 | public static let animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "phasy") 21 | private unowned var loady: (Loadiable & UIButton)! 22 | init(phases: LoadyAnimationOptions.FourPhases) { 23 | self.phases = phases 24 | currentPhase = .normal(phases.normalPhase) 25 | } 26 | 27 | private var phases: LoadyAnimationOptions.FourPhases 28 | open private(set) var currentPhase : LoadyAnimationOptions.FourPhases.Phases 29 | // these keys are used to mark some layers as temps layer and we will remove them after animation is done 30 | private enum LayerTempKeys: String { 31 | case tempLayer = "temps" 32 | case circularLoading = "circularLoading" 33 | case downloading_percentLabel = "downloading_percentLabel" 34 | case downloading_downloadLabel = "downloading_downloadLabel" 35 | } 36 | 37 | private func createFourPhaseButton(){ 38 | UIView.animate(withDuration: 0.3) { 39 | self.loady.titleEdgeInsets = UIEdgeInsets(top: 0, left: 28, bottom: 0, right: 0); 40 | self.loady.layoutIfNeeded() 41 | } 42 | UIView.beginAnimations("changeTextTransition", context: nil) 43 | let animation = CATransition() 44 | animation.isRemovedOnCompletion = true 45 | animation.duration = 0.2 46 | animation.type = CATransitionType.push 47 | animation.subtype = CATransitionSubtype.fromTop 48 | animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) 49 | self.loady.titleLabel!.layer.add(animation, forKey:"changeTextTransition") 50 | 51 | switch currentPhase { 52 | case .normal(let name, let image , let background): 53 | self.loady.setTitle(name , for: .normal) 54 | self.loady.backgroundColor = background 55 | setupImagesInFourPhases(image) 56 | 57 | break 58 | case .loading(let name, let image, let background): 59 | self.loady.setTitle(name , for: .normal) 60 | self.loady.backgroundColor = background 61 | let circle = setupImagesInFourPhases(image,shrinkContainerLayer: true) 62 | createCircularLoading(bounds: circle.bounds, center : circle.position) 63 | break 64 | case .success(let name, let image, let background): 65 | self.loady.setTitle(name , for: .normal) 66 | self.loady.backgroundColor = background 67 | setupImagesInFourPhases(image) 68 | cleanCircularLoading() 69 | break 70 | case .error(let name, let image, let background): 71 | self.loady.setTitle(name , for: .normal) 72 | self.loady.backgroundColor = background 73 | setupImagesInFourPhases(image) 74 | cleanCircularLoading() 75 | break 76 | } 77 | UIView.commitAnimations() 78 | 79 | } 80 | open func normalPhase(){ 81 | self.currentPhase = .normal(phases.normalPhase) 82 | createFourPhaseButton() 83 | cleanCircularLoading() 84 | } 85 | open func successPhase(){ 86 | self.currentPhase = .success(phases.successPhase) 87 | createFourPhaseButton() 88 | } 89 | open func errorPhase(){ 90 | self.currentPhase = .error(phases.errorPhase) 91 | createFourPhaseButton() 92 | } 93 | 94 | open func loadingPhase(){ 95 | self.currentPhase = .loading(phases.loadingPhase) 96 | createFourPhaseButton() 97 | } 98 | @discardableResult private func setupImagesInFourPhases(_ image : UIImage? , shrinkContainerLayer : Bool = false)->CAShapeLayer{ 99 | if let imageLayer = self.loady.layer.sublayers?.first(where: { $0.accessibilityHint == LayerTempKeys.tempLayer.rawValue}) { 100 | let animation = CATransition() 101 | animation.isRemovedOnCompletion = true 102 | animation.duration = 0.2 103 | animation.type = CATransitionType.push 104 | animation.subtype = CATransitionSubtype.fromTop 105 | animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) 106 | imageLayer.sublayers?[0].add(animation, forKey:"changeImageTransition") 107 | imageLayer.sublayers?[0].contents = image?.cgImage 108 | imageLayer.sublayers?[0].contentsScale = UIScreen.main.scale 109 | if shrinkContainerLayer { 110 | imageLayer.transform = CATransform3DMakeScale(0.7, 0.7, 1); 111 | }else{ 112 | imageLayer.transform = CATransform3DMakeScale(1, 1, 1); 113 | } 114 | return imageLayer as! CAShapeLayer 115 | }else{ 116 | let radius = self.loady.bounds.height / 3 117 | let circleContainer = LoadyCore.createCircleInside(bounds: self.loady.bounds, strokeColor: self.loady.loadingColor, radius: radius) 118 | circleContainer.fillColor = UIColor.white.cgColor 119 | circleContainer.position.x = (radius * 2) - 4 120 | let imageLayer = CAShapeLayer() 121 | imageLayer.bounds = CGRect(x:0,y: 0,width: radius,height: radius); 122 | imageLayer.position = CGPoint(x:circleContainer.bounds.midY,y: circleContainer.bounds.midY); 123 | imageLayer.anchorPoint = CGPoint(x:0.5,y: 0.5); 124 | imageLayer.contents = image?.cgImage 125 | imageLayer.contentsGravity = CALayerContentsGravity.resizeAspectFill 126 | circleContainer.addSublayer(imageLayer) 127 | circleContainer.accessibilityHint = LayerTempKeys.tempLayer.rawValue 128 | 129 | self.loady.addSublayer(circleContainer) 130 | 131 | return circleContainer 132 | } 133 | } 134 | 135 | private func cleanCircularLoading(){ 136 | guard let loading = self.loady.layer.sublayers?.first(where: { $0.accessibilityHint == LayerTempKeys.circularLoading.rawValue}) else { return } 137 | let animation = LoadyCore.createBasicAnimation(keypath: "opacity", from: 1.0, to: 0.0,duration: 0.5) 138 | animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) 139 | loading.add(animation, forKey: "fade") 140 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { 141 | loading.removeFromSuperlayer() 142 | } 143 | } 144 | 145 | private func createCircularLoading(bounds : CGRect, center : CGPoint){ 146 | cleanCircularLoading() 147 | let circularLoadingLayer = CAShapeLayer() 148 | circularLoadingLayer.fillColor = UIColor.clear.cgColor 149 | circularLoadingLayer.strokeColor = UIColor.black.cgColor 150 | circularLoadingLayer.lineWidth = 3 151 | circularLoadingLayer.bounds = bounds.insetBy(dx: 9, dy: 9) 152 | circularLoadingLayer.path = UIBezierPath(ovalIn: circularLoadingLayer.bounds).cgPath 153 | circularLoadingLayer.position = center 154 | circularLoadingLayer.anchorPoint = CGPoint(x:0.5,y: 0.5); 155 | circularLoadingLayer.accessibilityHint = LayerTempKeys.circularLoading.rawValue 156 | self.loady.addSublayer(circularLoadingLayer) 157 | startCircluarLoadingAnimation(circularLoadingLayer) 158 | } 159 | 160 | private func startCircluarLoadingAnimation(_ layer : CAShapeLayer) { 161 | var time: CFTimeInterval = 0 162 | var times = [CFTimeInterval]() 163 | var start: CGFloat = 0 164 | var rotations = [CGFloat]() 165 | var strokeEnds = [CGFloat]() 166 | 167 | let poses = LoadyCore.poses 168 | let totalSeconds = poses.reduce(0) { $0 + $1.secondsSincePriorPose } 169 | 170 | for pose in poses { 171 | time += pose.secondsSincePriorPose 172 | times.append(time / totalSeconds) 173 | start = pose.start 174 | rotations.append(start * 2 * .pi) 175 | strokeEnds.append(pose.length) 176 | } 177 | 178 | times.append(times.last!) 179 | rotations.append(rotations[0]) 180 | strokeEnds.append(strokeEnds[0]) 181 | 182 | LoadyCore.animateKeyPath(layer,keyPath: "strokeEnd", duration: totalSeconds, times: times, values: strokeEnds) 183 | LoadyCore.animateKeyPath(layer,keyPath: "transform.rotation", duration: totalSeconds, times: times, values: rotations) 184 | 185 | animateStrokeHueWithDuration(layer ,duration: totalSeconds * 5) 186 | } 187 | 188 | private func animateStrokeHueWithDuration(_ layer : CAShapeLayer, duration: CFTimeInterval) { 189 | let count = 200 190 | let animation = CAKeyframeAnimation(keyPath: "strokeColor") 191 | animation.keyTimes = (0 ... count).map { NSNumber(value: CFTimeInterval($0) / CFTimeInterval(count)) } 192 | let loadingColor = self.loady.loadingColor 193 | animation.values = (0 ... count).map {num in 194 | if num <= 3 && animation.accessibilityHint == nil{ 195 | return loadingColor.withAlphaComponent(CGFloat(num) / 3.0).cgColor 196 | }else{ 197 | return loadingColor.cgColor 198 | } 199 | } 200 | animation.duration = duration 201 | animation.calculationMode = .linear 202 | animation.autoreverses = true 203 | 204 | animation.repeatCount = Float.infinity 205 | layer.add(animation, forKey: animation.keyPath) 206 | } 207 | } 208 | 209 | 210 | extension LoadyFourPhaseAnimation: LoadyAnimation { 211 | public func isLoading() -> Bool { 212 | return loading 213 | } 214 | 215 | public func inject(loady: Loadiable) { 216 | guard let loady = loady as? Loadiable & UIButton else { 217 | assertionFailure("this animation will apply only on UIbutton") 218 | return 219 | } 220 | self.loady = loady 221 | } 222 | public func run() { 223 | loading = true 224 | createFourPhaseButton() 225 | } 226 | 227 | public func stop() { 228 | loading = false 229 | cleanCircularLoading() 230 | } 231 | 232 | } 233 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyIndicatorAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IndicatorAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/5/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension LoadyAnimationType { 12 | static func indicator(with options: LoadyIndicatorAnimation.AnimationOption)->LoadyIndicatorAnimation{ 13 | return LoadyIndicatorAnimation(options: options) 14 | } 15 | } 16 | 17 | public typealias IndicatorViewStyle = Bool 18 | public extension IndicatorViewStyle { 19 | static let light = false 20 | static let black = true 21 | } 22 | 23 | public class LoadyIndicatorAnimation: LoadyAnimation { 24 | public struct AnimationOption { 25 | var indicatorViewStyle: IndicatorViewStyle = .light 26 | public init(indicatorViewStyle: IndicatorViewStyle) { 27 | self.indicatorViewStyle = indicatorViewStyle 28 | } 29 | } 30 | private let options: AnimationOption 31 | init(options: AnimationOption) { 32 | self.options = options 33 | } 34 | 35 | public func inject(loady: Loadiable) { 36 | self.loady = loady 37 | } 38 | private var loading: Bool = false 39 | 40 | public func isLoading() -> Bool { 41 | return loading 42 | } 43 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "indicator") 44 | lazy var activiyIndicator : LoadyActivityIndicator = { UIActivityIndicatorView() }() 45 | private unowned var loady: Loadiable! 46 | private var oldTitleEdgeInsets: UIEdgeInsets = .zero 47 | private var oldImageEdgeInsets: UIEdgeInsets = .zero 48 | public func run() { 49 | loading = true 50 | let indicator = self.activiyIndicator 51 | indicator.frame = CGRect(x: 0, y: 0, width: 30, height: 30) 52 | if let button = self.loady as? UIButton, let titleLabel = button.titleLabel { 53 | self.oldTitleEdgeInsets = button.titleEdgeInsets 54 | self.oldImageEdgeInsets = button.imageEdgeInsets 55 | 56 | let rightLeftInset: (right:CGFloat,left: CGFloat) = self.loady.semanticContentAttribute == .forceRightToLeft ? (0,30) : (30,0) 57 | 58 | UIView.animate(withDuration: 0.3) { 59 | button.titleEdgeInsets = UIEdgeInsets(top: button.titleEdgeInsets.top, left: rightLeftInset.left + button.titleEdgeInsets.left, bottom: button.titleEdgeInsets.bottom, right: rightLeftInset.right + button.titleEdgeInsets.right); 60 | button.imageEdgeInsets = UIEdgeInsets(top: button.imageEdgeInsets.top, left: rightLeftInset.left + button.imageEdgeInsets.left, bottom: button.imageEdgeInsets.bottom, right: rightLeftInset.right + button.imageEdgeInsets.right); 61 | self.loady.layoutIfNeeded() 62 | } 63 | 64 | if let imageView = button.imageView, (imageView.frame.minX < 8 || imageView.frame.maxX > button.frame.width - 8) { 65 | button.imageView?.removeFromSuperview() 66 | } 67 | 68 | if titleLabel.frame.minX < 8 || titleLabel.frame.maxX > button.frame.size.width - 8 { 69 | button.imageView?.removeFromSuperview() 70 | } 71 | 72 | if titleLabel.superview == nil , button.imageView?.superview == nil { 73 | indicator.center = CGPoint(x: self.loady.bounds.midX,y: self.loady.bounds.midY) 74 | } else if button.frame.width < button.intrinsicContentSize.width + 38 { 75 | titleLabel.removeFromSuperview() 76 | button.imageView?.removeFromSuperview() 77 | indicator.center = CGPoint(x: self.loady.bounds.midX,y: self.loady.bounds.midY) 78 | } else { 79 | indicator.center = CGPoint(x: (rightLeftInset.left == 0 ? titleLabel.frame.maxX + 15 : titleLabel.frame.minX - 15) ,y: self.loady.bounds.midY) 80 | } 81 | 82 | } else { 83 | indicator.center = CGPoint(x: self.loady.bounds.midX,y: self.loady.bounds.midY) 84 | } 85 | 86 | // bounce animation 87 | indicator.transform = CGAffineTransform(scaleX: 0, y: 0) 88 | indicator.isUserInteractionEnabled = false 89 | 90 | if let indicator = indicator as? UIActivityIndicatorView{ 91 | indicator.style = self.options.indicatorViewStyle ? .gray : .white 92 | } 93 | 94 | indicator.startAnimating() 95 | self.loady.insertSubview(indicator, at: 0) 96 | UIView.animate(withDuration: 0.05, delay: 0.3, options: .curveLinear, animations: { 97 | indicator.transform = .identity 98 | self.loady.layoutIfNeeded() 99 | }, completion: nil) 100 | 101 | } 102 | 103 | public func stop() { 104 | loading = false 105 | 106 | UIView.animateKeyframes(withDuration: 0.3, delay: 0, options: [], animations: { 107 | UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.3) { 108 | self.activiyIndicator.transform = .init(scaleX: 0.1, y: 0.1) 109 | self.activiyIndicator.alpha = 1 110 | self.loady.layoutIfNeeded() 111 | } 112 | if let button = self.loady as? UIButton { 113 | UIView.addKeyframe(withRelativeStartTime: 0.3, relativeDuration: 0.7) { 114 | button.titleEdgeInsets = self.oldTitleEdgeInsets 115 | button.imageEdgeInsets = self.oldImageEdgeInsets 116 | button.titleLabel?.alpha = 1 117 | self.loady.layoutIfNeeded() 118 | } 119 | } 120 | }) { (done) in 121 | guard done else {return} 122 | self.activiyIndicator.removeFromSuperview() 123 | guard let button = self.loady as? UIButton else {return} 124 | if let titleLabel = button.titleLabel, titleLabel.superview == nil { 125 | titleLabel.isHidden = true 126 | button.addSubview(titleLabel) 127 | } 128 | 129 | if let imageView = button.imageView, imageView.superview == nil { 130 | imageView.isHidden = true 131 | button.addSubview(imageView) 132 | } 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Loady/Classes/Animations/LoadyTopLineAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyTopLineAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | import UIKit 9 | 10 | public extension LoadyAnimationType { 11 | static func topLine()->LoadyTopLineAnimation{ 12 | return LoadyTopLineAnimation() 13 | } 14 | } 15 | 16 | public class LoadyTopLineAnimation { 17 | public static var animationTypeKey: LoadyAnimationType.Key = .init(rawValue: "indicator") 18 | lazy var activiyIndicator : LoadyActivityIndicator = { UIActivityIndicatorView() }() 19 | private unowned var loady: Loadiable! 20 | var loadingLayer: CAShapeLayer? 21 | private var loading: Bool = false 22 | 23 | ///line loading 24 | private func createTopLineLoading(){ 25 | //create our loading layer and line path 26 | let loadingLayer = CAShapeLayer(); 27 | let path = UIBezierPath(); 28 | 29 | //height of the line 30 | let lineHeight : CGFloat = 2.0; 31 | 32 | //center the layer in our view and set the bounds 33 | loadingLayer.position = CGPoint(x:self.loady.frame.size.width / 2,y: -1); 34 | loadingLayer.bounds = CGRect(x:0,y: 0, width: self.loady.frame.size.width, height: lineHeight); 35 | 36 | //draw our line 37 | path.move(to: CGPoint(x:0,y: -1)) 38 | path.addLine(to: CGPoint(x:loadingLayer.bounds.size.width/2.4,y: -1)) 39 | 40 | //set the path layer, and costumizing it 41 | loadingLayer.path = path.cgPath; 42 | loadingLayer.strokeColor = self.loady.loadingColor.cgColor; 43 | loadingLayer.strokeEnd = 1; 44 | loadingLayer.lineWidth = lineHeight; 45 | loadingLayer.lineCap = CAShapeLayerLineCap(rawValue: "round"); 46 | loadingLayer.contentsScale = UIScreen.main.scale; 47 | loadingLayer.accessibilityHint = "button_topline_loading"; 48 | loadingLayer.opacity = 0 49 | //add the new layer 50 | self.loady.addSublayer(loadingLayer); 51 | 52 | //animated path 53 | let animatedPath = UIBezierPath() 54 | animatedPath.move(to: CGPoint(x:loadingLayer.bounds.size.width / 1.2,y: -1)) 55 | animatedPath.addLine(to: CGPoint(x:loadingLayer.bounds.size.width,y: -1)) 56 | let animateOpacity = LoadyCore.createBasicAnimation(keypath: "opacity", from: 0, to: 1,duration : 0.6) 57 | animateOpacity.isRemovedOnCompletion = false 58 | animateOpacity.fillMode = .forwards 59 | 60 | //create our animation and add it to the layer, animate indictor from left to right 61 | let animation = LoadyCore.createBasicAnimation(keypath: "path", from: path.cgPath, to: animatedPath.cgPath) 62 | animation.autoreverses = true; 63 | animation.repeatCount = 100; 64 | animation.isRemovedOnCompletion = false 65 | loadingLayer.add(animation,forKey:nil); 66 | loadingLayer.add(animateOpacity,forKey:nil); 67 | self.loadingLayer = loadingLayer 68 | } 69 | } 70 | 71 | extension LoadyTopLineAnimation: LoadyAnimation { 72 | public func inject(loady: Loadiable) { 73 | self.loady = loady 74 | } 75 | 76 | public func isLoading() -> Bool { 77 | return loading 78 | } 79 | 80 | public func run() { 81 | loading = true 82 | createTopLineLoading() 83 | } 84 | 85 | public func stop() { 86 | loading = false 87 | self.loadingLayer?.removeFromSuperlayer() 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Loady/Classes/Loadible.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Loadible.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | public protocol Loadiable where Self: UIView { 11 | /// some animations has a indicator like a line, this is that line color 12 | var loadingColor : UIColor {set get} 13 | /// some animations shows an image inside of the button, this is that image 14 | var pauseImage : UIImage? {set get} 15 | var backgroundFillColor : UIColor {set get} 16 | var backgroundColor : UIColor? {set get} 17 | func addSublayer(_ layer: CALayer) 18 | func addSublayer(_ layer: CALayer, at: UInt32) 19 | func cleanCanvas() 20 | func reloadDefaultState(duration: TimeInterval, done: (()->Void)?) 21 | } 22 | 23 | extension Loadiable where Self: UIButton { 24 | var titleLabel: UILabel? {get { 25 | self.titleLabel 26 | } 27 | } 28 | func setTitle(_ title: String?, for state: UIControl.State) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Loady/Classes/Loady+NVActivityIndicatorView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NVActivityIndicatorView.swift 3 | // loady 4 | // 5 | // Created by farshad on 2/21/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | import UIKit 9 | public protocol LoadyActivityIndicator where Self: UIView{ 10 | /** 11 | Start animating. 12 | */ 13 | func startAnimating() 14 | 15 | /** 16 | Stop animating. 17 | */ 18 | func stopAnimating() 19 | } 20 | 21 | extension UIActivityIndicatorView : LoadyActivityIndicator { 22 | // its a bug in Swift compiler? -_- 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Loady/Classes/LoadyAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyAnimation.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/5/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | // each animation needs to conform to this protocol 11 | public protocol LoadyAnimation: LoadyPercentageObserver { 12 | static var animationTypeKey: LoadyAnimationType.Key { get } 13 | func inject(loady: Loadiable) 14 | mutating func run() 15 | mutating func stop() 16 | func isLoading()->Bool 17 | } 18 | 19 | extension LoadyAnimation { 20 | mutating public func change(from: CGFloat, to: CGFloat) {} 21 | } 22 | 23 | public protocol LoadyPercentageObserver { 24 | /// notifies other functions about percent changes 25 | /// 26 | /// - Parameters: 27 | /// - new: new value 28 | /// - old: current value 29 | mutating func change(from: CGFloat, to: CGFloat) 30 | mutating func completed(lastetValue: CGFloat) 31 | } 32 | extension LoadyPercentageObserver { 33 | mutating public func completed(lastetValue: CGFloat) {} 34 | } 35 | -------------------------------------------------------------------------------- /Loady/Classes/LoadyAnimationOptions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyAnimationOptions.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/5/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | /// a structure for creating four phases button 11 | public struct LoadyAnimationOptions { 12 | public struct FourPhases { 13 | public typealias Phase = (title:String,image : UIImage?,background:UIColor) 14 | public enum Phases { 15 | case normal(Phase) 16 | case loading(Phase) 17 | case success(Phase) 18 | case error(Phase) 19 | } 20 | let normalPhase: Phase 21 | let loadingPhase: Phase 22 | let successPhase: Phase 23 | let errorPhase: Phase 24 | public init(normalPhase: Phase, loadingPhase: Phase, successPhase: Phase, errorPhase: Phase) { 25 | self.normalPhase = normalPhase 26 | self.loadingPhase = loadingPhase 27 | self.successPhase = successPhase 28 | self.errorPhase = errorPhase 29 | } 30 | } 31 | public struct Downloading { 32 | var downloadingLabel : (title:String,font : UIFont, textColor : UIColor)? 33 | var percentageLabel: (font : UIFont, textColor : UIColor)? 34 | var downloadedLabel : (title:String,font : UIFont, textColor : UIColor)? 35 | init(downloadingLabel : (title:String,font : UIFont, textColor : UIColor)?,percentageLabel: (font : UIFont, textColor : UIColor)?,downloadedLabel : (title:String,font : UIFont, textColor : UIColor)?) { 36 | self.downloadingLabel = downloadingLabel 37 | self.percentageLabel = percentageLabel 38 | self.downloadedLabel = downloadedLabel 39 | } 40 | } 41 | 42 | var downloading : Downloading? 43 | } 44 | -------------------------------------------------------------------------------- /Loady/Classes/LoadyAnimationType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyAnimationType.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | public struct LoadyAnimationType: RawRepresentable { 11 | public var rawValue: Key 12 | public init(rawValue: Key) { 13 | self.rawValue = rawValue 14 | } 15 | public struct Key: RawRepresentable, Equatable { 16 | public init(rawValue: String) { 17 | self.rawValue = rawValue 18 | } 19 | public var rawValue: String 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Loady/Classes/LoadyButton/Loady.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Loady.swift 3 | // loady 4 | // 5 | // Created by farshad jahanmanesh on 2/2/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | // NOTE : we have to make this better, there can be many imporvements like maganging options and handle them in one place, new animations and ... 9 | 10 | import UIKit 11 | extension LoadyAnimationType { 12 | static let none: LoadyAnimationType.Key = .init(rawValue: "none") 13 | } 14 | 15 | open class LoadyButton : UIButton, Loadiable { 16 | public func addSublayer(_ layer: CALayer) { 17 | self.layer.addSublayer(layer) 18 | // some shit swift bug 19 | if let imageview = self.imageView { 20 | self.bringSubviewToFront(imageview) 21 | } 22 | } 23 | public func addSublayer(_ layer: CALayer, at: UInt32) { 24 | self.layer.insertSublayer(layer, at: at) 25 | 26 | // some shit swift bug 27 | if let imageview = self.imageView { 28 | self.bringSubviewToFront(imageview) 29 | } 30 | } 31 | 32 | public func cleanCanvas() { 33 | copyBeforeAnyChanges() 34 | self.setTitle("", for: .normal); 35 | } 36 | 37 | private func reloadDefaultState() { 38 | guard let cached = self._cacheButtonBeforeAnimation else{ 39 | return 40 | } 41 | 42 | self.bounds = CGRect(x:0,y: 0,width: cached.frame.size.width,height: cached.frame.size.height) 43 | self.layer.cornerRadius = cached.layer.cornerRadius 44 | // self.frame.origin.x = 0 45 | self.backgroundColor = cached.backgroundColor 46 | self.transform = .identity 47 | self.layoutIfNeeded() 48 | } 49 | 50 | public func reloadDefaultState(duration: TimeInterval = 0, done: (() -> Void)?) { 51 | let otherStuff = { 52 | UIView.performWithoutAnimation { 53 | self.setTitle(self._cacheButtonBeforeAnimation?.titleLabel?.text, for: .normal) 54 | self.layoutIfNeeded() 55 | } 56 | done?() 57 | } 58 | if duration == 0 { 59 | reloadDefaultState() 60 | otherStuff() 61 | } else { 62 | UIView.animate(withDuration: duration, animations: { 63 | self.reloadDefaultState() 64 | }) { finish in if finish {otherStuff()}} 65 | } 66 | } 67 | 68 | /// some animations has a indicator like a line, this is that line color 69 | @IBInspectable open var loadingColor : UIColor = UIColor.black 70 | 71 | /// some animations fills the button with a color, this is that color 72 | @IBInspectable open var backgroundFillColor : UIColor = UIColor.black 73 | 74 | /// some animations shows a indiccatorView, this is the style of that indicator view 75 | @IBInspectable open var indicatorViewStyle: IndicatorViewStyle = .light 76 | 77 | /// some animations shows an image inside of the button, this is that image 78 | open var pauseImage : UIImage? 79 | open internal(set) var animationType: LoadyAnimationType.Key = LoadyAnimationType.none 80 | 81 | fileprivate var _percentFilled : CGFloat = 0 { 82 | willSet{ 83 | currentAnimation?.change(from: _percentFilled, to: newValue) 84 | } 85 | didSet { 86 | if _percentFilled == 100 { 87 | percentageCompleted() 88 | } 89 | } 90 | } 91 | open func setAnimation(_ animation: LoadyAnimation) { 92 | self.animationType = type(of: animation).animationTypeKey 93 | animation.inject(loady: self) 94 | self.currentAnimation = animation 95 | } 96 | internal var currentAnimation: LoadyAnimation? 97 | // we keep a copy of button properties before animation is begin and will restore them after animation is finished 98 | private var _cacheButtonBeforeAnimation : UIButton? 99 | 100 | override public init(frame: CGRect) { 101 | super.init(frame: frame) 102 | _percentFilled = 0; 103 | } 104 | 105 | required public init?(coder aDecoder: NSCoder) { 106 | super.init(coder: aDecoder) 107 | _percentFilled = 0; 108 | self.backgroundFillColor = .black; 109 | self.loadingColor = .black 110 | } 111 | 112 | /** 113 | cache the button before any animation,we keep a reference to data so we can restore everything to the first place 114 | */ 115 | func copyBeforeAnyChanges(){ 116 | _cacheButtonBeforeAnimation = UIButton(); 117 | if #available(iOS 11.0, *) { 118 | guard let archivedData = try? NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: false), let btn = ((try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(archivedData) as? UIButton) as UIButton??) else { 119 | return 120 | } 121 | 122 | _cacheButtonBeforeAnimation = btn 123 | } else { 124 | let archivedData = NSKeyedArchiver.archivedData(withRootObject: self) 125 | guard let btn = ((try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(archivedData) as? UIButton) as UIButton??) else { 126 | return 127 | } 128 | 129 | _cacheButtonBeforeAnimation = btn 130 | } 131 | 132 | _cacheButtonBeforeAnimation?.layer.cornerRadius = self.layer.cornerRadius 133 | 134 | } 135 | 136 | /// stop loading and remove all animations and temporary layers 137 | open func stopLoading(){ 138 | guard self.loadingIsShowing() else { return } 139 | _percentFilled = 0; 140 | currentAnimation?.stop() 141 | } 142 | 143 | open func startLoading(){ 144 | if self.currentAnimation?.isLoading() ?? false { 145 | return; 146 | } 147 | currentAnimation?.run() 148 | } 149 | 150 | open func update(percent: CGFloat){ 151 | if ( percent > 100){ 152 | if _percentFilled != 100 { 153 | _percentFilled = 100 154 | }else{ 155 | return 156 | } 157 | }else{ 158 | _percentFilled = percent; 159 | } 160 | } 161 | 162 | /// notifies all animations about 100%, some animations need to preform some actions 163 | private func percentageCompleted(){ 164 | currentAnimation?.completed(lastetValue: 100) 165 | } 166 | 167 | open func loadingIsShowing() -> Bool{ 168 | return self.currentAnimation?.isLoading() ?? false 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /Loady/Classes/LoadyButton/LoadyFourPhaseButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyFourPhaseButton.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/6/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | open class LoadyFourPhaseButton: LoadyButton { 11 | private var animation: LoadyFourPhaseAnimation? = nil 12 | open var currentPhase: LoadyAnimationOptions.FourPhases.Phases? { 13 | (currentAnimation as? LoadyFourPhaseAnimation)?.currentPhase 14 | } 15 | open func setPhases(phases: LoadyAnimationOptions.FourPhases){ 16 | animation = LoadyFourPhaseAnimation(phases: phases) 17 | animation?.inject(loady: self) 18 | } 19 | open override func startLoading() { 20 | if self.loadingIsShowing(){ 21 | return; 22 | } 23 | currentAnimation = animation 24 | currentAnimation?.run() 25 | } 26 | open func loadingPhase(){ 27 | (currentAnimation as? LoadyFourPhaseAnimation)?.loadingPhase() 28 | } 29 | open func normalPhase(){ 30 | (currentAnimation as? LoadyFourPhaseAnimation)?.normalPhase() 31 | } 32 | open func successPhase(){ 33 | (currentAnimation as? LoadyFourPhaseAnimation)?.successPhase() 34 | } 35 | open func errorPhase(){ 36 | (currentAnimation as? LoadyFourPhaseAnimation)?.errorPhase() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Loady/Classes/LoadyCore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadyCore.swift 3 | // loady 4 | // 5 | // Created by Farshad Jahanmanesh on 11/5/19. 6 | // Copyright © 2019 farshadJahanmanesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | final class LoadyCore { 11 | /// creates a circle inside or button, some animations like appstore, circleAndTick and ... needs to show a circle 12 | /// 13 | /// - Parameters: 14 | /// - radius: radius of the circle 15 | /// - centerX: x position, (nil) default is the center of the button 16 | /// - centerY: y position, (nil) default is the ceenter of the button 17 | /// - Returns: a circle 18 | class func createCircleInside(bounds: CGRect, strokeColor: UIColor, radius : CGFloat? = nil, centerX : CGFloat? = nil, centerY : CGFloat? = nil, anchorPoint: CGPoint = CGPoint(x:0.5,y: 0.5))-> CAShapeLayer{ 19 | let circle = CAShapeLayer() 20 | let path = UIBezierPath() 21 | let squre = min(bounds.height,bounds.width) 22 | let radius = radius ?? squre / 2 23 | circle.bounds = CGRect(x:0,y: 0,width: squre,height: squre) 24 | circle.strokeColor = strokeColor.cgColor 25 | circle.lineWidth = 3 26 | circle.fillColor = UIColor.clear.cgColor 27 | circle.lineCap = .round 28 | circle.strokeStart = 0.0 29 | circle.strokeEnd = 0.0 30 | let center = CGPoint(x: circle.bounds.midX,y: circle.bounds.midY) 31 | circle.position = CGPoint(x: centerX ?? bounds.midX,y: centerY ?? bounds.midY) 32 | circle.anchorPoint = anchorPoint 33 | path.addArc(withCenter: center, radius: radius , startAngle: LoadyCore.degreesToRadian(-90), endAngle: LoadyCore.degreesToRadian(270), clockwise: true) 34 | 35 | circle.path = path.cgPath 36 | return circle 37 | } 38 | struct Pose { 39 | let secondsSincePriorPose: CFTimeInterval 40 | let start: CGFloat 41 | let length: CGFloat 42 | init(_ secondsSincePriorPose: CFTimeInterval, _ start: CGFloat, _ length: CGFloat) { 43 | self.secondsSincePriorPose = secondsSincePriorPose 44 | self.start = start 45 | self.length = length 46 | } 47 | } 48 | class var poses: [Pose] { 49 | get { 50 | return [ 51 | Pose(0.0, 0.000, 0.7), 52 | Pose(0.6, 0.500, 0.5), 53 | Pose(0.6, 1.000, 0.3), 54 | Pose(0.6, 1.500, 0.1), 55 | Pose(0.2, 1.875, 0.1), 56 | Pose(0.2, 2.250, 0.3), 57 | Pose(0.2, 2.625, 0.5), 58 | Pose(0.2, 3.000, 0.7), 59 | ] 60 | } 61 | } 62 | class func animateKeyPath(_ layer : CAShapeLayer,keyPath: String, duration: CFTimeInterval, times: [CFTimeInterval], values: [CGFloat]) { 63 | let animation = CAKeyframeAnimation(keyPath: keyPath) 64 | animation.keyTimes = times as [NSNumber]? 65 | animation.values = values 66 | animation.calculationMode = .linear 67 | animation.duration = duration 68 | animation.repeatCount = Float.infinity 69 | animation.isRemovedOnCompletion = false 70 | layer.add(animation, forKey: animation.keyPath) 71 | } 72 | 73 | /// creates a copy of specific properties of the layer and makes a new layer with those 74 | /// 75 | /// - Parameter copy: layer to create a copy of 76 | /// - Returns: new layer 77 | class func copy(layer copy : CAShapeLayer)-> CAShapeLayer{ 78 | let newLayer = CAShapeLayer() 79 | newLayer.bounds = copy.bounds 80 | newLayer.strokeColor = copy.strokeColor 81 | newLayer.lineWidth = copy.lineWidth 82 | newLayer.fillColor = copy.fillColor 83 | newLayer.lineCap = copy.lineCap 84 | newLayer.strokeStart = copy.strokeStart 85 | newLayer.strokeEnd = copy.strokeEnd 86 | newLayer.position = copy.position 87 | newLayer.anchorPoint = copy.anchorPoint 88 | newLayer.path = copy.path 89 | newLayer.accessibilityHint = copy.accessibilityHint 90 | 91 | return newLayer 92 | } 93 | 94 | class func createBasicAnimation(keypath : String, from : Any,to:Any,duration : Double = 1) -> CABasicAnimation{ 95 | let animation = CABasicAnimation() 96 | animation.keyPath = keypath 97 | animation.fromValue = from 98 | animation.toValue = to 99 | animation.duration = duration; 100 | 101 | return animation 102 | } 103 | 104 | class func createTextLayers(layer:CAShapeLayer,string : String,font : UIFont)->CATextLayer{ 105 | let text = CATextLayer() 106 | text.string = string 107 | text.bounds = layer.bounds 108 | text.position = CGPoint(x:text.bounds.midX,y:text.bounds.midY) 109 | text.alignmentMode = .center 110 | text.font = font 111 | text.fontSize = font.pointSize 112 | text.foregroundColor = UIColor.black.cgColor 113 | text.contentsScale = UIScreen.main.scale 114 | return text 115 | } 116 | 117 | class func createTextPushAnimation(type : CATransitionSubtype,duration : Double)->CAAnimation{ 118 | let animation = CATransition() 119 | animation.isRemovedOnCompletion = true 120 | animation.duration = duration 121 | animation.type = CATransitionType.push 122 | animation.subtype = type 123 | animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) 124 | return animation 125 | } 126 | 127 | 128 | class func degreesToRadian(_ value: CGFloat)-> CGFloat { return value * .pi / 180 } 129 | class func radiansToDegrees(_ value: CGFloat)-> CGFloat { return value * 180 / .pi } 130 | 131 | class func calculateTextHeight(string : String,withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat { 132 | let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude) 133 | let boundingBox = string.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil) 134 | 135 | return ceil(boundingBox.height) 136 | } 137 | class func calculateTextWidth(string : String,withConstrainedHeight height: CGFloat, font: UIFont) -> CGFloat { 138 | let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height) 139 | let boundingBox = string.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil) 140 | 141 | return ceil(boundingBox.width) 142 | } 143 | 144 | 145 | /// Resizes Images to idle size 146 | /// 147 | /// - Parameters: 148 | /// - image: the UIImage to resize 149 | /// - targetSize: target size 150 | /// - Returns: the image with new size 151 | class func resizeImage(image: UIImage, targetSize: CGSize) -> UIImage { 152 | let size = image.size 153 | 154 | let widthRatio = targetSize.width / size.width 155 | let heightRatio = targetSize.height / size.height 156 | 157 | // Figure out what our orientation is, and use that to form the rectangle 158 | var newSize: CGSize 159 | if(widthRatio > heightRatio) { 160 | newSize = CGSize(width: size.width * heightRatio, height: size.height * heightRatio) 161 | } else { 162 | newSize = CGSize(width: size.width * widthRatio, height: size.height * widthRatio) 163 | } 164 | 165 | // This is the rect that we've calculated out and this is what is actually used below 166 | let rect = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height) 167 | 168 | // Actually do the resizing to the rect using the ImageContext stuff 169 | UIGraphicsBeginImageContextWithOptions(newSize, false, 1.0) 170 | image.draw(in: rect) 171 | let newImage = UIGraphicsGetImageFromCurrentImageContext() 172 | UIGraphicsEndImageContext() 173 | 174 | return newImage! 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.7 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "loady", 8 | products: [ 9 | // Products define the executables and libraries a package produces, and make them visible to other packages. 10 | .library( 11 | name: "Loady", 12 | targets: ["Loady"]), 13 | ], 14 | dependencies: [ 15 | // Dependencies declare other packages that this package depends on. 16 | // .package(url: /* package url */, from: "1.0.0"), 17 | ], 18 | targets: [ 19 | .target( 20 | name: "Loady", 21 | dependencies: [], 22 | path: "Loady/Classes"), 23 | ] 24 | ) 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/Whisper.svg?style=flat)](http://cocoadocs.org/docsets/Whisper) 4 | [![License](https://img.shields.io/cocoapods/l/Whisper.svg?style=flat)](http://cocoadocs.org/docsets/Whisper) 5 | [![Platform](https://img.shields.io/cocoapods/p/Whisper.svg?style=flat)](http://cocoadocs.org/docsets/Whisper) 6 | ![Swift](https://img.shields.io/badge/%20in-swift%204.4-orange.svg) 7 | 8 | 9 | # Loady 10 | this is a small library to show loading and indicator in UIButton, with fully customizable styles. there are 6 different styles, you can set the colors from interface builder or programmatically. 11 | 12 | 13 | ## Todo 14 | - [x] animation style : like appstore download button 15 | - [x] animation style : 4 phases Animation(normal, loading, success, error) 16 | - [x] animation style : like android 17 | - [x] animation style : downloading 18 | - [x] extendable to accept new animations 19 | - [ ] animation style : like telegram sharing 20 | - [ ] Carthage Support 21 | 22 | 23 | ![TOP_LINE](examples/_gif.gif) 24 | 25 | 26 | ## Requirements 27 | loady minimum target requirement is iOS 10.0 28 | 29 | 30 | ## Installation 31 | loady is available through [Swift Package Manager](https://www.swift.org/package-manager/) or [Cocoapods](http://cocoapods.org) 32 | 33 | ### Swift Package Manager (Recommended) 34 | ``` 35 | dependencies: [ 36 | .package(url: "https://github.com/farshadjahanmanesh/loady.git", .upToNextMajor(from: "1.0.8")) 37 | ] 38 | ``` 39 | 40 | ### Cocoapods 41 | ```swift 42 | pod "loady" 43 | ``` 44 | 45 | ### Manual 46 | simply copy the [Source Code](https://github.com/farshadjahanmanesh/loady/tree/master/loady/LoadingButton) into your project, take a look at the example project for more info 47 | 48 | 49 | 50 | ## Configs 51 | 52 | 53 | ## Setup programmatically : 54 | ```swift 55 | 56 | // sets animation type 57 | self.loadyButton.setAnimation(LoadyAnimationType.backgroundHighlighter()) 58 | 59 | // starts loading animation 60 | self.loadyButton?.startLoading() 61 | 62 | // some animations have filling background, or change the circle stroke, this sets the filling percent, number is something between 0 to 100 63 | loadyButton.update(percent: percent) 64 | ``` 65 | 66 | ___ 67 | 68 | ### 4 Phases Animation : 69 | ```swift 70 | // setup colors, titles and images 71 | self.fourPhases?.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0) 72 | self.fourPhases.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0) 73 | self.fourPhases.setPhases(phases: .init( 74 | normalPhase: 75 | (title: "Lock", image: UIImage(named: "unlocked"), background: UIColor(red:0.00, green:0.49, blue:0.90, alpha:1.0)), loadingPhase: 76 | (title: "Waiting...", image: nil, background: UIColor(red:0.17, green:0.24, blue:0.31, alpha:1.0)), 77 | successPhase: 78 | (title: "Activated", image: UIImage(named: "locked"), background: UIColor(red:0.15, green:0.68, blue:0.38, alpha:1.0)), errorPhase: 79 | (title: "Error", image: UIImage(named: "unlocked"), background: UIColor(red:0.64, green:0.00, blue:0.15, alpha:1.0)) 80 | ) 81 | ) 82 | 83 | // then later in your code after user click on the button just call, this line take the button to loading phase, 84 | self.fourPhasesLoadyButton?.startLoading() 85 | 86 | // in loading phase three different stage is available, you can cancel the loading by calling 87 | self.fourPhasesLoadyButton?.normalPhase() 88 | 89 | // you can take the button to success phase by calling 90 | self.fourPhasesLoadyButton?.successPhase() 91 | 92 | // you can take the button to error phase by calling 93 | self.fourPhasesLoadyButton?.errorPhase() 94 | 95 | ``` 96 | 97 | | Loading To Normal | Loading To Success | Loading To Error | 98 | | ------------- | ------------- | ------------- | 99 | | | | | 100 | 101 | ___ 102 | ### Downloading Animation : 103 | ```swift 104 | // setup download button details 105 | self.downloadingLoadyButton.setAnimation(LoadyAnimationType.downloading(with: .init( 106 | downloadingLabel: (title: "Copying Data...", font: UIFont.boldSystemFont(ofSize: 18), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)), 107 | percentageLabel: (font: UIFont.boldSystemFont(ofSize: 14), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)), 108 | downloadedLabel: (title: "Completed.", font: UIFont.boldSystemFont(ofSize: 20), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)) 109 | ) 110 | )) 111 | 112 | ``` 113 | 114 | 115 | ___ 116 | 117 | 118 | ## Setup in interface builder 119 | | Set class | change attributes | 120 | | ------------- | ------------- | 121 | | | | 122 | 123 | ___ 124 | 125 | ## BONUS - [NVActivityIndicatorView](https://github.com/ninjaprox/NVActivityIndicatorView) 126 | 127 | if you are a fan of NVActivityIndicatorView, its very easy to integrate it with loady, you can replace our default iOS indicatorView with NVActivityIndicatorView <3 128 | now we have a new property which accepts LoadyActivityIndicator Protocol, just set it with your favorite activity indicator view like below 129 | ```(swift) 130 | // first conform to the LoadyActivityIndicator protocol like this 131 | extension NVActivityIndicatorView : LoadyActivityIndicator { 132 | 133 | } 134 | 135 | // then replace loady default activity indicator with yours 136 | let nv = NVActivityIndicatorView(frame: .zero) 137 | nv.type = .circleStrokeSpin 138 | nv.color = .red 139 | nv.padding = 12 140 | self.loadyButton?.activiyIndicator = nv 141 | ``` 142 | | | | 143 | 144 | 145 | ## troubleshoot 146 | 1. Unable to find a specification for `loady` 147 | 148 | if you get some error like this with cocoapod, just update your pod with this commands in your terminal 149 | ``` 150 | > [!] Unable to find a specification for `loady` 151 | 152 | $ pod repo update 153 | $ pod install 154 | 155 | ``` 156 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /examples/_cancelPhase.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_cancelPhase.gif -------------------------------------------------------------------------------- /examples/_download.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_download.gif -------------------------------------------------------------------------------- /examples/_errorPhasee.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_errorPhasee.gif -------------------------------------------------------------------------------- /examples/_gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_gif.gif -------------------------------------------------------------------------------- /examples/_nvacctivityindicator1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_nvacctivityindicator1.gif -------------------------------------------------------------------------------- /examples/_nvacctivityindicator2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_nvacctivityindicator2.gif -------------------------------------------------------------------------------- /examples/_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_properties.png -------------------------------------------------------------------------------- /examples/_setClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_setClass.png -------------------------------------------------------------------------------- /examples/_specs.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_specs.jpeg -------------------------------------------------------------------------------- /examples/_successPhase.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/_successPhase.gif -------------------------------------------------------------------------------- /examples/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valentinjahanmanesh/loady/3ef0c35822def0402884257b8eaa18c1f88bea55/examples/logo.png --------------------------------------------------------------------------------