├── .gitignore ├── DownloadManager.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── DownloadManager.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── DownloadManager ├── AppDelegate │ ├── AppDelegate.swift │ └── SceneDelegate.swift ├── Controller │ └── ViewController.swift ├── Extension │ └── Codable+Extension.swift ├── Modal │ └── Response.swift ├── Storyboard │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ └── Main.storyboard ├── SupportFiles │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── Pause.imageset │ │ │ ├── Contents.json │ │ │ ├── Pause@1x.png │ │ │ ├── Pause@2x.png │ │ │ └── Pause@3x.png │ │ ├── Play.imageset │ │ │ ├── Contents.json │ │ │ ├── Play@1x.png │ │ │ ├── Play@2x.png │ │ │ └── Play@3x.png │ │ └── stop.imageset │ │ │ ├── Contents.json │ │ │ ├── stop@1x.png │ │ │ ├── stop@2x.png │ │ │ └── stop@3x.png │ └── Info.plist ├── Utilities │ ├── AppError.swift │ ├── AudioManager.swift │ ├── Download.swift │ ├── DownloadServices.swift │ ├── Helper.swift │ ├── Result.swift │ ├── ResuseableView.swift │ └── music-datasource.json └── View │ ├── TrackCell.swift │ └── TrackCell.xib ├── DownloadManagerTests ├── DownloadManagerTests.swift └── Info.plist ├── DownloadManagerUITests ├── DownloadManagerUITests.swift └── Info.plist ├── LICENSE ├── Media ├── download_manager.gif └── mi.png ├── Podfile ├── Podfile.lock ├── Pods ├── AHDownloadButton │ ├── AHDownloadButton │ │ └── Classes │ │ │ ├── AHDownloadButton+StateTransitionAnimation.swift │ │ │ ├── AHDownloadButton.swift │ │ │ ├── CircleView.swift │ │ │ ├── Color.swift │ │ │ ├── HighlightableRoundedButton.swift │ │ │ ├── ProgressButton.swift │ │ │ ├── ProgressCircleView.swift │ │ │ ├── UIButton+TitleWidth.swift │ │ │ └── UIView+Constraint.swift │ ├── LICENSE │ └── README.md ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── AHDownloadButton │ ├── AHDownloadButton-Info.plist │ ├── AHDownloadButton-dummy.m │ ├── AHDownloadButton-prefix.pch │ ├── AHDownloadButton-umbrella.h │ ├── AHDownloadButton.debug.xcconfig │ ├── AHDownloadButton.modulemap │ └── AHDownloadButton.release.xcconfig │ ├── Pods-DownloadManager-DownloadManagerUITests │ ├── Pods-DownloadManager-DownloadManagerUITests-Info.plist │ ├── Pods-DownloadManager-DownloadManagerUITests-acknowledgements.markdown │ ├── Pods-DownloadManager-DownloadManagerUITests-acknowledgements.plist │ ├── Pods-DownloadManager-DownloadManagerUITests-dummy.m │ ├── Pods-DownloadManager-DownloadManagerUITests-frameworks-Debug-input-files.xcfilelist │ ├── Pods-DownloadManager-DownloadManagerUITests-frameworks-Debug-output-files.xcfilelist │ ├── Pods-DownloadManager-DownloadManagerUITests-frameworks-Release-input-files.xcfilelist │ ├── Pods-DownloadManager-DownloadManagerUITests-frameworks-Release-output-files.xcfilelist │ ├── Pods-DownloadManager-DownloadManagerUITests-frameworks.sh │ ├── Pods-DownloadManager-DownloadManagerUITests-umbrella.h │ ├── Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig │ ├── Pods-DownloadManager-DownloadManagerUITests.modulemap │ └── Pods-DownloadManager-DownloadManagerUITests.release.xcconfig │ ├── Pods-DownloadManager │ ├── Pods-DownloadManager-Info.plist │ ├── Pods-DownloadManager-acknowledgements.markdown │ ├── Pods-DownloadManager-acknowledgements.plist │ ├── Pods-DownloadManager-dummy.m │ ├── Pods-DownloadManager-frameworks-Debug-input-files.xcfilelist │ ├── Pods-DownloadManager-frameworks-Debug-output-files.xcfilelist │ ├── Pods-DownloadManager-frameworks-Release-input-files.xcfilelist │ ├── Pods-DownloadManager-frameworks-Release-output-files.xcfilelist │ ├── Pods-DownloadManager-frameworks.sh │ ├── Pods-DownloadManager-umbrella.h │ ├── Pods-DownloadManager.debug.xcconfig │ ├── Pods-DownloadManager.modulemap │ └── Pods-DownloadManager.release.xcconfig │ └── Pods-DownloadManagerTests │ ├── Pods-DownloadManagerTests-Info.plist │ ├── Pods-DownloadManagerTests-acknowledgements.markdown │ ├── Pods-DownloadManagerTests-acknowledgements.plist │ ├── Pods-DownloadManagerTests-dummy.m │ ├── Pods-DownloadManagerTests-umbrella.h │ ├── Pods-DownloadManagerTests.debug.xcconfig │ ├── Pods-DownloadManagerTests.modulemap │ └── Pods-DownloadManagerTests.release.xcconfig └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /DownloadManager.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 23D757D9EC099CDDA58D9A11 /* Pods_DownloadManagerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D20677B1985634DB1AA473E3 /* Pods_DownloadManagerTests.framework */; }; 11 | 26317EFDC71D9E14B8F9E713 /* Pods_DownloadManager_DownloadManagerUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5BD44F0F21CA8E67DC716957 /* Pods_DownloadManager_DownloadManagerUITests.framework */; }; 12 | 5C512E24267B175500C605D3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E23267B175500C605D3 /* AppDelegate.swift */; }; 13 | 5C512E26267B175500C605D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E25267B175500C605D3 /* SceneDelegate.swift */; }; 14 | 5C512E2D267B175600C605D3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5C512E2C267B175600C605D3 /* Assets.xcassets */; }; 15 | 5C512E30267B175600C605D3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5C512E2E267B175600C605D3 /* LaunchScreen.storyboard */; }; 16 | 5C512E3B267B175600C605D3 /* DownloadManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E3A267B175600C605D3 /* DownloadManagerTests.swift */; }; 17 | 5C512E46267B175600C605D3 /* DownloadManagerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E45267B175600C605D3 /* DownloadManagerUITests.swift */; }; 18 | 5C512E5E267B176000C605D3 /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E56267B176000C605D3 /* Response.swift */; }; 19 | 5C512E5F267B176000C605D3 /* AppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E57267B176000C605D3 /* AppError.swift */; }; 20 | 5C512E60267B176000C605D3 /* ResuseableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E58267B176000C605D3 /* ResuseableView.swift */; }; 21 | 5C512E61267B176000C605D3 /* DownloadServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E59267B176000C605D3 /* DownloadServices.swift */; }; 22 | 5C512E62267B176000C605D3 /* Download.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E5A267B176000C605D3 /* Download.swift */; }; 23 | 5C512E63267B176000C605D3 /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E5B267B176000C605D3 /* Helper.swift */; }; 24 | 5C512E64267B176000C605D3 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E5C267B176000C605D3 /* Result.swift */; }; 25 | 5C512E65267B176000C605D3 /* Codable+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E5D267B176000C605D3 /* Codable+Extension.swift */; }; 26 | 5C512E6B267B176A00C605D3 /* TrackCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5C512E69267B176A00C605D3 /* TrackCell.xib */; }; 27 | 5C512E6C267B176A00C605D3 /* TrackCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E6A267B176A00C605D3 /* TrackCell.swift */; }; 28 | 5C512E74267B178000C605D3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C512E73267B178000C605D3 /* ViewController.swift */; }; 29 | 5C512E7C267B179700C605D3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5C512E7B267B179700C605D3 /* Main.storyboard */; }; 30 | 5C512E81267B182900C605D3 /* music-datasource.json in Resources */ = {isa = PBXBuildFile; fileRef = 5C512E80267B182900C605D3 /* music-datasource.json */; }; 31 | 5C835901268315D400D878D9 /* AudioManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C835900268315D400D878D9 /* AudioManager.swift */; }; 32 | 86DA782274F11F863B0B2051 /* Pods_DownloadManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0768712219396E59BB4CA8F3 /* Pods_DownloadManager.framework */; }; 33 | /* End PBXBuildFile section */ 34 | 35 | /* Begin PBXContainerItemProxy section */ 36 | 5C512E37267B175600C605D3 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = 5C512E18267B175500C605D3 /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = 5C512E1F267B175500C605D3; 41 | remoteInfo = DownloadManager; 42 | }; 43 | 5C512E42267B175600C605D3 /* PBXContainerItemProxy */ = { 44 | isa = PBXContainerItemProxy; 45 | containerPortal = 5C512E18267B175500C605D3 /* Project object */; 46 | proxyType = 1; 47 | remoteGlobalIDString = 5C512E1F267B175500C605D3; 48 | remoteInfo = DownloadManager; 49 | }; 50 | /* End PBXContainerItemProxy section */ 51 | 52 | /* Begin PBXFileReference section */ 53 | 0768712219396E59BB4CA8F3 /* Pods_DownloadManager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DownloadManager.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 3C3C8B8C48DDCFE9B08F071E /* Pods-DownloadManagerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DownloadManagerTests.release.xcconfig"; path = "Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests.release.xcconfig"; sourceTree = ""; }; 55 | 3D32D09C928E0C8471641025 /* Pods-DownloadManager.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DownloadManager.debug.xcconfig"; path = "Target Support Files/Pods-DownloadManager/Pods-DownloadManager.debug.xcconfig"; sourceTree = ""; }; 56 | 47A27100E91CF5DDDA1DF2FC /* Pods-DownloadManager-DownloadManagerUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DownloadManager-DownloadManagerUITests.release.xcconfig"; path = "Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests.release.xcconfig"; sourceTree = ""; }; 57 | 5BD44F0F21CA8E67DC716957 /* Pods_DownloadManager_DownloadManagerUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DownloadManager_DownloadManagerUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 5C512E20267B175500C605D3 /* DownloadManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DownloadManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 5C512E23267B175500C605D3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 60 | 5C512E25267B175500C605D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 61 | 5C512E2C267B175600C605D3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 62 | 5C512E2F267B175600C605D3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 63 | 5C512E31267B175600C605D3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 64 | 5C512E36267B175600C605D3 /* DownloadManagerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DownloadManagerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 65 | 5C512E3A267B175600C605D3 /* DownloadManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadManagerTests.swift; sourceTree = ""; }; 66 | 5C512E3C267B175600C605D3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 67 | 5C512E41267B175600C605D3 /* DownloadManagerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DownloadManagerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | 5C512E45267B175600C605D3 /* DownloadManagerUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadManagerUITests.swift; sourceTree = ""; }; 69 | 5C512E47267B175600C605D3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 5C512E56267B176000C605D3 /* Response.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Response.swift; sourceTree = ""; }; 71 | 5C512E57267B176000C605D3 /* AppError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppError.swift; sourceTree = ""; }; 72 | 5C512E58267B176000C605D3 /* ResuseableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResuseableView.swift; sourceTree = ""; }; 73 | 5C512E59267B176000C605D3 /* DownloadServices.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadServices.swift; sourceTree = ""; }; 74 | 5C512E5A267B176000C605D3 /* Download.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Download.swift; sourceTree = ""; }; 75 | 5C512E5B267B176000C605D3 /* Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = ""; }; 76 | 5C512E5C267B176000C605D3 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; 77 | 5C512E5D267B176000C605D3 /* Codable+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Codable+Extension.swift"; sourceTree = ""; }; 78 | 5C512E69267B176A00C605D3 /* TrackCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TrackCell.xib; sourceTree = ""; }; 79 | 5C512E6A267B176A00C605D3 /* TrackCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackCell.swift; sourceTree = ""; }; 80 | 5C512E73267B178000C605D3 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 81 | 5C512E7B267B179700C605D3 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 82 | 5C512E80267B182900C605D3 /* music-datasource.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "music-datasource.json"; sourceTree = ""; }; 83 | 5C835900268315D400D878D9 /* AudioManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioManager.swift; sourceTree = ""; }; 84 | 9401994DD518BF3EEB8AB50D /* Pods-DownloadManagerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DownloadManagerTests.debug.xcconfig"; path = "Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests.debug.xcconfig"; sourceTree = ""; }; 85 | 9AD775709EBB1537EA642171 /* Pods-DownloadManager.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DownloadManager.release.xcconfig"; path = "Target Support Files/Pods-DownloadManager/Pods-DownloadManager.release.xcconfig"; sourceTree = ""; }; 86 | D20677B1985634DB1AA473E3 /* Pods_DownloadManagerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DownloadManagerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 87 | FAA79F0F0AA73818D1A3643F /* Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig"; path = "Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig"; sourceTree = ""; }; 88 | /* End PBXFileReference section */ 89 | 90 | /* Begin PBXFrameworksBuildPhase section */ 91 | 5C512E1D267B175500C605D3 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | 86DA782274F11F863B0B2051 /* Pods_DownloadManager.framework in Frameworks */, 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | 5C512E33267B175600C605D3 /* Frameworks */ = { 100 | isa = PBXFrameworksBuildPhase; 101 | buildActionMask = 2147483647; 102 | files = ( 103 | 23D757D9EC099CDDA58D9A11 /* Pods_DownloadManagerTests.framework in Frameworks */, 104 | ); 105 | runOnlyForDeploymentPostprocessing = 0; 106 | }; 107 | 5C512E3E267B175600C605D3 /* Frameworks */ = { 108 | isa = PBXFrameworksBuildPhase; 109 | buildActionMask = 2147483647; 110 | files = ( 111 | 26317EFDC71D9E14B8F9E713 /* Pods_DownloadManager_DownloadManagerUITests.framework in Frameworks */, 112 | ); 113 | runOnlyForDeploymentPostprocessing = 0; 114 | }; 115 | /* End PBXFrameworksBuildPhase section */ 116 | 117 | /* Begin PBXGroup section */ 118 | 0C165E92931A1116608E05E5 /* Frameworks */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 0768712219396E59BB4CA8F3 /* Pods_DownloadManager.framework */, 122 | 5BD44F0F21CA8E67DC716957 /* Pods_DownloadManager_DownloadManagerUITests.framework */, 123 | D20677B1985634DB1AA473E3 /* Pods_DownloadManagerTests.framework */, 124 | ); 125 | name = Frameworks; 126 | sourceTree = ""; 127 | }; 128 | 50231BC271CE138F4B4DC0A5 /* Pods */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 3D32D09C928E0C8471641025 /* Pods-DownloadManager.debug.xcconfig */, 132 | 9AD775709EBB1537EA642171 /* Pods-DownloadManager.release.xcconfig */, 133 | FAA79F0F0AA73818D1A3643F /* Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig */, 134 | 47A27100E91CF5DDDA1DF2FC /* Pods-DownloadManager-DownloadManagerUITests.release.xcconfig */, 135 | 9401994DD518BF3EEB8AB50D /* Pods-DownloadManagerTests.debug.xcconfig */, 136 | 3C3C8B8C48DDCFE9B08F071E /* Pods-DownloadManagerTests.release.xcconfig */, 137 | ); 138 | path = Pods; 139 | sourceTree = ""; 140 | }; 141 | 5C512E17267B175500C605D3 = { 142 | isa = PBXGroup; 143 | children = ( 144 | 5C512E22267B175500C605D3 /* DownloadManager */, 145 | 5C512E39267B175600C605D3 /* DownloadManagerTests */, 146 | 5C512E44267B175600C605D3 /* DownloadManagerUITests */, 147 | 5C512E21267B175500C605D3 /* Products */, 148 | 50231BC271CE138F4B4DC0A5 /* Pods */, 149 | 0C165E92931A1116608E05E5 /* Frameworks */, 150 | ); 151 | sourceTree = ""; 152 | }; 153 | 5C512E21267B175500C605D3 /* Products */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 5C512E20267B175500C605D3 /* DownloadManager.app */, 157 | 5C512E36267B175600C605D3 /* DownloadManagerTests.xctest */, 158 | 5C512E41267B175600C605D3 /* DownloadManagerUITests.xctest */, 159 | ); 160 | name = Products; 161 | sourceTree = ""; 162 | }; 163 | 5C512E22267B175500C605D3 /* DownloadManager */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | 5C8358EC268306E200D878D9 /* AppDelegate */, 167 | 5C8358EB268306D800D878D9 /* Storyboard */, 168 | 5C8358E62683068400D878D9 /* Controller */, 169 | 5C8A479426821DB8000D8568 /* View */, 170 | 5C8358E7268306BD00D878D9 /* Modal */, 171 | 5C8A479826821DC7000D8568 /* Utilities */, 172 | 5C8358E22683067C00D878D9 /* Extension */, 173 | 5C8358F02683070500D878D9 /* SupportFiles */, 174 | ); 175 | path = DownloadManager; 176 | sourceTree = ""; 177 | }; 178 | 5C512E39267B175600C605D3 /* DownloadManagerTests */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 5C512E3A267B175600C605D3 /* DownloadManagerTests.swift */, 182 | 5C512E3C267B175600C605D3 /* Info.plist */, 183 | ); 184 | path = DownloadManagerTests; 185 | sourceTree = ""; 186 | }; 187 | 5C512E44267B175600C605D3 /* DownloadManagerUITests */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | 5C512E45267B175600C605D3 /* DownloadManagerUITests.swift */, 191 | 5C512E47267B175600C605D3 /* Info.plist */, 192 | ); 193 | path = DownloadManagerUITests; 194 | sourceTree = ""; 195 | }; 196 | 5C8358E22683067C00D878D9 /* Extension */ = { 197 | isa = PBXGroup; 198 | children = ( 199 | 5C512E5D267B176000C605D3 /* Codable+Extension.swift */, 200 | ); 201 | path = Extension; 202 | sourceTree = ""; 203 | }; 204 | 5C8358E62683068400D878D9 /* Controller */ = { 205 | isa = PBXGroup; 206 | children = ( 207 | 5C512E73267B178000C605D3 /* ViewController.swift */, 208 | ); 209 | path = Controller; 210 | sourceTree = ""; 211 | }; 212 | 5C8358E7268306BD00D878D9 /* Modal */ = { 213 | isa = PBXGroup; 214 | children = ( 215 | 5C512E56267B176000C605D3 /* Response.swift */, 216 | ); 217 | path = Modal; 218 | sourceTree = ""; 219 | }; 220 | 5C8358EB268306D800D878D9 /* Storyboard */ = { 221 | isa = PBXGroup; 222 | children = ( 223 | 5C512E7B267B179700C605D3 /* Main.storyboard */, 224 | 5C512E2E267B175600C605D3 /* LaunchScreen.storyboard */, 225 | ); 226 | path = Storyboard; 227 | sourceTree = ""; 228 | }; 229 | 5C8358EC268306E200D878D9 /* AppDelegate */ = { 230 | isa = PBXGroup; 231 | children = ( 232 | 5C512E23267B175500C605D3 /* AppDelegate.swift */, 233 | 5C512E25267B175500C605D3 /* SceneDelegate.swift */, 234 | ); 235 | path = AppDelegate; 236 | sourceTree = ""; 237 | }; 238 | 5C8358F02683070500D878D9 /* SupportFiles */ = { 239 | isa = PBXGroup; 240 | children = ( 241 | 5C512E2C267B175600C605D3 /* Assets.xcassets */, 242 | 5C512E31267B175600C605D3 /* Info.plist */, 243 | ); 244 | path = SupportFiles; 245 | sourceTree = ""; 246 | }; 247 | 5C8A479426821DB8000D8568 /* View */ = { 248 | isa = PBXGroup; 249 | children = ( 250 | 5C512E6A267B176A00C605D3 /* TrackCell.swift */, 251 | 5C512E69267B176A00C605D3 /* TrackCell.xib */, 252 | ); 253 | path = View; 254 | sourceTree = ""; 255 | }; 256 | 5C8A479826821DC7000D8568 /* Utilities */ = { 257 | isa = PBXGroup; 258 | children = ( 259 | 5C512E80267B182900C605D3 /* music-datasource.json */, 260 | 5C512E57267B176000C605D3 /* AppError.swift */, 261 | 5C512E5A267B176000C605D3 /* Download.swift */, 262 | 5C512E59267B176000C605D3 /* DownloadServices.swift */, 263 | 5C512E5B267B176000C605D3 /* Helper.swift */, 264 | 5C512E5C267B176000C605D3 /* Result.swift */, 265 | 5C512E58267B176000C605D3 /* ResuseableView.swift */, 266 | 5C835900268315D400D878D9 /* AudioManager.swift */, 267 | ); 268 | path = Utilities; 269 | sourceTree = ""; 270 | }; 271 | /* End PBXGroup section */ 272 | 273 | /* Begin PBXNativeTarget section */ 274 | 5C512E1F267B175500C605D3 /* DownloadManager */ = { 275 | isa = PBXNativeTarget; 276 | buildConfigurationList = 5C512E4A267B175600C605D3 /* Build configuration list for PBXNativeTarget "DownloadManager" */; 277 | buildPhases = ( 278 | 6B503E64E36464D75DE598BD /* [CP] Check Pods Manifest.lock */, 279 | 5C512E1C267B175500C605D3 /* Sources */, 280 | 5C512E1D267B175500C605D3 /* Frameworks */, 281 | 5C512E1E267B175500C605D3 /* Resources */, 282 | 4AB8396364C25642ECDE029D /* [CP] Embed Pods Frameworks */, 283 | ); 284 | buildRules = ( 285 | ); 286 | dependencies = ( 287 | ); 288 | name = DownloadManager; 289 | productName = DownloadManager; 290 | productReference = 5C512E20267B175500C605D3 /* DownloadManager.app */; 291 | productType = "com.apple.product-type.application"; 292 | }; 293 | 5C512E35267B175600C605D3 /* DownloadManagerTests */ = { 294 | isa = PBXNativeTarget; 295 | buildConfigurationList = 5C512E4D267B175600C605D3 /* Build configuration list for PBXNativeTarget "DownloadManagerTests" */; 296 | buildPhases = ( 297 | C539065B9C364C728D6B3454 /* [CP] Check Pods Manifest.lock */, 298 | 5C512E32267B175600C605D3 /* Sources */, 299 | 5C512E33267B175600C605D3 /* Frameworks */, 300 | 5C512E34267B175600C605D3 /* Resources */, 301 | ); 302 | buildRules = ( 303 | ); 304 | dependencies = ( 305 | 5C512E38267B175600C605D3 /* PBXTargetDependency */, 306 | ); 307 | name = DownloadManagerTests; 308 | productName = DownloadManagerTests; 309 | productReference = 5C512E36267B175600C605D3 /* DownloadManagerTests.xctest */; 310 | productType = "com.apple.product-type.bundle.unit-test"; 311 | }; 312 | 5C512E40267B175600C605D3 /* DownloadManagerUITests */ = { 313 | isa = PBXNativeTarget; 314 | buildConfigurationList = 5C512E50267B175600C605D3 /* Build configuration list for PBXNativeTarget "DownloadManagerUITests" */; 315 | buildPhases = ( 316 | EE595C8AAB64A4FB1E4BB69B /* [CP] Check Pods Manifest.lock */, 317 | 5C512E3D267B175600C605D3 /* Sources */, 318 | 5C512E3E267B175600C605D3 /* Frameworks */, 319 | 5C512E3F267B175600C605D3 /* Resources */, 320 | 210C4D1CF15FE8D729E6D523 /* [CP] Embed Pods Frameworks */, 321 | ); 322 | buildRules = ( 323 | ); 324 | dependencies = ( 325 | 5C512E43267B175600C605D3 /* PBXTargetDependency */, 326 | ); 327 | name = DownloadManagerUITests; 328 | productName = DownloadManagerUITests; 329 | productReference = 5C512E41267B175600C605D3 /* DownloadManagerUITests.xctest */; 330 | productType = "com.apple.product-type.bundle.ui-testing"; 331 | }; 332 | /* End PBXNativeTarget section */ 333 | 334 | /* Begin PBXProject section */ 335 | 5C512E18267B175500C605D3 /* Project object */ = { 336 | isa = PBXProject; 337 | attributes = { 338 | LastSwiftUpdateCheck = 1230; 339 | LastUpgradeCheck = 1230; 340 | TargetAttributes = { 341 | 5C512E1F267B175500C605D3 = { 342 | CreatedOnToolsVersion = 12.3; 343 | }; 344 | 5C512E35267B175600C605D3 = { 345 | CreatedOnToolsVersion = 12.3; 346 | TestTargetID = 5C512E1F267B175500C605D3; 347 | }; 348 | 5C512E40267B175600C605D3 = { 349 | CreatedOnToolsVersion = 12.3; 350 | TestTargetID = 5C512E1F267B175500C605D3; 351 | }; 352 | }; 353 | }; 354 | buildConfigurationList = 5C512E1B267B175500C605D3 /* Build configuration list for PBXProject "DownloadManager" */; 355 | compatibilityVersion = "Xcode 9.3"; 356 | developmentRegion = en; 357 | hasScannedForEncodings = 0; 358 | knownRegions = ( 359 | en, 360 | Base, 361 | ); 362 | mainGroup = 5C512E17267B175500C605D3; 363 | productRefGroup = 5C512E21267B175500C605D3 /* Products */; 364 | projectDirPath = ""; 365 | projectRoot = ""; 366 | targets = ( 367 | 5C512E1F267B175500C605D3 /* DownloadManager */, 368 | 5C512E35267B175600C605D3 /* DownloadManagerTests */, 369 | 5C512E40267B175600C605D3 /* DownloadManagerUITests */, 370 | ); 371 | }; 372 | /* End PBXProject section */ 373 | 374 | /* Begin PBXResourcesBuildPhase section */ 375 | 5C512E1E267B175500C605D3 /* Resources */ = { 376 | isa = PBXResourcesBuildPhase; 377 | buildActionMask = 2147483647; 378 | files = ( 379 | 5C512E30267B175600C605D3 /* LaunchScreen.storyboard in Resources */, 380 | 5C512E81267B182900C605D3 /* music-datasource.json in Resources */, 381 | 5C512E2D267B175600C605D3 /* Assets.xcassets in Resources */, 382 | 5C512E6B267B176A00C605D3 /* TrackCell.xib in Resources */, 383 | 5C512E7C267B179700C605D3 /* Main.storyboard in Resources */, 384 | ); 385 | runOnlyForDeploymentPostprocessing = 0; 386 | }; 387 | 5C512E34267B175600C605D3 /* Resources */ = { 388 | isa = PBXResourcesBuildPhase; 389 | buildActionMask = 2147483647; 390 | files = ( 391 | ); 392 | runOnlyForDeploymentPostprocessing = 0; 393 | }; 394 | 5C512E3F267B175600C605D3 /* Resources */ = { 395 | isa = PBXResourcesBuildPhase; 396 | buildActionMask = 2147483647; 397 | files = ( 398 | ); 399 | runOnlyForDeploymentPostprocessing = 0; 400 | }; 401 | /* End PBXResourcesBuildPhase section */ 402 | 403 | /* Begin PBXShellScriptBuildPhase section */ 404 | 210C4D1CF15FE8D729E6D523 /* [CP] Embed Pods Frameworks */ = { 405 | isa = PBXShellScriptBuildPhase; 406 | buildActionMask = 2147483647; 407 | files = ( 408 | ); 409 | inputFileListPaths = ( 410 | "${PODS_ROOT}/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks-${CONFIGURATION}-input-files.xcfilelist", 411 | ); 412 | name = "[CP] Embed Pods Frameworks"; 413 | outputFileListPaths = ( 414 | "${PODS_ROOT}/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks-${CONFIGURATION}-output-files.xcfilelist", 415 | ); 416 | runOnlyForDeploymentPostprocessing = 0; 417 | shellPath = /bin/sh; 418 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks.sh\"\n"; 419 | showEnvVarsInLog = 0; 420 | }; 421 | 4AB8396364C25642ECDE029D /* [CP] Embed Pods Frameworks */ = { 422 | isa = PBXShellScriptBuildPhase; 423 | buildActionMask = 2147483647; 424 | files = ( 425 | ); 426 | inputFileListPaths = ( 427 | "${PODS_ROOT}/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks-${CONFIGURATION}-input-files.xcfilelist", 428 | ); 429 | name = "[CP] Embed Pods Frameworks"; 430 | outputFileListPaths = ( 431 | "${PODS_ROOT}/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks-${CONFIGURATION}-output-files.xcfilelist", 432 | ); 433 | runOnlyForDeploymentPostprocessing = 0; 434 | shellPath = /bin/sh; 435 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks.sh\"\n"; 436 | showEnvVarsInLog = 0; 437 | }; 438 | 6B503E64E36464D75DE598BD /* [CP] Check Pods Manifest.lock */ = { 439 | isa = PBXShellScriptBuildPhase; 440 | buildActionMask = 2147483647; 441 | files = ( 442 | ); 443 | inputFileListPaths = ( 444 | ); 445 | inputPaths = ( 446 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 447 | "${PODS_ROOT}/Manifest.lock", 448 | ); 449 | name = "[CP] Check Pods Manifest.lock"; 450 | outputFileListPaths = ( 451 | ); 452 | outputPaths = ( 453 | "$(DERIVED_FILE_DIR)/Pods-DownloadManager-checkManifestLockResult.txt", 454 | ); 455 | runOnlyForDeploymentPostprocessing = 0; 456 | shellPath = /bin/sh; 457 | 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"; 458 | showEnvVarsInLog = 0; 459 | }; 460 | C539065B9C364C728D6B3454 /* [CP] Check Pods Manifest.lock */ = { 461 | isa = PBXShellScriptBuildPhase; 462 | buildActionMask = 2147483647; 463 | files = ( 464 | ); 465 | inputFileListPaths = ( 466 | ); 467 | inputPaths = ( 468 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 469 | "${PODS_ROOT}/Manifest.lock", 470 | ); 471 | name = "[CP] Check Pods Manifest.lock"; 472 | outputFileListPaths = ( 473 | ); 474 | outputPaths = ( 475 | "$(DERIVED_FILE_DIR)/Pods-DownloadManagerTests-checkManifestLockResult.txt", 476 | ); 477 | runOnlyForDeploymentPostprocessing = 0; 478 | shellPath = /bin/sh; 479 | 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"; 480 | showEnvVarsInLog = 0; 481 | }; 482 | EE595C8AAB64A4FB1E4BB69B /* [CP] Check Pods Manifest.lock */ = { 483 | isa = PBXShellScriptBuildPhase; 484 | buildActionMask = 2147483647; 485 | files = ( 486 | ); 487 | inputFileListPaths = ( 488 | ); 489 | inputPaths = ( 490 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 491 | "${PODS_ROOT}/Manifest.lock", 492 | ); 493 | name = "[CP] Check Pods Manifest.lock"; 494 | outputFileListPaths = ( 495 | ); 496 | outputPaths = ( 497 | "$(DERIVED_FILE_DIR)/Pods-DownloadManager-DownloadManagerUITests-checkManifestLockResult.txt", 498 | ); 499 | runOnlyForDeploymentPostprocessing = 0; 500 | shellPath = /bin/sh; 501 | 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"; 502 | showEnvVarsInLog = 0; 503 | }; 504 | /* End PBXShellScriptBuildPhase section */ 505 | 506 | /* Begin PBXSourcesBuildPhase section */ 507 | 5C512E1C267B175500C605D3 /* Sources */ = { 508 | isa = PBXSourcesBuildPhase; 509 | buildActionMask = 2147483647; 510 | files = ( 511 | 5C512E5E267B176000C605D3 /* Response.swift in Sources */, 512 | 5C512E62267B176000C605D3 /* Download.swift in Sources */, 513 | 5C512E60267B176000C605D3 /* ResuseableView.swift in Sources */, 514 | 5C512E61267B176000C605D3 /* DownloadServices.swift in Sources */, 515 | 5C512E63267B176000C605D3 /* Helper.swift in Sources */, 516 | 5C512E64267B176000C605D3 /* Result.swift in Sources */, 517 | 5C512E74267B178000C605D3 /* ViewController.swift in Sources */, 518 | 5C512E5F267B176000C605D3 /* AppError.swift in Sources */, 519 | 5C512E24267B175500C605D3 /* AppDelegate.swift in Sources */, 520 | 5C512E65267B176000C605D3 /* Codable+Extension.swift in Sources */, 521 | 5C512E26267B175500C605D3 /* SceneDelegate.swift in Sources */, 522 | 5C512E6C267B176A00C605D3 /* TrackCell.swift in Sources */, 523 | 5C835901268315D400D878D9 /* AudioManager.swift in Sources */, 524 | ); 525 | runOnlyForDeploymentPostprocessing = 0; 526 | }; 527 | 5C512E32267B175600C605D3 /* Sources */ = { 528 | isa = PBXSourcesBuildPhase; 529 | buildActionMask = 2147483647; 530 | files = ( 531 | 5C512E3B267B175600C605D3 /* DownloadManagerTests.swift in Sources */, 532 | ); 533 | runOnlyForDeploymentPostprocessing = 0; 534 | }; 535 | 5C512E3D267B175600C605D3 /* Sources */ = { 536 | isa = PBXSourcesBuildPhase; 537 | buildActionMask = 2147483647; 538 | files = ( 539 | 5C512E46267B175600C605D3 /* DownloadManagerUITests.swift in Sources */, 540 | ); 541 | runOnlyForDeploymentPostprocessing = 0; 542 | }; 543 | /* End PBXSourcesBuildPhase section */ 544 | 545 | /* Begin PBXTargetDependency section */ 546 | 5C512E38267B175600C605D3 /* PBXTargetDependency */ = { 547 | isa = PBXTargetDependency; 548 | target = 5C512E1F267B175500C605D3 /* DownloadManager */; 549 | targetProxy = 5C512E37267B175600C605D3 /* PBXContainerItemProxy */; 550 | }; 551 | 5C512E43267B175600C605D3 /* PBXTargetDependency */ = { 552 | isa = PBXTargetDependency; 553 | target = 5C512E1F267B175500C605D3 /* DownloadManager */; 554 | targetProxy = 5C512E42267B175600C605D3 /* PBXContainerItemProxy */; 555 | }; 556 | /* End PBXTargetDependency section */ 557 | 558 | /* Begin PBXVariantGroup section */ 559 | 5C512E2E267B175600C605D3 /* LaunchScreen.storyboard */ = { 560 | isa = PBXVariantGroup; 561 | children = ( 562 | 5C512E2F267B175600C605D3 /* Base */, 563 | ); 564 | name = LaunchScreen.storyboard; 565 | sourceTree = ""; 566 | }; 567 | /* End PBXVariantGroup section */ 568 | 569 | /* Begin XCBuildConfiguration section */ 570 | 5C512E48267B175600C605D3 /* Debug */ = { 571 | isa = XCBuildConfiguration; 572 | buildSettings = { 573 | ALWAYS_SEARCH_USER_PATHS = NO; 574 | ASSET_PACK_MANIFEST_URL_PREFIX = ""; 575 | CLANG_ANALYZER_NONNULL = YES; 576 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 577 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 578 | CLANG_CXX_LIBRARY = "libc++"; 579 | CLANG_ENABLE_MODULES = YES; 580 | CLANG_ENABLE_OBJC_ARC = YES; 581 | CLANG_ENABLE_OBJC_WEAK = YES; 582 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 583 | CLANG_WARN_BOOL_CONVERSION = YES; 584 | CLANG_WARN_COMMA = YES; 585 | CLANG_WARN_CONSTANT_CONVERSION = YES; 586 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 587 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 588 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 589 | CLANG_WARN_EMPTY_BODY = YES; 590 | CLANG_WARN_ENUM_CONVERSION = YES; 591 | CLANG_WARN_INFINITE_RECURSION = YES; 592 | CLANG_WARN_INT_CONVERSION = YES; 593 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 594 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 595 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 596 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 597 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 598 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 599 | CLANG_WARN_STRICT_PROTOTYPES = YES; 600 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 601 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 602 | CLANG_WARN_UNREACHABLE_CODE = YES; 603 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 604 | COPY_PHASE_STRIP = NO; 605 | DEBUG_INFORMATION_FORMAT = dwarf; 606 | ENABLE_STRICT_OBJC_MSGSEND = YES; 607 | ENABLE_TESTABILITY = YES; 608 | GCC_C_LANGUAGE_STANDARD = gnu11; 609 | GCC_DYNAMIC_NO_PIC = NO; 610 | GCC_NO_COMMON_BLOCKS = YES; 611 | GCC_OPTIMIZATION_LEVEL = 0; 612 | GCC_PREPROCESSOR_DEFINITIONS = ( 613 | "DEBUG=1", 614 | "$(inherited)", 615 | ); 616 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 617 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 618 | GCC_WARN_UNDECLARED_SELECTOR = YES; 619 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 620 | GCC_WARN_UNUSED_FUNCTION = YES; 621 | GCC_WARN_UNUSED_VARIABLE = YES; 622 | IPHONEOS_DEPLOYMENT_TARGET = 14.3; 623 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 624 | MTL_FAST_MATH = YES; 625 | ONLY_ACTIVE_ARCH = YES; 626 | SDKROOT = iphoneos; 627 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 628 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 629 | }; 630 | name = Debug; 631 | }; 632 | 5C512E49267B175600C605D3 /* Release */ = { 633 | isa = XCBuildConfiguration; 634 | buildSettings = { 635 | ALWAYS_SEARCH_USER_PATHS = NO; 636 | ASSET_PACK_MANIFEST_URL_PREFIX = ""; 637 | CLANG_ANALYZER_NONNULL = YES; 638 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 639 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 640 | CLANG_CXX_LIBRARY = "libc++"; 641 | CLANG_ENABLE_MODULES = YES; 642 | CLANG_ENABLE_OBJC_ARC = YES; 643 | CLANG_ENABLE_OBJC_WEAK = YES; 644 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 645 | CLANG_WARN_BOOL_CONVERSION = YES; 646 | CLANG_WARN_COMMA = YES; 647 | CLANG_WARN_CONSTANT_CONVERSION = YES; 648 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 649 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 650 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 651 | CLANG_WARN_EMPTY_BODY = YES; 652 | CLANG_WARN_ENUM_CONVERSION = YES; 653 | CLANG_WARN_INFINITE_RECURSION = YES; 654 | CLANG_WARN_INT_CONVERSION = YES; 655 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 656 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 657 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 658 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 659 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 660 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 661 | CLANG_WARN_STRICT_PROTOTYPES = YES; 662 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 663 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 664 | CLANG_WARN_UNREACHABLE_CODE = YES; 665 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 666 | COPY_PHASE_STRIP = NO; 667 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 668 | ENABLE_NS_ASSERTIONS = NO; 669 | ENABLE_STRICT_OBJC_MSGSEND = YES; 670 | GCC_C_LANGUAGE_STANDARD = gnu11; 671 | GCC_NO_COMMON_BLOCKS = YES; 672 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 673 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 674 | GCC_WARN_UNDECLARED_SELECTOR = YES; 675 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 676 | GCC_WARN_UNUSED_FUNCTION = YES; 677 | GCC_WARN_UNUSED_VARIABLE = YES; 678 | IPHONEOS_DEPLOYMENT_TARGET = 14.3; 679 | MTL_ENABLE_DEBUG_INFO = NO; 680 | MTL_FAST_MATH = YES; 681 | SDKROOT = iphoneos; 682 | SWIFT_COMPILATION_MODE = wholemodule; 683 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 684 | VALIDATE_PRODUCT = YES; 685 | }; 686 | name = Release; 687 | }; 688 | 5C512E4B267B175600C605D3 /* Debug */ = { 689 | isa = XCBuildConfiguration; 690 | baseConfigurationReference = 3D32D09C928E0C8471641025 /* Pods-DownloadManager.debug.xcconfig */; 691 | buildSettings = { 692 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 693 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 694 | ASSET_PACK_MANIFEST_URL_PREFIX = DownloadManager/SupportFiles/Info.plist; 695 | CODE_SIGN_STYLE = Automatic; 696 | INFOPLIST_FILE = DownloadManager/SupportFiles/Info.plist; 697 | LD_RUNPATH_SEARCH_PATHS = ( 698 | "$(inherited)", 699 | "@executable_path/Frameworks", 700 | ); 701 | PRODUCT_BUNDLE_IDENTIFIER = com.mi.DownloadManager; 702 | PRODUCT_NAME = "$(TARGET_NAME)"; 703 | SWIFT_VERSION = 5.0; 704 | TARGETED_DEVICE_FAMILY = "1,2"; 705 | }; 706 | name = Debug; 707 | }; 708 | 5C512E4C267B175600C605D3 /* Release */ = { 709 | isa = XCBuildConfiguration; 710 | baseConfigurationReference = 9AD775709EBB1537EA642171 /* Pods-DownloadManager.release.xcconfig */; 711 | buildSettings = { 712 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 713 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 714 | ASSET_PACK_MANIFEST_URL_PREFIX = DownloadManager/SupportFiles/Info.plist; 715 | CODE_SIGN_STYLE = Automatic; 716 | INFOPLIST_FILE = DownloadManager/SupportFiles/Info.plist; 717 | LD_RUNPATH_SEARCH_PATHS = ( 718 | "$(inherited)", 719 | "@executable_path/Frameworks", 720 | ); 721 | PRODUCT_BUNDLE_IDENTIFIER = com.mi.DownloadManager; 722 | PRODUCT_NAME = "$(TARGET_NAME)"; 723 | SWIFT_VERSION = 5.0; 724 | TARGETED_DEVICE_FAMILY = "1,2"; 725 | }; 726 | name = Release; 727 | }; 728 | 5C512E4E267B175600C605D3 /* Debug */ = { 729 | isa = XCBuildConfiguration; 730 | baseConfigurationReference = 9401994DD518BF3EEB8AB50D /* Pods-DownloadManagerTests.debug.xcconfig */; 731 | buildSettings = { 732 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 733 | BUNDLE_LOADER = "$(TEST_HOST)"; 734 | CODE_SIGN_STYLE = Automatic; 735 | INFOPLIST_FILE = DownloadManagerTests/Info.plist; 736 | IPHONEOS_DEPLOYMENT_TARGET = 14.3; 737 | LD_RUNPATH_SEARCH_PATHS = ( 738 | "$(inherited)", 739 | "@executable_path/Frameworks", 740 | "@loader_path/Frameworks", 741 | ); 742 | PRODUCT_BUNDLE_IDENTIFIER = com.mi.DownloadManagerTests; 743 | PRODUCT_NAME = "$(TARGET_NAME)"; 744 | SWIFT_VERSION = 5.0; 745 | TARGETED_DEVICE_FAMILY = "1,2"; 746 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DownloadManager.app/DownloadManager"; 747 | }; 748 | name = Debug; 749 | }; 750 | 5C512E4F267B175600C605D3 /* Release */ = { 751 | isa = XCBuildConfiguration; 752 | baseConfigurationReference = 3C3C8B8C48DDCFE9B08F071E /* Pods-DownloadManagerTests.release.xcconfig */; 753 | buildSettings = { 754 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 755 | BUNDLE_LOADER = "$(TEST_HOST)"; 756 | CODE_SIGN_STYLE = Automatic; 757 | INFOPLIST_FILE = DownloadManagerTests/Info.plist; 758 | IPHONEOS_DEPLOYMENT_TARGET = 14.3; 759 | LD_RUNPATH_SEARCH_PATHS = ( 760 | "$(inherited)", 761 | "@executable_path/Frameworks", 762 | "@loader_path/Frameworks", 763 | ); 764 | PRODUCT_BUNDLE_IDENTIFIER = com.mi.DownloadManagerTests; 765 | PRODUCT_NAME = "$(TARGET_NAME)"; 766 | SWIFT_VERSION = 5.0; 767 | TARGETED_DEVICE_FAMILY = "1,2"; 768 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DownloadManager.app/DownloadManager"; 769 | }; 770 | name = Release; 771 | }; 772 | 5C512E51267B175600C605D3 /* Debug */ = { 773 | isa = XCBuildConfiguration; 774 | baseConfigurationReference = FAA79F0F0AA73818D1A3643F /* Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig */; 775 | buildSettings = { 776 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 777 | CODE_SIGN_STYLE = Automatic; 778 | INFOPLIST_FILE = DownloadManagerUITests/Info.plist; 779 | LD_RUNPATH_SEARCH_PATHS = ( 780 | "$(inherited)", 781 | "@executable_path/Frameworks", 782 | "@loader_path/Frameworks", 783 | ); 784 | PRODUCT_BUNDLE_IDENTIFIER = com.mi.DownloadManagerUITests; 785 | PRODUCT_NAME = "$(TARGET_NAME)"; 786 | SWIFT_VERSION = 5.0; 787 | TARGETED_DEVICE_FAMILY = "1,2"; 788 | TEST_TARGET_NAME = DownloadManager; 789 | }; 790 | name = Debug; 791 | }; 792 | 5C512E52267B175600C605D3 /* Release */ = { 793 | isa = XCBuildConfiguration; 794 | baseConfigurationReference = 47A27100E91CF5DDDA1DF2FC /* Pods-DownloadManager-DownloadManagerUITests.release.xcconfig */; 795 | buildSettings = { 796 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 797 | CODE_SIGN_STYLE = Automatic; 798 | INFOPLIST_FILE = DownloadManagerUITests/Info.plist; 799 | LD_RUNPATH_SEARCH_PATHS = ( 800 | "$(inherited)", 801 | "@executable_path/Frameworks", 802 | "@loader_path/Frameworks", 803 | ); 804 | PRODUCT_BUNDLE_IDENTIFIER = com.mi.DownloadManagerUITests; 805 | PRODUCT_NAME = "$(TARGET_NAME)"; 806 | SWIFT_VERSION = 5.0; 807 | TARGETED_DEVICE_FAMILY = "1,2"; 808 | TEST_TARGET_NAME = DownloadManager; 809 | }; 810 | name = Release; 811 | }; 812 | /* End XCBuildConfiguration section */ 813 | 814 | /* Begin XCConfigurationList section */ 815 | 5C512E1B267B175500C605D3 /* Build configuration list for PBXProject "DownloadManager" */ = { 816 | isa = XCConfigurationList; 817 | buildConfigurations = ( 818 | 5C512E48267B175600C605D3 /* Debug */, 819 | 5C512E49267B175600C605D3 /* Release */, 820 | ); 821 | defaultConfigurationIsVisible = 0; 822 | defaultConfigurationName = Release; 823 | }; 824 | 5C512E4A267B175600C605D3 /* Build configuration list for PBXNativeTarget "DownloadManager" */ = { 825 | isa = XCConfigurationList; 826 | buildConfigurations = ( 827 | 5C512E4B267B175600C605D3 /* Debug */, 828 | 5C512E4C267B175600C605D3 /* Release */, 829 | ); 830 | defaultConfigurationIsVisible = 0; 831 | defaultConfigurationName = Release; 832 | }; 833 | 5C512E4D267B175600C605D3 /* Build configuration list for PBXNativeTarget "DownloadManagerTests" */ = { 834 | isa = XCConfigurationList; 835 | buildConfigurations = ( 836 | 5C512E4E267B175600C605D3 /* Debug */, 837 | 5C512E4F267B175600C605D3 /* Release */, 838 | ); 839 | defaultConfigurationIsVisible = 0; 840 | defaultConfigurationName = Release; 841 | }; 842 | 5C512E50267B175600C605D3 /* Build configuration list for PBXNativeTarget "DownloadManagerUITests" */ = { 843 | isa = XCConfigurationList; 844 | buildConfigurations = ( 845 | 5C512E51267B175600C605D3 /* Debug */, 846 | 5C512E52267B175600C605D3 /* Release */, 847 | ); 848 | defaultConfigurationIsVisible = 0; 849 | defaultConfigurationName = Release; 850 | }; 851 | /* End XCConfigurationList section */ 852 | }; 853 | rootObject = 5C512E18267B175500C605D3 /* Project object */; 854 | } 855 | -------------------------------------------------------------------------------- /DownloadManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DownloadManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DownloadManager.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /DownloadManager.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DownloadManager/AppDelegate/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DownloadManager 4 | // 5 | // Created by mac-00017 on 17/06/21. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /DownloadManager/AppDelegate/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // DownloadManager 4 | // 5 | // Created by mac-00017 on 17/06/21. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /DownloadManager/Controller/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SampleDownloadManager 4 | // 5 | // Created by mac-00017 on 14/06/21. 6 | // 7 | 8 | import UIKit 9 | import AVKit 10 | 11 | 12 | 13 | 14 | 15 | class ViewController: UIViewController { 16 | //MARK: - IBOutlets 17 | @IBOutlet weak var tableView: UITableView! 18 | 19 | //MARK: - Constants 20 | let downloadService = DownaloadServices.shared 21 | let audioManager = AudioManager.shared 22 | 23 | //MARK: - Private Properties 24 | private var player: AVAudioPlayer? = nil 25 | private var audioStateManager: [IndexPath: PlayerAudioState] = [:] 26 | private var downloadManager: [IndexPath: DownloadState] = [:] 27 | private var indexPath: IndexPath = IndexPath(row: 0, section: 0) 28 | private var tracks: [Track] = [Track]() { 29 | didSet { 30 | self.tableView.reloadData() 31 | } 32 | } 33 | 34 | 35 | 36 | //MARK: - Lazy Stored Properties 37 | lazy var downloadsSession: URLSession = { 38 | let configuration = URLSessionConfiguration.background(withIdentifier: 39 | "com.raywenderlich.HalfTunes.bgSession") 40 | return URLSession(configuration: configuration, delegate: self, delegateQueue: nil) 41 | }() 42 | 43 | 44 | //MARK: - Life Cycle Methods 45 | override func viewDidLoad() { 46 | super.viewDidLoad() 47 | self.title = "Tracks" 48 | self.initalSetup() 49 | } 50 | 51 | 52 | 53 | private func initalSetup() { 54 | self.tableView.register(TrackCell.self, forNib: true) 55 | self.tableView.delegate = self 56 | self.tableView.dataSource = self 57 | self.tableView.estimatedRowHeight = 80 58 | self.tableView.rowHeight = UITableView.automaticDimension 59 | self.tableView.tableFooterView = UIView() 60 | self.downloadService.urlSession = self.downloadsSession 61 | self.setupDataSource() 62 | } 63 | 64 | private func setupDataSource() { 65 | guard let response = JSONHelper.readJSON() else { return } 66 | self.tracks = response 67 | } 68 | 69 | func reload(at indexPath: IndexPath) { 70 | DispatchQueue.main.async { [weak self] in 71 | guard let strongSelf = self else { return } 72 | strongSelf.tableView.reloadRows(at: [indexPath], with: .none) 73 | } 74 | } 75 | 76 | private func play(atIndex index: Int) { 77 | let indexPath = IndexPath(row: index, section: 0) 78 | let condition = self.indexPath.row == indexPath.row && self.indexPath.section == indexPath.section 79 | if condition { 80 | self.audioStateManager[indexPath] = .start 81 | } else { 82 | self.audioStateManager[self.indexPath] = .initial 83 | self.audioStateManager[indexPath] = .start 84 | self.reload(at: self.indexPath) 85 | self.indexPath = indexPath 86 | } 87 | 88 | let track = self.tracks[indexPath.row] 89 | self.audioManager.playAudio(with: track, atIndex: indexPath, changeIndex: !condition, and: self.audioStateManager, downloadService: self.downloadService) { [weak self] (isPlayed) in 90 | guard let strongSelf = self else { return } 91 | if isPlayed { 92 | strongSelf.reload(at: indexPath) 93 | } 94 | } 95 | } 96 | 97 | func pauseAudio(atIndex index: Int) { 98 | let indexPath = IndexPath(row: index, section: 0) 99 | self.audioManager.pauseAudio { [weak self] (isPaused) in 100 | guard let strongSelf = self else { return } 101 | if isPaused { 102 | strongSelf.audioStateManager[indexPath] = .pause 103 | strongSelf.reload(at: indexPath) 104 | } 105 | } 106 | 107 | } 108 | 109 | 110 | 111 | func stopAudio(atIndex index: Int) { 112 | let indexPath = IndexPath(row: index, section: 0) 113 | 114 | self.audioManager.stopAudio { [weak self] (isStopped) in 115 | guard let strongSelf = self else { return } 116 | strongSelf.audioStateManager[indexPath] = .initial 117 | strongSelf.reload(at: indexPath) 118 | } 119 | 120 | } 121 | 122 | 123 | 124 | 125 | } 126 | 127 | extension ViewController: UITableViewDelegate { 128 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 129 | let track = self.tracks[indexPath.row] 130 | if let url = URL(string: track.previewURL), let destinationURL = downloadService.localFilePath(for: url) { 131 | 132 | print(destinationURL.path) 133 | if downloadService.isFileExist(destinationPath: destinationURL.path) { 134 | print("this song can play") 135 | } else { 136 | print("this song is not in your local directory. need to download") 137 | } 138 | } 139 | } 140 | } 141 | 142 | extension ViewController: UITableViewDataSource { 143 | 144 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 145 | return self.tracks.count 146 | } 147 | 148 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 149 | if let cell = tableView.dequeueReuseableCell(TrackCell.self, at: indexPath) { 150 | 151 | cell.onTapped = { [weak self] (state, indexPath) in 152 | guard let stongSelf = self, let ip = indexPath else { return } 153 | stongSelf.audioStateManager[ip] = state 154 | switch state { 155 | case .start: 156 | stongSelf.pauseAudio(atIndex: ip.row) 157 | case .pause: 158 | stongSelf.play(atIndex: ip.row) 159 | case .stop: 160 | stongSelf.stopAudio(atIndex: ip.row) 161 | case .initial: 162 | stongSelf.player = nil 163 | stongSelf.play(atIndex: ip.row) 164 | } 165 | } 166 | cell.onDownload = { [weak self] (state, indexPath) in 167 | guard let strongSelf = self, let selectedIndexPath = indexPath else { return } 168 | strongSelf.downloadManager[selectedIndexPath] = state 169 | switch state { 170 | case .start: 171 | strongSelf.downloadService.start(with: strongSelf.tracks[selectedIndexPath.row], downloadState: state) 172 | case .pause: 173 | strongSelf.downloadService.pauseTask(with: strongSelf.tracks[selectedIndexPath.row], downloadState: state) 174 | case .resume: 175 | strongSelf.downloadService.resumeTask(with: strongSelf.tracks[selectedIndexPath.row], downloadState: state) 176 | case .cancel: 177 | strongSelf.downloadService.cancelTask(with: strongSelf.tracks[selectedIndexPath.row], downloadState: state) 178 | case .alreadyDownloaded, .none: 179 | break 180 | 181 | } 182 | } 183 | let audioState = self.audioStateManager[indexPath] 184 | let downloadState = self.downloadManager[indexPath] 185 | let track = self.tracks[indexPath.row] 186 | cell.configure(with: track, isDownloaded: track.isDownloaded, and: downloadService.activeDownloads[URL(string: track.previewURL)!], state: audioState, downloadState: downloadState, indexPath: indexPath) 187 | return cell 188 | } 189 | return UITableViewCell() 190 | 191 | 192 | } 193 | } 194 | 195 | extension ViewController: URLSessionDownloadDelegate { 196 | 197 | func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) { 198 | print("Task has been resumed") 199 | } 200 | 201 | func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { 202 | 203 | 204 | 205 | guard let sourceUrl = downloadTask.originalRequest?.url else { 206 | return 207 | } 208 | 209 | let download = downloadService.activeDownloads[sourceUrl] 210 | downloadService.activeDownloads[sourceUrl] = nil 211 | 212 | guard let destinationURL = downloadService.localFilePath(for: sourceUrl) else { return } 213 | print(destinationURL) 214 | 215 | guard let index = self.tracks.firstIndex(where: {$0.previewURL == sourceUrl.absoluteString}) else { return } 216 | 217 | do { 218 | try FileManager.default.copyItem(at: location, to: destinationURL) 219 | download?.isDownloading = false 220 | download?.track.isDownloaded = true 221 | let indexPath = IndexPath(row: index, section: 0) 222 | self.downloadManager[indexPath] = .alreadyDownloaded 223 | 224 | DispatchQueue.main.async { 225 | self.tableView.reloadData() 226 | } 227 | } catch let error { 228 | print(error.localizedDescription) 229 | } 230 | } 231 | 232 | func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, 233 | didWriteData bytesWritten: Int64, totalBytesWritten: Int64, 234 | totalBytesExpectedToWrite: Int64) { 235 | 236 | debugPrint("ByteWritten: \(bytesWritten)") 237 | debugPrint("TotalbyteWritten:\(totalBytesWritten)") 238 | debugPrint("TotalExpectedBytes:\(totalBytesExpectedToWrite)") 239 | print(downloadTask.originalRequest?.url) 240 | // 1 241 | guard 242 | let url = downloadTask.originalRequest?.url, 243 | let download = downloadService.activeDownloads[url] else { 244 | return 245 | } 246 | 247 | guard let index = self.tracks.firstIndex(where: {$0.previewURL == url.absoluteString}) else { return } 248 | 249 | // 2 250 | download.progress = Double(Float(totalBytesWritten) / Float(totalBytesExpectedToWrite)) 251 | // 3 252 | let totalSize = ByteCountFormatter.string(fromByteCount: totalBytesExpectedToWrite, countStyle: .file) 253 | 254 | // 4 255 | DispatchQueue.main.async { 256 | if let trackCell = self.tableView.cellForRow(at: IndexPath(row: index, 257 | section: 0)) as? TrackCell { 258 | trackCell.updateDisplay(progress: download.progress, totalSize: totalSize) 259 | } 260 | } 261 | } 262 | } 263 | 264 | 265 | 266 | 267 | -------------------------------------------------------------------------------- /DownloadManager/Extension/Codable+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Codable+Extension.swift 3 | // TwilloChatDemo 4 | // 5 | // Created by macbook pro on 04/05/20. 6 | // Copyright © 2020 macbook pro. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | 13 | extension Decodable { 14 | static func decode(_ data: Data) -> Result { 15 | 16 | do { 17 | let decoder = JSONDecoder() 18 | let result = try decoder.decode(A.self, from: data) 19 | return .success(result) 20 | } catch { 21 | print(error.localizedDescription) 22 | return .failure(.unExpectedValue) 23 | } 24 | 25 | } 26 | 27 | static func decoded(from data: Data) -> Self? { 28 | do { 29 | let result = try JSONDecoder().decode(Self.self, from: data) 30 | return result 31 | } catch let error { 32 | print(error.localizedDescription) 33 | return nil 34 | } 35 | } 36 | } 37 | 38 | extension Encodable { 39 | var jsonEncoded: JSONType? { 40 | let encoder = JSONEncoder() 41 | do { 42 | let encodedData = try encoder.encode(self) 43 | let jsonObject = try JSONSerialization.jsonObject(with: encodedData, options: JSONSerialization.ReadingOptions.mutableContainers) 44 | return (jsonObject as? JSONType) 45 | } catch { 46 | print("Error while encoding \(self): \(error)") 47 | return nil 48 | } 49 | } 50 | 51 | var encodedData: Data? { 52 | do { 53 | let encodedData = try JSONEncoder().encode(self) 54 | return encodedData 55 | } catch let error { 56 | print(error.localizedDescription) 57 | return nil 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DownloadManager/Modal/Response.swift: -------------------------------------------------------------------------------- 1 | 2 | import Foundation 3 | 4 | // MARK: - WelcomeElement 5 | class Track: Codable { 6 | var index: Int = 0 7 | let trackCensoredName: String 8 | let collectionViewURL: String 9 | let currency: Currency 10 | let wrapperType: WrapperType 11 | let artworkUrl60: String 12 | let collectionName: String 13 | let isStreamable: Bool 14 | let releaseDate: String 15 | let artworkUrl100: String 16 | let trackExplicitness: Explicitness 17 | let trackCount, discNumber, trackNumber, trackID: Int 18 | let trackPrice: Double 19 | let artistID: Int 20 | let collectionExplicitness: Explicitness 21 | let trackName: String 22 | let artistName: ArtistName 23 | let trackTimeMillis: Int 24 | let artistViewURL: String 25 | let primaryGenreName: PrimaryGenreName 26 | let kind: Kind 27 | let country: Country 28 | let collectionID: Int 29 | let previewURL: String 30 | let artworkUrl30: String 31 | let trackViewURL: String 32 | let discCount: Int 33 | let collectionCensoredName: String 34 | let collectionPrice: Double 35 | let contentAdvisoryRating, collectionArtistName: String? 36 | let collectionArtistID: Int? 37 | var isDownloaded: Bool = false 38 | 39 | enum CodingKeys: String, CodingKey { 40 | case trackCensoredName 41 | case collectionViewURL = "collectionViewUrl" 42 | case currency, wrapperType, artworkUrl60, collectionName, isStreamable, releaseDate, artworkUrl100, trackExplicitness, trackCount, discNumber, trackNumber 43 | case trackID = "trackId" 44 | case trackPrice 45 | case artistID = "artistId" 46 | case collectionExplicitness, trackName, artistName, trackTimeMillis 47 | case artistViewURL = "artistViewUrl" 48 | case primaryGenreName, kind, country 49 | case collectionID = "collectionId" 50 | case previewURL = "previewUrl" 51 | case artworkUrl30 52 | case trackViewURL = "trackViewUrl" 53 | case discCount, collectionCensoredName, collectionPrice, contentAdvisoryRating, collectionArtistName 54 | case collectionArtistID = "collectionArtistId" 55 | } 56 | } 57 | 58 | extension Track { 59 | 60 | } 61 | 62 | enum ArtistName: String, Codable { 63 | case oneDirection = "One Direction" 64 | case zayn = "ZAYN" 65 | case zaynTaylorSwift = "ZAYN & Taylor Swift" 66 | } 67 | 68 | enum Explicitness: String, Codable { 69 | case explicit = "explicit" 70 | case notExplicit = "notExplicit" 71 | } 72 | 73 | enum Country: String, Codable { 74 | case usa = "USA" 75 | } 76 | 77 | enum Currency: String, Codable { 78 | case usd = "USD" 79 | } 80 | 81 | enum Kind: String, Codable { 82 | case song = "song" 83 | } 84 | 85 | enum PrimaryGenreName: String, Codable { 86 | case pop = "Pop" 87 | case soundtrack = "Soundtrack" 88 | } 89 | 90 | enum WrapperType: String, Codable { 91 | case track = "track" 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /DownloadManager/Storyboard/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /DownloadManager/Storyboard/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 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "Pause@1x.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "Pause@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "Pause@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "template" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Pause@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Pause@1x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Pause@2x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Pause@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/Pause.imageset/Pause@3x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "Play@1x.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "Play@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "Play@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "template" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Play@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Play@1x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Play@2x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Play@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/Play.imageset/Play@3x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "stop@1x.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "stop@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "stop@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "template" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/stop@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/stop@1x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/stop@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/stop@2x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/stop@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/DownloadManager/SupportFiles/Assets.xcassets/stop.imageset/stop@3x.png -------------------------------------------------------------------------------- /DownloadManager/SupportFiles/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSAppTransportSecurity 24 | 25 | NSAllowsArbitraryLoads 26 | 27 | 28 | UIApplicationSceneManifest 29 | 30 | UIApplicationSupportsMultipleScenes 31 | 32 | UISceneConfigurations 33 | 34 | UIWindowSceneSessionRoleApplication 35 | 36 | 37 | UISceneConfigurationName 38 | Default Configuration 39 | UISceneDelegateClassName 40 | $(PRODUCT_MODULE_NAME).SceneDelegate 41 | UISceneStoryboardFile 42 | Main 43 | 44 | 45 | 46 | 47 | UIApplicationSupportsIndirectInputEvents 48 | 49 | UILaunchStoryboardName 50 | LaunchScreen 51 | UIMainStoryboardFile 52 | Main 53 | UIRequiredDeviceCapabilities 54 | 55 | armv7 56 | 57 | UISupportedInterfaceOrientations 58 | 59 | UIInterfaceOrientationPortrait 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | UISupportedInterfaceOrientations~ipad 64 | 65 | UIInterfaceOrientationPortrait 66 | UIInterfaceOrientationPortraitUpsideDown 67 | UIInterfaceOrientationLandscapeLeft 68 | UIInterfaceOrientationLandscapeRight 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/AppError.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppError.swift 3 | // CoreDataExample 4 | // 5 | // Created by Hardik Modha on 28/12/19. 6 | // Copyright © 2019 Brijesh. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum AppError: Error { 12 | case noData 13 | case custom(title: String? = nil, message: String?, image: UIImage? = nil) 14 | case unExpectedValue 15 | case timeOut 16 | case noInternet 17 | case requestCancelled 18 | case sessionExpired401 19 | case internalServerError 20 | case error400 21 | case completed 22 | case notCompleted 23 | } 24 | 25 | extension AppError { 26 | 27 | var title: String { 28 | switch self { 29 | case .noData: 30 | return "No Records available" 31 | case .custom(_, let message, _): 32 | return message! 33 | case .noInternet: 34 | return "No Internet" 35 | case .requestCancelled: 36 | return "Request has been cancelled." 37 | case .timeOut: 38 | return "Request Time Out." 39 | case .sessionExpired401: 40 | return "Seesion Expired!" 41 | case .unExpectedValue: 42 | return "Unextected Value come form the api" 43 | case .internalServerError: 44 | return "Internal server error" 45 | case .error400: 46 | return "Torken not found" 47 | case .completed: 48 | return "Completed" 49 | case .notCompleted: 50 | return "Not Completed" 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/AudioManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AudioManager.swift 3 | // DownloadManager 4 | // 5 | // Created by mac-00017 on 23/06/21. 6 | // 7 | 8 | import Foundation 9 | import UIKit 10 | import AVKit 11 | 12 | enum PlayerAudioState { 13 | case initial 14 | case start 15 | case pause 16 | case stop 17 | 18 | var image: UIImage { 19 | switch self { 20 | case .initial, .pause, .stop: 21 | return #imageLiteral(resourceName: "Play") 22 | case .start: 23 | return #imageLiteral(resourceName: "Pause") 24 | } 25 | 26 | } 27 | 28 | private var isPlaying: Bool { 29 | switch self { 30 | case .start: 31 | return true 32 | default: 33 | return false 34 | } 35 | } 36 | 37 | var isShowStopButton: Bool { 38 | return self.isPlaying 39 | } 40 | } 41 | 42 | class AudioManager { 43 | 44 | private var player: AVAudioPlayer? = nil 45 | 46 | static let shared = AudioManager() 47 | 48 | 49 | func playAudio(with track: Track, atIndex indexPath: IndexPath, changeIndex: Bool, and audioManager: [IndexPath: PlayerAudioState], downloadService: DownaloadServices, completion: @escaping ConfirmationHandler) { 50 | 51 | if let url = URL(string: track.previewURL), let destinationURL = downloadService.localFilePath(for: url) { 52 | guard let state = audioManager[indexPath] else { return } 53 | if changeIndex { 54 | self.player = nil 55 | } 56 | switch state { 57 | case .start, .initial: 58 | if player == nil { 59 | player = try? AVAudioPlayer(contentsOf: destinationURL) 60 | player?.play() 61 | } else { 62 | if let player = player, !player.isPlaying { 63 | player.play() 64 | } 65 | } 66 | completion(true) 67 | break 68 | default: 69 | completion(false) 70 | break 71 | } 72 | 73 | } else { 74 | completion(false) 75 | } 76 | 77 | 78 | } 79 | 80 | func pauseAudio(with completion: @escaping ConfirmationHandler) { 81 | if let player = self.player, player.isPlaying { 82 | player.pause() 83 | completion(true) 84 | } 85 | completion(false) 86 | } 87 | 88 | func stopAudio(with completion: @escaping ConfirmationHandler) { 89 | if let player = self.player, player.isPlaying { 90 | player.stop() 91 | self.player = nil 92 | completion(true) 93 | 94 | } 95 | completion(false) 96 | } 97 | 98 | 99 | 100 | 101 | } 102 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/Download.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Download.swift 3 | // SampleDownloadManager 4 | // 5 | // Created by mac-00017 on 14/06/21. 6 | // 7 | 8 | import Foundation 9 | 10 | 11 | class Download { 12 | var track: Track 13 | var dowloadState: DownloadState = .none 14 | var isDownloading: Bool = false 15 | var progress: Double = 0.0 16 | var resumeData: Data? 17 | var sessionTask: URLSessionDownloadTask? 18 | 19 | 20 | init(track: Track) { 21 | self.track = track 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/DownloadServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DownloadServices.swift 3 | // SampleDownloadManager 4 | // 5 | // Created by mac-00017 on 14/06/21. 6 | // 7 | 8 | import Foundation 9 | 10 | enum ButtonTitle { 11 | static let download = "Download" 12 | static let pause = "Pause" 13 | static let resume = "Resume" 14 | } 15 | 16 | enum DownloadState: Int, CustomStringConvertible { 17 | case none = 0 18 | case start 19 | case pause 20 | case resume 21 | case cancel 22 | case alreadyDownloaded 23 | 24 | var isOngoing: Bool { 25 | return self == .start || self == .resume 26 | } 27 | 28 | var buttonTitle: String { 29 | switch self { 30 | case .none: 31 | return ButtonTitle.download 32 | case .start, .resume: 33 | return ButtonTitle.pause 34 | case .alreadyDownloaded, .cancel: 35 | return "" 36 | case .pause: 37 | return ButtonTitle.resume 38 | } 39 | } 40 | 41 | var isButtonHide: Bool { 42 | switch self { 43 | case .alreadyDownloaded, .cancel: 44 | return true 45 | default: 46 | return false 47 | 48 | } 49 | } 50 | 51 | var isHideCancelButton: Bool { 52 | switch self { 53 | case .start, .pause, .resume: 54 | return false 55 | case .alreadyDownloaded: 56 | return true 57 | default: 58 | return true 59 | } 60 | } 61 | 62 | var description: String { 63 | switch self { 64 | case .start: 65 | return "Download about start" 66 | case .resume: 67 | return "Download will resume" 68 | case .pause: 69 | return "Download is paused" 70 | 71 | default: 72 | return "" 73 | } 74 | } 75 | 76 | } 77 | 78 | class DownaloadServices { 79 | 80 | static let shared = DownaloadServices() 81 | 82 | var urlSession: URLSession = URLSession(configuration: .default) 83 | var activeDownloads: [URL: Download] = [:] 84 | 85 | 86 | func localFilePath(for url: URL) -> URL? { 87 | guard let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return nil } 88 | return documentsPath.appendingPathComponent(url.lastPathComponent) 89 | } 90 | 91 | func isFileExist(destinationPath: String) -> Bool { 92 | return FileManager.default.fileExists(atPath: destinationPath) 93 | } 94 | 95 | func cancelTask(with track: Track, downloadState: DownloadState) { 96 | guard let download = self.activeDownloads[URL(string: track.previewURL)!] else { return } 97 | 98 | download.sessionTask?.cancel() 99 | download.isDownloading = false 100 | activeDownloads[URL(string: track.previewURL)!] = nil 101 | download.dowloadState = downloadState 102 | } 103 | 104 | func pauseTask(with track: Track, downloadState: DownloadState) { 105 | guard let download = self.activeDownloads[URL(string: track.previewURL)!], download.isDownloading else { return } 106 | download.sessionTask?.cancel(byProducingResumeData: { (data) in 107 | download.resumeData = data 108 | }) 109 | download.dowloadState = downloadState 110 | download.isDownloading = false 111 | } 112 | 113 | func resumeTask(with track: Track, downloadState: DownloadState) { 114 | guard let download = self.activeDownloads[URL(string: track.previewURL)!] else { return } 115 | 116 | 117 | if let resumeData = download.resumeData { 118 | download.sessionTask = urlSession.downloadTask(withResumeData: resumeData) 119 | } else { 120 | download.sessionTask = urlSession.downloadTask(with: URL(string: track.previewURL)!) 121 | } 122 | 123 | download.dowloadState = downloadState 124 | download.sessionTask?.resume() 125 | download.isDownloading = true 126 | 127 | 128 | } 129 | 130 | 131 | func start(with track: Track, downloadState: DownloadState) { 132 | let download = Download(track: track) 133 | download.sessionTask = urlSession.downloadTask(with: URL(string: track.previewURL)!) 134 | download.sessionTask?.resume() 135 | download.dowloadState = downloadState 136 | download.isDownloading = true 137 | if let url = URL(string: track.previewURL) { 138 | activeDownloads[url] = download 139 | } 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/Helper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Helper.swift 3 | // WebCluesPracticle 4 | // 5 | // Created by Hardik Modha on 21/07/20. 6 | // Copyright © 2020 Hardik Modha. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum FileExtensionType: String, CustomStringConvertible { 12 | case swift 13 | case json 14 | case xml 15 | 16 | var description: String { 17 | return self.rawValue 18 | } 19 | 20 | } 21 | 22 | typealias JSONType = [String: Any] 23 | typealias Header = [String: String] 24 | typealias ResultHandler = (Result) -> Void 25 | typealias EmptyHandler = () -> Void 26 | typealias Progress = (Double) -> Void 27 | typealias ConfirmationHandler = (Bool) -> Void 28 | typealias ResponseStatusHandler = (Bool, String) -> Void 29 | 30 | 31 | struct JSONHelper { 32 | 33 | static func readJSON() -> [Track]? { 34 | do { 35 | if let fileURL = Bundle.main.url(forResource: "music-datasource", withExtension: "json") { 36 | let data = try Data(contentsOf: fileURL) 37 | let response = try JSONDecoder().decode([Track].self, from: data) 38 | return response 39 | } 40 | } catch let error { 41 | print(error.localizedDescription) 42 | return nil 43 | } 44 | return nil 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/Result.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Result.swift 3 | // ChatApp 4 | // 5 | // Created by Hardik Modha on 12/01/20. 6 | // Copyright © 2020 Hardik Modha. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum request { 12 | case fetching 13 | case refresh 14 | case loadMore 15 | } 16 | 17 | enum response { 18 | case success(value: Result) 19 | case error(error: Error) 20 | } 21 | 22 | enum Result { 23 | case success(A) 24 | case failure(AppError) 25 | 26 | var value: A? { 27 | switch self { 28 | case .success(let data): 29 | return data 30 | default: 31 | return nil 32 | } 33 | } 34 | 35 | var error: Error? { 36 | switch self { 37 | case .failure(let error): 38 | return error 39 | default: 40 | return nil 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /DownloadManager/Utilities/ResuseableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResuseableView.swift 3 | // DelegationDemo 4 | // 5 | // Created by scooby systems on 31/07/19. 6 | // Copyright © 2019 Hardik Modja. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol ResuseableView { 12 | static var identifier: String { get } 13 | } 14 | 15 | extension ResuseableView where Self: UIView { 16 | static var identifier: String { 17 | return String(describing: self) 18 | } 19 | } 20 | 21 | extension UITableViewCell: ResuseableView {} 22 | extension UITableViewHeaderFooterView: ResuseableView {} 23 | extension UICollectionReusableView : ResuseableView {} 24 | 25 | protocol NibLoadable { 26 | static var nibName: String { get } 27 | } 28 | 29 | extension NibLoadable where Self: UIView { 30 | static var nibName: String { 31 | return String(describing: self) 32 | } 33 | } 34 | 35 | extension UITableViewCell: NibLoadable {} 36 | extension UITableViewHeaderFooterView: NibLoadable {} 37 | extension UICollectionReusableView: NibLoadable {} 38 | 39 | 40 | extension UITableView { 41 | func register(_ : T.Type, forNib: Bool) { 42 | guard forNib else { 43 | register(T.self, forCellReuseIdentifier: T.identifier) 44 | return 45 | } 46 | 47 | let nib = UINib(nibName: T.nibName, bundle: nil) 48 | register(nib, forCellReuseIdentifier: T.identifier) 49 | } 50 | 51 | 52 | 53 | func register(_ : T.Type, forNib: Bool) { 54 | guard forNib else { 55 | register(T.self, forHeaderFooterViewReuseIdentifier: T.identifier) 56 | return 57 | } 58 | 59 | let reuseIdentifier = T.identifier 60 | let nib = UINib(nibName: T.nibName, bundle: nil) 61 | register(nib, forHeaderFooterViewReuseIdentifier: reuseIdentifier) 62 | } 63 | 64 | 65 | 66 | func dequeueHeaderFooterView(_ : T.Type) -> T? { 67 | return dequeueReusableHeaderFooterView(withIdentifier: T.identifier) as? T 68 | } 69 | 70 | func dequeueReuseableCell(_ :T.Type, at indexPath: IndexPath) -> T? { 71 | return dequeueReusableCell(withIdentifier: T.identifier, for: indexPath) as? T 72 | } 73 | } 74 | 75 | extension UICollectionView { 76 | func register(_ : T.Type) { 77 | register(T.self, forCellWithReuseIdentifier: T.identifier) 78 | } 79 | 80 | func register(_ : T.Type, ofKind kind: String) { 81 | register(T.self, forSupplementaryViewOfKind: kind, withReuseIdentifier: T.identifier) 82 | } 83 | 84 | func registerNib(_ : T.Type) { 85 | let reuseIdentifer = T.identifier 86 | let nib = UINib(nibName: T.nibName, bundle: nil) 87 | register(nib, forCellWithReuseIdentifier: reuseIdentifer) 88 | } 89 | 90 | func registerNib(_ : T.Type, ofKind kind: String) { 91 | let nib = UINib(nibName: T.nibName, bundle: nil) 92 | register(nib, forSupplementaryViewOfKind: kind, withReuseIdentifier: T.identifier) 93 | } 94 | 95 | func dequeueReusableCell(_ : T.Type, for indexPath: IndexPath) -> T { 96 | guard let cell = dequeueReusableCell(withReuseIdentifier: T.identifier, 97 | for: indexPath) as? T else { 98 | fatalError("Please verify cell identifier \(T.identifier)") 99 | } 100 | return cell 101 | } 102 | 103 | func dequeueReusableSupplementaryView(_ : T.Type, ofKind kind: String, for indexPath: IndexPath) -> T? { 104 | return dequeueReusableSupplementaryView(ofKind: kind, 105 | withReuseIdentifier: T.identifier, 106 | for: indexPath) as? T 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /DownloadManager/View/TrackCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackCell.swift 3 | // SampleDownloadManager 4 | // 5 | // Created by mac-00017 on 14/06/21. 6 | // 7 | 8 | import UIKit 9 | import AHDownloadButton 10 | 11 | class TrackCell: UITableViewCell { 12 | //MARK: - IBOutlets 13 | @IBOutlet weak var lbltrack: UILabel! 14 | @IBOutlet weak var lblArtist: UILabel! 15 | @IBOutlet weak var lblProgress: UILabel! 16 | @IBOutlet weak var stackView: UIStackView! 17 | @IBOutlet weak var downloadButton: AHDownloadButton! 18 | @IBOutlet weak var btnPlayPause: UIButton! 19 | @IBOutlet weak var btnStop: UIButton! 20 | 21 | //MARK: - Callbacks Properties 22 | var onTapped: ((PlayerAudioState, IndexPath?) -> Void)? 23 | var onDownload: ((DownloadState, IndexPath?) -> Void)? 24 | 25 | //MARK: - Private Properties 26 | private var indexPath: IndexPath? 27 | private var track: Track? = nil 28 | private var ongoignProgress: Double = 0.0 29 | private var downloadState: DownloadState = .none { 30 | didSet { 31 | self.onDownload?(self.downloadState, self.indexPath) 32 | } 33 | } 34 | 35 | //MARK: - Computed Properties 36 | var audioState: PlayerAudioState = .initial { 37 | didSet { 38 | self.btnPlayPause.setImage(audioState.image, for: .normal) 39 | } 40 | } 41 | 42 | //MARK: - Life Cycle Methods 43 | override func awakeFromNib() { 44 | super.awakeFromNib() 45 | print(#function, "Called") 46 | self.initialSetup() 47 | } 48 | 49 | //MARK: - Initialize Method 50 | private func initialSetup() { 51 | self.selectionStyle = .none 52 | self.btnStop.isHidden = true 53 | self.downloadButton.startDownloadButtonTitle = "Download" 54 | self.downloadButton.startDownloadButtonTitleFont = UIFont.systemFont(ofSize: 12.0) 55 | self.downloadButton.downloadingButtonCircleLineWidth = 2.0 56 | self.downloadButton.pendingCircleLineWidth = 2.0 57 | self.downloadButton.delegate = self 58 | self.lblProgress.isHidden = true 59 | } 60 | 61 | override func prepareForReuse() { 62 | super.prepareForReuse() 63 | self.downloadButton.state = self.downloadState.isOngoing ? .downloading : .startDownload 64 | self.downloadButton.progress = 0.0 65 | } 66 | 67 | //MARK: - Instance Methods 68 | func configure(with track: Track, isDownloaded: Bool, and download: Download?, state: PlayerAudioState?, downloadState: DownloadState?, indexPath: IndexPath) { 69 | self.indexPath = indexPath 70 | self.downloadState = downloadState ?? .none 71 | self.audioState = state ?? .initial 72 | self.lbltrack.text = track.trackName 73 | self.lblArtist.text = track.artistName.rawValue 74 | self.lblProgress.isHidden = true 75 | 76 | if let url = URL(string: track.previewURL), let destinationURL = DownaloadServices.shared.localFilePath(for: url) { 77 | self.btnPlayPause.isHidden = !DownaloadServices.shared.isFileExist(destinationPath: destinationURL.path) 78 | self.btnStop.isHidden = !self.audioState.isShowStopButton 79 | self.downloadButton.isHidden = DownaloadServices.shared.isFileExist(destinationPath: destinationURL.path) 80 | } 81 | } 82 | 83 | func updateDisplay(progress: Double, totalSize : String) { 84 | self.lblProgress.isHidden = false 85 | self.ongoignProgress = progress 86 | self.downloadButton.progress = CGFloat(progress) 87 | let percentage = Int(progress * 100) 88 | self.lblProgress.text = "\(percentage)%" 89 | } 90 | 91 | //MARK: - IBActions 92 | @IBAction func playPasueAction(_ sender: UIButton) { 93 | guard let ip = self.indexPath else { return } 94 | self.onTapped?(self.audioState, ip) 95 | } 96 | 97 | @IBAction func stopAction(_ sender: UIButton) { 98 | guard let ip = self.indexPath else { return } 99 | self.audioState = .stop 100 | self.onTapped?(self.audioState, ip) 101 | } 102 | } 103 | 104 | //MARK: - AHDownloadButtonDelegate 105 | extension TrackCell: AHDownloadButtonDelegate { 106 | func downloadButton(_ downloadButton: AHDownloadButton, tappedWithState state: AHDownloadButton.State) { 107 | self.lblProgress.isHidden = !self.downloadState.isOngoing 108 | print(self.downloadState.description) 109 | switch state { 110 | case .startDownload: 111 | self.downloadButton.state = .pending 112 | DispatchQueue.main.asyncAfter(deadline: .now() + 2) { 113 | self.downloadButton.state = .downloading 114 | self.downloadState = .start 115 | } 116 | break 117 | 118 | case .downloading: 119 | downloadButton.progress = CGFloat(self.ongoignProgress) 120 | downloadButton.state = .downloading 121 | self.downloadState = self.downloadState.isOngoing ? .pause : .resume 122 | break 123 | case .downloaded: 124 | self.lblProgress.isHidden = true 125 | self.downloadButton.isHidden = true 126 | default: 127 | break 128 | } 129 | } 130 | 131 | 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /DownloadManager/View/TrackCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 62 | 73 | 74 | 75 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /DownloadManagerTests/DownloadManagerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DownloadManagerTests.swift 3 | // DownloadManagerTests 4 | // 5 | // Created by mac-00017 on 17/06/21. 6 | // 7 | 8 | import XCTest 9 | @testable import DownloadManager 10 | 11 | class DownloadManagerTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /DownloadManagerTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /DownloadManagerUITests/DownloadManagerUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DownloadManagerUITests.swift 3 | // DownloadManagerUITests 4 | // 5 | // Created by mac-00017 on 17/06/21. 6 | // 7 | 8 | import XCTest 9 | 10 | class DownloadManagerUITests: XCTestCase { 11 | 12 | override func setUpWithError() throws { 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | 15 | // In UI tests it is usually best to stop immediately when a failure occurs. 16 | continueAfterFailure = false 17 | 18 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 19 | } 20 | 21 | override func tearDownWithError() throws { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | func testExample() throws { 26 | // UI tests must launch the application that they test. 27 | let app = XCUIApplication() 28 | app.launch() 29 | 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | func testLaunchPerformance() throws { 35 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 36 | // This measures how long it takes to launch your application. 37 | measure(metrics: [XCTApplicationLaunchMetric()]) { 38 | XCUIApplication().launch() 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /DownloadManagerUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 MindInventory 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 | -------------------------------------------------------------------------------- /Media/download_manager.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/Media/download_manager.gif -------------------------------------------------------------------------------- /Media/mi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/DownloadManager/f8acef7b05574bb48a67a90199a0d04ba6def8d8/Media/mi.png -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'DownloadManager' do 5 | # Comment the next line if you don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | pod 'AHDownloadButton' 9 | 10 | target 'DownloadManagerTests' do 11 | inherit! :search_paths 12 | # Pods for testing 13 | end 14 | 15 | target 'DownloadManagerUITests' do 16 | # Pods for testing 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AHDownloadButton (1.2.0) 3 | 4 | DEPENDENCIES: 5 | - AHDownloadButton 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - AHDownloadButton 10 | 11 | SPEC CHECKSUMS: 12 | AHDownloadButton: 7a3927c9365fbd6d08682d26832d87dd0cd5573f 13 | 14 | PODFILE CHECKSUM: d35d4529e9cbe190d129356580564364767d9455 15 | 16 | COCOAPODS: 1.10.1 17 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/AHDownloadButton+StateTransitionAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AHDownloadButton+StateTransitionAnimation.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 04/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension AHDownloadButton { 12 | 13 | func animateTransition(from oldState: State, to newState: State) { 14 | 15 | let completion: (Bool) -> Void = { completed in 16 | guard completed else { return } 17 | self.resetStateViews(except: newState) 18 | self.animationDispatchGroup.leave() 19 | } 20 | 21 | switch (oldState, newState) { 22 | case (.startDownload, .pending): 23 | animateTransitionFromStartDownloadToPending(completion: completion) 24 | 25 | case (.startDownload, .downloading): 26 | animateTransitionFromStartDownloadToDownloading(completion: completion) 27 | 28 | case (.pending, .startDownload): 29 | animateTransitionFromPendingToStartDownload(completion: completion) 30 | 31 | case (.pending, .downloading): 32 | animateTransitionFromPendingToDownloading(completion: completion) 33 | 34 | case (.downloading, .downloaded): 35 | animateTransitionFromDownloadingToDownloaded(completion: completion) 36 | 37 | case (.downloading, .startDownload): 38 | animateTransitionFromDownloadingToStartDownload(completion: completion) 39 | 40 | default: 41 | handleUnsupportedTransitionAnimation(toState: newState) 42 | } 43 | } 44 | 45 | private func animateTransitionFromStartDownloadToPending(completion: @escaping (Bool) -> Void) { 46 | startDownloadButton.titleLabel?.alpha = 0 47 | startDownloadButtonWidthConstraint.constant = pendingViewWidthConstraint.constant 48 | UIView.animate(withDuration: transitionAnimationDuration, animations: { 49 | self.layoutIfNeeded() 50 | }, completion: { completed in 51 | completion(completed) 52 | guard completed else { return } 53 | self.pendingCircleView.alpha = 1 54 | self.pendingCircleView.startSpinning() 55 | }) 56 | } 57 | 58 | private func animateTransitionFromStartDownloadToDownloading(completion: @escaping (Bool) -> Void) { 59 | startDownloadButton.titleLabel?.alpha = 0 60 | startDownloadButtonWidthConstraint.constant = downloadingButtonWidthConstraint.constant 61 | UIView.animate(withDuration: transitionAnimationDuration, animations: { 62 | self.layoutIfNeeded() 63 | }, completion: { completed in 64 | completion(completed) 65 | guard completed else { return } 66 | self.downloadingButton.alpha = 1 67 | }) 68 | } 69 | 70 | private func animateTransitionFromPendingToStartDownload(completion: @escaping (Bool) -> Void) { 71 | startDownloadButtonWidthConstraint.constant = pendingViewWidthConstraint.constant 72 | layoutIfNeeded() 73 | 74 | startDownloadButton.alpha = 1 75 | startDownloadButtonWidthConstraint.constant = startDownloadButtonFullWidth 76 | UIView.animate(withDuration: transitionAnimationDuration, animations: { 77 | self.pendingCircleView.alpha = 0 78 | self.startDownloadButton.titleLabel?.alpha = 1 79 | self.layoutIfNeeded() 80 | }, completion: completion) 81 | } 82 | 83 | private func animateTransitionFromPendingToDownloading(completion: @escaping (Bool) -> Void) { 84 | pendingCircleView.alpha = 1 85 | downloadingButton.alpha = 0 86 | UIView.animate(withDuration: transitionAnimationDuration, animations: { 87 | self.pendingCircleView.alpha = 0 88 | self.downloadingButton.alpha = 1 89 | }, completion: completion) 90 | } 91 | 92 | private func animateTransitionFromDownloadingToDownloaded(completion: @escaping (Bool) -> Void) { 93 | downloadedButton.alpha = 1 94 | downloadedButtonWidthConstraint.constant = downloadingButtonWidthConstraint.constant 95 | layoutIfNeeded() 96 | 97 | downloadedButton.titleLabel?.alpha = 0 98 | downloadedButtonWidthConstraint.constant = downloadedButtonFullWidth 99 | UIView.animate(withDuration: transitionAnimationDuration, animations: { 100 | self.downloadingButton.alpha = 0 101 | self.downloadedButton.titleLabel?.alpha = 1 102 | self.layoutIfNeeded() 103 | }, completion: completion) 104 | } 105 | 106 | private func animateTransitionFromDownloadingToStartDownload(completion: @escaping (Bool) -> Void) { 107 | startDownloadButtonWidthConstraint.constant = downloadingButtonWidthConstraint.constant 108 | layoutIfNeeded() 109 | 110 | downloadingButton.alpha = 0 111 | startDownloadButton.alpha = 1 112 | startDownloadButtonWidthConstraint.constant = startDownloadButtonFullWidth 113 | UIView.animate(withDuration: transitionAnimationDuration, animations: { 114 | self.startDownloadButton.titleLabel?.alpha = 1 115 | self.layoutIfNeeded() 116 | }, completion: completion) 117 | } 118 | 119 | private func handleUnsupportedTransitionAnimation(toState newState: State) { 120 | switch newState { 121 | case .startDownload: 122 | startDownloadButton.alpha = 1 123 | case .pending: 124 | pendingCircleView.alpha = 1 125 | case .downloading: 126 | downloadingButton.alpha = 1 127 | case .downloaded: 128 | downloadedButton.alpha = 1 129 | } 130 | resetStateViews(except: newState) 131 | animationDispatchGroup.leave() 132 | } 133 | 134 | private func resetStateViews(except state: State) { 135 | 136 | if state != .startDownload { 137 | startDownloadButton.alpha = 0 138 | startDownloadButton.titleLabel?.alpha = 1 139 | startDownloadButtonWidthConstraint.constant = startDownloadButtonFullWidth 140 | } 141 | 142 | if state != .pending { 143 | pendingCircleView.alpha = 0 144 | } 145 | 146 | if state != .downloading { 147 | downloadingButton.alpha = 0 148 | progress = 0 149 | } 150 | 151 | if state != .downloaded { 152 | downloadedButton.alpha = 0 153 | downloadedButton.titleLabel?.alpha = 1 154 | downloadedButtonWidthConstraint.constant = downloadedButtonFullWidth 155 | } 156 | 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/AHDownloadButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AHDownloadButton.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 03/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol AHDownloadButtonDelegate: class { 12 | @available(*, deprecated, message: "Use downloadButton(_:, tappedWithState:) method") 13 | func didTapDownloadButton(_ downloadButton: AHDownloadButton, withState state: AHDownloadButton.State) 14 | func downloadButton(_ downloadButton: AHDownloadButton, stateChanged state: AHDownloadButton.State) 15 | func downloadButton(_ downloadButton: AHDownloadButton, tappedWithState state: AHDownloadButton.State) 16 | } 17 | 18 | public extension AHDownloadButtonDelegate { 19 | func didTapDownloadButton(_ downloadButton: AHDownloadButton, withState state: AHDownloadButton.State) { } 20 | func downloadButton(_ downloadButton: AHDownloadButton, stateChanged state: AHDownloadButton.State) { } 21 | func downloadButton(_ downloadButton: AHDownloadButton, tappedWithState state: AHDownloadButton.State) { } 22 | } 23 | 24 | public final class AHDownloadButton: UIView { 25 | 26 | public enum State { 27 | case startDownload 28 | case pending 29 | case downloading 30 | case downloaded 31 | } 32 | 33 | public enum HorizontalAlignment: Int { 34 | case center, left, right 35 | 36 | var relativeLayoutAttribute: NSLayoutConstraint.Attribute { 37 | switch self { 38 | case .center: return .centerX 39 | case .right: return .right 40 | case .left: return .left 41 | } 42 | } 43 | } 44 | 45 | // MARK: Public properties 46 | 47 | /// Start download button customisation properties 48 | 49 | public var startDownloadButtonTitle: String = "GET" { 50 | didSet { 51 | startDownloadButton.setTitle(startDownloadButtonTitle, for: .normal) 52 | } 53 | } 54 | 55 | public var startDownloadButtonTitleFont: UIFont = .boldSystemFont(ofSize: 15) { 56 | didSet { 57 | startDownloadButton.titleLabel?.font = startDownloadButtonTitleFont 58 | } 59 | } 60 | 61 | public var startDownloadButtonTitleSidePadding: CGFloat = 12 62 | 63 | public var startDownloadButtonHighlightedBackgroundColor: UIColor = Color.Gray.light { 64 | didSet { 65 | startDownloadButton.highlightedBackgroundColor = startDownloadButtonHighlightedBackgroundColor 66 | } 67 | } 68 | 69 | public var startDownloadButtonNonhighlightedBackgroundColor: UIColor = Color.Gray.medium { 70 | didSet { 71 | startDownloadButton.nonhighlightedBackgroundColor = startDownloadButtonNonhighlightedBackgroundColor 72 | } 73 | } 74 | 75 | public var startDownloadButtonHighlightedTitleColor: UIColor = Color.Blue.light { 76 | didSet { 77 | startDownloadButton.highlightedTitleColor = startDownloadButtonHighlightedTitleColor 78 | } 79 | } 80 | 81 | public var startDownloadButtonNonhighlightedTitleColor: UIColor = Color.Blue.medium { 82 | didSet { 83 | startDownloadButton.nonhighlightedTitleColor = startDownloadButtonNonhighlightedTitleColor 84 | } 85 | } 86 | 87 | /// Pending view customisation properties 88 | 89 | public var pendingCircleColor: UIColor = Color.Gray.dark { 90 | didSet { 91 | pendingCircleView.circleColor = pendingCircleColor 92 | } 93 | } 94 | 95 | public var pendingCircleLineWidth: CGFloat = 2 { 96 | didSet { 97 | pendingCircleView.lineWidth = pendingCircleLineWidth 98 | } 99 | } 100 | 101 | /// Downloading button customisation properties 102 | 103 | public var downloadingButtonNonhighlightedTrackCircleColor: UIColor = Color.Gray.medium { 104 | didSet { 105 | downloadingButton.nonhighlightedTrackCircleColor = downloadingButtonNonhighlightedTrackCircleColor 106 | } 107 | } 108 | 109 | public var downloadingButtonHighlightedTrackCircleColor: UIColor = Color.Gray.light { 110 | didSet { 111 | downloadingButton.highlightedTrackCircleColor = downloadingButtonHighlightedTrackCircleColor 112 | } 113 | } 114 | 115 | public var downloadingButtonNonhighlightedProgressCircleColor: UIColor = Color.Blue.medium { 116 | didSet { 117 | downloadingButton.nonhighlightedProgressCircleColor = downloadingButtonNonhighlightedProgressCircleColor 118 | } 119 | } 120 | 121 | public var downloadingButtonHighlightedProgressCircleColor: UIColor = Color.Blue.light { 122 | didSet { 123 | downloadingButton.highlightedProgressCircleColor = downloadingButtonHighlightedProgressCircleColor 124 | } 125 | } 126 | 127 | public var downloadingButtonNonhighlightedStopViewColor: UIColor = Color.Blue.medium { 128 | didSet { 129 | downloadingButton.nonhighlightedStopViewColor = downloadingButtonNonhighlightedStopViewColor 130 | } 131 | } 132 | 133 | public var downloadingButtonHighlightedStopViewColor: UIColor = Color.Blue.light { 134 | didSet { 135 | downloadingButton.highlightedStopViewColor = downloadingButtonHighlightedStopViewColor 136 | } 137 | } 138 | 139 | public var downloadingButtonCircleLineWidth: CGFloat = 6 { 140 | didSet { 141 | downloadingButton.circleViewLineWidth = downloadingButtonCircleLineWidth 142 | } 143 | } 144 | 145 | public var progress: CGFloat = 0 { 146 | didSet { 147 | downloadingButton.progress = progress 148 | } 149 | } 150 | 151 | /// Downloaded button customisation properties 152 | 153 | public var downloadedButtonTitle: String = "OPEN" { 154 | didSet { 155 | downloadedButton.setTitle(downloadedButtonTitle, for: .normal) 156 | } 157 | } 158 | 159 | public var downloadedButtonTitleFont: UIFont = .boldSystemFont(ofSize: 15) { 160 | didSet { 161 | downloadedButton.titleLabel?.font = downloadedButtonTitleFont 162 | } 163 | } 164 | 165 | public var downloadedButtonTitleSidePadding: CGFloat = 12 166 | 167 | public var downloadedButtonHighlightedBackgroundColor: UIColor = Color.Gray.light { 168 | didSet { 169 | downloadedButton.highlightedBackgroundColor = downloadedButtonHighlightedBackgroundColor 170 | } 171 | } 172 | 173 | public var downloadedButtonNonhighlightedBackgroundColor: UIColor = Color.Gray.medium { 174 | didSet { 175 | downloadedButton.nonhighlightedBackgroundColor = downloadedButtonNonhighlightedBackgroundColor 176 | } 177 | } 178 | 179 | public var downloadedButtonHighlightedTitleColor: UIColor = Color.Blue.light { 180 | didSet { 181 | downloadedButton.highlightedTitleColor = downloadedButtonHighlightedTitleColor 182 | } 183 | } 184 | 185 | public var downloadedButtonNonhighlightedTitleColor: UIColor = Color.Blue.medium { 186 | didSet { 187 | downloadedButton.nonhighlightedTitleColor = downloadedButtonNonhighlightedTitleColor 188 | } 189 | } 190 | 191 | /// State transformation 192 | 193 | public var state: State = .startDownload { 194 | didSet { 195 | delegate?.downloadButton(self, stateChanged: state) 196 | downloadButtonStateChangedAction?(self, state) 197 | animationQueue.async { [currentState = state] in 198 | self.animationDispatchGroup.enter() 199 | 200 | var delay: TimeInterval = 0 201 | if oldValue == .downloading && currentState == .downloaded && self.downloadingButton.progress == 1 { 202 | delay = self.downloadingButton.progressCircleView.progressAnimationDuration 203 | } 204 | 205 | DispatchQueue.main.asyncAfter(deadline: .now() + delay) { 206 | self.animateTransition(from: oldValue, to: currentState) 207 | } 208 | self.animationDispatchGroup.wait() 209 | } 210 | } 211 | } 212 | 213 | public var transitionAnimationDuration: TimeInterval = 0.1 214 | 215 | /// Callbacks 216 | 217 | public weak var delegate: AHDownloadButtonDelegate? 218 | 219 | public var didTapDownloadButtonAction: ((AHDownloadButton, State) -> Void)? 220 | 221 | public var downloadButtonStateChangedAction: ((AHDownloadButton, State) -> Void)? 222 | 223 | // MARK: Private properties 224 | 225 | let startDownloadButton: HighlightableRoundedButton = { 226 | let button = HighlightableRoundedButton() 227 | button.addTarget(self, action: #selector(currentButtonTapped), for: .touchUpInside) 228 | return button 229 | }() 230 | 231 | let pendingCircleView: CircleView = { 232 | let view = CircleView() 233 | view.endAngleRadians = view.startAngleRadians + 12 * .pi / 7 234 | return view 235 | }() 236 | 237 | let downloadingButton: ProgressButton = { 238 | let button = ProgressButton() 239 | button.addTarget(self, action: #selector(currentButtonTapped), for: .touchUpInside) 240 | return button 241 | }() 242 | 243 | let downloadedButton: HighlightableRoundedButton = { 244 | let button = HighlightableRoundedButton() 245 | button.addTarget(self, action: #selector(currentButtonTapped), for: .touchUpInside) 246 | return button 247 | }() 248 | 249 | let contentHorizontalAlignment: HorizontalAlignment 250 | 251 | // MARK: Animation 252 | 253 | let animationDispatchGroup = DispatchGroup() 254 | let animationQueue = DispatchQueue(label: "com.amerhukic.animation") 255 | 256 | // MARK: Constraints 257 | 258 | var startDownloadButtonWidthConstraint: NSLayoutConstraint! 259 | var pendingViewWidthConstraint: NSLayoutConstraint! 260 | var downloadingButtonWidthConstraint: NSLayoutConstraint! 261 | var downloadedButtonWidthConstraint: NSLayoutConstraint! 262 | var horizontalAlignmentAttribute: NSLayoutConstraint.Attribute { 263 | return contentHorizontalAlignment.relativeLayoutAttribute 264 | } 265 | 266 | var startDownloadButtonTitleWidth: CGFloat = 0 { 267 | didSet { 268 | startDownloadButtonWidthConstraint.constant = startDownloadButtonFullWidth 269 | } 270 | } 271 | 272 | var downloadedButtonTitleWidth: CGFloat = 0 { 273 | didSet { 274 | downloadedButtonWidthConstraint.constant = downloadedButtonFullWidth 275 | } 276 | } 277 | 278 | var startDownloadButtonFullWidth: CGFloat { 279 | return startDownloadButtonTitleWidth + 2 * startDownloadButtonTitleSidePadding 280 | } 281 | 282 | var downloadedButtonFullWidth: CGFloat { 283 | return downloadedButtonTitleWidth + 2 * downloadedButtonTitleSidePadding 284 | } 285 | 286 | // MARK: Initializers 287 | 288 | public init(alignment: HorizontalAlignment) { 289 | contentHorizontalAlignment = alignment 290 | super.init(frame: .zero) 291 | commonInit() 292 | } 293 | 294 | public override init(frame: CGRect) { 295 | contentHorizontalAlignment = .center 296 | super.init(frame: frame) 297 | commonInit() 298 | } 299 | 300 | public required init?(coder aDecoder: NSCoder) { 301 | contentHorizontalAlignment = .center 302 | super.init(coder: aDecoder) 303 | commonInit() 304 | } 305 | 306 | private func commonInit() { 307 | addSubview(startDownloadButton) 308 | setUpStartDownloadButtonProperties() 309 | setUpStartDownloadButtonConstraints() 310 | 311 | addSubview(pendingCircleView) 312 | setUpPendingCircleViewProperties() 313 | setUpPendingButtonConstraints() 314 | 315 | addSubview(downloadingButton) 316 | setUpDownloadingButtonProperties() 317 | setUpDownloadingButtonConstraints() 318 | 319 | addSubview(downloadedButton) 320 | setUpDownloadedButtonProperties() 321 | setUpDownloadedButtonConstraints() 322 | } 323 | 324 | // MARK: Style customisation 325 | 326 | private func setUpStartDownloadButtonProperties() { 327 | startDownloadButton.setTitle(startDownloadButtonTitle, for: .normal) 328 | startDownloadButton.titleLabel?.font = startDownloadButtonTitleFont 329 | startDownloadButton.highlightedBackgroundColor = startDownloadButtonHighlightedBackgroundColor 330 | startDownloadButton.nonhighlightedBackgroundColor = startDownloadButtonNonhighlightedBackgroundColor 331 | startDownloadButton.highlightedTitleColor = startDownloadButtonHighlightedTitleColor 332 | startDownloadButton.nonhighlightedTitleColor = startDownloadButtonNonhighlightedTitleColor 333 | } 334 | 335 | private func setUpPendingCircleViewProperties() { 336 | pendingCircleView.circleColor = pendingCircleColor 337 | pendingCircleView.lineWidth = pendingCircleLineWidth 338 | pendingCircleView.alpha = 0 339 | 340 | let tapGesture = UITapGestureRecognizer(target: self, action: #selector(currentButtonTapped)) 341 | pendingCircleView.addGestureRecognizer(tapGesture) 342 | } 343 | 344 | private func setUpDownloadingButtonProperties() { 345 | downloadingButton.highlightedTrackCircleColor = downloadingButtonHighlightedTrackCircleColor 346 | downloadingButton.nonhighlightedTrackCircleColor = downloadingButtonNonhighlightedTrackCircleColor 347 | downloadingButton.highlightedProgressCircleColor = downloadingButtonHighlightedProgressCircleColor 348 | downloadingButton.nonhighlightedProgressCircleColor = downloadingButtonNonhighlightedProgressCircleColor 349 | downloadingButton.highlightedStopViewColor = downloadingButtonHighlightedStopViewColor 350 | downloadingButton.nonhighlightedStopViewColor = downloadingButtonNonhighlightedStopViewColor 351 | downloadingButton.alpha = 0 352 | } 353 | 354 | private func setUpDownloadedButtonProperties() { 355 | downloadedButton.setTitle(downloadedButtonTitle, for: .normal) 356 | downloadedButton.titleLabel?.font = downloadedButtonTitleFont 357 | downloadedButton.highlightedBackgroundColor = downloadedButtonHighlightedBackgroundColor 358 | downloadedButton.nonhighlightedBackgroundColor = downloadedButtonNonhighlightedBackgroundColor 359 | downloadedButton.highlightedTitleColor = downloadedButtonHighlightedTitleColor 360 | downloadedButton.nonhighlightedTitleColor = downloadedButtonNonhighlightedTitleColor 361 | downloadedButton.alpha = 0 362 | } 363 | 364 | // MARK: Constraints setup 365 | 366 | private func setUpStartDownloadButtonConstraints() { 367 | let topConstraint = startDownloadButton.constraint(attribute: .top, toItem: self, toAttribute: .top) 368 | 369 | let bottomConstraint = startDownloadButton.constraint(attribute: .bottom, toItem: self, toAttribute: .bottom) 370 | 371 | let horizontalPositionConstraint = startDownloadButton.constraint(attribute: horizontalAlignmentAttribute, toItem: self, toAttribute: horizontalAlignmentAttribute) 372 | 373 | startDownloadButtonWidthConstraint = startDownloadButton.constraint(attribute: .width, constant: 50) 374 | 375 | NSLayoutConstraint.activate([topConstraint, bottomConstraint, horizontalPositionConstraint, startDownloadButtonWidthConstraint]) 376 | } 377 | 378 | private func setUpPendingButtonConstraints() { 379 | let horizontalPositionConstraint = pendingCircleView.constraint(attribute: horizontalAlignmentAttribute, toItem: self, toAttribute: horizontalAlignmentAttribute) 380 | let heightConstraint = pendingCircleView.constraint(attribute: .height, relation: .equal, toItem: pendingCircleView, toAttribute: .width) 381 | let verticalPositionConstraint = pendingCircleView.constraint(attribute: .centerY, toItem: self, toAttribute: .centerY) 382 | 383 | pendingViewWidthConstraint = pendingCircleView.constraint(attribute: .width, constant: 30) 384 | NSLayoutConstraint.activate([horizontalPositionConstraint, verticalPositionConstraint, heightConstraint, pendingViewWidthConstraint]) 385 | } 386 | 387 | private func setUpDownloadingButtonConstraints() { 388 | let horizontalPositionConstraint = downloadingButton.constraint(attribute: horizontalAlignmentAttribute, toItem: self, toAttribute: horizontalAlignmentAttribute) 389 | let verticalPositionConstraint = downloadingButton.constraint(attribute: .centerY, toItem: self, toAttribute: .centerY) 390 | 391 | let heightConstraint = downloadingButton.constraint(attribute: .height, toItem: downloadingButton, toAttribute: .width) 392 | 393 | downloadingButtonWidthConstraint = downloadingButton.constraint(attribute: .width, constant: 30) 394 | 395 | NSLayoutConstraint.activate([horizontalPositionConstraint, verticalPositionConstraint, heightConstraint, downloadingButtonWidthConstraint]) 396 | } 397 | 398 | private func setUpDownloadedButtonConstraints() { 399 | let topConstraint = downloadedButton.constraint(attribute: .top, toItem: self, toAttribute: .top) 400 | let bottomConstraint = downloadedButton.constraint(attribute: .bottom, toItem: self, toAttribute: .bottom) 401 | let horizontalPositionConstraint = downloadedButton.constraint(attribute: horizontalAlignmentAttribute, toItem: self, toAttribute: horizontalAlignmentAttribute) 402 | 403 | // This constraint will be changed later on (in layoutSubviews), here we're just creating it 404 | downloadedButtonWidthConstraint = downloadedButton.constraint(attribute: .width, constant: 50) 405 | 406 | NSLayoutConstraint.activate([topConstraint, bottomConstraint, horizontalPositionConstraint, downloadedButtonWidthConstraint]) 407 | } 408 | 409 | // MARK: Method overrides 410 | 411 | public override func layoutSubviews() { 412 | super.layoutSubviews() 413 | let width = min(frame.width, frame.height) 414 | pendingViewWidthConstraint.constant = width 415 | downloadingButtonWidthConstraint.constant = width 416 | 417 | if startDownloadButtonTitleWidth == 0 { 418 | startDownloadButtonTitleWidth = startDownloadButton.titleWidth 419 | } 420 | 421 | if downloadedButtonTitleWidth == 0 { 422 | downloadedButtonTitleWidth = downloadedButton.titleWidth 423 | } 424 | } 425 | 426 | // MARK: Action methods 427 | 428 | @objc private func currentButtonTapped() { 429 | delegate?.downloadButton(self, tappedWithState: state) 430 | didTapDownloadButtonAction?(self, state) 431 | } 432 | 433 | } 434 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/CircleView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CircleView.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 03/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class CircleView: UIView { 12 | 13 | // MARK: Properties 14 | 15 | var startAngleRadians: CGFloat = -CGFloat.pi / 2 16 | 17 | var endAngleRadians: CGFloat = 3 * CGFloat.pi / 2 18 | 19 | var lineWidth: CGFloat = 1 { 20 | didSet { 21 | circleLayer.lineWidth = lineWidth 22 | } 23 | } 24 | 25 | var circleColor: UIColor = Color.Blue.medium { 26 | didSet { 27 | circleLayer.strokeColor = circleColor.cgColor 28 | } 29 | } 30 | 31 | let circleLayer: CAShapeLayer = { 32 | let layer = CAShapeLayer() 33 | layer.fillColor = UIColor.clear.cgColor 34 | layer.lineCap = .round 35 | return layer 36 | }() 37 | 38 | // MARK: Initializers 39 | 40 | override init(frame: CGRect) { 41 | super.init(frame: frame) 42 | commonInit() 43 | } 44 | 45 | required init?(coder aDecoder: NSCoder) { 46 | super.init(coder: aDecoder) 47 | commonInit() 48 | } 49 | 50 | private func commonInit() { 51 | backgroundColor = .clear 52 | circleLayer.strokeColor = circleColor.cgColor 53 | circleLayer.lineWidth = lineWidth 54 | layer.addSublayer(circleLayer) 55 | } 56 | 57 | override func layoutSubviews() { 58 | super.layoutSubviews() 59 | let radius = min(frame.width / 2, frame.height / 2) - lineWidth / 2 60 | let center = CGPoint(x: frame.width / 2, y: frame.height / 2) 61 | circleLayer.path = UIBezierPath(arcCenter: center, 62 | radius: radius, 63 | startAngle: startAngleRadians, 64 | endAngle: endAngleRadians, 65 | clockwise: true).cgPath 66 | } 67 | 68 | func startSpinning() { 69 | let animationKey = "rotation" 70 | layer.removeAnimation(forKey: animationKey) 71 | let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation") 72 | rotationAnimation.fromValue = 0.0 73 | rotationAnimation.toValue = CGFloat.pi * 2 74 | rotationAnimation.duration = 2 75 | rotationAnimation.repeatCount = .greatestFiniteMagnitude; 76 | layer.add(rotationAnimation, forKey: animationKey) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/Color.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Color.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 07/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum Color { 12 | 13 | enum Gray { 14 | static let light = UIColor(red: 245.0 / 255.0, green: 244.0 / 255.0, blue: 249.0 / 255.0, alpha: 1) 15 | static let medium = UIColor(red: 238.0 / 255.0, green: 239.0 / 255.0, blue: 245.0 / 255.0, alpha: 1) 16 | static let dark = UIColor(red: 229.0 / 255.0, green: 229.0 / 255.0, blue: 233.0 / 255.0, alpha: 1) 17 | } 18 | 19 | enum Blue { 20 | static let light = UIColor(red: 199.0 / 255.0, green: 222 / 255.0, blue: 243 / 255.0, alpha: 1) 21 | static let medium = UIColor(red: 9.0 / 255.0, green: 111.0 / 255.0, blue: 227.0 / 255.0, alpha: 1) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/HighlightableRoundedButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HighlightableRoundedButton.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 03/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class HighlightableRoundedButton: UIButton { 12 | 13 | // MARK: Properties 14 | 15 | var highlightedBackgroundColor = Color.Gray.light { 16 | didSet { 17 | updateColors() 18 | } 19 | } 20 | 21 | var nonhighlightedBackgroundColor = Color.Gray.medium { 22 | didSet { 23 | updateColors() 24 | } 25 | } 26 | 27 | var highlightedTitleColor = Color.Blue.light { 28 | didSet { 29 | updateColors() 30 | } 31 | } 32 | 33 | var nonhighlightedTitleColor = Color.Blue.medium { 34 | didSet { 35 | updateColors() 36 | } 37 | } 38 | 39 | override var isHighlighted: Bool { 40 | didSet { 41 | updateColors() 42 | } 43 | } 44 | 45 | // MARK: Initializers 46 | 47 | override init(frame: CGRect) { 48 | super.init(frame: frame) 49 | updateColors() 50 | } 51 | 52 | required init?(coder aDecoder: NSCoder) { 53 | super.init(coder: aDecoder) 54 | updateColors() 55 | } 56 | 57 | // MARK: Helper methods 58 | 59 | private func updateColors() { 60 | backgroundColor = isHighlighted ? highlightedBackgroundColor : nonhighlightedBackgroundColor 61 | let titleColor = isHighlighted ? highlightedTitleColor : nonhighlightedTitleColor 62 | setTitleColor(titleColor, for: .normal) 63 | } 64 | 65 | override func layoutSubviews() { 66 | super.layoutSubviews() 67 | layer.cornerRadius = frame.height / 2 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/ProgressButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ProgressButton.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 03/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class ProgressButton: UIControl { 12 | 13 | // MARK: Properties 14 | 15 | var circleViewLineWidth: CGFloat = 6 { 16 | didSet { 17 | progressCircleView.lineWidth = circleViewLineWidth 18 | trackCircleView.lineWidth = circleViewLineWidth 19 | } 20 | } 21 | 22 | let stopView: UIView = { 23 | let view = UIView() 24 | view.isUserInteractionEnabled = false 25 | view.layer.cornerRadius = 3 26 | return view 27 | }() 28 | 29 | lazy var trackCircleView: CircleView = { 30 | let circleView = CircleView() 31 | circleView.lineWidth = circleViewLineWidth 32 | circleView.isUserInteractionEnabled = false 33 | return circleView 34 | }() 35 | 36 | lazy var progressCircleView: ProgressCircleView = { 37 | let view = ProgressCircleView() 38 | view.lineWidth = circleViewLineWidth 39 | view.isUserInteractionEnabled = false 40 | return view 41 | }() 42 | 43 | var nonhighlightedTrackCircleColor: UIColor = Color.Gray.medium { 44 | didSet { 45 | updateColors() 46 | } 47 | } 48 | 49 | var highlightedTrackCircleColor: UIColor = Color.Gray.light { 50 | didSet { 51 | updateColors() 52 | } 53 | } 54 | 55 | var nonhighlightedProgressCircleColor: UIColor = Color.Blue.medium { 56 | didSet { 57 | updateColors() 58 | } 59 | } 60 | 61 | var highlightedProgressCircleColor: UIColor = Color.Blue.light { 62 | didSet { 63 | updateColors() 64 | } 65 | } 66 | 67 | var nonhighlightedStopViewColor: UIColor = Color.Blue.medium { 68 | didSet { 69 | updateColors() 70 | } 71 | } 72 | 73 | var highlightedStopViewColor: UIColor = Color.Blue.light { 74 | didSet { 75 | updateColors() 76 | } 77 | } 78 | 79 | var progress: CGFloat = 0 { 80 | didSet { 81 | if progress < 0 { 82 | progress = 0 83 | } else if progress > 1 { 84 | progress = 1 85 | } 86 | progressCircleView.progress = progress 87 | } 88 | } 89 | 90 | var stopButtonCornerRadius: CGFloat = 3 { 91 | didSet { 92 | stopView.layer.cornerRadius = stopButtonCornerRadius 93 | } 94 | } 95 | 96 | override var isHighlighted: Bool { 97 | didSet { 98 | updateColors() 99 | } 100 | } 101 | 102 | // MARK: Initializers 103 | 104 | override init(frame: CGRect) { 105 | super.init(frame: frame) 106 | commonInit() 107 | } 108 | 109 | required init?(coder aDecoder: NSCoder) { 110 | super.init(coder: aDecoder) 111 | commonInit() 112 | } 113 | 114 | // MARK: Helper methods 115 | 116 | private func commonInit() { 117 | backgroundColor = .clear 118 | 119 | addSubview(trackCircleView) 120 | trackCircleView.pinToSuperview() 121 | 122 | addSubview(progressCircleView) 123 | progressCircleView.pinToSuperview() 124 | 125 | addSubview(stopView) 126 | stopView.centerToSuperview() 127 | let heightConstraint = stopView.constraint(attribute: .height, toItem: stopView, toAttribute: .width) 128 | let widthConstraint = stopView.constraint(attribute: .width, toItem: self, toAttribute: .width, multiplier: 0.3, constant: 0) 129 | 130 | NSLayoutConstraint.activate([heightConstraint, widthConstraint]) 131 | updateColors() 132 | } 133 | 134 | private func updateColors() { 135 | trackCircleView.circleColor = isHighlighted ? highlightedTrackCircleColor : nonhighlightedTrackCircleColor 136 | progressCircleView.circleColor = isHighlighted ? highlightedProgressCircleColor : nonhighlightedProgressCircleColor 137 | stopView.backgroundColor = isHighlighted ? highlightedStopViewColor : nonhighlightedStopViewColor 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/ProgressCircleView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ProgressCircleView.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 17/09/2018. 6 | // 7 | 8 | import UIKit 9 | 10 | final class ProgressCircleView: UIView { 11 | 12 | // MARK: Properties 13 | 14 | private let circleView: CircleView = { 15 | let view = CircleView() 16 | view.circleColor = .red 17 | view.startAngleRadians = -CGFloat.pi / 2 18 | view.endAngleRadians = view.startAngleRadians + 2 * .pi 19 | return view 20 | }() 21 | 22 | private var isAnimating = false 23 | 24 | var progressAnimationDuration: TimeInterval = 0.3 25 | 26 | var progress: CGFloat = 0 { 27 | didSet { 28 | if progress == 1 && isAnimating { 29 | if let currentAnimatedProgress = circleView.circleLayer.presentation()?.strokeEnd { 30 | circleView.circleLayer.strokeEnd = currentAnimatedProgress 31 | animateProgress(from: currentAnimatedProgress, to: progress) 32 | } 33 | } 34 | 35 | guard !isAnimating else { return } 36 | animateProgress(from: circleView.circleLayer.strokeEnd, to: progress) 37 | } 38 | } 39 | 40 | var lineWidth: CGFloat = 1 { 41 | didSet { 42 | circleView.lineWidth = lineWidth 43 | } 44 | } 45 | 46 | var circleColor: UIColor = Color.Blue.medium { 47 | didSet { 48 | circleView.circleLayer.strokeColor = circleColor.cgColor 49 | } 50 | } 51 | 52 | // MARK: Initializers 53 | 54 | override init(frame: CGRect) { 55 | super.init(frame: frame) 56 | commonInit() 57 | } 58 | 59 | required init?(coder aDecoder: NSCoder) { 60 | super.init(coder: aDecoder) 61 | commonInit() 62 | } 63 | 64 | private func commonInit() { 65 | addSubview(circleView) 66 | circleView.pinToSuperview() 67 | } 68 | 69 | private func animateProgress(from startValue: CGFloat, to endValue: CGFloat) { 70 | isAnimating = true 71 | circleView.circleLayer.strokeEnd = endValue 72 | let animation = CABasicAnimation(keyPath: "strokeEnd") 73 | animation.timingFunction = CAMediaTimingFunction(name: .easeOut) 74 | animation.fromValue = startValue 75 | animation.duration = progressAnimationDuration 76 | animation.delegate = self 77 | circleView.circleLayer.add(animation, forKey: "strokeEnd") 78 | } 79 | } 80 | 81 | extension ProgressCircleView: CAAnimationDelegate { 82 | func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { 83 | isAnimating = !flag 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/UIButton+TitleWidth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+TitleWidth.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 03/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIButton { 12 | 13 | var titleWidth: CGFloat { 14 | guard let text = titleLabel?.text, let font = titleLabel?.font else { return 0 } 15 | return text.size(withAttributes: [.font: font]).width 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/AHDownloadButton/Classes/UIView+Constraint.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Constraint.swift 3 | // AHDownloadButton 4 | // 5 | // Created by Amer Hukic on 03/09/2018. 6 | // Copyright © 2018 Amer Hukic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIView { 12 | 13 | @discardableResult 14 | func constraint(attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation = .equal, toItem: Any? = nil, toAttribute: NSLayoutConstraint.Attribute = .notAnAttribute, multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint { 15 | translatesAutoresizingMaskIntoConstraints = false 16 | let constraint = NSLayoutConstraint(item: self, 17 | attribute: attribute, 18 | relatedBy: relation, 19 | toItem: toItem, 20 | attribute: toAttribute, 21 | multiplier: multiplier, 22 | constant: constant) 23 | return constraint 24 | } 25 | 26 | func pinToSuperview() { 27 | translatesAutoresizingMaskIntoConstraints = false 28 | let topConstraint = self.constraint(attribute: .top, toItem: superview, toAttribute: .top) 29 | let bottomConstraint = self.constraint(attribute: .bottom, toItem: superview, toAttribute: .bottom) 30 | let leadingConstraint = constraint(attribute: .leading, toItem: superview, toAttribute: .leading) 31 | let trailingConstraint = self.constraint(attribute: .trailing, toItem: superview, toAttribute: .trailing) 32 | NSLayoutConstraint.activate([trailingConstraint, topConstraint, leadingConstraint, bottomConstraint]) 33 | } 34 | 35 | func centerToSuperview() { 36 | translatesAutoresizingMaskIntoConstraints = false 37 | let centerXConstraint = constraint(attribute: .centerX, toItem: superview, toAttribute: .centerX) 38 | 39 | let centerYConstraint = constraint(attribute: .centerY, toItem: superview, toAttribute: .centerY) 40 | NSLayoutConstraint.activate([centerXConstraint, centerYConstraint]) 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 hukicamer@gmail.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pods/AHDownloadButton/README.md: -------------------------------------------------------------------------------- 1 |

2 | Logo 3 |

4 | 5 |

6 | 7 | 8 | Pod Version 9 | 10 | 11 | Carthage compatible 12 | 13 | 14 | License 15 | 16 | 17 | Twitter: @hukicamer 18 | 19 |

20 | 21 | **AHDownloadButton** is a customizable download button similar to the download button in the latest version of Apple's App Store app (since iOS 11). 22 | It features download progress animation as well as animated transitions between download states: start download, pending, downloading and downloaded. [You can find more details about the implementation on my blog](https://amerhukic.com/replicating-app-store-download-button). 23 | 24 |

25 |

26 | 27 | ## Requirements 28 | 29 | - iOS 8.0+ 30 | - Xcode 9.0+ 31 | - Swift 4.0+ 32 | 33 | ## Usage 34 | 35 | ### Code 36 | To use `AHDownloadButton` in code, you simply create a new instance and add it as a subview to your desired view: 37 | ```swift 38 | let downloadButton = AHDownloadButton() 39 | downloadButton.frame = CGRect(origin: origin, size: size) 40 | view.addSubview(downloadButton) 41 | ``` 42 | The button can have 4 different states: 43 | - `startDownload` - initial state before downloading 44 | - `pending` - state for preparing for download 45 | - `downloading` - state when the user is downloading 46 | - `downloaded` - state when the user finished downloading 47 | 48 | The state of the button can be changed through its `state` property. 49 | 50 | ### Delegate 51 | You can use the `AHDownloadButtonDelegate` to monitor taps on the button and update button's state if needed. To update the current download progress, use the `progress` property. Here is an example how it could be implemented: 52 | 53 | ```swift 54 | extension DownloadViewController: AHDownloadButtonDelegate { 55 | 56 | func downloadButton(_ downloadButton: AHDownloadButton, tappedWithState state: AHDownloadButton.State) 57 | switch state { 58 | case .startDownload: 59 | 60 | // set the download progress to 0 61 | downloadButton.progress = 0 62 | 63 | // change state to pending and wait for download to start 64 | downloadButton.state = .pending 65 | 66 | // initiate download and update state to .downloading 67 | startDownloadingFile() 68 | 69 | case .pending: 70 | 71 | // button tapped while in pending state 72 | break 73 | 74 | case .downloading: 75 | 76 | // button tapped while in downloading state - stop downloading 77 | downloadButton.progress = 0 78 | downloadButton.state = .startDownload 79 | 80 | case .downloaded: 81 | 82 | // file is downloaded and can be opened 83 | openDownloadedFile() 84 | 85 | } 86 | } 87 | } 88 | ``` 89 | 90 | You can also use closures instead of the `AHDownloadButtonDelegate` by setting the `didTapDownloadButtonAction` and `downloadButtonStateChangedAction` properties. 91 | 92 | ### Customisation 93 | 94 | `AHDownloadButton` can be customized. These are the properties that can be used for customizing the button: 95 | 96 | 1. Use the custom initializer `init(alignment: HorizontalAlignment)` to set the horizontal alignment property. `HorizontalAlignment` determines the position of the pending and downloading circles. The position can either be `center` , `left` or `right`. The default value is `center`. 97 | 98 | 99 | 2. Customization properties when button is in `startDownload` state: 100 | 101 | - `startDownloadButtonTitle` - button's title 102 | - `startDownloadButtonTitleFont` - button's title font 103 | - `startDownloadButtonTitleSidePadding` - padding for left and right side of button's title 104 | - `startDownloadButtonHighlightedBackgroundColor` - background color for the button when it's in highlighted state (when the user presses the button) 105 | - `startDownloadButtonNonhighlightedBackgroundColor` - background color for the button when it's in nonhighlighted state (when the button is not pressed) 106 | - `startDownloadButtonHighlightedTitleColor` - title color for the button when it's in highlighted state (when the user presses the button) 107 | - `startDownloadButtonNonhighlightedTitleColor` - title color for the button when it's in nonhighlighted state (when the button is not pressed) 108 | 109 | 110 | 3. Customization properties when button is in `pending` state: 111 | 112 | - `pendingCircleColor` - color of the pending circle 113 | - `pendingCircleLineWidth` - width of the pending circle 114 | 115 | 116 | 4. Customization properties when button is in `downloading` state: 117 | 118 | - `downloadingButtonHighlightedTrackCircleColor` - color for the track circle when it's in highlighted state (when the user presses the button) 119 | - `downloadingButtonNonhighlightedTrackCircleColor` - color for the track circle when it's in nonhighlighted state (when the button is not pressed) 120 | - `downloadingButtonHighlightedProgressCircleColor` - color for the progress circle when it's in highlighted state (when the user presses the button) 121 | - `downloadingButtonNonhighlightedProgressCircleColor` - color for the progress circle when it's in nonhighlighted state (when the button is not pressed) 122 | - `downloadingButtonHighlightedStopViewColor` - color for the stop view in the middle of the progress circle when it's in highlighted state (when the user presses the button) 123 | - `downloadingButtonNonhighlightedStopViewColor` - color for the stop view in the middle of the progress circle when it's in nonhighlighted state (when the button is not pressed) 124 | - `downloadingButtonCircleLineWidth` - width of the downloading circle 125 | 126 | 127 | 5. Customization properties when button is in `downloaded` state: 128 | 129 | - `downloadedButtonTitle` - button's title 130 | - `downloadedButtonTitleFont` - button's title font 131 | - `downloadedButtonTitleSidePadding` - padding for left and right side of button's title 132 | - `downloadedButtonHighlightedBackgroundColor` - background color for the button when it's in highlighted state (when the user presses the button) 133 | - `downloadedButtonNonhighlightedBackgroundColor` - background color for the button when it's in nonhighlighted state (when the button is not pressed) 134 | - `downloadedButtonHighlightedTitleColor` - title color for the button when it's in highlighted state (when the user presses the button) 135 | - `downloadedButtonNonhighlightedTitleColor` - title color for the button when it's in nonhighlighted state (when the button is not pressed) 136 | 137 | 6. `transitionAnimationDuration` - animation duration between the different states of the button 138 | 139 | ### Special note 140 | 141 | `AHDownloadButton` in `startDownload` and `downloaded` states calculates its width based on **button title**. Use the `startDownloadButtonTitleSidePadding` and `downloadedButtonTitleSidePadding` properties to customise the width when the button is in the aforementioned states. 142 | 143 | ## Example 144 | 145 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 146 | 147 | ## Installation 148 | 149 | ### CocoaPods 150 | 151 | [CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 152 | 153 | ```bash 154 | $ gem install cocoapods 155 | ``` 156 | 157 | To integrate AHDownloadButton into your Xcode project using CocoaPods, specify it in your `Podfile`: 158 | 159 | ```ruby 160 | source 'https://github.com/CocoaPods/Specs.git' 161 | platform :ios, '8.0' 162 | use_frameworks! 163 | 164 | target '' do 165 | pod 'AHDownloadButton' 166 | end 167 | ``` 168 | 169 | Then, run the following command: 170 | 171 | ```bash 172 | $ pod install 173 | ``` 174 | 175 | ## Author 176 | 177 | [Amer Hukić](https://amerhukic.com) 178 | 179 | ## License 180 | 181 | AHDownloadButton is licensed under the MIT license. Check the [LICENSE](LICENSE) file for details. 182 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AHDownloadButton (1.2.0) 3 | 4 | DEPENDENCIES: 5 | - AHDownloadButton 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - AHDownloadButton 10 | 11 | SPEC CHECKSUMS: 12 | AHDownloadButton: 7a3927c9365fbd6d08682d26832d87dd0cd5573f 13 | 14 | PODFILE CHECKSUM: d35d4529e9cbe190d129356580564364767d9455 15 | 16 | COCOAPODS: 1.10.1 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton-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.2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AHDownloadButton : NSObject 3 | @end 4 | @implementation PodsDummy_AHDownloadButton 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton-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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton-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 AHDownloadButtonVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char AHDownloadButtonVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "UIKit" 5 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AHDownloadButton 10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 11 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 12 | SKIP_INSTALL = YES 13 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 14 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton.modulemap: -------------------------------------------------------------------------------- 1 | framework module AHDownloadButton { 2 | umbrella header "AHDownloadButton-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AHDownloadButton/AHDownloadButton.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "UIKit" 5 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AHDownloadButton 10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 11 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 12 | SKIP_INSTALL = YES 13 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 14 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AHDownloadButton 5 | 6 | Copyright (c) 2018 hukicamer@gmail.com 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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-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) 2018 hukicamer@gmail.com <hukicamer@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 | AHDownloadButton 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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_DownloadManager_DownloadManagerUITests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_DownloadManager_DownloadManagerUITests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-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 | BCSYMBOLMAP_DIR="BCSymbolMaps" 23 | 24 | 25 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 26 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 27 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 28 | 29 | # Copies and strips a vendored framework 30 | install_framework() 31 | { 32 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 33 | local source="${BUILT_PRODUCTS_DIR}/$1" 34 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 35 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 36 | elif [ -r "$1" ]; then 37 | local source="$1" 38 | fi 39 | 40 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 41 | 42 | if [ -L "${source}" ]; then 43 | echo "Symlinked..." 44 | source="$(readlink "${source}")" 45 | fi 46 | 47 | if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then 48 | # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied 49 | find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do 50 | echo "Installing $f" 51 | install_bcsymbolmap "$f" "$destination" 52 | rm "$f" 53 | done 54 | rmdir "${source}/${BCSYMBOLMAP_DIR}" 55 | fi 56 | 57 | # Use filter instead of exclude so missing patterns don't throw errors. 58 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 59 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 60 | 61 | local basename 62 | basename="$(basename -s .framework "$1")" 63 | binary="${destination}/${basename}.framework/${basename}" 64 | 65 | if ! [ -r "$binary" ]; then 66 | binary="${destination}/${basename}" 67 | elif [ -L "${binary}" ]; then 68 | echo "Destination binary is symlinked..." 69 | dirname="$(dirname "${binary}")" 70 | binary="${dirname}/$(readlink "${binary}")" 71 | fi 72 | 73 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 74 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 75 | strip_invalid_archs "$binary" 76 | fi 77 | 78 | # Resign the code if required by the build settings to avoid unstable apps 79 | code_sign_if_enabled "${destination}/$(basename "$1")" 80 | 81 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 82 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 83 | local swift_runtime_libs 84 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) 85 | for lib in $swift_runtime_libs; do 86 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 87 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 88 | code_sign_if_enabled "${destination}/${lib}" 89 | done 90 | fi 91 | } 92 | # Copies and strips a vendored dSYM 93 | install_dsym() { 94 | local source="$1" 95 | warn_missing_arch=${2:-true} 96 | if [ -r "$source" ]; then 97 | # Copy the dSYM into the targets temp dir. 98 | 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}\"" 99 | 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}" 100 | 101 | local basename 102 | basename="$(basename -s .dSYM "$source")" 103 | binary_name="$(ls "$source/Contents/Resources/DWARF")" 104 | binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}" 105 | 106 | # Strip invalid architectures from the dSYM. 107 | if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then 108 | strip_invalid_archs "$binary" "$warn_missing_arch" 109 | fi 110 | if [[ $STRIP_BINARY_RETVAL == 0 ]]; then 111 | # Move the stripped file into its final destination. 112 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 113 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 114 | else 115 | # 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. 116 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM" 117 | fi 118 | fi 119 | } 120 | 121 | # Used as a return value for each invocation of `strip_invalid_archs` function. 122 | STRIP_BINARY_RETVAL=0 123 | 124 | # Strip invalid architectures 125 | strip_invalid_archs() { 126 | binary="$1" 127 | warn_missing_arch=${2:-true} 128 | # Get architectures for current target binary 129 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 130 | # Intersect them with the architectures we are building for 131 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 132 | # If there are no archs supported by this binary then warn the user 133 | if [[ -z "$intersected_archs" ]]; then 134 | if [[ "$warn_missing_arch" == "true" ]]; then 135 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 136 | fi 137 | STRIP_BINARY_RETVAL=1 138 | return 139 | fi 140 | stripped="" 141 | for arch in $binary_archs; do 142 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 143 | # Strip non-valid architectures in-place 144 | lipo -remove "$arch" -output "$binary" "$binary" 145 | stripped="$stripped $arch" 146 | fi 147 | done 148 | if [[ "$stripped" ]]; then 149 | echo "Stripped $binary of architectures:$stripped" 150 | fi 151 | STRIP_BINARY_RETVAL=0 152 | } 153 | 154 | # Copies the bcsymbolmap files of a vendored framework 155 | install_bcsymbolmap() { 156 | local bcsymbolmap_path="$1" 157 | local destination="${BUILT_PRODUCTS_DIR}" 158 | 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}"" 159 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" 160 | } 161 | 162 | # Signs a framework with the provided identity 163 | code_sign_if_enabled() { 164 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 165 | # Use the current code_sign_identity 166 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 167 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" 168 | 169 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 170 | code_sign_cmd="$code_sign_cmd &" 171 | fi 172 | echo "$code_sign_cmd" 173 | eval "$code_sign_cmd" 174 | fi 175 | } 176 | 177 | if [[ "$CONFIGURATION" == "Debug" ]]; then 178 | install_framework "${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework" 179 | fi 180 | if [[ "$CONFIGURATION" == "Release" ]]; then 181 | install_framework "${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework" 182 | fi 183 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 184 | wait 185 | fi 186 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests-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_DownloadManager_DownloadManagerUITestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_DownloadManager_DownloadManagerUITestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton/AHDownloadButton.framework/Headers" 6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 7 | OTHER_LDFLAGS = $(inherited) -framework "AHDownloadButton" -framework "UIKit" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_DownloadManager_DownloadManagerUITests { 2 | umbrella header "Pods-DownloadManager-DownloadManagerUITests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager-DownloadManagerUITests/Pods-DownloadManager-DownloadManagerUITests.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton/AHDownloadButton.framework/Headers" 6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 7 | OTHER_LDFLAGS = $(inherited) -framework "AHDownloadButton" -framework "UIKit" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AHDownloadButton 5 | 6 | Copyright (c) 2018 hukicamer@gmail.com 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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-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) 2018 hukicamer@gmail.com <hukicamer@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 | AHDownloadButton 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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_DownloadManager : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_DownloadManager 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AHDownloadButton.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-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 | BCSYMBOLMAP_DIR="BCSymbolMaps" 23 | 24 | 25 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 26 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 27 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 28 | 29 | # Copies and strips a vendored framework 30 | install_framework() 31 | { 32 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 33 | local source="${BUILT_PRODUCTS_DIR}/$1" 34 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 35 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 36 | elif [ -r "$1" ]; then 37 | local source="$1" 38 | fi 39 | 40 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 41 | 42 | if [ -L "${source}" ]; then 43 | echo "Symlinked..." 44 | source="$(readlink "${source}")" 45 | fi 46 | 47 | if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then 48 | # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied 49 | find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do 50 | echo "Installing $f" 51 | install_bcsymbolmap "$f" "$destination" 52 | rm "$f" 53 | done 54 | rmdir "${source}/${BCSYMBOLMAP_DIR}" 55 | fi 56 | 57 | # Use filter instead of exclude so missing patterns don't throw errors. 58 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 59 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 60 | 61 | local basename 62 | basename="$(basename -s .framework "$1")" 63 | binary="${destination}/${basename}.framework/${basename}" 64 | 65 | if ! [ -r "$binary" ]; then 66 | binary="${destination}/${basename}" 67 | elif [ -L "${binary}" ]; then 68 | echo "Destination binary is symlinked..." 69 | dirname="$(dirname "${binary}")" 70 | binary="${dirname}/$(readlink "${binary}")" 71 | fi 72 | 73 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 74 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 75 | strip_invalid_archs "$binary" 76 | fi 77 | 78 | # Resign the code if required by the build settings to avoid unstable apps 79 | code_sign_if_enabled "${destination}/$(basename "$1")" 80 | 81 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 82 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 83 | local swift_runtime_libs 84 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) 85 | for lib in $swift_runtime_libs; do 86 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 87 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 88 | code_sign_if_enabled "${destination}/${lib}" 89 | done 90 | fi 91 | } 92 | # Copies and strips a vendored dSYM 93 | install_dsym() { 94 | local source="$1" 95 | warn_missing_arch=${2:-true} 96 | if [ -r "$source" ]; then 97 | # Copy the dSYM into the targets temp dir. 98 | 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}\"" 99 | 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}" 100 | 101 | local basename 102 | basename="$(basename -s .dSYM "$source")" 103 | binary_name="$(ls "$source/Contents/Resources/DWARF")" 104 | binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}" 105 | 106 | # Strip invalid architectures from the dSYM. 107 | if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then 108 | strip_invalid_archs "$binary" "$warn_missing_arch" 109 | fi 110 | if [[ $STRIP_BINARY_RETVAL == 0 ]]; then 111 | # Move the stripped file into its final destination. 112 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 113 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 114 | else 115 | # 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. 116 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM" 117 | fi 118 | fi 119 | } 120 | 121 | # Used as a return value for each invocation of `strip_invalid_archs` function. 122 | STRIP_BINARY_RETVAL=0 123 | 124 | # Strip invalid architectures 125 | strip_invalid_archs() { 126 | binary="$1" 127 | warn_missing_arch=${2:-true} 128 | # Get architectures for current target binary 129 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 130 | # Intersect them with the architectures we are building for 131 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 132 | # If there are no archs supported by this binary then warn the user 133 | if [[ -z "$intersected_archs" ]]; then 134 | if [[ "$warn_missing_arch" == "true" ]]; then 135 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 136 | fi 137 | STRIP_BINARY_RETVAL=1 138 | return 139 | fi 140 | stripped="" 141 | for arch in $binary_archs; do 142 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 143 | # Strip non-valid architectures in-place 144 | lipo -remove "$arch" -output "$binary" "$binary" 145 | stripped="$stripped $arch" 146 | fi 147 | done 148 | if [[ "$stripped" ]]; then 149 | echo "Stripped $binary of architectures:$stripped" 150 | fi 151 | STRIP_BINARY_RETVAL=0 152 | } 153 | 154 | # Copies the bcsymbolmap files of a vendored framework 155 | install_bcsymbolmap() { 156 | local bcsymbolmap_path="$1" 157 | local destination="${BUILT_PRODUCTS_DIR}" 158 | 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}"" 159 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" 160 | } 161 | 162 | # Signs a framework with the provided identity 163 | code_sign_if_enabled() { 164 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 165 | # Use the current code_sign_identity 166 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 167 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" 168 | 169 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 170 | code_sign_cmd="$code_sign_cmd &" 171 | fi 172 | echo "$code_sign_cmd" 173 | eval "$code_sign_cmd" 174 | fi 175 | } 176 | 177 | if [[ "$CONFIGURATION" == "Debug" ]]; then 178 | install_framework "${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework" 179 | fi 180 | if [[ "$CONFIGURATION" == "Release" ]]; then 181 | install_framework "${BUILT_PRODUCTS_DIR}/AHDownloadButton/AHDownloadButton.framework" 182 | fi 183 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 184 | wait 185 | fi 186 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager-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_DownloadManagerVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_DownloadManagerVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton/AHDownloadButton.framework/Headers" 6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 7 | OTHER_LDFLAGS = $(inherited) -framework "AHDownloadButton" -framework "UIKit" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_DownloadManager { 2 | umbrella header "Pods-DownloadManager-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManager/Pods-DownloadManager.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton/AHDownloadButton.framework/Headers" 6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 7 | OTHER_LDFLAGS = $(inherited) -framework "AHDownloadButton" -framework "UIKit" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests-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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests-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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_DownloadManagerTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_DownloadManagerTests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests-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_DownloadManagerTestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_DownloadManagerTestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton/AHDownloadButton.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "AHDownloadButton" -framework "UIKit" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_DownloadManagerTests { 2 | umbrella header "Pods-DownloadManagerTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DownloadManagerTests/Pods-DownloadManagerTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AHDownloadButton/AHDownloadButton.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "AHDownloadButton" -framework "UIKit" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | ## Preview 12 | ![image](/Media/download_manager.gif) 13 | 14 |

15 | 16 | 17 | 18 |

19 | 20 | ## Description 21 | 22 | In download manager, download mp3 file, store that file in local and play, pause and stop that mp3 file 23 | 24 | ## Feature 25 | - Download mp3 media file 26 | - Store in local file system 27 | - Play pause and resume the mp3 file 28 | 29 | ## 30 | Read more from [MEDIUM](https://medium.com/mindful-engineering/downloadmanager-3839ce4f3b55) 31 | ## 32 | 33 | ## LICENSE! 34 | 35 | DownloadManager is [MIT-licensed](/LICENSE). 36 | --------------------------------------------------------------------------------