diff --git a/DanTangSwift.xcodeproj/project.pbxproj b/DanTangSwift.xcodeproj/project.pbxproj new file mode 100644 index 0000000..85babe5 --- /dev/null +++ b/DanTangSwift.xcodeproj/project.pbxproj @@ -0,0 +1,819 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 271D42F71F0CCD4600E04A82 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 271D42F61F0CCD4600E04A82 /* Assets.xcassets */; }; + 271D42F91F0CE0C500E04A82 /* NetworkTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271D42F81F0CE0C500E04A82 /* NetworkTool.swift */; }; + 271D42FB1F0CE45800E04A82 /* TXHomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271D42FA1F0CE45800E04A82 /* TXHomeModel.swift */; }; + 27E00AAD1F0C95E800B010C4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AAC1F0C95E800B010C4 /* AppDelegate.swift */; }; + 27E00AAF1F0C95E800B010C4 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AAE1F0C95E800B010C4 /* ViewController.swift */; }; + 27E00AB21F0C95E800B010C4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27E00AB01F0C95E800B010C4 /* Main.storyboard */; }; + 27E00AB71F0C95E800B010C4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27E00AB51F0C95E800B010C4 /* LaunchScreen.storyboard */; }; + 27E00AC21F0C95E800B010C4 /* DanTangSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AC11F0C95E800B010C4 /* DanTangSwiftTests.swift */; }; + 27E00ACD1F0C95E800B010C4 /* DanTangSwiftUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00ACC1F0C95E800B010C4 /* DanTangSwiftUITests.swift */; }; + 27E00AEE1F0CB6B200B010C4 /* TXBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AEC1F0CB6B200B010C4 /* TXBaseViewController.swift */; }; + 27E00AEF1F0CB6B200B010C4 /* TXTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AED1F0CB6B200B010C4 /* TXTabBarController.swift */; }; + 27E00AF21F0CB6CB00B010C4 /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AF11F0CB6CB00B010C4 /* UIColor+Extension.swift */; }; + 27E00AF51F0CB6D600B010C4 /* TXConst.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00AF41F0CB6D600B010C4 /* TXConst.swift */; }; + 27E00B081F0CB80400B010C4 /* HomeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00B071F0CB80400B010C4 /* HomeVC.swift */; }; + 27E00B0A1F0CB84E00B010C4 /* MineVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00B091F0CB84E00B010C4 /* MineVC.swift */; }; + 27E00B0C1F0CB88F00B010C4 /* ProductVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00B0B1F0CB88F00B010C4 /* ProductVC.swift */; }; + 27E00B0E1F0CB8DD00B010C4 /* ClassifyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00B0D1F0CB8DD00B010C4 /* ClassifyVC.swift */; }; + 27E00B141F0CCBC700B010C4 /* TXNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E00B131F0CCBC700B010C4 /* TXNavigationController.swift */; }; + 9F113184B7313CA5B8F61E14 /* Pods_DanTangSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3258C960B4FB24AB8B50A3F5 /* Pods_DanTangSwift.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 27E00ABE1F0C95E800B010C4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 27E00AA11F0C95E800B010C4 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 27E00AA81F0C95E800B010C4; + remoteInfo = DanTangSwift; + }; + 27E00AC91F0C95E800B010C4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 27E00AA11F0C95E800B010C4 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 27E00AA81F0C95E800B010C4; + remoteInfo = DanTangSwift; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 022002614A328256DCA5494F /* Pods-DanTangSwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DanTangSwift.release.xcconfig"; path = "Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.release.xcconfig"; sourceTree = ""; }; + 271D42F61F0CCD4600E04A82 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 271D42F81F0CE0C500E04A82 /* NetworkTool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkTool.swift; sourceTree = ""; }; + 271D42FA1F0CE45800E04A82 /* TXHomeModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TXHomeModel.swift; sourceTree = ""; }; + 27E00AA91F0C95E800B010C4 /* DanTangSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DanTangSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 27E00AAC1F0C95E800B010C4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 27E00AAE1F0C95E800B010C4 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 27E00AB11F0C95E800B010C4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 27E00AB61F0C95E800B010C4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 27E00AB81F0C95E800B010C4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 27E00ABD1F0C95E800B010C4 /* DanTangSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DanTangSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 27E00AC11F0C95E800B010C4 /* DanTangSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DanTangSwiftTests.swift; sourceTree = ""; }; + 27E00AC31F0C95E800B010C4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 27E00AC81F0C95E800B010C4 /* DanTangSwiftUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DanTangSwiftUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 27E00ACC1F0C95E800B010C4 /* DanTangSwiftUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DanTangSwiftUITests.swift; sourceTree = ""; }; + 27E00ACE1F0C95E800B010C4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 27E00AEC1F0CB6B200B010C4 /* TXBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TXBaseViewController.swift; sourceTree = ""; }; + 27E00AED1F0CB6B200B010C4 /* TXTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TXTabBarController.swift; sourceTree = ""; }; + 27E00AF11F0CB6CB00B010C4 /* UIColor+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; + 27E00AF41F0CB6D600B010C4 /* TXConst.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TXConst.swift; sourceTree = ""; }; + 27E00B071F0CB80400B010C4 /* HomeVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeVC.swift; sourceTree = ""; }; + 27E00B091F0CB84E00B010C4 /* MineVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MineVC.swift; path = DanTangSwift/Product/MineVC.swift; sourceTree = SOURCE_ROOT; }; + 27E00B0B1F0CB88F00B010C4 /* ProductVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductVC.swift; sourceTree = ""; }; + 27E00B0D1F0CB8DD00B010C4 /* ClassifyVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClassifyVC.swift; sourceTree = ""; }; + 27E00B121F0CC60800B010C4 /* PrefixHeader.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = ""; }; + 27E00B131F0CCBC700B010C4 /* TXNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TXNavigationController.swift; sourceTree = ""; }; + 3258C960B4FB24AB8B50A3F5 /* Pods_DanTangSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DanTangSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A30C285183F7DBA2B7149FD9 /* Pods-DanTangSwift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DanTangSwift.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 27E00AA61F0C95E800B010C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9F113184B7313CA5B8F61E14 /* Pods_DanTangSwift.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 27E00ABA1F0C95E800B010C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 27E00AC51F0C95E800B010C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 27E00AA01F0C95E800B010C4 = { + isa = PBXGroup; + children = ( + 27E00AAB1F0C95E800B010C4 /* DanTangSwift */, + 27E00AC01F0C95E800B010C4 /* DanTangSwiftTests */, + 27E00ACB1F0C95E800B010C4 /* DanTangSwiftUITests */, + 27E00AAA1F0C95E800B010C4 /* Products */, + 5910EAFABD88E57C1FE6908B /* Pods */, + 795870D38759369F640DC924 /* Frameworks */, + ); + sourceTree = ""; + }; + 27E00AAA1F0C95E800B010C4 /* Products */ = { + isa = PBXGroup; + children = ( + 27E00AA91F0C95E800B010C4 /* DanTangSwift.app */, + 27E00ABD1F0C95E800B010C4 /* DanTangSwiftTests.xctest */, + 27E00AC81F0C95E800B010C4 /* DanTangSwiftUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 27E00AAB1F0C95E800B010C4 /* DanTangSwift */ = { + isa = PBXGroup; + children = ( + 27E00AF81F0CB76800B010C4 /* Home */, + 27E00AF91F0CB76800B010C4 /* Mine */, + 27E00AFA1F0CB76800B010C4 /* Product */, + 27E00AF71F0CB75D00B010C4 /* Classify */, + 27E00AF31F0CB6D600B010C4 /* Tools */, + 27E00AF01F0CB6CB00B010C4 /* Extension */, + 27E00AEB1F0CB67300B010C4 /* BaseVC */, + 27E00AAC1F0C95E800B010C4 /* AppDelegate.swift */, + 27E00AAE1F0C95E800B010C4 /* ViewController.swift */, + 27E00AB01F0C95E800B010C4 /* Main.storyboard */, + 27E00AB51F0C95E800B010C4 /* LaunchScreen.storyboard */, + 27E00AB81F0C95E800B010C4 /* Info.plist */, + 271D42F61F0CCD4600E04A82 /* Assets.xcassets */, + ); + path = DanTangSwift; + sourceTree = ""; + }; + 27E00AC01F0C95E800B010C4 /* DanTangSwiftTests */ = { + isa = PBXGroup; + children = ( + 27E00AC11F0C95E800B010C4 /* DanTangSwiftTests.swift */, + 27E00AC31F0C95E800B010C4 /* Info.plist */, + 27E00B121F0CC60800B010C4 /* PrefixHeader.pch */, + ); + path = DanTangSwiftTests; + sourceTree = ""; + }; + 27E00ACB1F0C95E800B010C4 /* DanTangSwiftUITests */ = { + isa = PBXGroup; + children = ( + 27E00ACC1F0C95E800B010C4 /* DanTangSwiftUITests.swift */, + 27E00ACE1F0C95E800B010C4 /* Info.plist */, + ); + path = DanTangSwiftUITests; + sourceTree = ""; + }; + 27E00AEB1F0CB67300B010C4 /* BaseVC */ = { + isa = PBXGroup; + children = ( + 27E00AEC1F0CB6B200B010C4 /* TXBaseViewController.swift */, + 27E00AED1F0CB6B200B010C4 /* TXTabBarController.swift */, + 27E00B131F0CCBC700B010C4 /* TXNavigationController.swift */, + ); + path = BaseVC; + sourceTree = ""; + }; + 27E00AF01F0CB6CB00B010C4 /* Extension */ = { + isa = PBXGroup; + children = ( + 27E00AF11F0CB6CB00B010C4 /* UIColor+Extension.swift */, + ); + path = Extension; + sourceTree = ""; + }; + 27E00AF31F0CB6D600B010C4 /* Tools */ = { + isa = PBXGroup; + children = ( + 27E00AF41F0CB6D600B010C4 /* TXConst.swift */, + 271D42F81F0CE0C500E04A82 /* NetworkTool.swift */, + ); + path = Tools; + sourceTree = ""; + }; + 27E00AF71F0CB75D00B010C4 /* Classify */ = { + isa = PBXGroup; + children = ( + 27E00B041F0CB7B900B010C4 /* Controller */, + 27E00B051F0CB7B900B010C4 /* Model */, + 27E00B061F0CB7B900B010C4 /* View */, + ); + path = Classify; + sourceTree = ""; + }; + 27E00AF81F0CB76800B010C4 /* Home */ = { + isa = PBXGroup; + children = ( + 27E00AFB1F0CB7A000B010C4 /* Controller */, + 27E00AFC1F0CB7A000B010C4 /* Model */, + 27E00AFD1F0CB7A000B010C4 /* View */, + ); + path = Home; + sourceTree = ""; + }; + 27E00AF91F0CB76800B010C4 /* Mine */ = { + isa = PBXGroup; + children = ( + 27E00AFE1F0CB7A900B010C4 /* Controller */, + 27E00AFF1F0CB7A900B010C4 /* Model */, + 27E00B001F0CB7A900B010C4 /* View */, + ); + path = Mine; + sourceTree = ""; + }; + 27E00AFA1F0CB76800B010C4 /* Product */ = { + isa = PBXGroup; + children = ( + 27E00B011F0CB7B100B010C4 /* Controller */, + 27E00B021F0CB7B100B010C4 /* Model */, + 27E00B031F0CB7B100B010C4 /* View */, + ); + path = Product; + sourceTree = ""; + }; + 27E00AFB1F0CB7A000B010C4 /* Controller */ = { + isa = PBXGroup; + children = ( + 27E00B071F0CB80400B010C4 /* HomeVC.swift */, + ); + path = Controller; + sourceTree = ""; + }; + 27E00AFC1F0CB7A000B010C4 /* Model */ = { + isa = PBXGroup; + children = ( + 271D42FA1F0CE45800E04A82 /* TXHomeModel.swift */, + ); + path = Model; + sourceTree = ""; + }; + 27E00AFD1F0CB7A000B010C4 /* View */ = { + isa = PBXGroup; + children = ( + ); + path = View; + sourceTree = ""; + }; + 27E00AFE1F0CB7A900B010C4 /* Controller */ = { + isa = PBXGroup; + children = ( + 27E00B091F0CB84E00B010C4 /* MineVC.swift */, + ); + path = Controller; + sourceTree = ""; + }; + 27E00AFF1F0CB7A900B010C4 /* Model */ = { + isa = PBXGroup; + children = ( + ); + path = Model; + sourceTree = ""; + }; + 27E00B001F0CB7A900B010C4 /* View */ = { + isa = PBXGroup; + children = ( + ); + path = View; + sourceTree = ""; + }; + 27E00B011F0CB7B100B010C4 /* Controller */ = { + isa = PBXGroup; + children = ( + 27E00B0B1F0CB88F00B010C4 /* ProductVC.swift */, + ); + path = Controller; + sourceTree = ""; + }; + 27E00B021F0CB7B100B010C4 /* Model */ = { + isa = PBXGroup; + children = ( + ); + path = Model; + sourceTree = ""; + }; + 27E00B031F0CB7B100B010C4 /* View */ = { + isa = PBXGroup; + children = ( + ); + path = View; + sourceTree = ""; + }; + 27E00B041F0CB7B900B010C4 /* Controller */ = { + isa = PBXGroup; + children = ( + 27E00B0D1F0CB8DD00B010C4 /* ClassifyVC.swift */, + ); + path = Controller; + sourceTree = ""; + }; + 27E00B051F0CB7B900B010C4 /* Model */ = { + isa = PBXGroup; + children = ( + ); + path = Model; + sourceTree = ""; + }; + 27E00B061F0CB7B900B010C4 /* View */ = { + isa = PBXGroup; + children = ( + ); + path = View; + sourceTree = ""; + }; + 5910EAFABD88E57C1FE6908B /* Pods */ = { + isa = PBXGroup; + children = ( + A30C285183F7DBA2B7149FD9 /* Pods-DanTangSwift.debug.xcconfig */, + 022002614A328256DCA5494F /* Pods-DanTangSwift.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 795870D38759369F640DC924 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3258C960B4FB24AB8B50A3F5 /* Pods_DanTangSwift.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 27E00AA81F0C95E800B010C4 /* DanTangSwift */ = { + isa = PBXNativeTarget; + buildConfigurationList = 27E00AD11F0C95E800B010C4 /* Build configuration list for PBXNativeTarget "DanTangSwift" */; + buildPhases = ( + F63EDD72210848E2B04A66A7 /* [CP] Check Pods Manifest.lock */, + 27E00AA51F0C95E800B010C4 /* Sources */, + 27E00AA61F0C95E800B010C4 /* Frameworks */, + 27E00AA71F0C95E800B010C4 /* Resources */, + A6850B61A82997A0751137BD /* [CP] Embed Pods Frameworks */, + C2784BB81A983E97AA60A828 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DanTangSwift; + productName = DanTangSwift; + productReference = 27E00AA91F0C95E800B010C4 /* DanTangSwift.app */; + productType = "com.apple.product-type.application"; + }; + 27E00ABC1F0C95E800B010C4 /* DanTangSwiftTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 27E00AD41F0C95E800B010C4 /* Build configuration list for PBXNativeTarget "DanTangSwiftTests" */; + buildPhases = ( + 27E00AB91F0C95E800B010C4 /* Sources */, + 27E00ABA1F0C95E800B010C4 /* Frameworks */, + 27E00ABB1F0C95E800B010C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 27E00ABF1F0C95E800B010C4 /* PBXTargetDependency */, + ); + name = DanTangSwiftTests; + productName = DanTangSwiftTests; + productReference = 27E00ABD1F0C95E800B010C4 /* DanTangSwiftTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 27E00AC71F0C95E800B010C4 /* DanTangSwiftUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 27E00AD71F0C95E800B010C4 /* Build configuration list for PBXNativeTarget "DanTangSwiftUITests" */; + buildPhases = ( + 27E00AC41F0C95E800B010C4 /* Sources */, + 27E00AC51F0C95E800B010C4 /* Frameworks */, + 27E00AC61F0C95E800B010C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 27E00ACA1F0C95E800B010C4 /* PBXTargetDependency */, + ); + name = DanTangSwiftUITests; + productName = DanTangSwiftUITests; + productReference = 27E00AC81F0C95E800B010C4 /* DanTangSwiftUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 27E00AA11F0C95E800B010C4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0830; + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = ZTX; + TargetAttributes = { + 27E00AA81F0C95E800B010C4 = { + CreatedOnToolsVersion = 8.3.1; + DevelopmentTeam = 25ED8G2BTH; + ProvisioningStyle = Automatic; + }; + 27E00ABC1F0C95E800B010C4 = { + CreatedOnToolsVersion = 8.3.1; + DevelopmentTeam = 25ED8G2BTH; + ProvisioningStyle = Automatic; + TestTargetID = 27E00AA81F0C95E800B010C4; + }; + 27E00AC71F0C95E800B010C4 = { + CreatedOnToolsVersion = 8.3.1; + DevelopmentTeam = 25ED8G2BTH; + ProvisioningStyle = Automatic; + TestTargetID = 27E00AA81F0C95E800B010C4; + }; + }; + }; + buildConfigurationList = 27E00AA41F0C95E800B010C4 /* Build configuration list for PBXProject "DanTangSwift" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 27E00AA01F0C95E800B010C4; + productRefGroup = 27E00AAA1F0C95E800B010C4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 27E00AA81F0C95E800B010C4 /* DanTangSwift */, + 27E00ABC1F0C95E800B010C4 /* DanTangSwiftTests */, + 27E00AC71F0C95E800B010C4 /* DanTangSwiftUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 27E00AA71F0C95E800B010C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27E00AB71F0C95E800B010C4 /* LaunchScreen.storyboard in Resources */, + 271D42F71F0CCD4600E04A82 /* Assets.xcassets in Resources */, + 27E00AB21F0C95E800B010C4 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 27E00ABB1F0C95E800B010C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 27E00AC61F0C95E800B010C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + A6850B61A82997A0751137BD /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + C2784BB81A983E97AA60A828 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + F63EDD72210848E2B04A66A7 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../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"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 27E00AA51F0C95E800B010C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27E00AAF1F0C95E800B010C4 /* ViewController.swift in Sources */, + 27E00B0A1F0CB84E00B010C4 /* MineVC.swift in Sources */, + 27E00B081F0CB80400B010C4 /* HomeVC.swift in Sources */, + 27E00AEF1F0CB6B200B010C4 /* TXTabBarController.swift in Sources */, + 271D42F91F0CE0C500E04A82 /* NetworkTool.swift in Sources */, + 27E00AAD1F0C95E800B010C4 /* AppDelegate.swift in Sources */, + 271D42FB1F0CE45800E04A82 /* TXHomeModel.swift in Sources */, + 27E00B141F0CCBC700B010C4 /* TXNavigationController.swift in Sources */, + 27E00AF21F0CB6CB00B010C4 /* UIColor+Extension.swift in Sources */, + 27E00B0C1F0CB88F00B010C4 /* ProductVC.swift in Sources */, + 27E00AEE1F0CB6B200B010C4 /* TXBaseViewController.swift in Sources */, + 27E00B0E1F0CB8DD00B010C4 /* ClassifyVC.swift in Sources */, + 27E00AF51F0CB6D600B010C4 /* TXConst.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 27E00AB91F0C95E800B010C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27E00AC21F0C95E800B010C4 /* DanTangSwiftTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 27E00AC41F0C95E800B010C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27E00ACD1F0C95E800B010C4 /* DanTangSwiftUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 27E00ABF1F0C95E800B010C4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 27E00AA81F0C95E800B010C4 /* DanTangSwift */; + targetProxy = 27E00ABE1F0C95E800B010C4 /* PBXContainerItemProxy */; + }; + 27E00ACA1F0C95E800B010C4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 27E00AA81F0C95E800B010C4 /* DanTangSwift */; + targetProxy = 27E00AC91F0C95E800B010C4 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 27E00AB01F0C95E800B010C4 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 27E00AB11F0C95E800B010C4 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 27E00AB51F0C95E800B010C4 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 27E00AB61F0C95E800B010C4 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 27E00ACF1F0C95E800B010C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 27E00AD01F0C95E800B010C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 27E00AD21F0C95E800B010C4 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A30C285183F7DBA2B7149FD9 /* Pods-DanTangSwift.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 25ED8G2BTH; + GCC_PREFIX_HEADER = /Users/apple/Desktop/DanTang/DanTangSwiftTests/PrefixHeader.pch; + INFOPLIST_FILE = DanTangSwift/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = ztx.DanTangSwift; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 27E00AD31F0C95E800B010C4 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 022002614A328256DCA5494F /* Pods-DanTangSwift.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 25ED8G2BTH; + GCC_PREFIX_HEADER = /Users/apple/Desktop/DanTang/DanTangSwiftTests/PrefixHeader.pch; + INFOPLIST_FILE = DanTangSwift/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = ztx.DanTangSwift; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + 27E00AD51F0C95E800B010C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = 25ED8G2BTH; + INFOPLIST_FILE = DanTangSwiftTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = ztx.DanTangSwiftTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DanTangSwift.app/DanTangSwift"; + }; + name = Debug; + }; + 27E00AD61F0C95E800B010C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = 25ED8G2BTH; + INFOPLIST_FILE = DanTangSwiftTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = ztx.DanTangSwiftTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DanTangSwift.app/DanTangSwift"; + }; + name = Release; + }; + 27E00AD81F0C95E800B010C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + DEVELOPMENT_TEAM = 25ED8G2BTH; + INFOPLIST_FILE = DanTangSwiftUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = ztx.DanTangSwiftUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = DanTangSwift; + }; + name = Debug; + }; + 27E00AD91F0C95E800B010C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + DEVELOPMENT_TEAM = 25ED8G2BTH; + INFOPLIST_FILE = DanTangSwiftUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = ztx.DanTangSwiftUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = DanTangSwift; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 27E00AA41F0C95E800B010C4 /* Build configuration list for PBXProject "DanTangSwift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27E00ACF1F0C95E800B010C4 /* Debug */, + 27E00AD01F0C95E800B010C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 27E00AD11F0C95E800B010C4 /* Build configuration list for PBXNativeTarget "DanTangSwift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27E00AD21F0C95E800B010C4 /* Debug */, + 27E00AD31F0C95E800B010C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 27E00AD41F0C95E800B010C4 /* Build configuration list for PBXNativeTarget "DanTangSwiftTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27E00AD51F0C95E800B010C4 /* Debug */, + 27E00AD61F0C95E800B010C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 27E00AD71F0C95E800B010C4 /* Build configuration list for PBXNativeTarget "DanTangSwiftUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27E00AD81F0C95E800B010C4 /* Debug */, + 27E00AD91F0C95E800B010C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 27E00AA11F0C95E800B010C4 /* Project object */; +} diff --git a/DanTangSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DanTangSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..d264241 --- /dev/null +++ b/DanTangSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/DanTangSwift.xcodeproj/project.xcworkspace/xcuserdata/ZTX.xcuserdatad/UserInterfaceState.xcuserstate b/DanTangSwift.xcodeproj/project.xcworkspace/xcuserdata/ZTX.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..f33c2f6 Binary files /dev/null and b/DanTangSwift.xcodeproj/project.xcworkspace/xcuserdata/ZTX.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/DanTangSwift.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/DanTangSwift.xcscheme b/DanTangSwift.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/DanTangSwift.xcscheme new file mode 100644 index 0000000..0da0236 --- /dev/null +++ b/DanTangSwift.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/DanTangSwift.xcscheme @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DanTangSwift.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/xcschememanagement.plist b/DanTangSwift.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..4f55d61 --- /dev/null +++ b/DanTangSwift.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,32 @@ + + + + + SchemeUserState + + DanTangSwift.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 27E00AA81F0C95E800B010C4 + + primary + + + 27E00ABC1F0C95E800B010C4 + + primary + + + 27E00AC71F0C95E800B010C4 + + primary + + + + + diff --git a/DanTangSwift.xcworkspace/contents.xcworkspacedata b/DanTangSwift.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..4e5300b --- /dev/null +++ b/DanTangSwift.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/DanTangSwift.xcworkspace/xcuserdata/ZTX.xcuserdatad/UserInterfaceState.xcuserstate b/DanTangSwift.xcworkspace/xcuserdata/ZTX.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..704e731 Binary files /dev/null and b/DanTangSwift.xcworkspace/xcuserdata/ZTX.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/DanTangSwift.xcworkspace/xcuserdata/ZTX.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/DanTangSwift.xcworkspace/xcuserdata/ZTX.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..ed9a9b4 --- /dev/null +++ b/DanTangSwift.xcworkspace/xcuserdata/ZTX.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/DanTangSwift/AppDelegate.swift b/DanTangSwift/AppDelegate.swift new file mode 100644 index 0000000..c86033b --- /dev/null +++ b/DanTangSwift/AppDelegate.swift @@ -0,0 +1,49 @@ +// +// AppDelegate.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + window=UIWindow(frame:UIScreen.main.bounds) + window?.makeKeyAndVisible() + window?.rootViewController=TXTabBarController() + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png new file mode 100644 index 0000000..8697bb3 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon29x29@3x.png b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon29x29@3x.png new file mode 100644 index 0000000..5f00c54 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon29x29@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png new file mode 100644 index 0000000..a63cdcf Binary files /dev/null and b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon40x40@3x.png b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon40x40@3x.png new file mode 100644 index 0000000..1fd7e6b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon40x40@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png new file mode 100644 index 0000000..2493e7e Binary files /dev/null and b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png new file mode 100644 index 0000000..784680c Binary files /dev/null and b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/AppIcon.appiconset/Contents.json b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..09e28ea --- /dev/null +++ b/DanTangSwift/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,54 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "AppIcon40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "AppIcon40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon60x60@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/Contents.json b/DanTangSwift/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/Contents.json b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..cfb1754 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,43 @@ +{ + "images" : [ + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "736h", + "filename" : "LaunchImage-800-Portrait-736h@3x.png", + "minimum-system-version" : "8.0", + "orientation" : "portrait", + "scale" : "3x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "667h", + "filename" : "LaunchImage-800-667h@2x.png", + "minimum-system-version" : "8.0", + "orientation" : "portrait", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "filename" : "LaunchImage-700@2x.png", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "retina4", + "filename" : "LaunchImage-700-568h@2x.png", + "minimum-system-version" : "7.0", + "orientation" : "portrait", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-700-568h@2x.png b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-700-568h@2x.png new file mode 100644 index 0000000..43b10c0 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-700-568h@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-700@2x.png b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-700@2x.png new file mode 100644 index 0000000..2c23a9a Binary files /dev/null and b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-700@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-800-667h@2x.png b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-800-667h@2x.png new file mode 100644 index 0000000..9822307 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-800-667h@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-800-Portrait-736h@3x.png b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-800-Portrait-736h@3x.png new file mode 100644 index 0000000..b5c4322 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/LaunchImage.launchimage/LaunchImage-800-Portrait-736h@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/Loading/Contents.json b/DanTangSwift/Assets.xcassets/Loading/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/Loading/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/Loading/tableview_loading.imageset/Contents.json b/DanTangSwift/Assets.xcassets/Loading/tableview_loading.imageset/Contents.json new file mode 100644 index 0000000..665b781 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/Loading/tableview_loading.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tableview_loading@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/Loading/tableview_loading.imageset/tableview_loading@2x.png b/DanTangSwift/Assets.xcassets/Loading/tableview_loading.imageset/tableview_loading@2x.png new file mode 100644 index 0000000..62a6549 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/Loading/tableview_loading.imageset/tableview_loading@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/Loading/tableview_pull_refresh.imageset/Contents.json b/DanTangSwift/Assets.xcassets/Loading/tableview_pull_refresh.imageset/Contents.json new file mode 100644 index 0000000..6c74bb8 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/Loading/tableview_pull_refresh.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tableview_pull_refresh@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/Loading/tableview_pull_refresh.imageset/tableview_pull_refresh@2x.png b/DanTangSwift/Assets.xcassets/Loading/tableview_pull_refresh.imageset/tableview_pull_refresh@2x.png new file mode 100644 index 0000000..bba80bc Binary files /dev/null and b/DanTangSwift/Assets.xcassets/Loading/tableview_pull_refresh.imageset/tableview_pull_refresh@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/background/Contents.json b/DanTangSwift/Assets.xcassets/background/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/background/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/Contents.json new file mode 100644 index 0000000..e1aedbb --- /dev/null +++ b/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/Contents.json @@ -0,0 +1,50 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "resizing" : { + "mode" : "9-part", + "center" : { + "mode" : "tile", + "width" : 1, + "height" : 1 + }, + "cap-insets" : { + "bottom" : 28, + "top" : 63, + "right" : 60, + "left" : 18 + } + }, + "idiom" : "universal", + "filename" : "bg_menu_sort_140x46_@2x.png", + "scale" : "2x" + }, + { + "resizing" : { + "mode" : "9-part", + "center" : { + "mode" : "tile", + "width" : 1, + "height" : 1 + }, + "cap-insets" : { + "bottom" : 69, + "top" : 68, + "right" : 84, + "left" : 14 + } + }, + "idiom" : "universal", + "filename" : "bg_menu_sort_140x46_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/bg_menu_sort_140x46_@2x.png b/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/bg_menu_sort_140x46_@2x.png new file mode 100644 index 0000000..336ca3b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/bg_menu_sort_140x46_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/bg_menu_sort_140x46_@3x.png b/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/bg_menu_sort_140x46_@3x.png new file mode 100644 index 0000000..027a532 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/background/bg_menu_sort_140x46_.imageset/bg_menu_sort_140x46_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/Contents.json b/DanTangSwift/Assets.xcassets/baichuan/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/baichuan/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/Contents.json new file mode 100644 index 0000000..fe5e742 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_comments_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_comments_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/baichuan_btn_comments_21x21_@2x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/baichuan_btn_comments_21x21_@2x.png new file mode 100644 index 0000000..07e883d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/baichuan_btn_comments_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/baichuan_btn_comments_21x21_@3x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/baichuan_btn_comments_21x21_@3x.png new file mode 100644 index 0000000..8703bd8 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_comments_21x21_.imageset/baichuan_btn_comments_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/Contents.json new file mode 100644 index 0000000..b69077f --- /dev/null +++ b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_favorites_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_favorites_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/baichuan_btn_favorites_21x21_@2x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/baichuan_btn_favorites_21x21_@2x.png new file mode 100644 index 0000000..a602259 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/baichuan_btn_favorites_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/baichuan_btn_favorites_21x21_@3x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/baichuan_btn_favorites_21x21_@3x.png new file mode 100644 index 0000000..bd18ff0 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_21x21_.imageset/baichuan_btn_favorites_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/Contents.json new file mode 100644 index 0000000..478d1b9 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_favorites_selected_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_favorites_selected_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/baichuan_btn_favorites_selected_21x21_@2x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/baichuan_btn_favorites_selected_21x21_@2x.png new file mode 100644 index 0000000..4d2edf4 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/baichuan_btn_favorites_selected_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/baichuan_btn_favorites_selected_21x21_@3x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/baichuan_btn_favorites_selected_21x21_@3x.png new file mode 100644 index 0000000..b479977 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_favorites_selected_21x21_.imageset/baichuan_btn_favorites_selected_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/Contents.json new file mode 100644 index 0000000..b6f3916 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_share_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "baichuan_btn_share_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/baichuan_btn_share_21x21_@2x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/baichuan_btn_share_21x21_@2x.png new file mode 100644 index 0000000..7741ab3 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/baichuan_btn_share_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/baichuan_btn_share_21x21_@3x.png b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/baichuan_btn_share_21x21_@3x.png new file mode 100644 index 0000000..2557a85 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/baichuan/baichuan_btn_share_21x21_.imageset/baichuan_btn_share_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_5x8_.imageset/Category_PostCollectionSeeAll_5x8_@2x.png b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_5x8_.imageset/Category_PostCollectionSeeAll_5x8_@2x.png new file mode 100644 index 0000000..a5d2c68 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_5x8_.imageset/Category_PostCollectionSeeAll_5x8_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_5x8_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_5x8_.imageset/Contents.json new file mode 100644 index 0000000..774ec38 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_5x8_.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Category_PostCollectionSeeAll_5x8_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_nightMode_5x8_.imageset/Category_PostCollectionSeeAll_nightMode_5x8_@2x.png b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_nightMode_5x8_.imageset/Category_PostCollectionSeeAll_nightMode_5x8_@2x.png new file mode 100644 index 0000000..f965ecb Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_nightMode_5x8_.imageset/Category_PostCollectionSeeAll_nightMode_5x8_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_nightMode_5x8_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_nightMode_5x8_.imageset/Contents.json new file mode 100644 index 0000000..d85c782 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/Category_PostCollectionSeeAll_nightMode_5x8_.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Category_PostCollectionSeeAll_nightMode_5x8_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/CellDisclosureIndicator_8x12_.imageset/CellDisclosureIndicator_8x12_@2x.png b/DanTangSwift/Assets.xcassets/button/CellDisclosureIndicator_8x12_.imageset/CellDisclosureIndicator_8x12_@2x.png new file mode 100644 index 0000000..99cadfc Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/CellDisclosureIndicator_8x12_.imageset/CellDisclosureIndicator_8x12_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/CellDisclosureIndicator_8x12_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/CellDisclosureIndicator_8x12_.imageset/Contents.json new file mode 100644 index 0000000..380f3cb --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/CellDisclosureIndicator_8x12_.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "CellDisclosureIndicator_8x12_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/Contents.json b/DanTangSwift/Assets.xcassets/button/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/Contents.json new file mode 100644 index 0000000..6de446e --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "arrow_index_down_8x4_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "arrow_index_down_8x4_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/arrow_index_down_8x4_@2x.png b/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/arrow_index_down_8x4_@2x.png new file mode 100644 index 0000000..4042d55 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/arrow_index_down_8x4_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/arrow_index_down_8x4_@3x.png b/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/arrow_index_down_8x4_@3x.png new file mode 100644 index 0000000..8b11c23 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/arrow_index_down_8x4_.imageset/arrow_index_down_8x4_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/Contents.json new file mode 100644 index 0000000..6600b10 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "arrow_index_up_8x4_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "arrow_index_up_8x4_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/arrow_index_up_8x4_@2x.png b/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/arrow_index_up_8x4_@2x.png new file mode 100644 index 0000000..a478d98 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/arrow_index_up_8x4_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/arrow_index_up_8x4_@3x.png b/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/arrow_index_up_8x4_@3x.png new file mode 100644 index 0000000..48f8189 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/arrow_index_up_8x4_.imageset/arrow_index_up_8x4_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/btn_begin.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/btn_begin.imageset/Contents.json new file mode 100644 index 0000000..30a2db5 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/btn_begin.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "btn_begin.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/btn_begin.imageset/btn_begin.png b/DanTangSwift/Assets.xcassets/button/btn_begin.imageset/btn_begin.png new file mode 100644 index 0000000..c0533e2 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/btn_begin.imageset/btn_begin.png differ diff --git a/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/Contents.json new file mode 100644 index 0000000..8ca3aef --- /dev/null +++ b/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "btn_forward_nightmode_8x12_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "btn_forward_nightmode_8x12_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/btn_forward_nightmode_8x12_@2x.png b/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/btn_forward_nightmode_8x12_@2x.png new file mode 100644 index 0000000..9a01b99 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/btn_forward_nightmode_8x12_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/btn_forward_nightmode_8x12_@3x.png b/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/btn_forward_nightmode_8x12_@3x.png new file mode 100644 index 0000000..ee49747 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/button/btn_forward_nightmode_8x12_.imageset/btn_forward_nightmode_8x12_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/Contents.json b/DanTangSwift/Assets.xcassets/check_user_type/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/check_user_type/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Contents.json new file mode 100644 index 0000000..0130528 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Feed_SearchBtn_18x18_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Feed_SearchBtn_18x18_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Feed_SearchBtn_18x18_@2x.png b/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Feed_SearchBtn_18x18_@2x.png new file mode 100644 index 0000000..63b2890 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Feed_SearchBtn_18x18_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Feed_SearchBtn_18x18_@3x.png b/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Feed_SearchBtn_18x18_@3x.png new file mode 100644 index 0000000..c112621 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/Feed_SearchBtn_18x18_.imageset/Feed_SearchBtn_18x18_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/Contents.json new file mode 100644 index 0000000..9a616f0 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "checkUserType_backward_9x15_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "checkUserType_backward_9x15_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/checkUserType_backward_9x15_@2x.png b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/checkUserType_backward_9x15_@2x.png new file mode 100644 index 0000000..8f2eb29 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/checkUserType_backward_9x15_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/checkUserType_backward_9x15_@3x.png b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/checkUserType_backward_9x15_@3x.png new file mode 100644 index 0000000..8d9e4dc Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_backward_9x15_.imageset/checkUserType_backward_9x15_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/Contents.json new file mode 100644 index 0000000..9542f3e --- /dev/null +++ b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "checkUserType_icon_identity_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "checkUserType_icon_identity_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/checkUserType_icon_identity_21x21_@2x.png b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/checkUserType_icon_identity_21x21_@2x.png new file mode 100644 index 0000000..73dc2b2 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/checkUserType_icon_identity_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/checkUserType_icon_identity_21x21_@3x.png b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/checkUserType_icon_identity_21x21_@3x.png new file mode 100644 index 0000000..064403d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/checkUserType_icon_identity_21x21_.imageset/checkUserType_icon_identity_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/Contents.json new file mode 100644 index 0000000..7c4ea46 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "comments_blank_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "comments_blank_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/comments_blank_50x50_@2x.png b/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/comments_blank_50x50_@2x.png new file mode 100644 index 0000000..abcee3f Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/comments_blank_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/comments_blank_50x50_@3x.png b/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/comments_blank_50x50_@3x.png new file mode 100644 index 0000000..f621178 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/check_user_type/comments_blank_50x50_.imageset/comments_blank_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/Contents.json b/DanTangSwift/Assets.xcassets/content_detail/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/content_detail/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Contents.json new file mode 100644 index 0000000..b908a61 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Feed_FavoriteIcon_17x17_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Feed_FavoriteIcon_17x17_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Feed_FavoriteIcon_17x17_@2x.png b/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Feed_FavoriteIcon_17x17_@2x.png new file mode 100644 index 0000000..43cbc23 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Feed_FavoriteIcon_17x17_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Feed_FavoriteIcon_17x17_@3x.png b/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Feed_FavoriteIcon_17x17_@3x.png new file mode 100644 index 0000000..a2517d8 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/Feed_FavoriteIcon_17x17_.imageset/Feed_FavoriteIcon_17x17_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/Contents.json new file mode 100644 index 0000000..2748d5e --- /dev/null +++ b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "content-details_like_16x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "content-details_like_16x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/content-details_like_16x16_@2x.png b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/content-details_like_16x16_@2x.png new file mode 100644 index 0000000..2e71c52 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/content-details_like_16x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/content-details_like_16x16_@3x.png b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/content-details_like_16x16_@3x.png new file mode 100644 index 0000000..6237917 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_16x16_.imageset/content-details_like_16x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/Contents.json new file mode 100644 index 0000000..c80d453 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "content-details_like_selected_16x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "content-details_like_selected_16x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/content-details_like_selected_16x16_@2x.png b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/content-details_like_selected_16x16_@2x.png new file mode 100644 index 0000000..13dbc8a Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/content-details_like_selected_16x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/content-details_like_selected_16x16_@3x.png b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/content-details_like_selected_16x16_@3x.png new file mode 100644 index 0000000..9e4b7a4 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/content-details_like_selected_16x16_.imageset/content-details_like_selected_16x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/Contents.json new file mode 100644 index 0000000..d9c057c --- /dev/null +++ b/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "content-details_share_16x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "content-details_share_16x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/content-details_share_16x16_@2x.png b/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/content-details_share_16x16_@2x.png new file mode 100644 index 0000000..009163b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/content-details_share_16x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/content-details_share_16x16_@3x.png b/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/content-details_share_16x16_@3x.png new file mode 100644 index 0000000..98020f3 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/content_detail/content-details_share_16x16_.imageset/content-details_share_16x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/Contents.json b/DanTangSwift/Assets.xcassets/icon/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/Contents.json new file mode 100644 index 0000000..e34dae5 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_log_qq_63x63_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_log_qq_63x63_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/icon_log_qq_63x63_@2x.png b/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/icon_log_qq_63x63_@2x.png new file mode 100644 index 0000000..4095035 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/icon_log_qq_63x63_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/icon_log_qq_63x63_@3x.png b/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/icon_log_qq_63x63_@3x.png new file mode 100644 index 0000000..49b2a2c Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_log_qq_63x63_.imageset/icon_log_qq_63x63_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/Contents.json new file mode 100644 index 0000000..38646f3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_log_sina_63x63_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_log_sina_63x63_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/icon_log_sina_63x63_@2x.png b/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/icon_log_sina_63x63_@2x.png new file mode 100644 index 0000000..a9e405f Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/icon_log_sina_63x63_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/icon_log_sina_63x63_@3x.png b/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/icon_log_sina_63x63_@3x.png new file mode 100644 index 0000000..3a2daba Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_log_sina_63x63_.imageset/icon_log_sina_63x63_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/Contents.json new file mode 100644 index 0000000..548498c --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_log_wechat_63x63_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_log_wechat_63x63_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/icon_log_wechat_63x63_@2x.png b/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/icon_log_wechat_63x63_@2x.png new file mode 100644 index 0000000..4dc567d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/icon_log_wechat_63x63_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/icon_log_wechat_63x63_@3x.png b/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/icon_log_wechat_63x63_@3x.png new file mode 100644 index 0000000..79c8491 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_log_wechat_63x63_.imageset/icon_log_wechat_63x63_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/Contents.json new file mode 100644 index 0000000..74915d3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_nosignal_94x104_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_nosignal_94x104_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/icon_nosignal_94x104_@2x.png b/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/icon_nosignal_94x104_@2x.png new file mode 100644 index 0000000..e75beec Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/icon_nosignal_94x104_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/icon_nosignal_94x104_@3x.png b/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/icon_nosignal_94x104_@3x.png new file mode 100644 index 0000000..3d6c7fc Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_nosignal_94x104_.imageset/icon_nosignal_94x104_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/Contents.json new file mode 100644 index 0000000..a00fef3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_sina_share_64x64_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_sina_share_64x64_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/icon_sina_share_64x64_@2x.png b/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/icon_sina_share_64x64_@2x.png new file mode 100644 index 0000000..eac0d8d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/icon_sina_share_64x64_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/icon_sina_share_64x64_@3x.png b/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/icon_sina_share_64x64_@3x.png new file mode 100644 index 0000000..c1ddd0b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_sina_share_64x64_.imageset/icon_sina_share_64x64_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/Contents.json new file mode 100644 index 0000000..b5ac292 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_sort_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_sort_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/icon_sort_21x21_@2x.png b/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/icon_sort_21x21_@2x.png new file mode 100644 index 0000000..a6c059e Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/icon_sort_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/icon_sort_21x21_@3x.png b/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/icon_sort_21x21_@3x.png new file mode 100644 index 0000000..65990a7 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/icon/icon_sort_21x21_.imageset/icon_sort_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Contents.json b/DanTangSwift/Assets.xcassets/me/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/me/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Contents.json new file mode 100644 index 0000000..bfaa8f3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Me_AvatarPlaceholder_75x75_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Me_AvatarPlaceholder_75x75_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Me_AvatarPlaceholder_75x75_@2x.png b/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Me_AvatarPlaceholder_75x75_@2x.png new file mode 100644 index 0000000..519c24b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Me_AvatarPlaceholder_75x75_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Me_AvatarPlaceholder_75x75_@3x.png b/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Me_AvatarPlaceholder_75x75_@3x.png new file mode 100644 index 0000000..2832bac Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_AvatarPlaceholder_75x75_.imageset/Me_AvatarPlaceholder_75x75_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_ProfileBackground.imageset/Contents.json b/DanTangSwift/Assets.xcassets/me/Me_ProfileBackground.imageset/Contents.json new file mode 100644 index 0000000..9b0f0fd --- /dev/null +++ b/DanTangSwift/Assets.xcassets/me/Me_ProfileBackground.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Me_ProfileBackground@2x.jpg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/me/Me_ProfileBackground.imageset/Me_ProfileBackground@2x.jpg b/DanTangSwift/Assets.xcassets/me/Me_ProfileBackground.imageset/Me_ProfileBackground@2x.jpg new file mode 100644 index 0000000..13f1414 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_ProfileBackground.imageset/Me_ProfileBackground@2x.jpg differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Contents.json new file mode 100644 index 0000000..ae75c06 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Me_blank_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Me_blank_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Me_blank_50x50_@2x.png b/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Me_blank_50x50_@2x.png new file mode 100644 index 0000000..4fe3327 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Me_blank_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Me_blank_50x50_@3x.png b/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Me_blank_50x50_@3x.png new file mode 100644 index 0000000..c9b9609 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_blank_50x50_.imageset/Me_blank_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Contents.json new file mode 100644 index 0000000..fcb2f69 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Me_message_20x20_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Me_message_20x20_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Me_message_20x20_@2x.png b/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Me_message_20x20_@2x.png new file mode 100644 index 0000000..e59e7fc Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Me_message_20x20_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Me_message_20x20_@3x.png b/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Me_message_20x20_@3x.png new file mode 100644 index 0000000..a0ccf5c Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_message_20x20_.imageset/Me_message_20x20_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Contents.json new file mode 100644 index 0000000..37c79e1 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Me_settings_20x20_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Me_settings_20x20_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Me_settings_20x20_@2x.png b/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Me_settings_20x20_@2x.png new file mode 100644 index 0000000..017dd5d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Me_settings_20x20_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Me_settings_20x20_@3x.png b/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Me_settings_20x20_@3x.png new file mode 100644 index 0000000..09e0cc9 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/me/Me_settings_20x20_.imageset/Me_settings_20x20_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/Contents.json b/DanTangSwift/Assets.xcassets/more/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/Contents.json new file mode 100644 index 0000000..538a3b3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_about_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_about_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/more_icon_about_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/more_icon_about_21x21_@2x.png new file mode 100644 index 0000000..2884385 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/more_icon_about_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/more_icon_about_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/more_icon_about_21x21_@3x.png new file mode 100644 index 0000000..40a9ef7 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_about_21x21_.imageset/more_icon_about_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/Contents.json new file mode 100644 index 0000000..0083f61 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_clear_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_clear_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/more_icon_clear_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/more_icon_clear_21x21_@2x.png new file mode 100644 index 0000000..d59c862 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/more_icon_clear_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/more_icon_clear_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/more_icon_clear_21x21_@3x.png new file mode 100644 index 0000000..f1660ea Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_clear_21x21_.imageset/more_icon_clear_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/Contents.json new file mode 100644 index 0000000..29bc987 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_feedback_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_feedback_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/more_icon_feedback_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/more_icon_feedback_21x21_@2x.png new file mode 100644 index 0000000..a026449 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/more_icon_feedback_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/more_icon_feedback_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/more_icon_feedback_21x21_@3x.png new file mode 100644 index 0000000..aa6102b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_feedback_21x21_.imageset/more_icon_feedback_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/Contents.json new file mode 100644 index 0000000..e56ce60 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_notification_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_notification_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/more_icon_notification_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/more_icon_notification_21x21_@2x.png new file mode 100644 index 0000000..d76ebff Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/more_icon_notification_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/more_icon_notification_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/more_icon_notification_21x21_@3x.png new file mode 100644 index 0000000..d3ea9a0 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_notification_21x21_.imageset/more_icon_notification_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/Contents.json new file mode 100644 index 0000000..580c2a3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_recommended_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_recommended_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/more_icon_recommended_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/more_icon_recommended_21x21_@2x.png new file mode 100644 index 0000000..12590ba Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/more_icon_recommended_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/more_icon_recommended_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/more_icon_recommended_21x21_@3x.png new file mode 100644 index 0000000..e10a65c Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_recommended_21x21_.imageset/more_icon_recommended_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/Contents.json new file mode 100644 index 0000000..fef0268 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_score_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_score_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/more_icon_score_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/more_icon_score_21x21_@2x.png new file mode 100644 index 0000000..90ab656 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/more_icon_score_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/more_icon_score_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/more_icon_score_21x21_@3x.png new file mode 100644 index 0000000..5e03d4c Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_score_21x21_.imageset/more_icon_score_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/Contents.json new file mode 100644 index 0000000..8eb797b --- /dev/null +++ b/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_share_21x21_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "more_icon_share_21x21_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/more_icon_share_21x21_@2x.png b/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/more_icon_share_21x21_@2x.png new file mode 100644 index 0000000..0002213 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/more_icon_share_21x21_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/more_icon_share_21x21_@3x.png b/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/more_icon_share_21x21_@3x.png new file mode 100644 index 0000000..df10b93 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/more/more_icon_share_21x21_.imageset/more_icon_share_21x21_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/new_feature/Contents.json b/DanTangSwift/Assets.xcassets/new_feature/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/new_feature/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_1.imageset/Contents.json b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_1.imageset/Contents.json new file mode 100644 index 0000000..a5a6da5 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "walkthrough_1.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_1.imageset/walkthrough_1.jpg b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_1.imageset/walkthrough_1.jpg new file mode 100644 index 0000000..bbdf106 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_1.imageset/walkthrough_1.jpg differ diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_2.imageset/Contents.json b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_2.imageset/Contents.json new file mode 100644 index 0000000..196783e --- /dev/null +++ b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "walkthrough_2.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_2.imageset/walkthrough_2.jpg b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_2.imageset/walkthrough_2.jpg new file mode 100644 index 0000000..d42c1e0 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_2.imageset/walkthrough_2.jpg differ diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_3.imageset/Contents.json b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_3.imageset/Contents.json new file mode 100644 index 0000000..2fbb3c7 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "walkthrough_3.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_3.imageset/walkthrough_3.jpg b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_3.imageset/walkthrough_3.jpg new file mode 100644 index 0000000..2769e34 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_3.imageset/walkthrough_3.jpg differ diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_4.imageset/Contents.json b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_4.imageset/Contents.json new file mode 100644 index 0000000..634fec3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_4.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "walkthrough_4.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/new_feature/walkthrough_4.imageset/walkthrough_4.jpg b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_4.imageset/walkthrough_4.jpg new file mode 100644 index 0000000..7509ebc Binary files /dev/null and b/DanTangSwift/Assets.xcassets/new_feature/walkthrough_4.imageset/walkthrough_4.jpg differ diff --git a/DanTangSwift/Assets.xcassets/placeholder/Contents.json b/DanTangSwift/Assets.xcassets/placeholder/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/placeholder/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/Contents.json new file mode 100644 index 0000000..4e5b5a3 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PlaceHolderImage_small_31x26_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PlaceHolderImage_small_31x26_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/PlaceHolderImage_small_31x26_@2x.png b/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/PlaceHolderImage_small_31x26_@2x.png new file mode 100644 index 0000000..aabe377 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/PlaceHolderImage_small_31x26_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/PlaceHolderImage_small_31x26_@3x.png b/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/PlaceHolderImage_small_31x26_@3x.png new file mode 100644 index 0000000..09ffb6d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/placeholder/PlaceHolderImage_small_31x26_.imageset/PlaceHolderImage_small_31x26_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Contents.json b/DanTangSwift/Assets.xcassets/post/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/Contents.json new file mode 100644 index 0000000..a3ebc67 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PostComment_AvatarPlaceholder_40x40_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PostComment_AvatarPlaceholder_40x40_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/PostComment_AvatarPlaceholder_40x40_@2x.png b/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/PostComment_AvatarPlaceholder_40x40_@2x.png new file mode 100644 index 0000000..7617e20 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/PostComment_AvatarPlaceholder_40x40_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/PostComment_AvatarPlaceholder_40x40_@3x.png b/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/PostComment_AvatarPlaceholder_40x40_@3x.png new file mode 100644 index 0000000..c0dd33d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostComment_AvatarPlaceholder_40x40_.imageset/PostComment_AvatarPlaceholder_40x40_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/Contents.json new file mode 100644 index 0000000..133ac14 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_Like_18x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_Like_18x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/PostItem_Like_18x16_@2x.png b/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/PostItem_Like_18x16_@2x.png new file mode 100644 index 0000000..b0c3702 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/PostItem_Like_18x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/PostItem_Like_18x16_@3x.png b/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/PostItem_Like_18x16_@3x.png new file mode 100644 index 0000000..fcd7106 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_Like_18x16_.imageset/PostItem_Like_18x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/Contents.json new file mode 100644 index 0000000..47184a8 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_Liked_18x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_Liked_18x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/PostItem_Liked_18x16_@2x.png b/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/PostItem_Liked_18x16_@2x.png new file mode 100644 index 0000000..d48ecce Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/PostItem_Liked_18x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/PostItem_Liked_18x16_@3x.png b/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/PostItem_Liked_18x16_@3x.png new file mode 100644 index 0000000..ae2fa01 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_Liked_18x16_.imageset/PostItem_Liked_18x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/Contents.json new file mode 100644 index 0000000..5c62b0f --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_Share_18x22_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_Share_18x22_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/PostItem_Share_18x22_@2x.png b/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/PostItem_Share_18x22_@2x.png new file mode 100644 index 0000000..4a1a345 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/PostItem_Share_18x22_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/PostItem_Share_18x22_@3x.png b/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/PostItem_Share_18x22_@3x.png new file mode 100644 index 0000000..ee30523 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_Share_18x22_.imageset/PostItem_Share_18x22_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/Contents.json new file mode 100644 index 0000000..7e12a7a --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_comment_38x38_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PostItem_comment_38x38_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/PostItem_comment_38x38_@2x.png b/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/PostItem_comment_38x38_@2x.png new file mode 100644 index 0000000..91887b4 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/PostItem_comment_38x38_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/PostItem_comment_38x38_@3x.png b/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/PostItem_comment_38x38_@3x.png new file mode 100644 index 0000000..39b94ac Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/PostItem_comment_38x38_.imageset/PostItem_comment_38x38_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Contents.json new file mode 100644 index 0000000..6a4f2d4 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_FavoriteButton_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_FavoriteButton_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Post_FavoriteButton_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Post_FavoriteButton_50x50_@2x.png new file mode 100644 index 0000000..e56389a Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Post_FavoriteButton_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Post_FavoriteButton_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Post_FavoriteButton_50x50_@3x.png new file mode 100644 index 0000000..509dbc5 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_50x50_.imageset/Post_FavoriteButton_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Contents.json new file mode 100644 index 0000000..404097c --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_FavoriteButton_Highlighted_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_FavoriteButton_Highlighted_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Post_FavoriteButton_Highlighted_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Post_FavoriteButton_Highlighted_50x50_@2x.png new file mode 100644 index 0000000..4f5ad45 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Post_FavoriteButton_Highlighted_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Post_FavoriteButton_Highlighted_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Post_FavoriteButton_Highlighted_50x50_@3x.png new file mode 100644 index 0000000..4ecc379 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Highlighted_50x50_.imageset/Post_FavoriteButton_Highlighted_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Contents.json new file mode 100644 index 0000000..e3fdff1 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_FavoriteButton_Selected_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_FavoriteButton_Selected_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Post_FavoriteButton_Selected_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Post_FavoriteButton_Selected_50x50_@2x.png new file mode 100644 index 0000000..48340d1 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Post_FavoriteButton_Selected_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Post_FavoriteButton_Selected_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Post_FavoriteButton_Selected_50x50_@3x.png new file mode 100644 index 0000000..b8a6386 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_FavoriteButton_Selected_50x50_.imageset/Post_FavoriteButton_Selected_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Contents.json new file mode 100644 index 0000000..672df3f --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_ReplyButton_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_ReplyButton_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Post_ReplyButton_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Post_ReplyButton_50x50_@2x.png new file mode 100644 index 0000000..1b1f89a Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Post_ReplyButton_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Post_ReplyButton_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Post_ReplyButton_50x50_@3x.png new file mode 100644 index 0000000..759a5a8 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_50x50_.imageset/Post_ReplyButton_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Contents.json new file mode 100644 index 0000000..ec1625e --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_ReplyButton_Highlighted_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_ReplyButton_Highlighted_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Post_ReplyButton_Highlighted_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Post_ReplyButton_Highlighted_50x50_@2x.png new file mode 100644 index 0000000..b75628f Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Post_ReplyButton_Highlighted_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Post_ReplyButton_Highlighted_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Post_ReplyButton_Highlighted_50x50_@3x.png new file mode 100644 index 0000000..ef7e0db Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ReplyButton_Highlighted_50x50_.imageset/Post_ReplyButton_Highlighted_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Contents.json new file mode 100644 index 0000000..bc8b9c2 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_ShareButton_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_ShareButton_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Post_ShareButton_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Post_ShareButton_50x50_@2x.png new file mode 100644 index 0000000..f7138cf Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Post_ShareButton_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Post_ShareButton_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Post_ShareButton_50x50_@3x.png new file mode 100644 index 0000000..de3502f Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_50x50_.imageset/Post_ShareButton_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Contents.json new file mode 100644 index 0000000..cbfe8ba --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_ShareButton_Highlighted_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_ShareButton_Highlighted_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Post_ShareButton_Highlighted_50x50_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Post_ShareButton_Highlighted_50x50_@2x.png new file mode 100644 index 0000000..6c3d8a3 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Post_ShareButton_Highlighted_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Post_ShareButton_Highlighted_50x50_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Post_ShareButton_Highlighted_50x50_@3x.png new file mode 100644 index 0000000..f1fe432 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ShareButton_Highlighted_50x50_.imageset/Post_ShareButton_Highlighted_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Contents.json new file mode 100644 index 0000000..a5d56b9 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Post_ShareIcon_15x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Post_ShareIcon_15x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Post_ShareIcon_15x16_@2x.png b/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Post_ShareIcon_15x16_@2x.png new file mode 100644 index 0000000..f2f767e Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Post_ShareIcon_15x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Post_ShareIcon_15x16_@3x.png b/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Post_ShareIcon_15x16_@3x.png new file mode 100644 index 0000000..356425a Binary files /dev/null and b/DanTangSwift/Assets.xcassets/post/Post_ShareIcon_15x16_.imageset/Post_ShareIcon_15x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Contents.json b/DanTangSwift/Assets.xcassets/search/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Contents.json new file mode 100644 index 0000000..9f19a98 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Explore_ScanButton_22x22_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Explore_ScanButton_22x22_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Explore_ScanButton_22x22_@2x.png b/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Explore_ScanButton_22x22_@2x.png new file mode 100644 index 0000000..eb77f86 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Explore_ScanButton_22x22_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Explore_ScanButton_22x22_@3x.png b/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Explore_ScanButton_22x22_@3x.png new file mode 100644 index 0000000..646e141 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Explore_ScanButton_22x22_.imageset/Explore_ScanButton_22x22_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Contents.json new file mode 100644 index 0000000..024268b --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Search_GiftBtn_Default_12x10_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Search_GiftBtn_Default_12x10_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Search_GiftBtn_Default_12x10_@2x.png b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Search_GiftBtn_Default_12x10_@2x.png new file mode 100644 index 0000000..8b75ff8 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Search_GiftBtn_Default_12x10_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Search_GiftBtn_Default_12x10_@3x.png b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Search_GiftBtn_Default_12x10_@3x.png new file mode 100644 index 0000000..064a52d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Default_12x10_.imageset/Search_GiftBtn_Default_12x10_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Contents.json new file mode 100644 index 0000000..680e3be --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Search_GiftBtn_Selected_12x10_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Search_GiftBtn_Selected_12x10_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Search_GiftBtn_Selected_12x10_@2x.png b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Search_GiftBtn_Selected_12x10_@2x.png new file mode 100644 index 0000000..8ae2614 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Search_GiftBtn_Selected_12x10_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Search_GiftBtn_Selected_12x10_@3x.png b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Search_GiftBtn_Selected_12x10_@3x.png new file mode 100644 index 0000000..a7c7927 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Search_GiftBtn_Selected_12x10_.imageset/Search_GiftBtn_Selected_12x10_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Contents.json new file mode 100644 index 0000000..810bc9c --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Search_fruitless_50x50_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Search_fruitless_50x50_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Search_fruitless_50x50_@2x.png b/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Search_fruitless_50x50_@2x.png new file mode 100644 index 0000000..158b12b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Search_fruitless_50x50_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Search_fruitless_50x50_@3x.png b/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Search_fruitless_50x50_@3x.png new file mode 100644 index 0000000..afb4901 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/Search_fruitless_50x50_.imageset/Search_fruitless_50x50_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/Contents.json new file mode 100644 index 0000000..36b69e5 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "hotSearch_icon_clear_11x11_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "hotSearch_icon_clear_11x11_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/hotSearch_icon_clear_11x11_@2x.png b/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/hotSearch_icon_clear_11x11_@2x.png new file mode 100644 index 0000000..61e9132 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/hotSearch_icon_clear_11x11_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/hotSearch_icon_clear_11x11_@3x.png b/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/hotSearch_icon_clear_11x11_@3x.png new file mode 100644 index 0000000..7f7fa2d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/hotSearch_icon_clear_11x11_.imageset/hotSearch_icon_clear_11x11_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/search/search_direction_231x124_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/search/search_direction_231x124_.imageset/Contents.json new file mode 100644 index 0000000..38da9f5 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/search/search_direction_231x124_.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "search_direction_231x124_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/search/search_direction_231x124_.imageset/search_direction_231x124_@2x.png b/DanTangSwift/Assets.xcassets/search/search_direction_231x124_.imageset/search_direction_231x124_@2x.png new file mode 100644 index 0000000..37e7bff Binary files /dev/null and b/DanTangSwift/Assets.xcassets/search/search_direction_231x124_.imageset/search_direction_231x124_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Contents.json b/DanTangSwift/Assets.xcassets/share/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/Contents.json new file mode 100644 index 0000000..522969b --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "GiftShare_icon_18x22_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "GiftShare_icon_18x22_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/GiftShare_icon_18x22_@2x.png b/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/GiftShare_icon_18x22_@2x.png new file mode 100644 index 0000000..4a1a345 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/GiftShare_icon_18x22_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/GiftShare_icon_18x22_@3x.png b/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/GiftShare_icon_18x22_@3x.png new file mode 100644 index 0000000..ee30523 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/GiftShare_icon_18x22_.imageset/GiftShare_icon_18x22_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Contents.json new file mode 100644 index 0000000..dc91572 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Share_CopyLinkIcon_70x70_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Share_CopyLinkIcon_70x70_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Share_CopyLinkIcon_70x70_@2x.png b/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Share_CopyLinkIcon_70x70_@2x.png new file mode 100644 index 0000000..a8af6d2 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Share_CopyLinkIcon_70x70_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Share_CopyLinkIcon_70x70_@3x.png b/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Share_CopyLinkIcon_70x70_@3x.png new file mode 100644 index 0000000..3e14791 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_CopyLinkIcon_70x70_.imageset/Share_CopyLinkIcon_70x70_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Contents.json new file mode 100644 index 0000000..2438698 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Share_QQIcon_70x70_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Share_QQIcon_70x70_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Share_QQIcon_70x70_@2x.png b/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Share_QQIcon_70x70_@2x.png new file mode 100644 index 0000000..73b7886 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Share_QQIcon_70x70_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Share_QQIcon_70x70_@3x.png b/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Share_QQIcon_70x70_@3x.png new file mode 100644 index 0000000..ba36cde Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_QQIcon_70x70_.imageset/Share_QQIcon_70x70_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Contents.json new file mode 100644 index 0000000..6d41603 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Share_QzoneIcon_70x70_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Share_QzoneIcon_70x70_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Share_QzoneIcon_70x70_@2x.png b/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Share_QzoneIcon_70x70_@2x.png new file mode 100644 index 0000000..b6a6369 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Share_QzoneIcon_70x70_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Share_QzoneIcon_70x70_@3x.png b/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Share_QzoneIcon_70x70_@3x.png new file mode 100644 index 0000000..a6d06c6 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_QzoneIcon_70x70_.imageset/Share_QzoneIcon_70x70_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Contents.json new file mode 100644 index 0000000..32dda81 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Share_WeChatSessionIcon_70x70_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Share_WeChatSessionIcon_70x70_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Share_WeChatSessionIcon_70x70_@2x.png b/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Share_WeChatSessionIcon_70x70_@2x.png new file mode 100644 index 0000000..7496f82 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Share_WeChatSessionIcon_70x70_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Share_WeChatSessionIcon_70x70_@3x.png b/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Share_WeChatSessionIcon_70x70_@3x.png new file mode 100644 index 0000000..8c82db4 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_WeChatSessionIcon_70x70_.imageset/Share_WeChatSessionIcon_70x70_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Contents.json new file mode 100644 index 0000000..66cbe64 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Share_WeChatTimelineIcon_70x70_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Share_WeChatTimelineIcon_70x70_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Share_WeChatTimelineIcon_70x70_@2x.png b/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Share_WeChatTimelineIcon_70x70_@2x.png new file mode 100644 index 0000000..eaff4e2 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Share_WeChatTimelineIcon_70x70_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Share_WeChatTimelineIcon_70x70_@3x.png b/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Share_WeChatTimelineIcon_70x70_@3x.png new file mode 100644 index 0000000..a31cc3b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_WeChatTimelineIcon_70x70_.imageset/Share_WeChatTimelineIcon_70x70_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Contents.json new file mode 100644 index 0000000..8ff2a1d --- /dev/null +++ b/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Share_WeiboIcon_70x70_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Share_WeiboIcon_70x70_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Share_WeiboIcon_70x70_@2x.png b/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Share_WeiboIcon_70x70_@2x.png new file mode 100644 index 0000000..2e32ba1 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Share_WeiboIcon_70x70_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Share_WeiboIcon_70x70_@3x.png b/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Share_WeiboIcon_70x70_@3x.png new file mode 100644 index 0000000..0dac783 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/share/Share_WeiboIcon_70x70_.imageset/Share_WeiboIcon_70x70_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/Contents.json new file mode 100644 index 0000000..9774f76 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_category_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_category_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/TabBar_category_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/TabBar_category_23x23_@2x.png new file mode 100644 index 0000000..ef847fa Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/TabBar_category_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/TabBar_category_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/TabBar_category_23x23_@3x.png new file mode 100644 index 0000000..9295333 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_.imageset/TabBar_category_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/Contents.json new file mode 100644 index 0000000..ac3a029 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_category_Selected_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_category_Selected_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/TabBar_category_Selected_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/TabBar_category_Selected_23x23_@2x.png new file mode 100644 index 0000000..4e9a22d Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/TabBar_category_Selected_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/TabBar_category_Selected_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/TabBar_category_Selected_23x23_@3x.png new file mode 100644 index 0000000..fc4ef78 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_category_23x23_selected.imageset/TabBar_category_Selected_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/Contents.json new file mode 100644 index 0000000..1ef9962 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_gift_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_gift_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/TabBar_gift_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/TabBar_gift_23x23_@2x.png new file mode 100644 index 0000000..e01e058 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/TabBar_gift_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/TabBar_gift_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/TabBar_gift_23x23_@3x.png new file mode 100644 index 0000000..caecf58 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_.imageset/TabBar_gift_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/Contents.json new file mode 100644 index 0000000..fcf18e2 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_gift_selected_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_gift_selected_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/TabBar_gift_selected_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/TabBar_gift_selected_23x23_@2x.png new file mode 100644 index 0000000..6c18f72 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/TabBar_gift_selected_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/TabBar_gift_selected_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/TabBar_gift_selected_23x23_@3x.png new file mode 100644 index 0000000..1ddf93b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_gift_23x23_selected.imageset/TabBar_gift_selected_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/Contents.json new file mode 100644 index 0000000..e4d6727 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_home_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_home_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/TabBar_home_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/TabBar_home_23x23_@2x.png new file mode 100644 index 0000000..822188c Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/TabBar_home_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/TabBar_home_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/TabBar_home_23x23_@3x.png new file mode 100644 index 0000000..4eb0dbe Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_.imageset/TabBar_home_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/Contents.json new file mode 100644 index 0000000..71d1408 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_home_selected_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_home_selected_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/TabBar_home_selected_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/TabBar_home_selected_23x23_@2x.png new file mode 100644 index 0000000..2757396 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/TabBar_home_selected_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/TabBar_home_selected_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/TabBar_home_selected_23x23_@3x.png new file mode 100644 index 0000000..a5ed269 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_home_23x23_selected.imageset/TabBar_home_selected_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/Contents.json new file mode 100644 index 0000000..4364d5b --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_boy_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_boy_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/TabBar_me_boy_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/TabBar_me_boy_23x23_@2x.png new file mode 100644 index 0000000..9217c05 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/TabBar_me_boy_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/TabBar_me_boy_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/TabBar_me_boy_23x23_@3x.png new file mode 100644 index 0000000..ffc3f3b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_.imageset/TabBar_me_boy_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/Contents.json new file mode 100644 index 0000000..059ac66 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_boy_selected_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_boy_selected_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/TabBar_me_boy_selected_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/TabBar_me_boy_selected_23x23_@2x.png new file mode 100644 index 0000000..e2c2514 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/TabBar_me_boy_selected_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/TabBar_me_boy_selected_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/TabBar_me_boy_selected_23x23_@3x.png new file mode 100644 index 0000000..fb27414 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_boy_23x23_selected.imageset/TabBar_me_boy_selected_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/Contents.json new file mode 100644 index 0000000..2ea6b84 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_girl_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_girl_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/TabBar_me_girl_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/TabBar_me_girl_23x23_@2x.png new file mode 100644 index 0000000..819c8fb Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/TabBar_me_girl_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/TabBar_me_girl_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/TabBar_me_girl_23x23_@3x.png new file mode 100644 index 0000000..93058f2 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_23x23_.imageset/TabBar_me_girl_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/Contents.json new file mode 100644 index 0000000..e75995d --- /dev/null +++ b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_girl_selected_23x23_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "TabBar_me_girl_selected_23x23_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/TabBar_me_girl_selected_23x23_@2x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/TabBar_me_girl_selected_23x23_@2x.png new file mode 100644 index 0000000..abe19a7 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/TabBar_me_girl_selected_23x23_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/TabBar_me_girl_selected_23x23_@3x.png b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/TabBar_me_girl_selected_23x23_@3x.png new file mode 100644 index 0000000..d23cae1 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/tabbar/TabBar_me_girl_selected_23x23_.imageset/TabBar_me_girl_selected_23x23_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/time/Contents.json b/DanTangSwift/Assets.xcassets/time/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/time/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/Contents.json new file mode 100644 index 0000000..42b0848 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "time_article_12x12_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "time_article_12x12_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/time_article_12x12_@2x.png b/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/time_article_12x12_@2x.png new file mode 100644 index 0000000..fa9368a Binary files /dev/null and b/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/time_article_12x12_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/time_article_12x12_@3x.png b/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/time_article_12x12_@3x.png new file mode 100644 index 0000000..39ec693 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/time/time_article_12x12_.imageset/time_article_12x12_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/Contents.json new file mode 100644 index 0000000..592b278 --- /dev/null +++ b/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "time_commodity_16x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "time_commodity_16x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/time_commodity_16x16_@2x.png b/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/time_commodity_16x16_@2x.png new file mode 100644 index 0000000..33181d5 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/time_commodity_16x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/time_commodity_16x16_@3x.png b/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/time_commodity_16x16_@3x.png new file mode 100644 index 0000000..fd5e2e4 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/time/time_commodity_16x16_.imageset/time_commodity_16x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/Contents.json b/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/Contents.json new file mode 100644 index 0000000..367537e --- /dev/null +++ b/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "time_commodity_night_16x16_@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "time_commodity_night_16x16_@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/time_commodity_night_16x16_@2x.png b/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/time_commodity_night_16x16_@2x.png new file mode 100644 index 0000000..0a4eb2b Binary files /dev/null and b/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/time_commodity_night_16x16_@2x.png differ diff --git a/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/time_commodity_night_16x16_@3x.png b/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/time_commodity_night_16x16_@3x.png new file mode 100644 index 0000000..098ff09 Binary files /dev/null and b/DanTangSwift/Assets.xcassets/time/time_commodity_night_16x16_.imageset/time_commodity_night_16x16_@3x.png differ diff --git a/DanTangSwift/Assets.xcassets/yw_1222.imageset/Contents.json b/DanTangSwift/Assets.xcassets/yw_1222.imageset/Contents.json new file mode 100644 index 0000000..09f383d --- /dev/null +++ b/DanTangSwift/Assets.xcassets/yw_1222.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "yw_1222.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/DanTangSwift/Assets.xcassets/yw_1222.imageset/yw_1222.jpg b/DanTangSwift/Assets.xcassets/yw_1222.imageset/yw_1222.jpg new file mode 100644 index 0000000..cb554ad Binary files /dev/null and b/DanTangSwift/Assets.xcassets/yw_1222.imageset/yw_1222.jpg differ diff --git a/DanTangSwift/Base.lproj/LaunchScreen.storyboard b/DanTangSwift/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/DanTangSwift/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DanTangSwift/Base.lproj/Main.storyboard b/DanTangSwift/Base.lproj/Main.storyboard new file mode 100644 index 0000000..273375f --- /dev/null +++ b/DanTangSwift/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DanTangSwift/BaseVC/TXBaseViewController.swift b/DanTangSwift/BaseVC/TXBaseViewController.swift new file mode 100644 index 0000000..1180711 --- /dev/null +++ b/DanTangSwift/BaseVC/TXBaseViewController.swift @@ -0,0 +1,42 @@ +// +// TXBaseViewController.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit +import FDFullscreenPopGesture +class TXBaseViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + view.backgroundColor = UIColor.colorWithHexString(hex: "#f5f5f5") + navigationController?.fd_prefersNavigationBarHidden=true; + + } + + override var preferredStatusBarStyle: UIStatusBarStyle{ + return .lightContent + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/BaseVC/TXNavigationController.swift b/DanTangSwift/BaseVC/TXNavigationController.swift new file mode 100644 index 0000000..2d7c558 --- /dev/null +++ b/DanTangSwift/BaseVC/TXNavigationController.swift @@ -0,0 +1,66 @@ +// +// TXNavigationController.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class TXNavigationController: UINavigationController { + + internal override class func initialize() { + super.initialize() + // 设置导航栏标题 + let navBar = UINavigationBar.appearance() + navBar.barTintColor=TXGlobalRedColor() + navBar.titleTextAttributes=[NSForegroundColorAttributeName:UIColor.white,NSFontAttributeName:UIFont.systemFont(ofSize: 20)] + } + + /** + # 统一所有控制器导航栏左上角的返回按钮 + # 让所有push进来的控制器,它的导航栏左上角的内容都一样 + # 能拦截所有的push操作 + - parameter viewController: 需要压栈的控制器 + - parameter animated: 是否动画 + */ + override func pushViewController(_ viewController: UIViewController, animated: Bool) { + if viewControllers.count>0 { + viewController.hidesBottomBarWhenPushed=true; + viewController.navigationItem.leftBarButtonItem=UIBarButtonItem(image:UIImage(named:"checkUserType_backward_9x15_"),style:.plain,target:self,action:#selector(navigationBackClick)) + } + super.pushViewController(viewController, animated: true) + } + + /// 返回按钮 + func navigationBackClick() { + if UIApplication.shared.isNetworkActivityIndicatorVisible { + UIApplication.shared.isNetworkActivityIndicatorVisible=false + } + popViewController(animated: true) + } + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/BaseVC/TXTabBarController.swift b/DanTangSwift/BaseVC/TXTabBarController.swift new file mode 100644 index 0000000..4c22606 --- /dev/null +++ b/DanTangSwift/BaseVC/TXTabBarController.swift @@ -0,0 +1,52 @@ +// +// TXTabBarController.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class TXTabBarController: UITabBarController { + + override func viewDidLoad() { + super.viewDidLoad() + let tabBar = UITabBar.appearance() + tabBar.tintColor = TXColor(r: 245, g: 90, b: 93, a: 1/0) + addChildViewControllers() + // Do any additional setup after loading the view. + } + + private func addChildViewControllers() { + addChildViewController(childController: HomeVC(), title: "单糖", imaged: "TabBar_home_23x23_") + addChildViewController(childController: HomeVC(), title: "单品", imaged: "TabBar_gift_23x23_") + addChildViewController(childController: HomeVC(), title: "分类", imaged: "TabBar_category_23x23_") + addChildViewController(childController: HomeVC(), title: "我的", imaged: "TabBar_me_boy_23x23_") + } + + private func addChildViewController(childController:UIViewController,title:String,imaged:String) { + childController.tabBarItem.title=title; + childController.tabBarItem.image=UIImage(named:imaged); + childController.tabBarItem.selectedImage=UIImage(named:imaged+"selected") + let nav=TXNavigationController(rootViewController: childController) + addChildViewController(nav) + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/Classify/Controller/ClassifyVC.swift b/DanTangSwift/Classify/Controller/ClassifyVC.swift new file mode 100644 index 0000000..a8aa264 --- /dev/null +++ b/DanTangSwift/Classify/Controller/ClassifyVC.swift @@ -0,0 +1,35 @@ +// +// ClassifyVC.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class ClassifyVC: TXBaseViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/Extension/UIColor+Extension.swift b/DanTangSwift/Extension/UIColor+Extension.swift new file mode 100644 index 0000000..bbfc692 --- /dev/null +++ b/DanTangSwift/Extension/UIColor+Extension.swift @@ -0,0 +1,40 @@ +// +// UIColor+Extension.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import Foundation +import UIKit +extension UIColor { + class func colorWithHexString(hex:String) ->UIColor { + + var cString = hex.trimmingCharacters(in:CharacterSet.whitespacesAndNewlines).uppercased() + + if (cString.hasPrefix("#")) { + let index = cString.index(cString.startIndex, offsetBy:1) + cString = cString.substring(from: index) + } + + if (cString.characters.count != 6) { + return UIColor.red + } + + let rIndex = cString.index(cString.startIndex, offsetBy: 2) + let rString = cString.substring(to: rIndex) + let otherString = cString.substring(from: rIndex) + let gIndex = otherString.index(otherString.startIndex, offsetBy: 2) + let gString = otherString.substring(to: gIndex) + let bIndex = cString.index(cString.endIndex, offsetBy: -2) + let bString = cString.substring(from: bIndex) + + var r:CUnsignedInt = 0, g:CUnsignedInt = 0, b:CUnsignedInt = 0; + Scanner(string: rString).scanHexInt32(&r) + Scanner(string: gString).scanHexInt32(&g) + Scanner(string: bString).scanHexInt32(&b) + + return UIColor(red: CGFloat(r) / 255.0, green: CGFloat(g) / 255.0, blue: CGFloat(b) / 255.0, alpha: CGFloat(1)) + } +} diff --git a/DanTangSwift/Home/Controller/HomeVC.swift b/DanTangSwift/Home/Controller/HomeVC.swift new file mode 100644 index 0000000..27e4c8d --- /dev/null +++ b/DanTangSwift/Home/Controller/HomeVC.swift @@ -0,0 +1,54 @@ +// +// HomeVC.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class HomeVC: TXBaseViewController { + + override func viewDidLoad() { + super.viewDidLoad() + initNav() + requestData() + initTitlesView() + // Do any additional setup after loading the view. + } + + private func initNav() { + navigationItem.rightBarButtonItem=UIBarButtonItem(image: UIImage(named:"Feed_SearchBtn_18x18_"), style: .plain, target: self, action: #selector(rightButtonClick)) + navigationItem.rightBarButtonItem?.tintColor=UIColor.white + } + + private func requestData() { + + } + + private func initTitlesView() { + + } + + func rightButtonClick() { + print("123") + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/Home/Model/TXHomeModel.swift b/DanTangSwift/Home/Model/TXHomeModel.swift new file mode 100644 index 0000000..ac71dcb --- /dev/null +++ b/DanTangSwift/Home/Model/TXHomeModel.swift @@ -0,0 +1,47 @@ +// +// TXHomeModel.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class TXHomeModel: NSObject { + + var content_url: String? + var cover_image_url: String? + var created_at: Int? + var id: Int? + var liked: Int? + var likes_count: Int? + var share_msg: String? + var published_at: Int? + var short_title: String? + var status: Int? + var type: String? + var title: String? + var template: String? + var updated_at: Int? + var url: String? + + init(dict:[String:AnyObject]) { + super.init() + content_url=dict["content_url"] as? String + cover_image_url = dict["cover_image_url"] as? String + created_at = dict["created_at"] as? Int + id = dict["id"] as? Int + liked = dict["liked"] as? Int + likes_count = dict["likes_count"] as? Int + share_msg = dict["share_msg"] as? String + published_at = dict["published_at"] as? Int + short_title = dict["short_title"] as? String + status = dict["status"] as? Int + type = dict["type"] as? String + title = dict["title"] as? String + template = dict["template"] as? String + updated_at = dict["updated_at"] as? Int + url = dict["url"] as? String + } +} diff --git a/DanTangSwift/Info.plist b/DanTangSwift/Info.plist new file mode 100644 index 0000000..d1f4ae8 --- /dev/null +++ b/DanTangSwift/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + 单糖 + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/DanTangSwift/Product/Controller/ProductVC.swift b/DanTangSwift/Product/Controller/ProductVC.swift new file mode 100644 index 0000000..308e708 --- /dev/null +++ b/DanTangSwift/Product/Controller/ProductVC.swift @@ -0,0 +1,35 @@ +// +// ProductVC.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class ProductVC: TXBaseViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/Product/MineVC.swift b/DanTangSwift/Product/MineVC.swift new file mode 100644 index 0000000..08b1fd1 --- /dev/null +++ b/DanTangSwift/Product/MineVC.swift @@ -0,0 +1,35 @@ +// +// MineVC.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class MineVC: TXBaseViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/DanTangSwift/Tools/NetworkTool.swift b/DanTangSwift/Tools/NetworkTool.swift new file mode 100644 index 0000000..4f7d2a5 --- /dev/null +++ b/DanTangSwift/Tools/NetworkTool.swift @@ -0,0 +1,19 @@ +// +// NetworkTool.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit +import Alamofire +import SwiftyJSON + +class NetworkTool: NSObject { + +// static let shared = NetworkTool() +// func loadHomeInfo(id: Int , finished:@escaping(_ homeModel:[TXHomeModel]->())) { +// +// } +} diff --git a/DanTangSwift/Tools/TXConst.swift b/DanTangSwift/Tools/TXConst.swift new file mode 100644 index 0000000..6cc4b8c --- /dev/null +++ b/DanTangSwift/Tools/TXConst.swift @@ -0,0 +1,21 @@ +// +// TXConst.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +let BASE_URL = "http://api.dantangapp.com/" + +func TXColor(r:CGFloat,g:CGFloat,b:CGFloat,a:CGFloat) -> UIColor { +// return UIColor(red:r/255.0,green:g/255.0,blue:b/255.0,alpha:a); + return UIColor.init(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a); +} + +/// 红色 +func TXGlobalRedColor() -> UIColor { + return TXColor(r: 245, g: 80, b: 83, a: 1.0) +} diff --git a/DanTangSwift/ViewController.swift b/DanTangSwift/ViewController.swift new file mode 100644 index 0000000..98d84c5 --- /dev/null +++ b/DanTangSwift/ViewController.swift @@ -0,0 +1,25 @@ +// +// ViewController.swift +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/DanTangSwiftTests/DanTangSwiftTests.swift b/DanTangSwiftTests/DanTangSwiftTests.swift new file mode 100644 index 0000000..04b124b --- /dev/null +++ b/DanTangSwiftTests/DanTangSwiftTests.swift @@ -0,0 +1,36 @@ +// +// DanTangSwiftTests.swift +// DanTangSwiftTests +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import XCTest +@testable import DanTangSwift + +class DanTangSwiftTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/DanTangSwiftTests/Info.plist b/DanTangSwiftTests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/DanTangSwiftTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/DanTangSwiftTests/PrefixHeader.pch b/DanTangSwiftTests/PrefixHeader.pch new file mode 100644 index 0000000..4a94624 --- /dev/null +++ b/DanTangSwiftTests/PrefixHeader.pch @@ -0,0 +1,16 @@ +// +// PrefixHeader.pch +// DanTangSwift +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +#ifndef PrefixHeader_pch +#define PrefixHeader_pch + +// Include any system framework and library headers here that should be included in all compilation units. +// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. + +#endif /* PrefixHeader_pch */ +import TXConst diff --git a/DanTangSwiftUITests/DanTangSwiftUITests.swift b/DanTangSwiftUITests/DanTangSwiftUITests.swift new file mode 100644 index 0000000..fcbdd46 --- /dev/null +++ b/DanTangSwiftUITests/DanTangSwiftUITests.swift @@ -0,0 +1,36 @@ +// +// DanTangSwiftUITests.swift +// DanTangSwiftUITests +// +// Created by 赵天旭 on 2017/7/5. +// Copyright © 2017年 ZTX. All rights reserved. +// + +import XCTest + +class DanTangSwiftUITests: XCTestCase { + + override func setUp() { + super.setUp() + + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + XCUIApplication().launch() + + // 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. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + +} diff --git a/DanTangSwiftUITests/Info.plist b/DanTangSwiftUITests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/DanTangSwiftUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..4e52259 --- /dev/null +++ b/Podfile @@ -0,0 +1,11 @@ +platform :ios, "8.0" +use_frameworks! + +target "DanTangSwift" do +pod 'SVProgressHUD' +pod 'FDFullscreenPopGesture', '~> 1.1' +pod 'SnapKit', '~> 3.1.2' +pod 'Kingfisher', '~>3.3.4' +pod 'Alamofire', '~> 4.3.0' +pod 'SwiftyJSON', '~> 3.1.4' +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..fc68e22 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,27 @@ +PODS: + - Alamofire (4.3.0) + - FDFullscreenPopGesture (1.1) + - Kingfisher (3.3.4) + - SnapKit (3.1.2) + - SVProgressHUD (2.1.2) + - SwiftyJSON (3.1.4) + +DEPENDENCIES: + - Alamofire (~> 4.3.0) + - FDFullscreenPopGesture (~> 1.1) + - Kingfisher (~> 3.3.4) + - SnapKit (~> 3.1.2) + - SVProgressHUD + - SwiftyJSON (~> 3.1.4) + +SPEC CHECKSUMS: + Alamofire: 856a113053a7bc9cbe5d6367a555d773fc5cfef7 + FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0 + Kingfisher: 35f289f015d26e81ea6c85048718c6205f3933c6 + SnapKit: 12b24f569cb7c143acc9c22b9d91b23e7b1c84a2 + SVProgressHUD: c404a55d78acbeb7ebb78b76d3faf986475a6994 + SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220 + +PODFILE CHECKSUM: 05f5431693d14c3f23850e24699be1c097e7ac3d + +COCOAPODS: 1.2.0 diff --git a/Pods/Alamofire/LICENSE b/Pods/Alamofire/LICENSE new file mode 100644 index 0000000..4cfbf72 --- /dev/null +++ b/Pods/Alamofire/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Pods/Alamofire/README.md b/Pods/Alamofire/README.md new file mode 100644 index 0000000..9526a9a --- /dev/null +++ b/Pods/Alamofire/README.md @@ -0,0 +1,1764 @@ +![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/Alamofire/Alamofire/assets/alamofire.png) + +[![Build Status](https://travis-ci.org/Alamofire/Alamofire.svg?branch=master)](https://travis-ci.org/Alamofire/Alamofire) +[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Alamofire.svg)](https://img.shields.io/cocoapods/v/Alamofire.svg) +[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Platform](https://img.shields.io/cocoapods/p/Alamofire.svg?style=flat)](http://cocoadocs.org/docsets/Alamofire) +[![Twitter](https://img.shields.io/badge/twitter-@AlamofireSF-blue.svg?style=flat)](http://twitter.com/AlamofireSF) + +Alamofire is an HTTP networking library written in Swift. + +- [Features](#features) +- [Component Libraries](#component-libraries) +- [Requirements](#requirements) +- [Migration Guides](#migration-guides) +- [Communication](#communication) +- [Installation](#installation) +- [Usage](#usage) + - **Intro -** [Making a Request](#making-a-request), [Response Handling](#response-handling), [Response Validation](#response-validation), [Response Caching](#response-caching) + - **HTTP -** [HTTP Methods](#http-methods), [Parameter Encoding](#parameter-encoding), [HTTP Headers](#http-headers), [Authentication](#authentication) + - **Large Data -** [Downloading Data to a File](#downloading-data-to-a-file), [Uploading Data to a Server](#uploading-data-to-a-server) + - **Tools -** [Statistical Metrics](#statistical-metrics), [cURL Command Output](#curl-command-output) +- [Advanced Usage](#advanced-usage) + - **URL Session -** [Session Manager](#session-manager), [Session Delegate](#session-delegate), [Request](#request) + - **Routing -** [Routing Requests](#routing-requests), [Adapting and Retrying Requests](#adapting-and-retrying-requests) + - **Model Objects -** [Custom Response Serialization](#custom-response-serialization) + - **Connection -** [Security](#security), [Network Reachability](#network-reachability) +- [Open Radars](#open-radars) +- [FAQ](#faq) +- [Credits](#credits) +- [Donations](#donations) +- [License](#license) + +## Features + +- [x] Chainable Request / Response Methods +- [x] URL / JSON / plist Parameter Encoding +- [x] Upload File / Data / Stream / MultipartFormData +- [x] Download File using Request or Resume Data +- [x] Authentication with URLCredential +- [x] HTTP Response Validation +- [x] Upload and Download Progress Closures with Progress +- [x] cURL Command Output +- [x] Dynamically Adapt and Retry Requests +- [x] TLS Certificate and Public Key Pinning +- [x] Network Reachability +- [x] Comprehensive Unit and Integration Test Coverage +- [x] [Complete Documentation](http://cocoadocs.org/docsets/Alamofire) + +## Component Libraries + +In order to keep Alamofire focused specifically on core networking implementations, additional component libraries have been created by the [Alamofire Software Foundation](https://github.com/Alamofire/Foundation) to bring additional functionality to the Alamofire ecosystem. + +- [AlamofireImage](https://github.com/Alamofire/AlamofireImage) - An image library including image response serializers, `UIImage` and `UIImageView` extensions, custom image filters, an auto-purging in-memory cache and a priority-based image downloading system. +- [AlamofireNetworkActivityIndicator](https://github.com/Alamofire/AlamofireNetworkActivityIndicator) - Controls the visibility of the network activity indicator on iOS using Alamofire. It contains configurable delay timers to help mitigate flicker and can support `URLSession` instances not managed by Alamofire. + +## Requirements + +- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ +- Xcode 8.1+ +- Swift 3.0+ + +## Migration Guides + +- [Alamofire 4.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md) +- [Alamofire 3.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%203.0%20Migration%20Guide.md) +- [Alamofire 2.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%202.0%20Migration%20Guide.md) + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/alamofire). (Tag 'alamofire') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/alamofire). +- If you **found a bug**, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +## Installation + +### CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +> CocoaPods 1.1.0+ is required to build Alamofire 4.0.0+. + +To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '10.0' +use_frameworks! + +target '' do + pod 'Alamofire', '~> 4.3' +end +``` + +Then, run the following command: + +```bash +$ pod install +``` + +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "Alamofire/Alamofire" ~> 4.3 +``` + +Run `carthage update` to build the framework and drag the built `Alamofire.framework` into your Xcode project. + +### Swift Pacakge Manager + +The [Swift Pacakage Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but Alamofire does support its use on supported platforms. + +Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. + +```swift +dependencies: [ + .Package(url: "https://github.com/Alamofire/Alamofire.git", majorVersion: 4) +] +``` + +### Manually + +If you prefer not to use either of the aforementioned dependency managers, you can integrate Alamofire into your project manually. + +#### Embedded Framework + +- Open up Terminal, `cd` into your top-level project directory, and run the following command "if" your project is not initialized as a git repository: + + ```bash +$ git init +``` + +- Add Alamofire as a git [submodule](http://git-scm.com/docs/git-submodule) by running the following command: + + ```bash +$ git submodule add https://github.com/Alamofire/Alamofire.git +``` + +- Open the new `Alamofire` folder, and drag the `Alamofire.xcodeproj` into the Project Navigator of your application's Xcode project. + + > It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter. + +- Select the `Alamofire.xcodeproj` in the Project Navigator and verify the deployment target matches that of your application target. +- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar. +- In the tab bar at the top of that window, open the "General" panel. +- Click on the `+` button under the "Embedded Binaries" section. +- You will see two different `Alamofire.xcodeproj` folders each with two different versions of the `Alamofire.framework` nested inside a `Products` folder. + + > It does not matter which `Products` folder you choose from, but it does matter whether you choose the top or bottom `Alamofire.framework`. + +- Select the top `Alamofire.framework` for iOS and the bottom one for OS X. + + > You can verify which one you selected by inspecting the build log for your project. The build target for `Alamofire` will be listed as either `Alamofire iOS`, `Alamofire macOS`, `Alamofire tvOS` or `Alamofire watchOS`. + +- And that's it! + + > The `Alamofire.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device. + +--- + +## Usage + +### Making a Request + +```swift +import Alamofire + +Alamofire.request("https://httpbin.org/get") +``` + +### Response Handling + +Handling the `Response` of a `Request` made in Alamofire involves chaining a response handler onto the `Request`. + +```swift +Alamofire.request("https://httpbin.org/get").responseJSON { response in + print(response.request) // original URL request + print(response.response) // HTTP URL response + print(response.data) // server data + print(response.result) // result of response serialization + + if let JSON = response.result.value { + print("JSON: \(JSON)") + } +} +``` + +In the above example, the `responseJSON` handler is appended to the `Request` to be executed once the `Request` is complete. Rather than blocking execution to wait for a response from the server, a [callback](http://en.wikipedia.org/wiki/Callback_%28computer_programming%29) in the form of a closure is specified to handle the response once it's received. The result of a request is only available inside the scope of a response closure. Any execution contingent on the response or data received from the server must be done within a response closure. + +> Networking in Alamofire is done _asynchronously_. Asynchronous programming may be a source of frustration to programmers unfamiliar with the concept, but there are [very good reasons](https://developer.apple.com/library/ios/qa/qa1693/_index.html) for doing it this way. + +Alamofire contains five different response handlers by default including: + +```swift +// Response Handler - Unserialized Response +func response( + queue: DispatchQueue?, + completionHandler: @escaping (DefaultDataResponse) -> Void) + -> Self + +// Response Data Handler - Serialized into Data +func responseData( + queue: DispatchQueue?, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + +// Response String Handler - Serialized into String +func responseString( + queue: DispatchQueue?, + encoding: String.Encoding?, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + +// Response JSON Handler - Serialized into Any +func responseJSON( + queue: DispatchQueue?, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + +// Response PropertyList (plist) Handler - Serialized into Any +func responsePropertyList( + queue: DispatchQueue?, + completionHandler: @escaping (DataResponse) -> Void)) + -> Self +``` + +None of the response handlers perform any validation of the `HTTPURLResponse` it gets back from the server. + +> For example, response status codes in the `400..<499` and `500..<599` ranges do NOT automatically trigger an `Error`. Alamofire uses [Response Validation](#response-validation) method chaining to achieve this. + +#### Response Handler + +The `response` handler does NOT evaluate any of the response data. It merely forwards on all information directly from the URL session delegate. It is the Alamofire equivalent of using `cURL` to execute a `Request`. + +```swift +Alamofire.request("https://httpbin.org/get").response { response in + print("Request: \(response.request)") + print("Response: \(response.response)") + print("Error: \(response.error)") + + if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) { + print("Data: \(utf8Text)") + } +} +``` + +> We strongly encourage you to leverage the other response serializers taking advantage of `Response` and `Result` types. + +#### Response Data Handler + +The `responseData` handler uses the `responseDataSerializer` (the object that serializes the server data into some other type) to extract the `Data` returned by the server. If no errors occur and `Data` is returned, the response `Result` will be a `.success` and the `value` will be of type `Data`. + +```swift +Alamofire.request("https://httpbin.org/get").responseData { response in + debugPrint("All Response Info: \(response)") + + if let data = response.result.value, let utf8Text = String(data: data, encoding: .utf8) { + print("Data: \(utf8Text)") + } +} +``` + +#### Response String Handler + +The `responseString` handler uses the `responseStringSerializer` to convert the `Data` returned by the server into a `String` with the specified encoding. If no errors occur and the server data is successfully serialized into a `String`, the response `Result` will be a `.success` and the `value` will be of type `String`. + +```swift +Alamofire.request("https://httpbin.org/get").responseString { response in + print("Success: \(response.result.isSuccess)") + print("Response String: \(response.result.value)") +} +``` + +> If no encoding is specified, Alamofire will use the text encoding specified in the `HTTPURLResponse` from the server. If the text encoding cannot be determined by the server response, it defaults to `.isoLatin1`. + +#### Response JSON Handler + +The `responseJSON` handler uses the `responseJSONSerializer` to convert the `Data` returned by the server into an `Any` type using the specified `JSONSerialization.ReadingOptions`. If no errors occur and the server data is successfully serialized into a JSON object, the response `Result` will be a `.success` and the `value` will be of type `Any`. + +```swift +Alamofire.request("https://httpbin.org/get").responseJSON { response in + debugPrint(response) + + if let json = response.result.value { + print("JSON: \(json)") + } +} +``` + +> All JSON serialization is handled by the `JSONSerialization` API in the `Foundation` framework. + +#### Chained Response Handlers + +Response handlers can even be chained: + +```swift +Alamofire.request("https://httpbin.org/get") + .responseString { response in + print("Response String: \(response.result.value)") + } + .responseJSON { response in + print("Response JSON: \(response.result.value)") + } +``` + +> It is important to note that using multiple response handlers on the same `Request` requires the server data to be serialized multiple times. Once for each response handler. + +#### Response Handler Queue + +Response handlers by default are executed on the main dispatch queue. However, a custom dispatch queue can be provided instead. + +```swift +let utilityQueue = DispatchQueue.global(qos: .utility) + +Alamofire.request("https://httpbin.org/get").responseJSON(queue: utilityQueue) { response in + print("Executing response handler on utility queue") +} +``` + +### Response Validation + +By default, Alamofire treats any completed request to be successful, regardless of the content of the response. Calling `validate` before a response handler causes an error to be generated if the response had an unacceptable status code or MIME type. + +#### Manual Validation + +```swift +Alamofire.request("https://httpbin.org/get") + .validate(statusCode: 200..<300) + .validate(contentType: ["application/json"]) + .responseData { response in + switch response.result { + case .success: + print("Validation Successful") + case .failure(let error): + print(error) + } + } +``` + +#### Automatic Validation + +Automatically validates status code within `200...299` range, and that the `Content-Type` header of the response matches the `Accept` header of the request, if one is provided. + +```swift +Alamofire.request("https://httpbin.org/get").validate().responseJSON { response in + switch response.result { + case .success: + print("Validation Successful") + case .failure(let error): + print(error) + } +} +``` + +### Response Caching + +Response Caching is handled on the system framework level by [`URLCache`](https://developer.apple.com/reference/foundation/urlcache). It provides a composite in-memory and on-disk cache and lets you manipulate the sizes of both the in-memory and on-disk portions. + +> By default, Alamofire leverages the shared `URLCache`. In order to customize it, see the [Session Manager Configurations](#session-manager) section. + +### HTTP Methods + +The `HTTPMethod` enumeration lists the HTTP methods defined in [RFC 7231 §4.3](http://tools.ietf.org/html/rfc7231#section-4.3): + +```swift +public enum HTTPMethod: String { + case options = "OPTIONS" + case get = "GET" + case head = "HEAD" + case post = "POST" + case put = "PUT" + case patch = "PATCH" + case delete = "DELETE" + case trace = "TRACE" + case connect = "CONNECT" +} +``` + +These values can be passed as the `method` argument to the `Alamofire.request` API: + +```swift +Alamofire.request("https://httpbin.org/get") // method defaults to `.get` + +Alamofire.request("https://httpbin.org/post", method: .post) +Alamofire.request("https://httpbin.org/put", method: .put) +Alamofire.request("https://httpbin.org/delete", method: .delete) +``` + +> The `Alamofire.request` method parameter defaults to `.get`. + +### Parameter Encoding + +Alamofire supports three types of parameter encoding including: `URL`, `JSON` and `PropertyList`. It can also support any custom encoding that conforms to the `ParameterEncoding` protocol. + +#### URL Encoding + +The `URLEncoding` type creates a url-encoded query string to be set as or appended to any existing URL query string or set as the HTTP body of the URL request. Whether the query string is set or appended to any existing URL query string or set as the HTTP body depends on the `Destination` of the encoding. The `Destination` enumeration has three cases: + +- `.methodDependent` - Applies encoded query string result to existing query string for `GET`, `HEAD` and `DELETE` requests and sets as the HTTP body for requests with any other HTTP method. +- `.queryString` - Sets or appends encoded query string result to existing query string. +- `.httpBody` - Sets encoded query string result as the HTTP body of the URL request. + +The `Content-Type` HTTP header field of an encoded request with HTTP body is set to `application/x-www-form-urlencoded; charset=utf-8`. Since there is no published specification for how to encode collection types, the convention of appending `[]` to the key for array values (`foo[]=1&foo[]=2`), and appending the key surrounded by square brackets for nested dictionary values (`foo[bar]=baz`). + +##### GET Request With URL-Encoded Parameters + +```swift +let parameters: Parameters = ["foo": "bar"] + +// All three of these calls are equivalent +Alamofire.request("https://httpbin.org/get", parameters: parameters) // encoding defaults to `URLEncoding.default` +Alamofire.request("https://httpbin.org/get", parameters: parameters, encoding: URLEncoding.default) +Alamofire.request("https://httpbin.org/get", parameters: parameters, encoding: URLEncoding(destination: .methodDependent)) + +// https://httpbin.org/get?foo=bar +``` + +##### POST Request With URL-Encoded Parameters + +```swift +let parameters: Parameters = [ + "foo": "bar", + "baz": ["a", 1], + "qux": [ + "x": 1, + "y": 2, + "z": 3 + ] +] + +// All three of these calls are equivalent +Alamofire.request("https://httpbin.org/post", parameters: parameters) +Alamofire.request("https://httpbin.org/post", parameters: parameters, encoding: URLEncoding.default) +Alamofire.request("https://httpbin.org/post", parameters: parameters, encoding: URLEncoding.httpBody) + +// HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3 +``` + +#### JSON Encoding + +The `JSONEncoding` type creates a JSON representation of the parameters object, which is set as the HTTP body of the request. The `Content-Type` HTTP header field of an encoded request is set to `application/json`. + +##### POST Request with JSON-Encoded Parameters + +```swift +let parameters: Parameters = [ + "foo": [1,2,3], + "bar": [ + "baz": "qux" + ] +] + +// Both calls are equivalent +Alamofire.request("https://httpbin.org/post", method: .post, parameters: parameters, encoding: JSONEncoding.default) +Alamofire.request("https://httpbin.org/post", method: .post, parameters: parameters, encoding: JSONEncoding(options: [])) + +// HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}} +``` + +#### Property List Encoding + +The `PropertyListEncoding` uses `PropertyListSerialization` to create a plist representation of the parameters object, according to the associated format and write options values, which is set as the body of the request. The `Content-Type` HTTP header field of an encoded request is set to `application/x-plist`. + +#### Custom Encoding + +In the event that the provided `ParameterEncoding` types do not meet your needs, you can create your own custom encoding. Here's a quick example of how you could build a custom `JSONStringArrayEncoding` type to encode a JSON string array onto a `Request`. + +```swift +struct JSONStringArrayEncoding: ParameterEncoding { + private let array: [String] + + init(array: [String]) { + self.array = array + } + + func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { + var urlRequest = urlRequest.urlRequest + + let data = try JSONSerialization.data(withJSONObject: array, options: []) + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = data + + return urlRequest + } +} +``` + +#### Manual Parameter Encoding of a URLRequest + +The `ParameterEncoding` APIs can be used outside of making network requests. + +```swift +let url = URL(string: "https://httpbin.org/get")! +var urlRequest = URLRequest(url: url) + +let parameters: Parameters = ["foo": "bar"] +let encodedURLRequest = try URLEncoding.queryString.encode(urlRequest, with: parameters) +``` + +### HTTP Headers + +Adding a custom HTTP header to a `Request` is supported directly in the global `request` method. This makes it easy to attach HTTP headers to a `Request` that can be constantly changing. + +```swift +let headers: HTTPHeaders = [ + "Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", + "Accept": "application/json" +] + +Alamofire.request("https://httpbin.org/headers", headers: headers).responseJSON { response in + debugPrint(response) +} +``` + +> For HTTP headers that do not change, it is recommended to set them on the `URLSessionConfiguration` so they are automatically applied to any `URLSessionTask` created by the underlying `URLSession`. For more information, see the [Session Manager Configurations](#session-manager) section. + +The default Alamofire `SessionManager` provides a default set of headers for every `Request`. These include: + +- `Accept-Encoding`, which defaults to `gzip;q=1.0, compress;q=0.5`, per [RFC 7230 §4.2.3](https://tools.ietf.org/html/rfc7230#section-4.2.3). +- `Accept-Language`, which defaults to up to the top 6 preferred languages on the system, formatted like `en;q=1.0`, per [RFC 7231 §5.3.5](https://tools.ietf.org/html/rfc7231#section-5.3.5). +- `User-Agent`, which contains versioning information about the current app. For example: `iOS Example/1.0 (com.alamofire.iOS-Example; build:1; iOS 10.0.0) Alamofire/4.0.0`, per [RFC 7231 §5.5.3](https://tools.ietf.org/html/rfc7231#section-5.5.3). + +If you need to customize these headers, a custom `URLSessionConfiguration` should be created, the `defaultHTTPHeaders` property updated and the configuration applied to a new `SessionManager` instance. + +### Authentication + +Authentication is handled on the system framework level by [`URLCredential`](https://developer.apple.com/reference/foundation/nsurlcredential) and [`URLAuthenticationChallenge`](https://developer.apple.com/reference/foundation/urlauthenticationchallenge). + +**Supported Authentication Schemes** + +- [HTTP Basic](http://en.wikipedia.org/wiki/Basic_access_authentication) +- [HTTP Digest](http://en.wikipedia.org/wiki/Digest_access_authentication) +- [Kerberos](http://en.wikipedia.org/wiki/Kerberos_%28protocol%29) +- [NTLM](http://en.wikipedia.org/wiki/NT_LAN_Manager) + +#### HTTP Basic Authentication + +The `authenticate` method on a `Request` will automatically provide a `URLCredential` to a `URLAuthenticationChallenge` when appropriate: + +```swift +let user = "user" +let password = "password" + +Alamofire.request("https://httpbin.org/basic-auth/\(user)/\(password)") + .authenticate(user: user, password: password) + .responseJSON { response in + debugPrint(response) + } +``` + +Depending upon your server implementation, an `Authorization` header may also be appropriate: + +```swift +let user = "user" +let password = "password" + +var headers: HTTPHeaders = [:] + +if let authorizationHeader = Request.authorizationHeader(user: user, password: password) { + headers[authorizationHeader.key] = authorizationHeader.value +} + +Alamofire.request("https://httpbin.org/basic-auth/user/password", headers: headers) + .responseJSON { response in + debugPrint(response) + } +``` + +#### Authentication with URLCredential + +```swift +let user = "user" +let password = "password" + +let credential = URLCredential(user: user, password: password, persistence: .forSession) + +Alamofire.request("https://httpbin.org/basic-auth/\(user)/\(password)") + .authenticate(usingCredential: credential) + .responseJSON { response in + debugPrint(response) + } +``` + +> It is important to note that when using a `URLCredential` for authentication, the underlying `URLSession` will actually end up making two requests if a challenge is issued by the server. The first request will not include the credential which "may" trigger a challenge from the server. The challenge is then received by Alamofire, the credential is appended and the request is retried by the underlying `URLSession`. + +### Downloading Data to a File + +Requests made in Alamofire that fetch data from a server can download the data in-memory or on-disk. The `Alamofire.request` APIs used in all the examples so far always downloads the server data in-memory. This is great for smaller payloads because it's more efficient, but really bad for larger payloads because the download could run your entire application out-of-memory. Because of this, you can also use the `Alamofire.download` APIs to download the server data to a temporary file on-disk. + +> This will only work on `macOS` as is. Other platforms don't allow access to the filesystem outside of your app's sandbox. To download files on other platforms, see the [Download File Destination](#download-file-destination) section. + +```swift +Alamofire.download("https://httpbin.org/image/png").responseData { response in + if let data = response.result.value { + let image = UIImage(data: data) + } +} +``` + +> The `Alamofire.download` APIs should also be used if you need to download data while your app is in the background. For more information, please see the [Session Manager Configurations](#session-manager) section. + +#### Download File Destination + +You can also provide a `DownloadFileDestination` closure to move the file from the temporary directory to a final destination. Before the temporary file is actually moved to the `destinationURL`, the `DownloadOptions` specified in the closure will be executed. The two currently supported `DownloadOptions` are: + +- `.createIntermediateDirectories` - Creates intermediate directories for the destination URL if specified. +- `.removePreviousFile` - Removes a previous file from the destination URL if specified. + +```swift +let destination: DownloadRequest.DownloadFileDestination = { _, _ in + let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + let fileURL = documentsURL.appendPathComponent("pig.png") + + return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) +} + +Alamofire.download(urlString, to: destination).response { response in + print(response) + + if response.error == nil, let imagePath = response.destinationURL?.path { + let image = UIImage(contentsOfFile: imagePath) + } +} +``` + +You can also use the suggested download destination API. + +```swift +let destination = DownloadRequest.suggestedDownloadDestination(directory: .documentDirectory) +Alamofire.download("https://httpbin.org/image/png", to: destination) +``` + +#### Download Progress + +Many times it can be helpful to report download progress to the user. Any `DownloadRequest` can report download progress using the `downloadProgress` API. + +```swift +Alamofire.download("https://httpbin.org/image/png") + .downloadProgress { progress in + print("Download Progress: \(progress.fractionCompleted)") + } + .responseData { response in + if let data = response.result.value { + let image = UIImage(data: data) + } + } +``` + +The `downloadProgress` API also takes a `queue` parameter which defines which `DispatchQueue` the download progress closure should be called on. + +```swift +let utilityQueue = DispatchQueue.global(qos: .utility) + +Alamofire.download("https://httpbin.org/image/png") + .downloadProgress(queue: utilityQueue) { progress in + print("Download Progress: \(progress.fractionCompleted)") + } + .responseData { response in + if let data = response.result.value { + let image = UIImage(data: data) + } + } +``` + +#### Resuming a Download + +If a `DownloadRequest` is cancelled or interrupted, the underlying URL session may generate resume data for the active `DownloadRequest`. If this happens, the resume data can be re-used to restart the `DownloadRequest` where it left off. The resume data can be accessed through the download response, then reused when trying to restart the request. + +> **IMPORTANT:** On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the data is written incorrectly and will always fail to resume the download. For more information about the bug and possible workarounds, please see this Stack Overflow [post](http://stackoverflow.com/a/39347461/1342462). + +```swift +class ImageRequestor { + private var resumeData: Data? + private var image: UIImage? + + func fetchImage(completion: (UIImage?) -> Void) { + guard image == nil else { completion(image) ; return } + + let destination: DownloadRequest.DownloadFileDestination = { _, _ in + let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + let fileURL = documentsURL.appendPathComponent("pig.png") + + return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) + } + + let request: DownloadRequest + + if let resumeData = resumeData { + request = Alamofire.download(resumingWith: resumeData) + } else { + request = Alamofire.download("https://httpbin.org/image/png") + } + + request.responseData { response in + switch response.result { + case .success(let data): + self.image = UIImage(data: data) + case .failure: + self.resumeData = response.resumeData + } + } + } +} +``` + +### Uploading Data to a Server + +When sending relatively small amounts of data to a server using JSON or URL encoded parameters, the `Alamofire.request` APIs are usually sufficient. If you need to send much larger amounts of data from a file URL or an `InputStream`, then the `Alamofire.upload` APIs are what you want to use. + +> The `Alamofire.upload` APIs should also be used if you need to upload data while your app is in the background. For more information, please see the [Session Manager Configurations](#session-manager) section. + +#### Uploading Data + +```swift +let imageData = UIPNGRepresentation(image)! + +Alamofire.upload(imageData, to: "https://httpbin.org/post").responseJSON { response in + debugPrint(response) +} +``` + +#### Uploading a File + +```swift +let fileURL = Bundle.main.url(forResource: "video", withExtension: "mov") + +Alamofire.upload(fileURL, to: "https://httpbin.org/post").responseJSON { response in + debugPrint(response) +} +``` + +#### Uploading Multipart Form Data + +```swift +Alamofire.upload( + multipartFormData: { multipartFormData in + multipartFormData.append(unicornImageURL, withName: "unicorn") + multipartFormData.append(rainbowImageURL, withName: "rainbow") + }, + to: "https://httpbin.org/post", + encodingCompletion: { encodingResult in + switch encodingResult { + case .success(let upload, _, _): + upload.responseJSON { response in + debugPrint(response) + } + case .failure(let encodingError): + print(encodingError) + } + } +) +``` + +#### Upload Progress + +While your user is waiting for their upload to complete, sometimes it can be handy to show the progress of the upload to the user. Any `UploadRequest` can report both upload progress and download progress of the response data using the `uploadProgress` and `downloadProgress` APIs. + +```swift +let fileURL = Bundle.main.url(forResource: "video", withExtension: "mov") + +Alamofire.upload(fileURL, to: "https://httpbin.org/post") + .uploadProgress { progress in // main queue by default + print("Upload Progress: \(progress.fractionCompleted)") + } + .downloadProgress { progress in // main queue by default + print("Download Progress: \(progress.fractionCompleted)") + } + .responseJSON { response in + debugPrint(response) + } +``` + +### Statistical Metrics + +#### Timeline + +Alamofire collects timings throughout the lifecycle of a `Request` and creates a `Timeline` object exposed as a property on all response types. + +```swift +Alamofire.request("https://httpbin.org/get").responseJSON { response in + print(response.timeline) +} +``` + +The above reports the following `Timeline` info: + +- `Latency`: 0.428 seconds +- `Request Duration`: 0.428 seconds +- `Serialization Duration`: 0.001 seconds +- `Total Duration`: 0.429 seconds + +#### URL Session Task Metrics + +In iOS and tvOS 10 and macOS 10.12, Apple introduced the new [URLSessionTaskMetrics](https://developer.apple.com/reference/foundation/urlsessiontaskmetrics) APIs. The task metrics encapsulate some fantastic statistical information about the request and response execution. The API is very similar to the `Timeline`, but provides many more statistics that Alamofire doesn't have access to compute. The metrics can be accessed through any response type. + +```swift +Alamofire.request("https://httpbin.org/get").responseJSON { response in + print(response.metrics) +} +``` + +It's important to note that these APIs are only available on iOS and tvOS 10 and macOS 10.12. Therefore, depending on your deployment target, you may need to use these inside availability checks: + +```swift +Alamofire.request("https://httpbin.org/get").responseJSON { response in + if #available(iOS 10.0. *) { + print(response.metrics) + } +} +``` + +### cURL Command Output + +Debugging platform issues can be frustrating. Thankfully, Alamofire `Request` objects conform to both the `CustomStringConvertible` and `CustomDebugStringConvertible` protocols to provide some VERY helpful debugging tools. + +#### CustomStringConvertible + +```swift +let request = Alamofire.request("https://httpbin.org/ip") + +print(request) +// GET https://httpbin.org/ip (200) +``` + +#### CustomDebugStringConvertible + +```swift +let request = Alamofire.request("https://httpbin.org/get", parameters: ["foo": "bar"]) +debugPrint(request) +``` + +Outputs: + +```bash +$ curl -i \ + -H "User-Agent: Alamofire/4.0.0" \ + -H "Accept-Encoding: gzip;q=1.0, compress;q=0.5" \ + -H "Accept-Language: en;q=1.0,fr;q=0.9,de;q=0.8,zh-Hans;q=0.7,zh-Hant;q=0.6,ja;q=0.5" \ + "https://httpbin.org/get?foo=bar" +``` + +--- + +## Advanced Usage + +Alamofire is built on `URLSession` and the Foundation URL Loading System. To make the most of this framework, it is recommended that you be familiar with the concepts and capabilities of the underlying networking stack. + +**Recommended Reading** + +- [URL Loading System Programming Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html) +- [URLSession Class Reference](https://developer.apple.com/reference/foundation/nsurlsession) +- [URLCache Class Reference](https://developer.apple.com/reference/foundation/urlcache) +- [URLAuthenticationChallenge Class Reference](https://developer.apple.com/reference/foundation/urlauthenticationchallenge) + +### Session Manager + +Top-level convenience methods like `Alamofire.request` use a default instance of `Alamofire.SessionManager`, which is configured with the default `URLSessionConfiguration`. + +As such, the following two statements are equivalent: + +```swift +Alamofire.request("https://httpbin.org/get") +``` + +```swift +let sessionManager = Alamofire.SessionManager.default +sessionManager.request("https://httpbin.org/get") +``` + +Applications can create session managers for background and ephemeral sessions, as well as new managers that customize the default session configuration, such as for default headers (`httpAdditionalHeaders`) or timeout interval (`timeoutIntervalForRequest`). + +#### Creating a Session Manager with Default Configuration + +```swift +let configuration = URLSessionConfiguration.default +let sessionManager = Alamofire.SessionManager(configuration: configuration) +``` + +#### Creating a Session Manager with Background Configuration + +```swift +let configuration = URLSessionConfiguration.background(withIdentifier: "com.example.app.background") +let sessionManager = Alamofire.SessionManager(configuration: configuration) +``` + +#### Creating a Session Manager with Ephemeral Configuration + +```swift +let configuration = URLSessionConfiguration.ephemeral +let sessionManager = Alamofire.SessionManager(configuration: configuration) +``` + +#### Modifying the Session Configuration + +```swift +var defaultHeaders = Alamofire.SessionManager.default.defaultHTTPHeaders +defaultHeaders["DNT"] = "1 (Do Not Track Enabled)" + +let configuration = URLSessionConfiguration.default +configuration.httpAdditionalHeaders = defaultHeaders + +let sessionManager = Alamofire.SessionManager(configuration: configuration) +``` + +> This is **not** recommended for `Authorization` or `Content-Type` headers. Instead, use the `headers` parameter in the top-level `Alamofire.request` APIs, `URLRequestConvertible` and `ParameterEncoding`, respectively. + +### Session Delegate + +By default, an Alamofire `SessionManager` instance creates a `SessionDelegate` object to handle all the various types of delegate callbacks that are generated by the underlying `URLSession`. The implementations of each delegate method handle the most common use cases for these types of calls abstracting the complexity away from the top-level APIs. However, advanced users may find the need to override the default functionality for various reasons. + +#### Override Closures + +The first way to customize the `SessionDelegate` behavior is through the use of the override closures. Each closure gives you the ability to override the implementation of the matching `SessionDelegate` API, yet still use the default implementation for all other APIs. This makes it easy to customize subsets of the delegate functionality. Here are a few examples of some of the override closures available: + +```swift +/// Overrides default behavior for URLSessionDelegate method `urlSession(_:didReceive:completionHandler:)`. +open var sessionDidReceiveChallenge: ((URLSession, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? + +/// Overrides default behavior for URLSessionDelegate method `urlSessionDidFinishEvents(forBackgroundURLSession:)`. +open var sessionDidFinishEventsForBackgroundURLSession: ((URLSession) -> Void)? + +/// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)`. +open var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> URLRequest?)? + +/// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:willCacheResponse:completionHandler:)`. +open var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)? +``` + +The following is a short example of how to use the `taskWillPerformHTTPRedirection` to avoid following redirects to any `apple.com` domains. + +```swift +let sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default) +let delegate: Alamofire.SessionDelegate = sessionManager.delegate + +delegate.taskWillPerformHTTPRedirection = { session, task, response, request in + var finalRequest = request + + if + let originalRequest = task.originalRequest, + let urlString = originalRequest.url?.urlString, + urlString.contains("apple.com") + { + finalRequest = originalRequest + } + + return finalRequest +} +``` + +#### Subclassing + +Another way to override the default implementation of the `SessionDelegate` is to subclass it. Subclassing allows you completely customize the behavior of the API or to create a proxy for the API and still use the default implementation. Creating a proxy allows you to log events, emit notifications, provide pre and post hook implementations, etc. Here's a quick example of subclassing the `SessionDelegate` and logging a message when a redirect occurs. + +```swift +class LoggingSessionDelegate: SessionDelegate { + override func urlSession( + _ session: URLSession, + task: URLSessionTask, + willPerformHTTPRedirection response: HTTPURLResponse, + newRequest request: URLRequest, + completionHandler: @escaping (URLRequest?) -> Void) + { + print("URLSession will perform HTTP redirection to request: \(request)") + + super.urlSession( + session, + task: task, + willPerformHTTPRedirection: response, + newRequest: request, + completionHandler: completionHandler + ) + } +} +``` + +Generally speaking, either the default implementation or the override closures should provide the necessary functionality required. Subclassing should only be used as a last resort. + +> It is important to keep in mind that the `subdelegates` are initialized and destroyed in the default implementation. Be careful when subclassing to not introduce memory leaks. + +### Request + +The result of a `request`, `download`, `upload` or `stream` methods are a `DataRequest`, `DownloadRequest`, `UploadRequest` and `StreamRequest` which all inherit from `Request`. All `Request` instances are always created by an owning session manager, and never initialized directly. + +Each subclass has specialized methods such as `authenticate`, `validate`, `responseJSON` and `uploadProgress` that each return the caller instance in order to facilitate method chaining. + +Requests can be suspended, resumed and cancelled: + +- `suspend()`: Suspends the underlying task and dispatch queue. +- `resume()`: Resumes the underlying task and dispatch queue. If the owning manager does not have `startRequestsImmediately` set to `true`, the request must call `resume()` in order to start. +- `cancel()`: Cancels the underlying task, producing an error that is passed to any registered response handlers. + +### Routing Requests + +As apps grow in size, it's important to adopt common patterns as you build out your network stack. An important part of that design is how to route your requests. The Alamofire `URLConvertible` and `URLRequestConvertible` protocols along with the `Router` design pattern are here to help. + +#### URLConvertible + +Types adopting the `URLConvertible` protocol can be used to construct URLs, which are then used to construct URL requests internally. `String`, `URL`, and `URLComponents` conform to `URLConvertible` by default, allowing any of them to be passed as `url` parameters to the `request`, `upload`, and `download` methods: + +```swift +let urlString = "https://httpbin.org/post" +Alamofire.request(urlString, method: .post) + +let url = URL(string: urlString)! +Alamofire.request(url, method: .post) + +let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: true)! +Alamofire.request(urlComponents, method: .post) +``` + +Applications interacting with web applications in a significant manner are encouraged to have custom types conform to `URLConvertible` as a convenient way to map domain-specific models to server resources. + +##### Type-Safe Routing + +```swift +extension User: URLConvertible { + static let baseURLString = "https://example.com" + + func asURL() throws -> URL { + let urlString = User.baseURLString + "/users/\(username)/" + return try urlString.asURL() + } +} +``` + +```swift +let user = User(username: "mattt") +Alamofire.request(user) // https://example.com/users/mattt +``` + +#### URLRequestConvertible + +Types adopting the `URLRequestConvertible` protocol can be used to construct URL requests. `URLRequest` conforms to `URLRequestConvertible` by default, allowing it to be passed into `request`, `upload`, and `download` methods directly (this is the recommended way to specify custom HTTP body for individual requests): + +```swift +let url = URL(string: "https://httpbin.org/post")! +var urlRequest = URLRequest(url: url) +urlRequest.httpMethod = "POST" + +let parameters = ["foo": "bar"] + +do { + urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: []) +} catch { + // No-op +} + +urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + +Alamofire.request(urlRequest) +``` + +Applications interacting with web applications in a significant manner are encouraged to have custom types conform to `URLRequestConvertible` as a way to ensure consistency of requested endpoints. Such an approach can be used to abstract away server-side inconsistencies and provide type-safe routing, as well as manage authentication credentials and other state. + +##### API Parameter Abstraction + +```swift +enum Router: URLRequestConvertible { + case search(query: String, page: Int) + + static let baseURLString = "https://example.com" + static let perPage = 50 + + // MARK: URLRequestConvertible + + func asURLRequest() throws -> URLRequest { + let result: (path: String, parameters: Parameters) = { + switch self { + case let .search(query, page) where page > 0: + return ("/search", ["q": query, "offset": Router.perPage * page]) + case let .search(query, _): + return ("/search", ["q": query]) + } + }() + + let url = try Router.baseURLString.asURL() + let urlRequest = URLRequest(url: url.appendingPathComponent(result.path)) + + return try URLEncoding.default.encode(urlRequest, with: result.parameters) + } +} +``` + +```swift +Alamofire.request(Router.search(query: "foo bar", page: 1)) // https://example.com/search?q=foo%20bar&offset=50 +``` + +##### CRUD & Authorization + +```swift +import Alamofire + +enum Router: URLRequestConvertible { + case createUser(parameters: Parameters) + case readUser(username: String) + case updateUser(username: String, parameters: Parameters) + case destroyUser(username: String) + + static let baseURLString = "https://example.com" + + var method: HTTPMethod { + switch self { + case .createUser: + return .post + case .readUser: + return .get + case .updateUser: + return .put + case .destroyUser: + return .delete + } + } + + var path: String { + switch self { + case .createUser: + return "/users" + case .readUser(let username): + return "/users/\(username)" + case .updateUser(let username, _): + return "/users/\(username)" + case .destroyUser(let username): + return "/users/\(username)" + } + } + + // MARK: URLRequestConvertible + + func asURLRequest() throws -> URLRequest { + let url = try Router.baseURLString.asURL() + + var urlRequest = URLRequest(url: url.appendingPathComponent(path)) + urlRequest.httpMethod = method.rawValue + + switch self { + case .createUser(let parameters): + urlRequest = try URLEncoding.default.encode(urlRequest, with: parameters) + case .updateUser(_, let parameters): + urlRequest = try URLEncoding.default.encode(urlRequest, with: parameters) + default: + break + } + + return urlRequest + } +} +``` + +```swift +Alamofire.request(Router.readUser("mattt")) // GET https://example.com/users/mattt +``` + +### Adapting and Retrying Requests + +Most web services these days are behind some sort of authentication system. One of the more common ones today is OAuth. This generally involves generating an access token authorizing your application or user to call the various supported web services. While creating these initial access tokens can be laborsome, it can be even more complicated when your access token expires and you need to fetch a new one. There are many thread-safety issues that need to be considered. + +The `RequestAdapter` and `RequestRetrier` protocols were created to make it much easier to create a thread-safe authentication system for a specific set of web services. + +#### RequestAdapter + +The `RequestAdapter` protocol allows each `Request` made on a `SessionManager` to be inspected and adapted before being created. One very specific way to use an adapter is to append an `Authorization` header to requests behind a certain type of authentication. + +```swift +class AccessTokenAdapter: RequestAdapter { + private let accessToken: String + + init(accessToken: String) { + self.accessToken = accessToken + } + + func adapt(_ urlRequest: URLRequest) throws -> URLRequest { + var urlRequest = urlRequest + + if let urlString = urlRequest.url?.absoluteString, urlString.hasPrefix("https://httpbin.org") { + urlRequest.setValue("Bearer " + accessToken, forHTTPHeaderField: "Authorization") + } + + return urlRequest + } +} +``` + +```swift +let sessionManager = SessionManager() +sessionManager.adapter = AccessTokenAdapter(accessToken: "1234") + +sessionManager.request("https://httpbin.org/get") +``` + +#### RequestRetrier + +The `RequestRetrier` protocol allows a `Request` that encountered an `Error` while being executed to be retried. When using both the `RequestAdapter` and `RequestRetrier` protocols together, you can create credential refresh systems for OAuth1, OAuth2, Basic Auth and even exponential backoff retry policies. The possibilities are endless. Here's an example of how you could implement a refresh flow for OAuth2 access tokens. + +> **DISCLAIMER:** This is **NOT** a global `OAuth2` solution. It is merely an example demonstrating how one could use the `RequestAdapter` in conjunction with the `RequestRetrier` to create a thread-safe refresh system. + +> To reiterate, **do NOT copy** this sample code and drop it into a production application. This is merely an example. Each authentication system must be tailored to a particular platform and authentication type. + +```swift +class OAuth2Handler: RequestAdapter, RequestRetrier { + private typealias RefreshCompletion = (_ succeeded: Bool, _ accessToken: String?, _ refreshToken: String?) -> Void + + private let sessionManager: SessionManager = { + let configuration = URLSessionConfiguration.default + configuration.httpAdditionalHeaders = SessionManager.defaultHTTPHeaders + + return SessionManager(configuration: configuration) + }() + + private let lock = NSLock() + + private var clientID: String + private var baseURLString: String + private var accessToken: String + private var refreshToken: String + + private var isRefreshing = false + private var requestsToRetry: [RequestRetryCompletion] = [] + + // MARK: - Initialization + + public init(clientID: String, baseURLString: String, accessToken: String, refreshToken: String) { + self.clientID = clientID + self.baseURLString = baseURLString + self.accessToken = accessToken + self.refreshToken = refreshToken + } + + // MARK: - RequestAdapter + + func adapt(_ urlRequest: URLRequest) throws -> URLRequest { + if let urlString = urlRequest.url?.absoluteString, urlString.hasPrefix(baseURLString) { + var urlRequest = urlRequest + urlRequest.setValue("Bearer " + accessToken, forHTTPHeaderField: "Authorization") + return urlRequest + } + + return urlRequest + } + + // MARK: - RequestRetrier + + func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion) { + lock.lock() ; defer { lock.unlock() } + + if let response = request.task?.response as? HTTPURLResponse, response.statusCode == 401 { + requestsToRetry.append(completion) + + if !isRefreshing { + refreshTokens { [weak self] succeeded, accessToken, refreshToken in + guard let strongSelf = self else { return } + + strongSelf.lock.lock() ; defer { strongSelf.lock.unlock() } + + if let accessToken = accessToken, let refreshToken = refreshToken { + strongSelf.accessToken = accessToken + strongSelf.refreshToken = refreshToken + } + + strongSelf.requestsToRetry.forEach { $0(succeeded, 0.0) } + strongSelf.requestsToRetry.removeAll() + } + } + } else { + completion(false, 0.0) + } + } + + // MARK: - Private - Refresh Tokens + + private func refreshTokens(completion: @escaping RefreshCompletion) { + guard !isRefreshing else { return } + + isRefreshing = true + + let urlString = "\(baseURLString)/oauth2/token" + + let parameters: [String: Any] = [ + "access_token": accessToken, + "refresh_token": refreshToken, + "client_id": clientID, + "grant_type": "refresh_token" + ] + + sessionManager.request(urlString, method: .post, parameters: parameters, encoding: JSONEncoding.default) + .responseJSON { [weak self] response in + guard let strongSelf = self else { return } + + if + let json = response.result.value as? [String: Any], + let accessToken = json["access_token"] as? String, + let refreshToken = json["refresh_token"] as? String + { + completion(true, accessToken, refreshToken) + } else { + completion(false, nil, nil) + } + + strongSelf.isRefreshing = false + } + } +} +``` + +```swift +let baseURLString = "https://some.domain-behind-oauth2.com" + +let oauthHandler = OAuth2Handler( + clientID: "12345678", + baseURLString: baseURLString, + accessToken: "abcd1234", + refreshToken: "ef56789a" +) + +let sessionManager = SessionManager() +sessionManager.adapter = oauthHandler +sessionManager.retrier = oauthHandler + +let urlString = "\(baseURLString)/some/endpoint" + +sessionManager.request(urlString).validate().responseJSON { response in + debugPrint(response) +} +``` + +Once the `OAuth2Handler` is applied as both the `adapter` and `retrier` for the `SessionManager`, it will handle an invalid access token error by automatically refreshing the access token and retrying all failed requests in the same order they failed. + +> If you needed them to execute in the same order they were created, you could sort them by their task identifiers. + +The example above only checks for a `401` response code which is not nearly robust enough, but does demonstrate how one could check for an invalid access token error. In a production application, one would want to check the `realm` and most likely the `www-authenticate` header response although it depends on the OAuth2 implementation. + +Another important note is that this authentication system could be shared between multiple session managers. For example, you may need to use both a `default` and `ephemeral` session configuration for the same set of web services. The example above allows the same `oauthHandler` instance to be shared across multiple session managers to manage the single refresh flow. + +### Custom Response Serialization + +#### Handling Errors + +Before implementing custom response serializers or object serialization methods, it's important to consider how to handle any errors that may occur. There are two basic options: passing existing errors along unmodified, to be dealt with at response time; or, wrapping all errors in an `Error` type specific to your app. + +For example, here's a simple `BackendError` enum which will be used in later examples: + +```swift +enum BackendError: Error { + case network(error: Error) // Capture any underlying Error from the URLSession API + case dataSerialization(error: Error) + case jsonSerialization(error: Error) + case xmlSerialization(error: Error) + case objectSerialization(reason: String) +} +``` + +#### Creating a Custom Response Serializer + +Alamofire provides built-in response serialization for strings, JSON, and property lists, but others can be added in extensions on `Alamofire.DataRequest` and / or `Alamofire.DownloadRequest`. + +For example, here's how a response handler using [Ono](https://github.com/mattt/Ono) might be implemented: + +```swift +extension DataRequest { + static func xmlResponseSerializer() -> DataResponseSerializer { + return DataResponseSerializer { request, response, data, error in + // Pass through any underlying URLSession error to the .network case. + guard error == nil else { return .failure(BackendError.network(error: error!)) } + + // Use Alamofire's existing data serializer to extract the data, passing the error as nil, as it has + // already been handled. + let result = Request.serializeResponseData(response: response, data: data, error: nil) + + guard case let .success(validData) = result else { + return .failure(BackendError.dataSerialization(error: result.error! as! AFError)) + } + + do { + let xml = try ONOXMLDocument(data: validData) + return .success(xml) + } catch { + return .failure(BackendError.xmlSerialization(error: error)) + } + } + } + + @discardableResult + func responseXMLDocument( + queue: DispatchQueue? = nil, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DataRequest.xmlResponseSerializer(), + completionHandler: completionHandler + ) + } +} +``` + +#### Generic Response Object Serialization + +Generics can be used to provide automatic, type-safe response object serialization. + +```swift +protocol ResponseObjectSerializable { + init?(response: HTTPURLResponse, representation: Any) +} + +extension DataRequest { + func responseObject( + queue: DispatchQueue? = nil, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + let responseSerializer = DataResponseSerializer { request, response, data, error in + guard error == nil else { return .failure(BackendError.network(error: error!)) } + + let jsonResponseSerializer = DataRequest.jsonResponseSerializer(options: .allowFragments) + let result = jsonResponseSerializer.serializeResponse(request, response, data, nil) + + guard case let .success(jsonObject) = result else { + return .failure(BackendError.jsonSerialization(error: result.error!)) + } + + guard let response = response, let responseObject = T(response: response, representation: jsonObject) else { + return .failure(BackendError.objectSerialization(reason: "JSON could not be serialized: \(jsonObject)")) + } + + return .success(responseObject) + } + + return response(queue: queue, responseSerializer: responseSerializer, completionHandler: completionHandler) + } +} +``` + +```swift +struct User: ResponseObjectSerializable, CustomStringConvertible { + let username: String + let name: String + + var description: String { + return "User: { username: \(username), name: \(name) }" + } + + init?(response: HTTPURLResponse, representation: Any) { + guard + let username = response.url?.lastPathComponent, + let representation = representation as? [String: Any], + let name = representation["name"] as? String + else { return nil } + + self.username = username + self.name = name + } +} +``` + +```swift +Alamofire.request("https://example.com/users/mattt").responseObject { (response: DataResponse) in + debugPrint(response) + + if let user = response.result.value { + print("User: { username: \(user.username), name: \(user.name) }") + } +} +``` + +The same approach can also be used to handle endpoints that return a representation of a collection of objects: + +```swift +protocol ResponseCollectionSerializable { + static func collection(from response: HTTPURLResponse, withRepresentation representation: Any) -> [Self] +} + +extension ResponseCollectionSerializable where Self: ResponseObjectSerializable { + static func collection(from response: HTTPURLResponse, withRepresentation representation: Any) -> [Self] { + var collection: [Self] = [] + + if let representation = representation as? [[String: Any]] { + for itemRepresentation in representation { + if let item = Self(response: response, representation: itemRepresentation) { + collection.append(item) + } + } + } + + return collection + } +} +``` + +```swift +extension DataRequest { + @discardableResult + func responseCollection( + queue: DispatchQueue? = nil, + completionHandler: @escaping (DataResponse<[T]>) -> Void) -> Self + { + let responseSerializer = DataResponseSerializer<[T]> { request, response, data, error in + guard error == nil else { return .failure(BackendError.network(error: error!)) } + + let jsonSerializer = DataRequest.jsonResponseSerializer(options: .allowFragments) + let result = jsonSerializer.serializeResponse(request, response, data, nil) + + guard case let .success(jsonObject) = result else { + return .failure(BackendError.jsonSerialization(error: result.error!)) + } + + guard let response = response else { + let reason = "Response collection could not be serialized due to nil response." + return .failure(BackendError.objectSerialization(reason: reason)) + } + + return .success(T.collection(from: response, withRepresentation: jsonObject)) + } + + return response(responseSerializer: responseSerializer, completionHandler: completionHandler) + } +} +``` + +```swift +struct User: ResponseObjectSerializable, ResponseCollectionSerializable, CustomStringConvertible { + let username: String + let name: String + + var description: String { + return "User: { username: \(username), name: \(name) }" + } + + init?(response: HTTPURLResponse, representation: Any) { + guard + let username = response.url?.lastPathComponent, + let representation = representation as? [String: Any], + let name = representation["name"] as? String + else { return nil } + + self.username = username + self.name = name + } +} +``` + +```swift +Alamofire.request("https://example.com/users").responseCollection { (response: DataResponse<[User]>) in + debugPrint(response) + + if let users = response.result.value { + users.forEach { print("- \($0)") } + } +} +``` + +### Security + +Using a secure HTTPS connection when communicating with servers and web services is an important step in securing sensitive data. By default, Alamofire will evaluate the certificate chain provided by the server using Apple's built in validation provided by the Security framework. While this guarantees the certificate chain is valid, it does not prevent man-in-the-middle (MITM) attacks or other potential vulnerabilities. In order to mitigate MITM attacks, applications dealing with sensitive customer data or financial information should use certificate or public key pinning provided by the `ServerTrustPolicy`. + +#### ServerTrustPolicy + +The `ServerTrustPolicy` enumeration evaluates the server trust generally provided by an `URLAuthenticationChallenge` when connecting to a server over a secure HTTPS connection. + +```swift +let serverTrustPolicy = ServerTrustPolicy.pinCertificates( + certificates: ServerTrustPolicy.certificatesInBundle(), + validateCertificateChain: true, + validateHost: true +) +``` + +There are many different cases of server trust evaluation giving you complete control over the validation process: + +* `performDefaultEvaluation`: Uses the default server trust evaluation while allowing you to control whether to validate the host provided by the challenge. +* `pinCertificates`: Uses the pinned certificates to validate the server trust. The server trust is considered valid if one of the pinned certificates match one of the server certificates. +* `pinPublicKeys`: Uses the pinned public keys to validate the server trust. The server trust is considered valid if one of the pinned public keys match one of the server certificate public keys. +* `disableEvaluation`: Disables all evaluation which in turn will always consider any server trust as valid. +* `customEvaluation`: Uses the associated closure to evaluate the validity of the server trust thus giving you complete control over the validation process. Use with caution. + +#### Server Trust Policy Manager + +The `ServerTrustPolicyManager` is responsible for storing an internal mapping of server trust policies to a particular host. This allows Alamofire to evaluate each host against a different server trust policy. + +```swift +let serverTrustPolicies: [String: ServerTrustPolicy] = [ + "test.example.com": .pinCertificates( + certificates: ServerTrustPolicy.certificatesInBundle(), + validateCertificateChain: true, + validateHost: true + ), + "insecure.expired-apis.com": .disableEvaluation +] + +let sessionManager = SessionManager( + serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies) +) +``` + +> Make sure to keep a reference to the new `SessionManager` instance, otherwise your requests will all get cancelled when your `sessionManager` is deallocated. + +These server trust policies will result in the following behavior: + +- `test.example.com` will always use certificate pinning with certificate chain and host validation enabled thus requiring the following criteria to be met to allow the TLS handshake to succeed: + - Certificate chain MUST be valid. + - Certificate chain MUST include one of the pinned certificates. + - Challenge host MUST match the host in the certificate chain's leaf certificate. +- `insecure.expired-apis.com` will never evaluate the certificate chain and will always allow the TLS handshake to succeed. +- All other hosts will use the default evaluation provided by Apple. + +##### Subclassing Server Trust Policy Manager + +If you find yourself needing more flexible server trust policy matching behavior (i.e. wildcarded domains), then subclass the `ServerTrustPolicyManager` and override the `serverTrustPolicyForHost` method with your own custom implementation. + +```swift +class CustomServerTrustPolicyManager: ServerTrustPolicyManager { + override func serverTrustPolicy(forHost host: String) -> ServerTrustPolicy? { + var policy: ServerTrustPolicy? + + // Implement your custom domain matching behavior... + + return policy + } +} +``` + +#### Validating the Host + +The `.performDefaultEvaluation`, `.pinCertificates` and `.pinPublicKeys` server trust policies all take a `validateHost` parameter. Setting the value to `true` will cause the server trust evaluation to verify that hostname in the certificate matches the hostname of the challenge. If they do not match, evaluation will fail. A `validateHost` value of `false` will still evaluate the full certificate chain, but will not validate the hostname of the leaf certificate. + +> It is recommended that `validateHost` always be set to `true` in production environments. + +#### Validating the Certificate Chain + +Pinning certificates and public keys both have the option of validating the certificate chain using the `validateCertificateChain` parameter. By setting this value to `true`, the full certificate chain will be evaluated in addition to performing a byte equality check against the pinned certificates or public keys. A value of `false` will skip the certificate chain validation, but will still perform the byte equality check. + +There are several cases where it may make sense to disable certificate chain validation. The most common use cases for disabling validation are self-signed and expired certificates. The evaluation would always fail in both of these cases, but the byte equality check will still ensure you are receiving the certificate you expect from the server. + +> It is recommended that `validateCertificateChain` always be set to `true` in production environments. + +#### App Transport Security + +With the addition of App Transport Security (ATS) in iOS 9, it is possible that using a custom `ServerTrustPolicyManager` with several `ServerTrustPolicy` objects will have no effect. If you continuously see `CFNetwork SSLHandshake failed (-9806)` errors, you have probably run into this problem. Apple's ATS system overrides the entire challenge system unless you configure the ATS settings in your app's plist to disable enough of it to allow your app to evaluate the server trust. + +If you run into this problem (high probability with self-signed certificates), you can work around this issue by adding the following to your `Info.plist`. + +```xml + + NSAppTransportSecurity + + NSExceptionDomains + + example.com + + NSExceptionAllowsInsecureHTTPLoads + + NSExceptionRequiresForwardSecrecy + + NSIncludesSubdomains + + + NSTemporaryExceptionMinimumTLSVersion + TLSv1.2 + + + + +``` + +Whether you need to set the `NSExceptionRequiresForwardSecrecy` to `NO` depends on whether your TLS connection is using an allowed cipher suite. In certain cases, it will need to be set to `NO`. The `NSExceptionAllowsInsecureHTTPLoads` MUST be set to `YES` in order to allow the `SessionDelegate` to receive challenge callbacks. Once the challenge callbacks are being called, the `ServerTrustPolicyManager` will take over the server trust evaluation. You may also need to specify the `NSTemporaryExceptionMinimumTLSVersion` if you're trying to connect to a host that only supports TLS versions less than `1.2`. + +> It is recommended to always use valid certificates in production environments. + +### Network Reachability + +The `NetworkReachabilityManager` listens for reachability changes of hosts and addresses for both WWAN and WiFi network interfaces. + +```swift +let manager = NetworkReachabilityManager(host: "www.apple.com") + +manager?.listener = { status in + print("Network Status Changed: \(status)") +} + +manager?.startListening() +``` + +> Make sure to remember to retain the `manager` in the above example, or no status changes will be reported. + +There are some important things to remember when using network reachability to determine what to do next. + +- **Do NOT** use Reachability to determine if a network request should be sent. + - You should **ALWAYS** send it. +- When Reachability is restored, use the event to retry failed network requests. + - Even though the network requests may still fail, this is a good moment to retry them. +- The network reachability status can be useful for determining why a network request may have failed. + - If a network request fails, it is more useful to tell the user that the network request failed due to being offline rather than a more technical error, such as "request timed out." + +> It is recommended to check out [WWDC 2012 Session 706, "Networking Best Practices"](https://developer.apple.com/videos/play/wwdc2012-706/) for more info. + +--- + +## Open Radars + +The following radars have some effect on the current implementation of Alamofire. + +- [`rdar://21349340`](http://www.openradar.me/radar?id=5517037090635776) - Compiler throwing warning due to toll-free bridging issue in test case +- [`rdar://26761490`](http://www.openradar.me/radar?id=5010235949318144) - Swift string interpolation causing memory leak with common usage +- `rdar://26870455` - Background URL Session Configurations do not work in the simulator +- `rdar://26849668` - Some URLProtocol APIs do not properly handle `URLRequest` + +## FAQ + +### What's the origin of the name Alamofire? + +Alamofire is named after the [Alamo Fire flower](https://aggie-horticulture.tamu.edu/wildseed/alamofire.html), a hybrid variant of the Bluebonnet, the official state flower of Texas. + +### What logic belongs in a Router vs. a Request Adapter? + +Simple, static data such as paths, parameters and common headers belong in the `Router`. Dynamic data such as an `Authorization` header whose value can changed based on an authentication system belongs in a `RequestAdapter`. + +The reason the dynamic data MUST be placed into the `RequestAdapter` is to support retry operations. When a `Request` is retried, the original request is not rebuilt meaning the `Router` will not be called again. The `RequestAdapter` is called again allowing the dynamic data to be updated on the original request before retrying the `Request`. + +--- + +## Credits + +Alamofire is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). You can follow them on Twitter at [@AlamofireSF](https://twitter.com/AlamofireSF) for project updates and releases. + +### Security Disclosure + +If you believe you have identified a security vulnerability with Alamofire, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## Donations + +The [ASF](https://github.com/Alamofire/Foundation#members) is looking to raise money to officially register as a federal non-profit organization. Registering will allow us members to gain some legal protections and also allow us to put donations to use, tax free. Donating to the ASF will enable us to: + +- Pay our legal fees to register as a federal non-profit organization +- Pay our yearly legal fees to keep the non-profit in good status +- Pay for our mail servers to help us stay on top of all questions and security issues +- Potentially fund test servers to make it easier for us to test the edge cases +- Potentially fund developers to work on one of our projects full-time + +The community adoption of the ASF libraries has been amazing. We are greatly humbled by your enthusiasm around the projects, and want to continue to do everything we can to move the needle forward. With your continued support, the ASF will be able to improve its reach and also provide better legal safety for the core members. If you use any of our libraries for work, see if your employers would be interested in donating. Our initial goal is to raise $1000 to get all our legal ducks in a row and kickstart this campaign. Any amount you can donate today to help us reach our goal would be greatly appreciated. + +Click here to lend your support to: Alamofire Software Foundation and make a donation at pledgie.com ! + +## License + +Alamofire is released under the MIT license. See LICENSE for details. diff --git a/Pods/Alamofire/Source/AFError.swift b/Pods/Alamofire/Source/AFError.swift new file mode 100644 index 0000000..f047695 --- /dev/null +++ b/Pods/Alamofire/Source/AFError.swift @@ -0,0 +1,460 @@ +// +// AFError.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// `AFError` is the error type returned by Alamofire. It encompasses a few different types of errors, each with +/// their own associated reasons. +/// +/// - invalidURL: Returned when a `URLConvertible` type fails to create a valid `URL`. +/// - parameterEncodingFailed: Returned when a parameter encoding object throws an error during the encoding process. +/// - multipartEncodingFailed: Returned when some step in the multipart encoding process fails. +/// - responseValidationFailed: Returned when a `validate()` call fails. +/// - responseSerializationFailed: Returned when a response serializer encounters an error in the serialization process. +public enum AFError: Error { + /// The underlying reason the parameter encoding error occurred. + /// + /// - missingURL: The URL request did not have a URL to encode. + /// - jsonEncodingFailed: JSON serialization failed with an underlying system error during the + /// encoding process. + /// - propertyListEncodingFailed: Property list serialization failed with an underlying system error during + /// encoding process. + public enum ParameterEncodingFailureReason { + case missingURL + case jsonEncodingFailed(error: Error) + case propertyListEncodingFailed(error: Error) + } + + /// The underlying reason the multipart encoding error occurred. + /// + /// - bodyPartURLInvalid: The `fileURL` provided for reading an encodable body part isn't a + /// file URL. + /// - bodyPartFilenameInvalid: The filename of the `fileURL` provided has either an empty + /// `lastPathComponent` or `pathExtension. + /// - bodyPartFileNotReachable: The file at the `fileURL` provided was not reachable. + /// - bodyPartFileNotReachableWithError: Attempting to check the reachability of the `fileURL` provided threw + /// an error. + /// - bodyPartFileIsDirectory: The file at the `fileURL` provided is actually a directory. + /// - bodyPartFileSizeNotAvailable: The size of the file at the `fileURL` provided was not returned by + /// the system. + /// - bodyPartFileSizeQueryFailedWithError: The attempt to find the size of the file at the `fileURL` provided + /// threw an error. + /// - bodyPartInputStreamCreationFailed: An `InputStream` could not be created for the provided `fileURL`. + /// - outputStreamCreationFailed: An `OutputStream` could not be created when attempting to write the + /// encoded data to disk. + /// - outputStreamFileAlreadyExists: The encoded body data could not be writtent disk because a file + /// already exists at the provided `fileURL`. + /// - outputStreamURLInvalid: The `fileURL` provided for writing the encoded body data to disk is + /// not a file URL. + /// - outputStreamWriteFailed: The attempt to write the encoded body data to disk failed with an + /// underlying error. + /// - inputStreamReadFailed: The attempt to read an encoded body part `InputStream` failed with + /// underlying system error. + public enum MultipartEncodingFailureReason { + case bodyPartURLInvalid(url: URL) + case bodyPartFilenameInvalid(in: URL) + case bodyPartFileNotReachable(at: URL) + case bodyPartFileNotReachableWithError(atURL: URL, error: Error) + case bodyPartFileIsDirectory(at: URL) + case bodyPartFileSizeNotAvailable(at: URL) + case bodyPartFileSizeQueryFailedWithError(forURL: URL, error: Error) + case bodyPartInputStreamCreationFailed(for: URL) + + case outputStreamCreationFailed(for: URL) + case outputStreamFileAlreadyExists(at: URL) + case outputStreamURLInvalid(url: URL) + case outputStreamWriteFailed(error: Error) + + case inputStreamReadFailed(error: Error) + } + + /// The underlying reason the response validation error occurred. + /// + /// - dataFileNil: The data file containing the server response did not exist. + /// - dataFileReadFailed: The data file containing the server response could not be read. + /// - missingContentType: The response did not contain a `Content-Type` and the `acceptableContentTypes` + /// provided did not contain wildcard type. + /// - unacceptableContentType: The response `Content-Type` did not match any type in the provided + /// `acceptableContentTypes`. + /// - unacceptableStatusCode: The response status code was not acceptable. + public enum ResponseValidationFailureReason { + case dataFileNil + case dataFileReadFailed(at: URL) + case missingContentType(acceptableContentTypes: [String]) + case unacceptableContentType(acceptableContentTypes: [String], responseContentType: String) + case unacceptableStatusCode(code: Int) + } + + /// The underlying reason the response serialization error occurred. + /// + /// - inputDataNil: The server response contained no data. + /// - inputDataNilOrZeroLength: The server response contained no data or the data was zero length. + /// - inputFileNil: The file containing the server response did not exist. + /// - inputFileReadFailed: The file containing the server response could not be read. + /// - stringSerializationFailed: String serialization failed using the provided `String.Encoding`. + /// - jsonSerializationFailed: JSON serialization failed with an underlying system error. + /// - propertyListSerializationFailed: Property list serialization failed with an underlying system error. + public enum ResponseSerializationFailureReason { + case inputDataNil + case inputDataNilOrZeroLength + case inputFileNil + case inputFileReadFailed(at: URL) + case stringSerializationFailed(encoding: String.Encoding) + case jsonSerializationFailed(error: Error) + case propertyListSerializationFailed(error: Error) + } + + case invalidURL(url: URLConvertible) + case parameterEncodingFailed(reason: ParameterEncodingFailureReason) + case multipartEncodingFailed(reason: MultipartEncodingFailureReason) + case responseValidationFailed(reason: ResponseValidationFailureReason) + case responseSerializationFailed(reason: ResponseSerializationFailureReason) +} + +// MARK: - Adapt Error + +struct AdaptError: Error { + let error: Error +} + +extension Error { + var underlyingAdaptError: Error? { return (self as? AdaptError)?.error } +} + +// MARK: - Error Booleans + +extension AFError { + /// Returns whether the AFError is an invalid URL error. + public var isInvalidURLError: Bool { + if case .invalidURL = self { return true } + return false + } + + /// Returns whether the AFError is a parameter encoding error. When `true`, the `underlyingError` property will + /// contain the associated value. + public var isParameterEncodingError: Bool { + if case .parameterEncodingFailed = self { return true } + return false + } + + /// Returns whether the AFError is a multipart encoding error. When `true`, the `url` and `underlyingError` properties + /// will contain the associated values. + public var isMultipartEncodingError: Bool { + if case .multipartEncodingFailed = self { return true } + return false + } + + /// Returns whether the `AFError` is a response validation error. When `true`, the `acceptableContentTypes`, + /// `responseContentType`, and `responseCode` properties will contain the associated values. + public var isResponseValidationError: Bool { + if case .responseValidationFailed = self { return true } + return false + } + + /// Returns whether the `AFError` is a response serialization error. When `true`, the `failedStringEncoding` and + /// `underlyingError` properties will contain the associated values. + public var isResponseSerializationError: Bool { + if case .responseSerializationFailed = self { return true } + return false + } +} + +// MARK: - Convenience Properties + +extension AFError { + /// The `URLConvertible` associated with the error. + public var urlConvertible: URLConvertible? { + switch self { + case .invalidURL(let url): + return url + default: + return nil + } + } + + /// The `URL` associated with the error. + public var url: URL? { + switch self { + case .multipartEncodingFailed(let reason): + return reason.url + default: + return nil + } + } + + /// The `Error` returned by a system framework associated with a `.parameterEncodingFailed`, + /// `.multipartEncodingFailed` or `.responseSerializationFailed` error. + public var underlyingError: Error? { + switch self { + case .parameterEncodingFailed(let reason): + return reason.underlyingError + case .multipartEncodingFailed(let reason): + return reason.underlyingError + case .responseSerializationFailed(let reason): + return reason.underlyingError + default: + return nil + } + } + + /// The acceptable `Content-Type`s of a `.responseValidationFailed` error. + public var acceptableContentTypes: [String]? { + switch self { + case .responseValidationFailed(let reason): + return reason.acceptableContentTypes + default: + return nil + } + } + + /// The response `Content-Type` of a `.responseValidationFailed` error. + public var responseContentType: String? { + switch self { + case .responseValidationFailed(let reason): + return reason.responseContentType + default: + return nil + } + } + + /// The response code of a `.responseValidationFailed` error. + public var responseCode: Int? { + switch self { + case .responseValidationFailed(let reason): + return reason.responseCode + default: + return nil + } + } + + /// The `String.Encoding` associated with a failed `.stringResponse()` call. + public var failedStringEncoding: String.Encoding? { + switch self { + case .responseSerializationFailed(let reason): + return reason.failedStringEncoding + default: + return nil + } + } +} + +extension AFError.ParameterEncodingFailureReason { + var underlyingError: Error? { + switch self { + case .jsonEncodingFailed(let error), .propertyListEncodingFailed(let error): + return error + default: + return nil + } + } +} + +extension AFError.MultipartEncodingFailureReason { + var url: URL? { + switch self { + case .bodyPartURLInvalid(let url), .bodyPartFilenameInvalid(let url), .bodyPartFileNotReachable(let url), + .bodyPartFileIsDirectory(let url), .bodyPartFileSizeNotAvailable(let url), + .bodyPartInputStreamCreationFailed(let url), .outputStreamCreationFailed(let url), + .outputStreamFileAlreadyExists(let url), .outputStreamURLInvalid(let url), + .bodyPartFileNotReachableWithError(let url, _), .bodyPartFileSizeQueryFailedWithError(let url, _): + return url + default: + return nil + } + } + + var underlyingError: Error? { + switch self { + case .bodyPartFileNotReachableWithError(_, let error), .bodyPartFileSizeQueryFailedWithError(_, let error), + .outputStreamWriteFailed(let error), .inputStreamReadFailed(let error): + return error + default: + return nil + } + } +} + +extension AFError.ResponseValidationFailureReason { + var acceptableContentTypes: [String]? { + switch self { + case .missingContentType(let types), .unacceptableContentType(let types, _): + return types + default: + return nil + } + } + + var responseContentType: String? { + switch self { + case .unacceptableContentType(_, let responseType): + return responseType + default: + return nil + } + } + + var responseCode: Int? { + switch self { + case .unacceptableStatusCode(let code): + return code + default: + return nil + } + } +} + +extension AFError.ResponseSerializationFailureReason { + var failedStringEncoding: String.Encoding? { + switch self { + case .stringSerializationFailed(let encoding): + return encoding + default: + return nil + } + } + + var underlyingError: Error? { + switch self { + case .jsonSerializationFailed(let error), .propertyListSerializationFailed(let error): + return error + default: + return nil + } + } +} + +// MARK: - Error Descriptions + +extension AFError: LocalizedError { + public var errorDescription: String? { + switch self { + case .invalidURL(let url): + return "URL is not valid: \(url)" + case .parameterEncodingFailed(let reason): + return reason.localizedDescription + case .multipartEncodingFailed(let reason): + return reason.localizedDescription + case .responseValidationFailed(let reason): + return reason.localizedDescription + case .responseSerializationFailed(let reason): + return reason.localizedDescription + } + } +} + +extension AFError.ParameterEncodingFailureReason { + var localizedDescription: String { + switch self { + case .missingURL: + return "URL request to encode was missing a URL" + case .jsonEncodingFailed(let error): + return "JSON could not be encoded because of error:\n\(error.localizedDescription)" + case .propertyListEncodingFailed(let error): + return "PropertyList could not be encoded because of error:\n\(error.localizedDescription)" + } + } +} + +extension AFError.MultipartEncodingFailureReason { + var localizedDescription: String { + switch self { + case .bodyPartURLInvalid(let url): + return "The URL provided is not a file URL: \(url)" + case .bodyPartFilenameInvalid(let url): + return "The URL provided does not have a valid filename: \(url)" + case .bodyPartFileNotReachable(let url): + return "The URL provided is not reachable: \(url)" + case .bodyPartFileNotReachableWithError(let url, let error): + return ( + "The system returned an error while checking the provided URL for " + + "reachability.\nURL: \(url)\nError: \(error)" + ) + case .bodyPartFileIsDirectory(let url): + return "The URL provided is a directory: \(url)" + case .bodyPartFileSizeNotAvailable(let url): + return "Could not fetch the file size from the provided URL: \(url)" + case .bodyPartFileSizeQueryFailedWithError(let url, let error): + return ( + "The system returned an error while attempting to fetch the file size from the " + + "provided URL.\nURL: \(url)\nError: \(error)" + ) + case .bodyPartInputStreamCreationFailed(let url): + return "Failed to create an InputStream for the provided URL: \(url)" + case .outputStreamCreationFailed(let url): + return "Failed to create an OutputStream for URL: \(url)" + case .outputStreamFileAlreadyExists(let url): + return "A file already exists at the provided URL: \(url)" + case .outputStreamURLInvalid(let url): + return "The provided OutputStream URL is invalid: \(url)" + case .outputStreamWriteFailed(let error): + return "OutputStream write failed with error: \(error)" + case .inputStreamReadFailed(let error): + return "InputStream read failed with error: \(error)" + } + } +} + +extension AFError.ResponseSerializationFailureReason { + var localizedDescription: String { + switch self { + case .inputDataNil: + return "Response could not be serialized, input data was nil." + case .inputDataNilOrZeroLength: + return "Response could not be serialized, input data was nil or zero length." + case .inputFileNil: + return "Response could not be serialized, input file was nil." + case .inputFileReadFailed(let url): + return "Response could not be serialized, input file could not be read: \(url)." + case .stringSerializationFailed(let encoding): + return "String could not be serialized with encoding: \(encoding)." + case .jsonSerializationFailed(let error): + return "JSON could not be serialized because of error:\n\(error.localizedDescription)" + case .propertyListSerializationFailed(let error): + return "PropertyList could not be serialized because of error:\n\(error.localizedDescription)" + } + } +} + +extension AFError.ResponseValidationFailureReason { + var localizedDescription: String { + switch self { + case .dataFileNil: + return "Response could not be validated, data file was nil." + case .dataFileReadFailed(let url): + return "Response could not be validated, data file could not be read: \(url)." + case .missingContentType(let types): + return ( + "Response Content-Type was missing and acceptable content types " + + "(\(types.joined(separator: ","))) do not match \"*/*\"." + ) + case .unacceptableContentType(let acceptableTypes, let responseType): + return ( + "Response Content-Type \"\(responseType)\" does not match any acceptable types: " + + "\(acceptableTypes.joined(separator: ","))." + ) + case .unacceptableStatusCode(let code): + return "Response status code was unacceptable: \(code)." + } + } +} diff --git a/Pods/Alamofire/Source/Alamofire.swift b/Pods/Alamofire/Source/Alamofire.swift new file mode 100644 index 0000000..86d54d8 --- /dev/null +++ b/Pods/Alamofire/Source/Alamofire.swift @@ -0,0 +1,465 @@ +// +// Alamofire.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Types adopting the `URLConvertible` protocol can be used to construct URLs, which are then used to construct +/// URL requests. +public protocol URLConvertible { + /// Returns a URL that conforms to RFC 2396 or throws an `Error`. + /// + /// - throws: An `Error` if the type cannot be converted to a `URL`. + /// + /// - returns: A URL or throws an `Error`. + func asURL() throws -> URL +} + +extension String: URLConvertible { + /// Returns a URL if `self` represents a valid URL string that conforms to RFC 2396 or throws an `AFError`. + /// + /// - throws: An `AFError.invalidURL` if `self` is not a valid URL string. + /// + /// - returns: A URL or throws an `AFError`. + public func asURL() throws -> URL { + guard let url = URL(string: self) else { throw AFError.invalidURL(url: self) } + return url + } +} + +extension URL: URLConvertible { + /// Returns self. + public func asURL() throws -> URL { return self } +} + +extension URLComponents: URLConvertible { + /// Returns a URL if `url` is not nil, otherise throws an `Error`. + /// + /// - throws: An `AFError.invalidURL` if `url` is `nil`. + /// + /// - returns: A URL or throws an `AFError`. + public func asURL() throws -> URL { + guard let url = url else { throw AFError.invalidURL(url: self) } + return url + } +} + +// MARK: - + +/// Types adopting the `URLRequestConvertible` protocol can be used to construct URL requests. +public protocol URLRequestConvertible { + /// Returns a URL request or throws if an `Error` was encountered. + /// + /// - throws: An `Error` if the underlying `URLRequest` is `nil`. + /// + /// - returns: A URL request. + func asURLRequest() throws -> URLRequest +} + +extension URLRequestConvertible { + /// The URL request. + public var urlRequest: URLRequest? { return try? asURLRequest() } +} + +extension URLRequest: URLRequestConvertible { + /// Returns a URL request or throws if an `Error` was encountered. + public func asURLRequest() throws -> URLRequest { return self } +} + +// MARK: - + +extension URLRequest { + /// Creates an instance with the specified `method`, `urlString` and `headers`. + /// + /// - parameter url: The URL. + /// - parameter method: The HTTP method. + /// - parameter headers: The HTTP headers. `nil` by default. + /// + /// - returns: The new `URLRequest` instance. + public init(url: URLConvertible, method: HTTPMethod, headers: HTTPHeaders? = nil) throws { + let url = try url.asURL() + + self.init(url: url) + + httpMethod = method.rawValue + + if let headers = headers { + for (headerField, headerValue) in headers { + setValue(headerValue, forHTTPHeaderField: headerField) + } + } + } + + func adapt(using adapter: RequestAdapter?) throws -> URLRequest { + guard let adapter = adapter else { return self } + return try adapter.adapt(self) + } +} + +// MARK: - Data Request + +/// Creates a `DataRequest` using the default `SessionManager` to retrieve the contents of the specified `url`, +/// `method`, `parameters`, `encoding` and `headers`. +/// +/// - parameter url: The URL. +/// - parameter method: The HTTP method. `.get` by default. +/// - parameter parameters: The parameters. `nil` by default. +/// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. +/// - parameter headers: The HTTP headers. `nil` by default. +/// +/// - returns: The created `DataRequest`. +@discardableResult +public func request( + _ url: URLConvertible, + method: HTTPMethod = .get, + parameters: Parameters? = nil, + encoding: ParameterEncoding = URLEncoding.default, + headers: HTTPHeaders? = nil) + -> DataRequest +{ + return SessionManager.default.request( + url, + method: method, + parameters: parameters, + encoding: encoding, + headers: headers + ) +} + +/// Creates a `DataRequest` using the default `SessionManager` to retrieve the contents of a URL based on the +/// specified `urlRequest`. +/// +/// - parameter urlRequest: The URL request +/// +/// - returns: The created `DataRequest`. +@discardableResult +public func request(_ urlRequest: URLRequestConvertible) -> DataRequest { + return SessionManager.default.request(urlRequest) +} + +// MARK: - Download Request + +// MARK: URL Request + +/// Creates a `DownloadRequest` using the default `SessionManager` to retrieve the contents of the specified `url`, +/// `method`, `parameters`, `encoding`, `headers` and save them to the `destination`. +/// +/// If `destination` is not specified, the contents will remain in the temporary location determined by the +/// underlying URL session. +/// +/// - parameter url: The URL. +/// - parameter method: The HTTP method. `.get` by default. +/// - parameter parameters: The parameters. `nil` by default. +/// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. +/// - parameter headers: The HTTP headers. `nil` by default. +/// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. +/// +/// - returns: The created `DownloadRequest`. +@discardableResult +public func download( + _ url: URLConvertible, + method: HTTPMethod = .get, + parameters: Parameters? = nil, + encoding: ParameterEncoding = URLEncoding.default, + headers: HTTPHeaders? = nil, + to destination: DownloadRequest.DownloadFileDestination? = nil) + -> DownloadRequest +{ + return SessionManager.default.download( + url, + method: method, + parameters: parameters, + encoding: encoding, + headers: headers, + to: destination + ) +} + +/// Creates a `DownloadRequest` using the default `SessionManager` to retrieve the contents of a URL based on the +/// specified `urlRequest` and save them to the `destination`. +/// +/// If `destination` is not specified, the contents will remain in the temporary location determined by the +/// underlying URL session. +/// +/// - parameter urlRequest: The URL request. +/// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. +/// +/// - returns: The created `DownloadRequest`. +@discardableResult +public func download( + _ urlRequest: URLRequestConvertible, + to destination: DownloadRequest.DownloadFileDestination? = nil) + -> DownloadRequest +{ + return SessionManager.default.download(urlRequest, to: destination) +} + +// MARK: Resume Data + +/// Creates a `DownloadRequest` using the default `SessionManager` from the `resumeData` produced from a +/// previous request cancellation to retrieve the contents of the original request and save them to the `destination`. +/// +/// If `destination` is not specified, the contents will remain in the temporary location determined by the +/// underlying URL session. +/// +/// On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken +/// on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the +/// data is written incorrectly and will always fail to resume the download. For more information about the bug and +/// possible workarounds, please refer to the following Stack Overflow post: +/// +/// - http://stackoverflow.com/a/39347461/1342462 +/// +/// - parameter resumeData: The resume data. This is an opaque data blob produced by `URLSessionDownloadTask` +/// when a task is cancelled. See `URLSession -downloadTask(withResumeData:)` for additional +/// information. +/// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. +/// +/// - returns: The created `DownloadRequest`. +@discardableResult +public func download( + resumingWith resumeData: Data, + to destination: DownloadRequest.DownloadFileDestination? = nil) + -> DownloadRequest +{ + return SessionManager.default.download(resumingWith: resumeData, to: destination) +} + +// MARK: - Upload Request + +// MARK: File + +/// Creates an `UploadRequest` using the default `SessionManager` from the specified `url`, `method` and `headers` +/// for uploading the `file`. +/// +/// - parameter file: The file to upload. +/// - parameter url: The URL. +/// - parameter method: The HTTP method. `.post` by default. +/// - parameter headers: The HTTP headers. `nil` by default. +/// +/// - returns: The created `UploadRequest`. +@discardableResult +public func upload( + _ fileURL: URL, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil) + -> UploadRequest +{ + return SessionManager.default.upload(fileURL, to: url, method: method, headers: headers) +} + +/// Creates a `UploadRequest` using the default `SessionManager` from the specified `urlRequest` for +/// uploading the `file`. +/// +/// - parameter file: The file to upload. +/// - parameter urlRequest: The URL request. +/// +/// - returns: The created `UploadRequest`. +@discardableResult +public func upload(_ fileURL: URL, with urlRequest: URLRequestConvertible) -> UploadRequest { + return SessionManager.default.upload(fileURL, with: urlRequest) +} + +// MARK: Data + +/// Creates an `UploadRequest` using the default `SessionManager` from the specified `url`, `method` and `headers` +/// for uploading the `data`. +/// +/// - parameter data: The data to upload. +/// - parameter url: The URL. +/// - parameter method: The HTTP method. `.post` by default. +/// - parameter headers: The HTTP headers. `nil` by default. +/// +/// - returns: The created `UploadRequest`. +@discardableResult +public func upload( + _ data: Data, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil) + -> UploadRequest +{ + return SessionManager.default.upload(data, to: url, method: method, headers: headers) +} + +/// Creates an `UploadRequest` using the default `SessionManager` from the specified `urlRequest` for +/// uploading the `data`. +/// +/// - parameter data: The data to upload. +/// - parameter urlRequest: The URL request. +/// +/// - returns: The created `UploadRequest`. +@discardableResult +public func upload(_ data: Data, with urlRequest: URLRequestConvertible) -> UploadRequest { + return SessionManager.default.upload(data, with: urlRequest) +} + +// MARK: InputStream + +/// Creates an `UploadRequest` using the default `SessionManager` from the specified `url`, `method` and `headers` +/// for uploading the `stream`. +/// +/// - parameter stream: The stream to upload. +/// - parameter url: The URL. +/// - parameter method: The HTTP method. `.post` by default. +/// - parameter headers: The HTTP headers. `nil` by default. +/// +/// - returns: The created `UploadRequest`. +@discardableResult +public func upload( + _ stream: InputStream, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil) + -> UploadRequest +{ + return SessionManager.default.upload(stream, to: url, method: method, headers: headers) +} + +/// Creates an `UploadRequest` using the default `SessionManager` from the specified `urlRequest` for +/// uploading the `stream`. +/// +/// - parameter urlRequest: The URL request. +/// - parameter stream: The stream to upload. +/// +/// - returns: The created `UploadRequest`. +@discardableResult +public func upload(_ stream: InputStream, with urlRequest: URLRequestConvertible) -> UploadRequest { + return SessionManager.default.upload(stream, with: urlRequest) +} + +// MARK: MultipartFormData + +/// Encodes `multipartFormData` using `encodingMemoryThreshold` with the default `SessionManager` and calls +/// `encodingCompletion` with new `UploadRequest` using the `url`, `method` and `headers`. +/// +/// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative +/// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most +/// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to +/// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory +/// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be +/// used for larger payloads such as video content. +/// +/// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory +/// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, +/// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk +/// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding +/// technique was used. +/// +/// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. +/// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. +/// `multipartFormDataEncodingMemoryThreshold` by default. +/// - parameter url: The URL. +/// - parameter method: The HTTP method. `.post` by default. +/// - parameter headers: The HTTP headers. `nil` by default. +/// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. +public func upload( + multipartFormData: @escaping (MultipartFormData) -> Void, + usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil, + encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?) +{ + return SessionManager.default.upload( + multipartFormData: multipartFormData, + usingThreshold: encodingMemoryThreshold, + to: url, + method: method, + headers: headers, + encodingCompletion: encodingCompletion + ) +} + +/// Encodes `multipartFormData` using `encodingMemoryThreshold` and the default `SessionManager` and +/// calls `encodingCompletion` with new `UploadRequest` using the `urlRequest`. +/// +/// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative +/// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most +/// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to +/// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory +/// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be +/// used for larger payloads such as video content. +/// +/// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory +/// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, +/// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk +/// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding +/// technique was used. +/// +/// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. +/// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. +/// `multipartFormDataEncodingMemoryThreshold` by default. +/// - parameter urlRequest: The URL request. +/// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. +public func upload( + multipartFormData: @escaping (MultipartFormData) -> Void, + usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, + with urlRequest: URLRequestConvertible, + encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?) +{ + return SessionManager.default.upload( + multipartFormData: multipartFormData, + usingThreshold: encodingMemoryThreshold, + with: urlRequest, + encodingCompletion: encodingCompletion + ) +} + +#if !os(watchOS) + +// MARK: - Stream Request + +// MARK: Hostname and Port + +/// Creates a `StreamRequest` using the default `SessionManager` for bidirectional streaming with the `hostname` +/// and `port`. +/// +/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. +/// +/// - parameter hostName: The hostname of the server to connect to. +/// - parameter port: The port of the server to connect to. +/// +/// - returns: The created `StreamRequest`. +@discardableResult +@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) +public func stream(withHostName hostName: String, port: Int) -> StreamRequest { + return SessionManager.default.stream(withHostName: hostName, port: port) +} + +// MARK: NetService + +/// Creates a `StreamRequest` using the default `SessionManager` for bidirectional streaming with the `netService`. +/// +/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. +/// +/// - parameter netService: The net service used to identify the endpoint. +/// +/// - returns: The created `StreamRequest`. +@discardableResult +@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) +public func stream(with netService: NetService) -> StreamRequest { + return SessionManager.default.stream(with: netService) +} + +#endif diff --git a/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift b/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift new file mode 100644 index 0000000..78e214e --- /dev/null +++ b/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift @@ -0,0 +1,37 @@ +// +// DispatchQueue+Alamofire.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Dispatch +import Foundation + +extension DispatchQueue { + static var userInteractive: DispatchQueue { return DispatchQueue.global(qos: .userInteractive) } + static var userInitiated: DispatchQueue { return DispatchQueue.global(qos: .userInitiated) } + static var utility: DispatchQueue { return DispatchQueue.global(qos: .utility) } + static var background: DispatchQueue { return DispatchQueue.global(qos: .background) } + + func after(_ delay: TimeInterval, execute closure: @escaping () -> Void) { + asyncAfter(deadline: .now() + delay, execute: closure) + } +} diff --git a/Pods/Alamofire/Source/MultipartFormData.swift b/Pods/Alamofire/Source/MultipartFormData.swift new file mode 100644 index 0000000..1ce4d19 --- /dev/null +++ b/Pods/Alamofire/Source/MultipartFormData.swift @@ -0,0 +1,581 @@ +// +// MultipartFormData.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +#if os(iOS) || os(watchOS) || os(tvOS) +import MobileCoreServices +#elseif os(macOS) +import CoreServices +#endif + +/// Constructs `multipart/form-data` for uploads within an HTTP or HTTPS body. There are currently two ways to encode +/// multipart form data. The first way is to encode the data directly in memory. This is very efficient, but can lead +/// to memory issues if the dataset is too large. The second way is designed for larger datasets and will write all the +/// data to a single file on disk with all the proper boundary segmentation. The second approach MUST be used for +/// larger datasets such as video content, otherwise your app may run out of memory when trying to encode the dataset. +/// +/// For more information on `multipart/form-data` in general, please refer to the RFC-2388 and RFC-2045 specs as well +/// and the w3 form documentation. +/// +/// - https://www.ietf.org/rfc/rfc2388.txt +/// - https://www.ietf.org/rfc/rfc2045.txt +/// - https://www.w3.org/TR/html401/interact/forms.html#h-17.13 +open class MultipartFormData { + + // MARK: - Helper Types + + struct EncodingCharacters { + static let crlf = "\r\n" + } + + struct BoundaryGenerator { + enum BoundaryType { + case initial, encapsulated, final + } + + static func randomBoundary() -> String { + return String(format: "alamofire.boundary.%08x%08x", arc4random(), arc4random()) + } + + static func boundaryData(forBoundaryType boundaryType: BoundaryType, boundary: String) -> Data { + let boundaryText: String + + switch boundaryType { + case .initial: + boundaryText = "--\(boundary)\(EncodingCharacters.crlf)" + case .encapsulated: + boundaryText = "\(EncodingCharacters.crlf)--\(boundary)\(EncodingCharacters.crlf)" + case .final: + boundaryText = "\(EncodingCharacters.crlf)--\(boundary)--\(EncodingCharacters.crlf)" + } + + return boundaryText.data(using: String.Encoding.utf8, allowLossyConversion: false)! + } + } + + class BodyPart { + let headers: HTTPHeaders + let bodyStream: InputStream + let bodyContentLength: UInt64 + var hasInitialBoundary = false + var hasFinalBoundary = false + + init(headers: HTTPHeaders, bodyStream: InputStream, bodyContentLength: UInt64) { + self.headers = headers + self.bodyStream = bodyStream + self.bodyContentLength = bodyContentLength + } + } + + // MARK: - Properties + + /// The `Content-Type` header value containing the boundary used to generate the `multipart/form-data`. + open var contentType: String { return "multipart/form-data; boundary=\(boundary)" } + + /// The content length of all body parts used to generate the `multipart/form-data` not including the boundaries. + public var contentLength: UInt64 { return bodyParts.reduce(0) { $0 + $1.bodyContentLength } } + + /// The boundary used to separate the body parts in the encoded form data. + public let boundary: String + + private var bodyParts: [BodyPart] + private var bodyPartError: AFError? + private let streamBufferSize: Int + + // MARK: - Lifecycle + + /// Creates a multipart form data object. + /// + /// - returns: The multipart form data object. + public init() { + self.boundary = BoundaryGenerator.randomBoundary() + self.bodyParts = [] + + /// + /// The optimal read/write buffer size in bytes for input and output streams is 1024 (1KB). For more + /// information, please refer to the following article: + /// - https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Streams/Articles/ReadingInputStreams.html + /// + + self.streamBufferSize = 1024 + } + + // MARK: - Body Parts + + /// Creates a body part from the data and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - `Content-Disposition: form-data; name=#{name}` (HTTP Header) + /// - Encoded data + /// - Multipart form boundary + /// + /// - parameter data: The data to encode into the multipart form data. + /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. + public func append(_ data: Data, withName name: String) { + let headers = contentHeaders(withName: name) + let stream = InputStream(data: data) + let length = UInt64(data.count) + + append(stream, withLength: length, headers: headers) + } + + /// Creates a body part from the data and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - `Content-Disposition: form-data; name=#{name}` (HTTP Header) + /// - `Content-Type: #{generated mimeType}` (HTTP Header) + /// - Encoded data + /// - Multipart form boundary + /// + /// - parameter data: The data to encode into the multipart form data. + /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. + /// - parameter mimeType: The MIME type to associate with the data content type in the `Content-Type` HTTP header. + public func append(_ data: Data, withName name: String, mimeType: String) { + let headers = contentHeaders(withName: name, mimeType: mimeType) + let stream = InputStream(data: data) + let length = UInt64(data.count) + + append(stream, withLength: length, headers: headers) + } + + /// Creates a body part from the data and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - `Content-Disposition: form-data; name=#{name}; filename=#{filename}` (HTTP Header) + /// - `Content-Type: #{mimeType}` (HTTP Header) + /// - Encoded file data + /// - Multipart form boundary + /// + /// - parameter data: The data to encode into the multipart form data. + /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. + /// - parameter fileName: The filename to associate with the data in the `Content-Disposition` HTTP header. + /// - parameter mimeType: The MIME type to associate with the data in the `Content-Type` HTTP header. + public func append(_ data: Data, withName name: String, fileName: String, mimeType: String) { + let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType) + let stream = InputStream(data: data) + let length = UInt64(data.count) + + append(stream, withLength: length, headers: headers) + } + + /// Creates a body part from the file and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - `Content-Disposition: form-data; name=#{name}; filename=#{generated filename}` (HTTP Header) + /// - `Content-Type: #{generated mimeType}` (HTTP Header) + /// - Encoded file data + /// - Multipart form boundary + /// + /// The filename in the `Content-Disposition` HTTP header is generated from the last path component of the + /// `fileURL`. The `Content-Type` HTTP header MIME type is generated by mapping the `fileURL` extension to the + /// system associated MIME type. + /// + /// - parameter fileURL: The URL of the file whose content will be encoded into the multipart form data. + /// - parameter name: The name to associate with the file content in the `Content-Disposition` HTTP header. + public func append(_ fileURL: URL, withName name: String) { + let fileName = fileURL.lastPathComponent + let pathExtension = fileURL.pathExtension + + if !fileName.isEmpty && !pathExtension.isEmpty { + let mime = mimeType(forPathExtension: pathExtension) + append(fileURL, withName: name, fileName: fileName, mimeType: mime) + } else { + setBodyPartError(withReason: .bodyPartFilenameInvalid(in: fileURL)) + } + } + + /// Creates a body part from the file and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - Content-Disposition: form-data; name=#{name}; filename=#{filename} (HTTP Header) + /// - Content-Type: #{mimeType} (HTTP Header) + /// - Encoded file data + /// - Multipart form boundary + /// + /// - parameter fileURL: The URL of the file whose content will be encoded into the multipart form data. + /// - parameter name: The name to associate with the file content in the `Content-Disposition` HTTP header. + /// - parameter fileName: The filename to associate with the file content in the `Content-Disposition` HTTP header. + /// - parameter mimeType: The MIME type to associate with the file content in the `Content-Type` HTTP header. + public func append(_ fileURL: URL, withName name: String, fileName: String, mimeType: String) { + let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType) + + //============================================================ + // Check 1 - is file URL? + //============================================================ + + guard fileURL.isFileURL else { + setBodyPartError(withReason: .bodyPartURLInvalid(url: fileURL)) + return + } + + //============================================================ + // Check 2 - is file URL reachable? + //============================================================ + + do { + let isReachable = try fileURL.checkPromisedItemIsReachable() + guard isReachable else { + setBodyPartError(withReason: .bodyPartFileNotReachable(at: fileURL)) + return + } + } catch { + setBodyPartError(withReason: .bodyPartFileNotReachableWithError(atURL: fileURL, error: error)) + return + } + + //============================================================ + // Check 3 - is file URL a directory? + //============================================================ + + var isDirectory: ObjCBool = false + let path = fileURL.path + + guard FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory) && !isDirectory.boolValue else + { + setBodyPartError(withReason: .bodyPartFileIsDirectory(at: fileURL)) + return + } + + //============================================================ + // Check 4 - can the file size be extracted? + //============================================================ + + let bodyContentLength: UInt64 + + do { + guard let fileSize = try FileManager.default.attributesOfItem(atPath: path)[.size] as? NSNumber else { + setBodyPartError(withReason: .bodyPartFileSizeNotAvailable(at: fileURL)) + return + } + + bodyContentLength = fileSize.uint64Value + } + catch { + setBodyPartError(withReason: .bodyPartFileSizeQueryFailedWithError(forURL: fileURL, error: error)) + return + } + + //============================================================ + // Check 5 - can a stream be created from file URL? + //============================================================ + + guard let stream = InputStream(url: fileURL) else { + setBodyPartError(withReason: .bodyPartInputStreamCreationFailed(for: fileURL)) + return + } + + append(stream, withLength: bodyContentLength, headers: headers) + } + + /// Creates a body part from the stream and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - `Content-Disposition: form-data; name=#{name}; filename=#{filename}` (HTTP Header) + /// - `Content-Type: #{mimeType}` (HTTP Header) + /// - Encoded stream data + /// - Multipart form boundary + /// + /// - parameter stream: The input stream to encode in the multipart form data. + /// - parameter length: The content length of the stream. + /// - parameter name: The name to associate with the stream content in the `Content-Disposition` HTTP header. + /// - parameter fileName: The filename to associate with the stream content in the `Content-Disposition` HTTP header. + /// - parameter mimeType: The MIME type to associate with the stream content in the `Content-Type` HTTP header. + public func append( + _ stream: InputStream, + withLength length: UInt64, + name: String, + fileName: String, + mimeType: String) + { + let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType) + append(stream, withLength: length, headers: headers) + } + + /// Creates a body part with the headers, stream and length and appends it to the multipart form data object. + /// + /// The body part data will be encoded using the following format: + /// + /// - HTTP headers + /// - Encoded stream data + /// - Multipart form boundary + /// + /// - parameter stream: The input stream to encode in the multipart form data. + /// - parameter length: The content length of the stream. + /// - parameter headers: The HTTP headers for the body part. + public func append(_ stream: InputStream, withLength length: UInt64, headers: HTTPHeaders) { + let bodyPart = BodyPart(headers: headers, bodyStream: stream, bodyContentLength: length) + bodyParts.append(bodyPart) + } + + // MARK: - Data Encoding + + /// Encodes all the appended body parts into a single `Data` value. + /// + /// It is important to note that this method will load all the appended body parts into memory all at the same + /// time. This method should only be used when the encoded data will have a small memory footprint. For large data + /// cases, please use the `writeEncodedDataToDisk(fileURL:completionHandler:)` method. + /// + /// - throws: An `AFError` if encoding encounters an error. + /// + /// - returns: The encoded `Data` if encoding is successful. + public func encode() throws -> Data { + if let bodyPartError = bodyPartError { + throw bodyPartError + } + + var encoded = Data() + + bodyParts.first?.hasInitialBoundary = true + bodyParts.last?.hasFinalBoundary = true + + for bodyPart in bodyParts { + let encodedData = try encode(bodyPart) + encoded.append(encodedData) + } + + return encoded + } + + /// Writes the appended body parts into the given file URL. + /// + /// This process is facilitated by reading and writing with input and output streams, respectively. Thus, + /// this approach is very memory efficient and should be used for large body part data. + /// + /// - parameter fileURL: The file URL to write the multipart form data into. + /// + /// - throws: An `AFError` if encoding encounters an error. + public func writeEncodedData(to fileURL: URL) throws { + if let bodyPartError = bodyPartError { + throw bodyPartError + } + + if FileManager.default.fileExists(atPath: fileURL.path) { + throw AFError.multipartEncodingFailed(reason: .outputStreamFileAlreadyExists(at: fileURL)) + } else if !fileURL.isFileURL { + throw AFError.multipartEncodingFailed(reason: .outputStreamURLInvalid(url: fileURL)) + } + + guard let outputStream = OutputStream(url: fileURL, append: false) else { + throw AFError.multipartEncodingFailed(reason: .outputStreamCreationFailed(for: fileURL)) + } + + outputStream.open() + defer { outputStream.close() } + + self.bodyParts.first?.hasInitialBoundary = true + self.bodyParts.last?.hasFinalBoundary = true + + for bodyPart in self.bodyParts { + try write(bodyPart, to: outputStream) + } + } + + // MARK: - Private - Body Part Encoding + + private func encode(_ bodyPart: BodyPart) throws -> Data { + var encoded = Data() + + let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData() + encoded.append(initialData) + + let headerData = encodeHeaders(for: bodyPart) + encoded.append(headerData) + + let bodyStreamData = try encodeBodyStream(for: bodyPart) + encoded.append(bodyStreamData) + + if bodyPart.hasFinalBoundary { + encoded.append(finalBoundaryData()) + } + + return encoded + } + + private func encodeHeaders(for bodyPart: BodyPart) -> Data { + var headerText = "" + + for (key, value) in bodyPart.headers { + headerText += "\(key): \(value)\(EncodingCharacters.crlf)" + } + headerText += EncodingCharacters.crlf + + return headerText.data(using: String.Encoding.utf8, allowLossyConversion: false)! + } + + private func encodeBodyStream(for bodyPart: BodyPart) throws -> Data { + let inputStream = bodyPart.bodyStream + inputStream.open() + defer { inputStream.close() } + + var encoded = Data() + + while inputStream.hasBytesAvailable { + var buffer = [UInt8](repeating: 0, count: streamBufferSize) + let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize) + + if let error = inputStream.streamError { + throw AFError.multipartEncodingFailed(reason: .inputStreamReadFailed(error: error)) + } + + if bytesRead > 0 { + encoded.append(buffer, count: bytesRead) + } else { + break + } + } + + return encoded + } + + // MARK: - Private - Writing Body Part to Output Stream + + private func write(_ bodyPart: BodyPart, to outputStream: OutputStream) throws { + try writeInitialBoundaryData(for: bodyPart, to: outputStream) + try writeHeaderData(for: bodyPart, to: outputStream) + try writeBodyStream(for: bodyPart, to: outputStream) + try writeFinalBoundaryData(for: bodyPart, to: outputStream) + } + + private func writeInitialBoundaryData(for bodyPart: BodyPart, to outputStream: OutputStream) throws { + let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData() + return try write(initialData, to: outputStream) + } + + private func writeHeaderData(for bodyPart: BodyPart, to outputStream: OutputStream) throws { + let headerData = encodeHeaders(for: bodyPart) + return try write(headerData, to: outputStream) + } + + private func writeBodyStream(for bodyPart: BodyPart, to outputStream: OutputStream) throws { + let inputStream = bodyPart.bodyStream + + inputStream.open() + defer { inputStream.close() } + + while inputStream.hasBytesAvailable { + var buffer = [UInt8](repeating: 0, count: streamBufferSize) + let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize) + + if let streamError = inputStream.streamError { + throw AFError.multipartEncodingFailed(reason: .inputStreamReadFailed(error: streamError)) + } + + if bytesRead > 0 { + if buffer.count != bytesRead { + buffer = Array(buffer[0.. 0, outputStream.hasSpaceAvailable { + let bytesWritten = outputStream.write(buffer, maxLength: bytesToWrite) + + if let error = outputStream.streamError { + throw AFError.multipartEncodingFailed(reason: .outputStreamWriteFailed(error: error)) + } + + bytesToWrite -= bytesWritten + + if bytesToWrite > 0 { + buffer = Array(buffer[bytesWritten.. String { + if + let id = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as CFString, nil)?.takeRetainedValue(), + let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?.takeRetainedValue() + { + return contentType as String + } + + return "application/octet-stream" + } + + // MARK: - Private - Content Headers + + private func contentHeaders(withName name: String, fileName: String? = nil, mimeType: String? = nil) -> [String: String] { + var disposition = "form-data; name=\"\(name)\"" + if let fileName = fileName { disposition += "; filename=\"\(fileName)\"" } + + var headers = ["Content-Disposition": disposition] + if let mimeType = mimeType { headers["Content-Type"] = mimeType } + + return headers + } + + // MARK: - Private - Boundary Encoding + + private func initialBoundaryData() -> Data { + return BoundaryGenerator.boundaryData(forBoundaryType: .initial, boundary: boundary) + } + + private func encapsulatedBoundaryData() -> Data { + return BoundaryGenerator.boundaryData(forBoundaryType: .encapsulated, boundary: boundary) + } + + private func finalBoundaryData() -> Data { + return BoundaryGenerator.boundaryData(forBoundaryType: .final, boundary: boundary) + } + + // MARK: - Private - Errors + + private func setBodyPartError(withReason reason: AFError.MultipartEncodingFailureReason) { + guard bodyPartError == nil else { return } + bodyPartError = AFError.multipartEncodingFailed(reason: reason) + } +} diff --git a/Pods/Alamofire/Source/NetworkReachabilityManager.swift b/Pods/Alamofire/Source/NetworkReachabilityManager.swift new file mode 100644 index 0000000..888818d --- /dev/null +++ b/Pods/Alamofire/Source/NetworkReachabilityManager.swift @@ -0,0 +1,230 @@ +// +// NetworkReachabilityManager.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#if !os(watchOS) + +import Foundation +import SystemConfiguration + +/// The `NetworkReachabilityManager` class listens for reachability changes of hosts and addresses for both WWAN and +/// WiFi network interfaces. +/// +/// Reachability can be used to determine background information about why a network operation failed, or to retry +/// network requests when a connection is established. It should not be used to prevent a user from initiating a network +/// request, as it's possible that an initial request may be required to establish reachability. +public class NetworkReachabilityManager { + /// Defines the various states of network reachability. + /// + /// - unknown: It is unknown whether the network is reachable. + /// - notReachable: The network is not reachable. + /// - reachable: The network is reachable. + public enum NetworkReachabilityStatus { + case unknown + case notReachable + case reachable(ConnectionType) + } + + /// Defines the various connection types detected by reachability flags. + /// + /// - ethernetOrWiFi: The connection type is either over Ethernet or WiFi. + /// - wwan: The connection type is a WWAN connection. + public enum ConnectionType { + case ethernetOrWiFi + case wwan + } + + /// A closure executed when the network reachability status changes. The closure takes a single argument: the + /// network reachability status. + public typealias Listener = (NetworkReachabilityStatus) -> Void + + // MARK: - Properties + + /// Whether the network is currently reachable. + public var isReachable: Bool { return isReachableOnWWAN || isReachableOnEthernetOrWiFi } + + /// Whether the network is currently reachable over the WWAN interface. + public var isReachableOnWWAN: Bool { return networkReachabilityStatus == .reachable(.wwan) } + + /// Whether the network is currently reachable over Ethernet or WiFi interface. + public var isReachableOnEthernetOrWiFi: Bool { return networkReachabilityStatus == .reachable(.ethernetOrWiFi) } + + /// The current network reachability status. + public var networkReachabilityStatus: NetworkReachabilityStatus { + guard let flags = self.flags else { return .unknown } + return networkReachabilityStatusForFlags(flags) + } + + /// The dispatch queue to execute the `listener` closure on. + public var listenerQueue: DispatchQueue = DispatchQueue.main + + /// A closure executed when the network reachability status changes. + public var listener: Listener? + + private var flags: SCNetworkReachabilityFlags? { + var flags = SCNetworkReachabilityFlags() + + if SCNetworkReachabilityGetFlags(reachability, &flags) { + return flags + } + + return nil + } + + private let reachability: SCNetworkReachability + private var previousFlags: SCNetworkReachabilityFlags + + // MARK: - Initialization + + /// Creates a `NetworkReachabilityManager` instance with the specified host. + /// + /// - parameter host: The host used to evaluate network reachability. + /// + /// - returns: The new `NetworkReachabilityManager` instance. + public convenience init?(host: String) { + guard let reachability = SCNetworkReachabilityCreateWithName(nil, host) else { return nil } + self.init(reachability: reachability) + } + + /// Creates a `NetworkReachabilityManager` instance that monitors the address 0.0.0.0. + /// + /// Reachability treats the 0.0.0.0 address as a special token that causes it to monitor the general routing + /// status of the device, both IPv4 and IPv6. + /// + /// - returns: The new `NetworkReachabilityManager` instance. + public convenience init?() { + var address = sockaddr_in() + address.sin_len = UInt8(MemoryLayout.size) + address.sin_family = sa_family_t(AF_INET) + + guard let reachability = withUnsafePointer(to: &address, { pointer in + return pointer.withMemoryRebound(to: sockaddr.self, capacity: MemoryLayout.size) { + return SCNetworkReachabilityCreateWithAddress(nil, $0) + } + }) else { return nil } + + self.init(reachability: reachability) + } + + private init(reachability: SCNetworkReachability) { + self.reachability = reachability + self.previousFlags = SCNetworkReachabilityFlags() + } + + deinit { + stopListening() + } + + // MARK: - Listening + + /// Starts listening for changes in network reachability status. + /// + /// - returns: `true` if listening was started successfully, `false` otherwise. + @discardableResult + public func startListening() -> Bool { + var context = SCNetworkReachabilityContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil) + context.info = Unmanaged.passUnretained(self).toOpaque() + + let callbackEnabled = SCNetworkReachabilitySetCallback( + reachability, + { (_, flags, info) in + let reachability = Unmanaged.fromOpaque(info!).takeUnretainedValue() + reachability.notifyListener(flags) + }, + &context + ) + + let queueEnabled = SCNetworkReachabilitySetDispatchQueue(reachability, listenerQueue) + + listenerQueue.async { + self.previousFlags = SCNetworkReachabilityFlags() + self.notifyListener(self.flags ?? SCNetworkReachabilityFlags()) + } + + return callbackEnabled && queueEnabled + } + + /// Stops listening for changes in network reachability status. + public func stopListening() { + SCNetworkReachabilitySetCallback(reachability, nil, nil) + SCNetworkReachabilitySetDispatchQueue(reachability, nil) + } + + // MARK: - Internal - Listener Notification + + func notifyListener(_ flags: SCNetworkReachabilityFlags) { + guard previousFlags != flags else { return } + previousFlags = flags + + listener?(networkReachabilityStatusForFlags(flags)) + } + + // MARK: - Internal - Network Reachability Status + + func networkReachabilityStatusForFlags(_ flags: SCNetworkReachabilityFlags) -> NetworkReachabilityStatus { + guard flags.contains(.reachable) else { return .notReachable } + + var networkStatus: NetworkReachabilityStatus = .notReachable + + if !flags.contains(.connectionRequired) { networkStatus = .reachable(.ethernetOrWiFi) } + + if flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic) { + if !flags.contains(.interventionRequired) { networkStatus = .reachable(.ethernetOrWiFi) } + } + + #if os(iOS) + if flags.contains(.isWWAN) { networkStatus = .reachable(.wwan) } + #endif + + return networkStatus + } +} + +// MARK: - + +extension NetworkReachabilityManager.NetworkReachabilityStatus: Equatable {} + +/// Returns whether the two network reachability status values are equal. +/// +/// - parameter lhs: The left-hand side value to compare. +/// - parameter rhs: The right-hand side value to compare. +/// +/// - returns: `true` if the two values are equal, `false` otherwise. +public func ==( + lhs: NetworkReachabilityManager.NetworkReachabilityStatus, + rhs: NetworkReachabilityManager.NetworkReachabilityStatus) + -> Bool +{ + switch (lhs, rhs) { + case (.unknown, .unknown): + return true + case (.notReachable, .notReachable): + return true + case let (.reachable(lhsConnectionType), .reachable(rhsConnectionType)): + return lhsConnectionType == rhsConnectionType + default: + return false + } +} + +#endif diff --git a/Pods/Alamofire/Source/Notifications.swift b/Pods/Alamofire/Source/Notifications.swift new file mode 100644 index 0000000..81f6e37 --- /dev/null +++ b/Pods/Alamofire/Source/Notifications.swift @@ -0,0 +1,52 @@ +// +// Notifications.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +extension Notification.Name { + /// Used as a namespace for all `URLSessionTask` related notifications. + public struct Task { + /// Posted when a `URLSessionTask` is resumed. The notification `object` contains the resumed `URLSessionTask`. + public static let DidResume = Notification.Name(rawValue: "org.alamofire.notification.name.task.didResume") + + /// Posted when a `URLSessionTask` is suspended. The notification `object` contains the suspended `URLSessionTask`. + public static let DidSuspend = Notification.Name(rawValue: "org.alamofire.notification.name.task.didSuspend") + + /// Posted when a `URLSessionTask` is cancelled. The notification `object` contains the cancelled `URLSessionTask`. + public static let DidCancel = Notification.Name(rawValue: "org.alamofire.notification.name.task.didCancel") + + /// Posted when a `URLSessionTask` is completed. The notification `object` contains the completed `URLSessionTask`. + public static let DidComplete = Notification.Name(rawValue: "org.alamofire.notification.name.task.didComplete") + } +} + +// MARK: - + +extension Notification { + /// Used as a namespace for all `Notification` user info dictionary keys. + public struct Key { + /// User info dictionary key representing the `URLSessionTask` associated with the notification. + public static let Task = "org.alamofire.notification.key.task" + } +} diff --git a/Pods/Alamofire/Source/ParameterEncoding.swift b/Pods/Alamofire/Source/ParameterEncoding.swift new file mode 100644 index 0000000..242f6a8 --- /dev/null +++ b/Pods/Alamofire/Source/ParameterEncoding.swift @@ -0,0 +1,433 @@ +// +// ParameterEncoding.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// HTTP method definitions. +/// +/// See https://tools.ietf.org/html/rfc7231#section-4.3 +public enum HTTPMethod: String { + case options = "OPTIONS" + case get = "GET" + case head = "HEAD" + case post = "POST" + case put = "PUT" + case patch = "PATCH" + case delete = "DELETE" + case trace = "TRACE" + case connect = "CONNECT" +} + +// MARK: - + +/// A dictionary of parameters to apply to a `URLRequest`. +public typealias Parameters = [String: Any] + +/// A type used to define how a set of parameters are applied to a `URLRequest`. +public protocol ParameterEncoding { + /// Creates a URL request by encoding parameters and applying them onto an existing request. + /// + /// - parameter urlRequest: The request to have parameters applied. + /// - parameter parameters: The parameters to apply. + /// + /// - throws: An `AFError.parameterEncodingFailed` error if encoding fails. + /// + /// - returns: The encoded request. + func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest +} + +// MARK: - + +/// Creates a url-encoded query string to be set as or appended to any existing URL query string or set as the HTTP +/// body of the URL request. Whether the query string is set or appended to any existing URL query string or set as +/// the HTTP body depends on the destination of the encoding. +/// +/// The `Content-Type` HTTP header field of an encoded request with HTTP body is set to +/// `application/x-www-form-urlencoded; charset=utf-8`. Since there is no published specification for how to encode +/// collection types, the convention of appending `[]` to the key for array values (`foo[]=1&foo[]=2`), and appending +/// the key surrounded by square brackets for nested dictionary values (`foo[bar]=baz`). +public struct URLEncoding: ParameterEncoding { + + // MARK: Helper Types + + /// Defines whether the url-encoded query string is applied to the existing query string or HTTP body of the + /// resulting URL request. + /// + /// - methodDependent: Applies encoded query string result to existing query string for `GET`, `HEAD` and `DELETE` + /// requests and sets as the HTTP body for requests with any other HTTP method. + /// - queryString: Sets or appends encoded query string result to existing query string. + /// - httpBody: Sets encoded query string result as the HTTP body of the URL request. + public enum Destination { + case methodDependent, queryString, httpBody + } + + // MARK: Properties + + /// Returns a default `URLEncoding` instance. + public static var `default`: URLEncoding { return URLEncoding() } + + /// Returns a `URLEncoding` instance with a `.methodDependent` destination. + public static var methodDependent: URLEncoding { return URLEncoding() } + + /// Returns a `URLEncoding` instance with a `.queryString` destination. + public static var queryString: URLEncoding { return URLEncoding(destination: .queryString) } + + /// Returns a `URLEncoding` instance with an `.httpBody` destination. + public static var httpBody: URLEncoding { return URLEncoding(destination: .httpBody) } + + /// The destination defining where the encoded query string is to be applied to the URL request. + public let destination: Destination + + // MARK: Initialization + + /// Creates a `URLEncoding` instance using the specified destination. + /// + /// - parameter destination: The destination defining where the encoded query string is to be applied. + /// + /// - returns: The new `URLEncoding` instance. + public init(destination: Destination = .methodDependent) { + self.destination = destination + } + + // MARK: Encoding + + /// Creates a URL request by encoding parameters and applying them onto an existing request. + /// + /// - parameter urlRequest: The request to have parameters applied. + /// - parameter parameters: The parameters to apply. + /// + /// - throws: An `Error` if the encoding process encounters an error. + /// + /// - returns: The encoded request. + public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { + var urlRequest = try urlRequest.asURLRequest() + + guard let parameters = parameters else { return urlRequest } + + if let method = HTTPMethod(rawValue: urlRequest.httpMethod ?? "GET"), encodesParametersInURL(with: method) { + guard let url = urlRequest.url else { + throw AFError.parameterEncodingFailed(reason: .missingURL) + } + + if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false), !parameters.isEmpty { + let percentEncodedQuery = (urlComponents.percentEncodedQuery.map { $0 + "&" } ?? "") + query(parameters) + urlComponents.percentEncodedQuery = percentEncodedQuery + urlRequest.url = urlComponents.url + } + } else { + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = query(parameters).data(using: .utf8, allowLossyConversion: false) + } + + return urlRequest + } + + /// Creates percent-escaped, URL encoded query string components from the given key-value pair using recursion. + /// + /// - parameter key: The key of the query component. + /// - parameter value: The value of the query component. + /// + /// - returns: The percent-escaped, URL encoded query string components. + public func queryComponents(fromKey key: String, value: Any) -> [(String, String)] { + var components: [(String, String)] = [] + + if let dictionary = value as? [String: Any] { + for (nestedKey, value) in dictionary { + components += queryComponents(fromKey: "\(key)[\(nestedKey)]", value: value) + } + } else if let array = value as? [Any] { + for value in array { + components += queryComponents(fromKey: "\(key)[]", value: value) + } + } else if let value = value as? NSNumber { + if value.isBool { + components.append((escape(key), escape((value.boolValue ? "1" : "0")))) + } else { + components.append((escape(key), escape("\(value)"))) + } + } else if let bool = value as? Bool { + components.append((escape(key), escape((bool ? "1" : "0")))) + } else { + components.append((escape(key), escape("\(value)"))) + } + + return components + } + + /// Returns a percent-escaped string following RFC 3986 for a query string key or value. + /// + /// RFC 3986 states that the following characters are "reserved" characters. + /// + /// - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + /// - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + /// + /// In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + /// query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + /// should be percent-escaped in the query string. + /// + /// - parameter string: The string to be percent-escaped. + /// + /// - returns: The percent-escaped string. + public func escape(_ string: String) -> String { + let generalDelimitersToEncode = ":#[]@" // does not include "?" or "/" due to RFC 3986 - Section 3.4 + let subDelimitersToEncode = "!$&'()*+,;=" + + var allowedCharacterSet = CharacterSet.urlQueryAllowed + allowedCharacterSet.remove(charactersIn: "\(generalDelimitersToEncode)\(subDelimitersToEncode)") + + var escaped = "" + + //========================================================================================================== + // + // Batching is required for escaping due to an internal bug in iOS 8.1 and 8.2. Encoding more than a few + // hundred Chinese characters causes various malloc error crashes. To avoid this issue until iOS 8 is no + // longer supported, batching MUST be used for encoding. This introduces roughly a 20% overhead. For more + // info, please refer to: + // + // - https://github.com/Alamofire/Alamofire/issues/206 + // + //========================================================================================================== + + if #available(iOS 8.3, *) { + escaped = string.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) ?? string + } else { + let batchSize = 50 + var index = string.startIndex + + while index != string.endIndex { + let startIndex = index + let endIndex = string.index(index, offsetBy: batchSize, limitedBy: string.endIndex) ?? string.endIndex + let range = startIndex.. String { + var components: [(String, String)] = [] + + for key in parameters.keys.sorted(by: <) { + let value = parameters[key]! + components += queryComponents(fromKey: key, value: value) + } + + return components.map { "\($0)=\($1)" }.joined(separator: "&") + } + + private func encodesParametersInURL(with method: HTTPMethod) -> Bool { + switch destination { + case .queryString: + return true + case .httpBody: + return false + default: + break + } + + switch method { + case .get, .head, .delete: + return true + default: + return false + } + } +} + +// MARK: - + +/// Uses `JSONSerialization` to create a JSON representation of the parameters object, which is set as the body of the +/// request. The `Content-Type` HTTP header field of an encoded request is set to `application/json`. +public struct JSONEncoding: ParameterEncoding { + + // MARK: Properties + + /// Returns a `JSONEncoding` instance with default writing options. + public static var `default`: JSONEncoding { return JSONEncoding() } + + /// Returns a `JSONEncoding` instance with `.prettyPrinted` writing options. + public static var prettyPrinted: JSONEncoding { return JSONEncoding(options: .prettyPrinted) } + + /// The options for writing the parameters as JSON data. + public let options: JSONSerialization.WritingOptions + + // MARK: Initialization + + /// Creates a `JSONEncoding` instance using the specified options. + /// + /// - parameter options: The options for writing the parameters as JSON data. + /// + /// - returns: The new `JSONEncoding` instance. + public init(options: JSONSerialization.WritingOptions = []) { + self.options = options + } + + // MARK: Encoding + + /// Creates a URL request by encoding parameters and applying them onto an existing request. + /// + /// - parameter urlRequest: The request to have parameters applied. + /// - parameter parameters: The parameters to apply. + /// + /// - throws: An `Error` if the encoding process encounters an error. + /// + /// - returns: The encoded request. + public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { + var urlRequest = try urlRequest.asURLRequest() + + guard let parameters = parameters else { return urlRequest } + + do { + let data = try JSONSerialization.data(withJSONObject: parameters, options: options) + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = data + } catch { + throw AFError.parameterEncodingFailed(reason: .jsonEncodingFailed(error: error)) + } + + return urlRequest + } + + /// Creates a URL request by encoding the JSON object and setting the resulting data on the HTTP body. + /// + /// - parameter urlRequest: The request to apply the JSON object to. + /// - parameter jsonObject: The JSON object to apply to the request. + /// + /// - throws: An `Error` if the encoding process encounters an error. + /// + /// - returns: The encoded request. + public func encode(_ urlRequest: URLRequestConvertible, withJSONObject jsonObject: Any? = nil) throws -> URLRequest { + var urlRequest = try urlRequest.asURLRequest() + + guard let jsonObject = jsonObject else { return urlRequest } + + do { + let data = try JSONSerialization.data(withJSONObject: jsonObject, options: options) + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = data + } catch { + throw AFError.parameterEncodingFailed(reason: .jsonEncodingFailed(error: error)) + } + + return urlRequest + } +} + +// MARK: - + +/// Uses `PropertyListSerialization` to create a plist representation of the parameters object, according to the +/// associated format and write options values, which is set as the body of the request. The `Content-Type` HTTP header +/// field of an encoded request is set to `application/x-plist`. +public struct PropertyListEncoding: ParameterEncoding { + + // MARK: Properties + + /// Returns a default `PropertyListEncoding` instance. + public static var `default`: PropertyListEncoding { return PropertyListEncoding() } + + /// Returns a `PropertyListEncoding` instance with xml formatting and default writing options. + public static var xml: PropertyListEncoding { return PropertyListEncoding(format: .xml) } + + /// Returns a `PropertyListEncoding` instance with binary formatting and default writing options. + public static var binary: PropertyListEncoding { return PropertyListEncoding(format: .binary) } + + /// The property list serialization format. + public let format: PropertyListSerialization.PropertyListFormat + + /// The options for writing the parameters as plist data. + public let options: PropertyListSerialization.WriteOptions + + // MARK: Initialization + + /// Creates a `PropertyListEncoding` instance using the specified format and options. + /// + /// - parameter format: The property list serialization format. + /// - parameter options: The options for writing the parameters as plist data. + /// + /// - returns: The new `PropertyListEncoding` instance. + public init( + format: PropertyListSerialization.PropertyListFormat = .xml, + options: PropertyListSerialization.WriteOptions = 0) + { + self.format = format + self.options = options + } + + // MARK: Encoding + + /// Creates a URL request by encoding parameters and applying them onto an existing request. + /// + /// - parameter urlRequest: The request to have parameters applied. + /// - parameter parameters: The parameters to apply. + /// + /// - throws: An `Error` if the encoding process encounters an error. + /// + /// - returns: The encoded request. + public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { + var urlRequest = try urlRequest.asURLRequest() + + guard let parameters = parameters else { return urlRequest } + + do { + let data = try PropertyListSerialization.data( + fromPropertyList: parameters, + format: format, + options: options + ) + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/x-plist", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = data + } catch { + throw AFError.parameterEncodingFailed(reason: .propertyListEncodingFailed(error: error)) + } + + return urlRequest + } +} + +// MARK: - + +extension NSNumber { + fileprivate var isBool: Bool { return CFBooleanGetTypeID() == CFGetTypeID(self) } +} diff --git a/Pods/Alamofire/Source/Request.swift b/Pods/Alamofire/Source/Request.swift new file mode 100644 index 0000000..7886495 --- /dev/null +++ b/Pods/Alamofire/Source/Request.swift @@ -0,0 +1,647 @@ +// +// Request.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// A type that can inspect and optionally adapt a `URLRequest` in some manner if necessary. +public protocol RequestAdapter { + /// Inspects and adapts the specified `URLRequest` in some manner if necessary and returns the result. + /// + /// - parameter urlRequest: The URL request to adapt. + /// + /// - throws: An `Error` if the adaptation encounters an error. + /// + /// - returns: The adapted `URLRequest`. + func adapt(_ urlRequest: URLRequest) throws -> URLRequest +} + +// MARK: - + +/// A closure executed when the `RequestRetrier` determines whether a `Request` should be retried or not. +public typealias RequestRetryCompletion = (_ shouldRetry: Bool, _ timeDelay: TimeInterval) -> Void + +/// A type that determines whether a request should be retried after being executed by the specified session manager +/// and encountering an error. +public protocol RequestRetrier { + /// Determines whether the `Request` should be retried by calling the `completion` closure. + /// + /// This operation is fully asychronous. Any amount of time can be taken to determine whether the request needs + /// to be retried. The one requirement is that the completion closure is called to ensure the request is properly + /// cleaned up after. + /// + /// - parameter manager: The session manager the request was executed on. + /// - parameter request: The request that failed due to the encountered error. + /// - parameter error: The error encountered when executing the request. + /// - parameter completion: The completion closure to be executed when retry decision has been determined. + func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion) +} + +// MARK: - + +protocol TaskConvertible { + func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask +} + +/// A dictionary of headers to apply to a `URLRequest`. +public typealias HTTPHeaders = [String: String] + +// MARK: - + +/// Responsible for sending a request and receiving the response and associated data from the server, as well as +/// managing its underlying `URLSessionTask`. +open class Request { + + // MARK: Helper Types + + /// A closure executed when monitoring upload or download progress of a request. + public typealias ProgressHandler = (Progress) -> Void + + enum RequestTask { + case data(TaskConvertible?, URLSessionTask?) + case download(TaskConvertible?, URLSessionTask?) + case upload(TaskConvertible?, URLSessionTask?) + case stream(TaskConvertible?, URLSessionTask?) + } + + // MARK: Properties + + /// The delegate for the underlying task. + open internal(set) var delegate: TaskDelegate { + get { + taskDelegateLock.lock() ; defer { taskDelegateLock.unlock() } + return taskDelegate + } + set { + taskDelegateLock.lock() ; defer { taskDelegateLock.unlock() } + taskDelegate = newValue + } + } + + /// The underlying task. + open var task: URLSessionTask? { return delegate.task } + + /// The session belonging to the underlying task. + open let session: URLSession + + /// The request sent or to be sent to the server. + open var request: URLRequest? { return task?.originalRequest } + + /// The response received from the server, if any. + open var response: HTTPURLResponse? { return task?.response as? HTTPURLResponse } + + /// The number of times the request has been retried. + open internal(set) var retryCount: UInt = 0 + + let originalTask: TaskConvertible? + + var startTime: CFAbsoluteTime? + var endTime: CFAbsoluteTime? + + var validations: [() -> Void] = [] + + private var taskDelegate: TaskDelegate + private var taskDelegateLock = NSLock() + + // MARK: Lifecycle + + init(session: URLSession, requestTask: RequestTask, error: Error? = nil) { + self.session = session + + switch requestTask { + case .data(let originalTask, let task): + taskDelegate = DataTaskDelegate(task: task) + self.originalTask = originalTask + case .download(let originalTask, let task): + taskDelegate = DownloadTaskDelegate(task: task) + self.originalTask = originalTask + case .upload(let originalTask, let task): + taskDelegate = UploadTaskDelegate(task: task) + self.originalTask = originalTask + case .stream(let originalTask, let task): + taskDelegate = TaskDelegate(task: task) + self.originalTask = originalTask + } + + delegate.error = error + delegate.queue.addOperation { self.endTime = CFAbsoluteTimeGetCurrent() } + } + + // MARK: Authentication + + /// Associates an HTTP Basic credential with the request. + /// + /// - parameter user: The user. + /// - parameter password: The password. + /// - parameter persistence: The URL credential persistence. `.ForSession` by default. + /// + /// - returns: The request. + @discardableResult + open func authenticate( + user: String, + password: String, + persistence: URLCredential.Persistence = .forSession) + -> Self + { + let credential = URLCredential(user: user, password: password, persistence: persistence) + return authenticate(usingCredential: credential) + } + + /// Associates a specified credential with the request. + /// + /// - parameter credential: The credential. + /// + /// - returns: The request. + @discardableResult + open func authenticate(usingCredential credential: URLCredential) -> Self { + delegate.credential = credential + return self + } + + /// Returns a base64 encoded basic authentication credential as an authorization header tuple. + /// + /// - parameter user: The user. + /// - parameter password: The password. + /// + /// - returns: A tuple with Authorization header and credential value if encoding succeeds, `nil` otherwise. + open static func authorizationHeader(user: String, password: String) -> (key: String, value: String)? { + guard let data = "\(user):\(password)".data(using: .utf8) else { return nil } + + let credential = data.base64EncodedString(options: []) + + return (key: "Authorization", value: "Basic \(credential)") + } + + // MARK: State + + /// Resumes the request. + open func resume() { + guard let task = task else { delegate.queue.isSuspended = false ; return } + + if startTime == nil { startTime = CFAbsoluteTimeGetCurrent() } + + task.resume() + + NotificationCenter.default.post( + name: Notification.Name.Task.DidResume, + object: self, + userInfo: [Notification.Key.Task: task] + ) + } + + /// Suspends the request. + open func suspend() { + guard let task = task else { return } + + task.suspend() + + NotificationCenter.default.post( + name: Notification.Name.Task.DidSuspend, + object: self, + userInfo: [Notification.Key.Task: task] + ) + } + + /// Cancels the request. + open func cancel() { + guard let task = task else { return } + + task.cancel() + + NotificationCenter.default.post( + name: Notification.Name.Task.DidCancel, + object: self, + userInfo: [Notification.Key.Task: task] + ) + } +} + +// MARK: - CustomStringConvertible + +extension Request: CustomStringConvertible { + /// The textual representation used when written to an output stream, which includes the HTTP method and URL, as + /// well as the response status code if a response has been received. + open var description: String { + var components: [String] = [] + + if let HTTPMethod = request?.httpMethod { + components.append(HTTPMethod) + } + + if let urlString = request?.url?.absoluteString { + components.append(urlString) + } + + if let response = response { + components.append("(\(response.statusCode))") + } + + return components.joined(separator: " ") + } +} + +// MARK: - CustomDebugStringConvertible + +extension Request: CustomDebugStringConvertible { + /// The textual representation used when written to an output stream, in the form of a cURL command. + open var debugDescription: String { + return cURLRepresentation() + } + + func cURLRepresentation() -> String { + var components = ["$ curl -i"] + + guard let request = self.request, + let url = request.url, + let host = url.host + else { + return "$ curl command could not be created" + } + + if let httpMethod = request.httpMethod, httpMethod != "GET" { + components.append("-X \(httpMethod)") + } + + if let credentialStorage = self.session.configuration.urlCredentialStorage { + let protectionSpace = URLProtectionSpace( + host: host, + port: url.port ?? 0, + protocol: url.scheme, + realm: host, + authenticationMethod: NSURLAuthenticationMethodHTTPBasic + ) + + if let credentials = credentialStorage.credentials(for: protectionSpace)?.values { + for credential in credentials { + components.append("-u \(credential.user!):\(credential.password!)") + } + } else { + if let credential = delegate.credential { + components.append("-u \(credential.user!):\(credential.password!)") + } + } + } + + if session.configuration.httpShouldSetCookies { + if + let cookieStorage = session.configuration.httpCookieStorage, + let cookies = cookieStorage.cookies(for: url), !cookies.isEmpty + { + let string = cookies.reduce("") { $0 + "\($1.name)=\($1.value);" } + components.append("-b \"\(string.substring(to: string.characters.index(before: string.endIndex)))\"") + } + } + + var headers: [AnyHashable: Any] = [:] + + if let additionalHeaders = session.configuration.httpAdditionalHeaders { + for (field, value) in additionalHeaders where field != AnyHashable("Cookie") { + headers[field] = value + } + } + + if let headerFields = request.allHTTPHeaderFields { + for (field, value) in headerFields where field != "Cookie" { + headers[field] = value + } + } + + for (field, value) in headers { + components.append("-H \"\(field): \(value)\"") + } + + if let httpBodyData = request.httpBody, let httpBody = String(data: httpBodyData, encoding: .utf8) { + var escapedBody = httpBody.replacingOccurrences(of: "\\\"", with: "\\\\\"") + escapedBody = escapedBody.replacingOccurrences(of: "\"", with: "\\\"") + + components.append("-d \"\(escapedBody)\"") + } + + components.append("\"\(url.absoluteString)\"") + + return components.joined(separator: " \\\n\t") + } +} + +// MARK: - + +/// Specific type of `Request` that manages an underlying `URLSessionDataTask`. +open class DataRequest: Request { + + // MARK: Helper Types + + struct Requestable: TaskConvertible { + let urlRequest: URLRequest + + func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { + do { + let urlRequest = try self.urlRequest.adapt(using: adapter) + return queue.sync { session.dataTask(with: urlRequest) } + } catch { + throw AdaptError(error: error) + } + } + } + + // MARK: Properties + + /// The request sent or to be sent to the server. + open override var request: URLRequest? { + if let request = super.request { return request } + if let requestable = originalTask as? Requestable { return requestable.urlRequest } + + return nil + } + + /// The progress of fetching the response data from the server for the request. + open var progress: Progress { return dataDelegate.progress } + + var dataDelegate: DataTaskDelegate { return delegate as! DataTaskDelegate } + + // MARK: Stream + + /// Sets a closure to be called periodically during the lifecycle of the request as data is read from the server. + /// + /// This closure returns the bytes most recently received from the server, not including data from previous calls. + /// If this closure is set, data will only be available within this closure, and will not be saved elsewhere. It is + /// also important to note that the server data in any `Response` object will be `nil`. + /// + /// - parameter closure: The code to be executed periodically during the lifecycle of the request. + /// + /// - returns: The request. + @discardableResult + open func stream(closure: ((Data) -> Void)? = nil) -> Self { + dataDelegate.dataStream = closure + return self + } + + // MARK: Progress + + /// Sets a closure to be called periodically during the lifecycle of the `Request` as data is read from the server. + /// + /// - parameter queue: The dispatch queue to execute the closure on. + /// - parameter closure: The code to be executed periodically as data is read from the server. + /// + /// - returns: The request. + @discardableResult + open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self { + dataDelegate.progressHandler = (closure, queue) + return self + } +} + +// MARK: - + +/// Specific type of `Request` that manages an underlying `URLSessionDownloadTask`. +open class DownloadRequest: Request { + + // MARK: Helper Types + + /// A collection of options to be executed prior to moving a downloaded file from the temporary URL to the + /// destination URL. + public struct DownloadOptions: OptionSet { + /// Returns the raw bitmask value of the option and satisfies the `RawRepresentable` protocol. + public let rawValue: UInt + + /// A `DownloadOptions` flag that creates intermediate directories for the destination URL if specified. + public static let createIntermediateDirectories = DownloadOptions(rawValue: 1 << 0) + + /// A `DownloadOptions` flag that removes a previous file from the destination URL if specified. + public static let removePreviousFile = DownloadOptions(rawValue: 1 << 1) + + /// Creates a `DownloadFileDestinationOptions` instance with the specified raw value. + /// + /// - parameter rawValue: The raw bitmask value for the option. + /// + /// - returns: A new log level instance. + public init(rawValue: UInt) { + self.rawValue = rawValue + } + } + + /// A closure executed once a download request has successfully completed in order to determine where to move the + /// temporary file written to during the download process. The closure takes two arguments: the temporary file URL + /// and the URL response, and returns a two arguments: the file URL where the temporary file should be moved and + /// the options defining how the file should be moved. + public typealias DownloadFileDestination = ( + _ temporaryURL: URL, + _ response: HTTPURLResponse) + -> (destinationURL: URL, options: DownloadOptions) + + enum Downloadable: TaskConvertible { + case request(URLRequest) + case resumeData(Data) + + func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { + do { + let task: URLSessionTask + + switch self { + case let .request(urlRequest): + let urlRequest = try urlRequest.adapt(using: adapter) + task = queue.sync { session.downloadTask(with: urlRequest) } + case let .resumeData(resumeData): + task = queue.sync { session.downloadTask(withResumeData: resumeData) } + } + + return task + } catch { + throw AdaptError(error: error) + } + } + } + + // MARK: Properties + + /// The request sent or to be sent to the server. + open override var request: URLRequest? { + if let request = super.request { return request } + + if let downloadable = originalTask as? Downloadable, case let .request(urlRequest) = downloadable { + return urlRequest + } + + return nil + } + + /// The resume data of the underlying download task if available after a failure. + open var resumeData: Data? { return downloadDelegate.resumeData } + + /// The progress of downloading the response data from the server for the request. + open var progress: Progress { return downloadDelegate.progress } + + var downloadDelegate: DownloadTaskDelegate { return delegate as! DownloadTaskDelegate } + + // MARK: State + + /// Cancels the request. + open override func cancel() { + downloadDelegate.downloadTask.cancel { self.downloadDelegate.resumeData = $0 } + + NotificationCenter.default.post( + name: Notification.Name.Task.DidCancel, + object: self, + userInfo: [Notification.Key.Task: task as Any] + ) + } + + // MARK: Progress + + /// Sets a closure to be called periodically during the lifecycle of the `Request` as data is read from the server. + /// + /// - parameter queue: The dispatch queue to execute the closure on. + /// - parameter closure: The code to be executed periodically as data is read from the server. + /// + /// - returns: The request. + @discardableResult + open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self { + downloadDelegate.progressHandler = (closure, queue) + return self + } + + // MARK: Destination + + /// Creates a download file destination closure which uses the default file manager to move the temporary file to a + /// file URL in the first available directory with the specified search path directory and search path domain mask. + /// + /// - parameter directory: The search path directory. `.DocumentDirectory` by default. + /// - parameter domain: The search path domain mask. `.UserDomainMask` by default. + /// + /// - returns: A download file destination closure. + open class func suggestedDownloadDestination( + for directory: FileManager.SearchPathDirectory = .documentDirectory, + in domain: FileManager.SearchPathDomainMask = .userDomainMask) + -> DownloadFileDestination + { + return { temporaryURL, response in + let directoryURLs = FileManager.default.urls(for: directory, in: domain) + + if !directoryURLs.isEmpty { + return (directoryURLs[0].appendingPathComponent(response.suggestedFilename!), []) + } + + return (temporaryURL, []) + } + } +} + +// MARK: - + +/// Specific type of `Request` that manages an underlying `URLSessionUploadTask`. +open class UploadRequest: DataRequest { + + // MARK: Helper Types + + enum Uploadable: TaskConvertible { + case data(Data, URLRequest) + case file(URL, URLRequest) + case stream(InputStream, URLRequest) + + func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { + do { + let task: URLSessionTask + + switch self { + case let .data(data, urlRequest): + let urlRequest = try urlRequest.adapt(using: adapter) + task = queue.sync { session.uploadTask(with: urlRequest, from: data) } + case let .file(url, urlRequest): + let urlRequest = try urlRequest.adapt(using: adapter) + task = queue.sync { session.uploadTask(with: urlRequest, fromFile: url) } + case let .stream(_, urlRequest): + let urlRequest = try urlRequest.adapt(using: adapter) + task = queue.sync { session.uploadTask(withStreamedRequest: urlRequest) } + } + + return task + } catch { + throw AdaptError(error: error) + } + } + } + + // MARK: Properties + + /// The request sent or to be sent to the server. + open override var request: URLRequest? { + if let request = super.request { return request } + + guard let uploadable = originalTask as? Uploadable else { return nil } + + switch uploadable { + case .data(_, let urlRequest), .file(_, let urlRequest), .stream(_, let urlRequest): + return urlRequest + } + } + + /// The progress of uploading the payload to the server for the upload request. + open var uploadProgress: Progress { return uploadDelegate.uploadProgress } + + var uploadDelegate: UploadTaskDelegate { return delegate as! UploadTaskDelegate } + + // MARK: Upload Progress + + /// Sets a closure to be called periodically during the lifecycle of the `UploadRequest` as data is sent to + /// the server. + /// + /// After the data is sent to the server, the `progress(queue:closure:)` APIs can be used to monitor the progress + /// of data being read from the server. + /// + /// - parameter queue: The dispatch queue to execute the closure on. + /// - parameter closure: The code to be executed periodically as data is sent to the server. + /// + /// - returns: The request. + @discardableResult + open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self { + uploadDelegate.uploadProgressHandler = (closure, queue) + return self + } +} + +// MARK: - + +#if !os(watchOS) + +/// Specific type of `Request` that manages an underlying `URLSessionStreamTask`. +@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) +open class StreamRequest: Request { + enum Streamable: TaskConvertible { + case stream(hostName: String, port: Int) + case netService(NetService) + + func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { + let task: URLSessionTask + + switch self { + case let .stream(hostName, port): + task = queue.sync { session.streamTask(withHostName: hostName, port: port) } + case let .netService(netService): + task = queue.sync { session.streamTask(with: netService) } + } + + return task + } + } +} + +#endif diff --git a/Pods/Alamofire/Source/Response.swift b/Pods/Alamofire/Source/Response.swift new file mode 100644 index 0000000..318596d --- /dev/null +++ b/Pods/Alamofire/Source/Response.swift @@ -0,0 +1,345 @@ +// +// Response.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Used to store all data associated with an non-serialized response of a data or upload request. +public struct DefaultDataResponse { + /// The URL request sent to the server. + public let request: URLRequest? + + /// The server's response to the URL request. + public let response: HTTPURLResponse? + + /// The data returned by the server. + public let data: Data? + + /// The error encountered while executing or validating the request. + public let error: Error? + + /// The timeline of the complete lifecycle of the request. + public let timeline: Timeline + + var _metrics: AnyObject? + + /// Creates a `DefaultDataResponse` instance from the specified parameters. + /// + /// - Parameters: + /// - request: The URL request sent to the server. + /// - response: The server's response to the URL request. + /// - data: The data returned by the server. + /// - error: The error encountered while executing or validating the request. + /// - timeline: The timeline of the complete lifecycle of the request. `Timeline()` by default. + /// - metrics: The task metrics containing the request / response statistics. `nil` by default. + public init( + request: URLRequest?, + response: HTTPURLResponse?, + data: Data?, + error: Error?, + timeline: Timeline = Timeline(), + metrics: AnyObject? = nil) + { + self.request = request + self.response = response + self.data = data + self.error = error + self.timeline = timeline + } +} + +// MARK: - + +/// Used to store all data associated with a serialized response of a data or upload request. +public struct DataResponse { + /// The URL request sent to the server. + public let request: URLRequest? + + /// The server's response to the URL request. + public let response: HTTPURLResponse? + + /// The data returned by the server. + public let data: Data? + + /// The result of response serialization. + public let result: Result + + /// The timeline of the complete lifecycle of the request. + public let timeline: Timeline + + /// Returns the associated value of the result if it is a success, `nil` otherwise. + public var value: Value? { return result.value } + + /// Returns the associated error value if the result if it is a failure, `nil` otherwise. + public var error: Error? { return result.error } + + var _metrics: AnyObject? + + /// Creates a `DataResponse` instance with the specified parameters derived from response serialization. + /// + /// - parameter request: The URL request sent to the server. + /// - parameter response: The server's response to the URL request. + /// - parameter data: The data returned by the server. + /// - parameter result: The result of response serialization. + /// - parameter timeline: The timeline of the complete lifecycle of the `Request`. Defaults to `Timeline()`. + /// + /// - returns: The new `DataResponse` instance. + public init( + request: URLRequest?, + response: HTTPURLResponse?, + data: Data?, + result: Result, + timeline: Timeline = Timeline()) + { + self.request = request + self.response = response + self.data = data + self.result = result + self.timeline = timeline + } +} + +// MARK: - + +extension DataResponse: CustomStringConvertible, CustomDebugStringConvertible { + /// The textual representation used when written to an output stream, which includes whether the result was a + /// success or failure. + public var description: String { + return result.debugDescription + } + + /// The debug textual representation used when written to an output stream, which includes the URL request, the URL + /// response, the server data, the response serialization result and the timeline. + public var debugDescription: String { + var output: [String] = [] + + output.append(request != nil ? "[Request]: \(request!.httpMethod ?? "GET") \(request!)" : "[Request]: nil") + output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil") + output.append("[Data]: \(data?.count ?? 0) bytes") + output.append("[Result]: \(result.debugDescription)") + output.append("[Timeline]: \(timeline.debugDescription)") + + return output.joined(separator: "\n") + } +} + +// MARK: - + +/// Used to store all data associated with an non-serialized response of a download request. +public struct DefaultDownloadResponse { + /// The URL request sent to the server. + public let request: URLRequest? + + /// The server's response to the URL request. + public let response: HTTPURLResponse? + + /// The temporary destination URL of the data returned from the server. + public let temporaryURL: URL? + + /// The final destination URL of the data returned from the server if it was moved. + public let destinationURL: URL? + + /// The resume data generated if the request was cancelled. + public let resumeData: Data? + + /// The error encountered while executing or validating the request. + public let error: Error? + + /// The timeline of the complete lifecycle of the request. + public let timeline: Timeline + + var _metrics: AnyObject? + + /// Creates a `DefaultDownloadResponse` instance from the specified parameters. + /// + /// - Parameters: + /// - request: The URL request sent to the server. + /// - response: The server's response to the URL request. + /// - temporaryURL: The temporary destination URL of the data returned from the server. + /// - destinationURL: The final destination URL of the data returned from the server if it was moved. + /// - resumeData: The resume data generated if the request was cancelled. + /// - error: The error encountered while executing or validating the request. + /// - timeline: The timeline of the complete lifecycle of the request. `Timeline()` by default. + /// - metrics: The task metrics containing the request / response statistics. `nil` by default. + public init( + request: URLRequest?, + response: HTTPURLResponse?, + temporaryURL: URL?, + destinationURL: URL?, + resumeData: Data?, + error: Error?, + timeline: Timeline = Timeline(), + metrics: AnyObject? = nil) + { + self.request = request + self.response = response + self.temporaryURL = temporaryURL + self.destinationURL = destinationURL + self.resumeData = resumeData + self.error = error + self.timeline = timeline + } +} + +// MARK: - + +/// Used to store all data associated with a serialized response of a download request. +public struct DownloadResponse { + /// The URL request sent to the server. + public let request: URLRequest? + + /// The server's response to the URL request. + public let response: HTTPURLResponse? + + /// The temporary destination URL of the data returned from the server. + public let temporaryURL: URL? + + /// The final destination URL of the data returned from the server if it was moved. + public let destinationURL: URL? + + /// The resume data generated if the request was cancelled. + public let resumeData: Data? + + /// The result of response serialization. + public let result: Result + + /// The timeline of the complete lifecycle of the request. + public let timeline: Timeline + + /// Returns the associated value of the result if it is a success, `nil` otherwise. + public var value: Value? { return result.value } + + /// Returns the associated error value if the result if it is a failure, `nil` otherwise. + public var error: Error? { return result.error } + + var _metrics: AnyObject? + + /// Creates a `DownloadResponse` instance with the specified parameters derived from response serialization. + /// + /// - parameter request: The URL request sent to the server. + /// - parameter response: The server's response to the URL request. + /// - parameter temporaryURL: The temporary destination URL of the data returned from the server. + /// - parameter destinationURL: The final destination URL of the data returned from the server if it was moved. + /// - parameter resumeData: The resume data generated if the request was cancelled. + /// - parameter result: The result of response serialization. + /// - parameter timeline: The timeline of the complete lifecycle of the `Request`. Defaults to `Timeline()`. + /// + /// - returns: The new `DownloadResponse` instance. + public init( + request: URLRequest?, + response: HTTPURLResponse?, + temporaryURL: URL?, + destinationURL: URL?, + resumeData: Data?, + result: Result, + timeline: Timeline = Timeline()) + { + self.request = request + self.response = response + self.temporaryURL = temporaryURL + self.destinationURL = destinationURL + self.resumeData = resumeData + self.result = result + self.timeline = timeline + } +} + +// MARK: - + +extension DownloadResponse: CustomStringConvertible, CustomDebugStringConvertible { + /// The textual representation used when written to an output stream, which includes whether the result was a + /// success or failure. + public var description: String { + return result.debugDescription + } + + /// The debug textual representation used when written to an output stream, which includes the URL request, the URL + /// response, the temporary and destination URLs, the resume data, the response serialization result and the + /// timeline. + public var debugDescription: String { + var output: [String] = [] + + output.append(request != nil ? "[Request]: \(request!.httpMethod ?? "GET") \(request!)" : "[Request]: nil") + output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil") + output.append("[TemporaryURL]: \(temporaryURL?.path ?? "nil")") + output.append("[DestinationURL]: \(destinationURL?.path ?? "nil")") + output.append("[ResumeData]: \(resumeData?.count ?? 0) bytes") + output.append("[Result]: \(result.debugDescription)") + output.append("[Timeline]: \(timeline.debugDescription)") + + return output.joined(separator: "\n") + } +} + +// MARK: - + +protocol Response { + /// The task metrics containing the request / response statistics. + var _metrics: AnyObject? { get set } + mutating func add(_ metrics: AnyObject?) +} + +extension Response { + mutating func add(_ metrics: AnyObject?) { + #if !os(watchOS) + guard #available(iOS 10.0, macOS 10.12, tvOS 10.0, *) else { return } + guard let metrics = metrics as? URLSessionTaskMetrics else { return } + + _metrics = metrics + #endif + } +} + +// MARK: - + +@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) +extension DefaultDataResponse: Response { +#if !os(watchOS) + /// The task metrics containing the request / response statistics. + public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } +#endif +} + +@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) +extension DataResponse: Response { +#if !os(watchOS) + /// The task metrics containing the request / response statistics. + public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } +#endif +} + +@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) +extension DefaultDownloadResponse: Response { +#if !os(watchOS) + /// The task metrics containing the request / response statistics. + public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } +#endif +} + +@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) +extension DownloadResponse: Response { +#if !os(watchOS) + /// The task metrics containing the request / response statistics. + public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } +#endif +} diff --git a/Pods/Alamofire/Source/ResponseSerialization.swift b/Pods/Alamofire/Source/ResponseSerialization.swift new file mode 100644 index 0000000..47780fd --- /dev/null +++ b/Pods/Alamofire/Source/ResponseSerialization.swift @@ -0,0 +1,714 @@ +// +// ResponseSerialization.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// The type in which all data response serializers must conform to in order to serialize a response. +public protocol DataResponseSerializerProtocol { + /// The type of serialized object to be created by this `DataResponseSerializerType`. + associatedtype SerializedObject + + /// A closure used by response handlers that takes a request, response, data and error and returns a result. + var serializeResponse: (URLRequest?, HTTPURLResponse?, Data?, Error?) -> Result { get } +} + +// MARK: - + +/// A generic `DataResponseSerializerType` used to serialize a request, response, and data into a serialized object. +public struct DataResponseSerializer: DataResponseSerializerProtocol { + /// The type of serialized object to be created by this `DataResponseSerializer`. + public typealias SerializedObject = Value + + /// A closure used by response handlers that takes a request, response, data and error and returns a result. + public var serializeResponse: (URLRequest?, HTTPURLResponse?, Data?, Error?) -> Result + + /// Initializes the `ResponseSerializer` instance with the given serialize response closure. + /// + /// - parameter serializeResponse: The closure used to serialize the response. + /// + /// - returns: The new generic response serializer instance. + public init(serializeResponse: @escaping (URLRequest?, HTTPURLResponse?, Data?, Error?) -> Result) { + self.serializeResponse = serializeResponse + } +} + +// MARK: - + +/// The type in which all download response serializers must conform to in order to serialize a response. +public protocol DownloadResponseSerializerProtocol { + /// The type of serialized object to be created by this `DownloadResponseSerializerType`. + associatedtype SerializedObject + + /// A closure used by response handlers that takes a request, response, url and error and returns a result. + var serializeResponse: (URLRequest?, HTTPURLResponse?, URL?, Error?) -> Result { get } +} + +// MARK: - + +/// A generic `DownloadResponseSerializerType` used to serialize a request, response, and data into a serialized object. +public struct DownloadResponseSerializer: DownloadResponseSerializerProtocol { + /// The type of serialized object to be created by this `DownloadResponseSerializer`. + public typealias SerializedObject = Value + + /// A closure used by response handlers that takes a request, response, url and error and returns a result. + public var serializeResponse: (URLRequest?, HTTPURLResponse?, URL?, Error?) -> Result + + /// Initializes the `ResponseSerializer` instance with the given serialize response closure. + /// + /// - parameter serializeResponse: The closure used to serialize the response. + /// + /// - returns: The new generic response serializer instance. + public init(serializeResponse: @escaping (URLRequest?, HTTPURLResponse?, URL?, Error?) -> Result) { + self.serializeResponse = serializeResponse + } +} + +// MARK: - Timeline + +extension Request { + var timeline: Timeline { + let requestCompletedTime = self.endTime ?? CFAbsoluteTimeGetCurrent() + let initialResponseTime = self.delegate.initialResponseTime ?? requestCompletedTime + + return Timeline( + requestStartTime: self.startTime ?? CFAbsoluteTimeGetCurrent(), + initialResponseTime: initialResponseTime, + requestCompletedTime: requestCompletedTime, + serializationCompletedTime: CFAbsoluteTimeGetCurrent() + ) + } +} + +// MARK: - Default + +extension DataRequest { + /// Adds a handler to be called once the request has finished. + /// + /// - parameter queue: The queue on which the completion handler is dispatched. + /// - parameter completionHandler: The code to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func response(queue: DispatchQueue? = nil, completionHandler: @escaping (DefaultDataResponse) -> Void) -> Self { + delegate.queue.addOperation { + (queue ?? DispatchQueue.main).async { + var dataResponse = DefaultDataResponse( + request: self.request, + response: self.response, + data: self.delegate.data, + error: self.delegate.error, + timeline: self.timeline + ) + + dataResponse.add(self.delegate.metrics) + + completionHandler(dataResponse) + } + } + + return self + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter queue: The queue on which the completion handler is dispatched. + /// - parameter responseSerializer: The response serializer responsible for serializing the request, response, + /// and data. + /// - parameter completionHandler: The code to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func response( + queue: DispatchQueue? = nil, + responseSerializer: T, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + delegate.queue.addOperation { + let result = responseSerializer.serializeResponse( + self.request, + self.response, + self.delegate.data, + self.delegate.error + ) + + var dataResponse = DataResponse( + request: self.request, + response: self.response, + data: self.delegate.data, + result: result, + timeline: self.timeline + ) + + dataResponse.add(self.delegate.metrics) + + (queue ?? DispatchQueue.main).async { completionHandler(dataResponse) } + } + + return self + } +} + +extension DownloadRequest { + /// Adds a handler to be called once the request has finished. + /// + /// - parameter queue: The queue on which the completion handler is dispatched. + /// - parameter completionHandler: The code to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func response( + queue: DispatchQueue? = nil, + completionHandler: @escaping (DefaultDownloadResponse) -> Void) + -> Self + { + delegate.queue.addOperation { + (queue ?? DispatchQueue.main).async { + var downloadResponse = DefaultDownloadResponse( + request: self.request, + response: self.response, + temporaryURL: self.downloadDelegate.temporaryURL, + destinationURL: self.downloadDelegate.destinationURL, + resumeData: self.downloadDelegate.resumeData, + error: self.downloadDelegate.error, + timeline: self.timeline + ) + + downloadResponse.add(self.delegate.metrics) + + completionHandler(downloadResponse) + } + } + + return self + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter queue: The queue on which the completion handler is dispatched. + /// - parameter responseSerializer: The response serializer responsible for serializing the request, response, + /// and data contained in the destination url. + /// - parameter completionHandler: The code to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func response( + queue: DispatchQueue? = nil, + responseSerializer: T, + completionHandler: @escaping (DownloadResponse) -> Void) + -> Self + { + delegate.queue.addOperation { + let result = responseSerializer.serializeResponse( + self.request, + self.response, + self.downloadDelegate.fileURL, + self.downloadDelegate.error + ) + + var downloadResponse = DownloadResponse( + request: self.request, + response: self.response, + temporaryURL: self.downloadDelegate.temporaryURL, + destinationURL: self.downloadDelegate.destinationURL, + resumeData: self.downloadDelegate.resumeData, + result: result, + timeline: self.timeline + ) + + downloadResponse.add(self.delegate.metrics) + + (queue ?? DispatchQueue.main).async { completionHandler(downloadResponse) } + } + + return self + } +} + +// MARK: - Data + +extension Request { + /// Returns a result data type that contains the response data as-is. + /// + /// - parameter response: The response from the server. + /// - parameter data: The data returned from the server. + /// - parameter error: The error already encountered if it exists. + /// + /// - returns: The result data type. + public static func serializeResponseData(response: HTTPURLResponse?, data: Data?, error: Error?) -> Result { + guard error == nil else { return .failure(error!) } + + if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(Data()) } + + guard let validData = data else { + return .failure(AFError.responseSerializationFailed(reason: .inputDataNil)) + } + + return .success(validData) + } +} + +extension DataRequest { + /// Creates a response serializer that returns the associated data as-is. + /// + /// - returns: A data response serializer. + public static func dataResponseSerializer() -> DataResponseSerializer { + return DataResponseSerializer { _, response, data, error in + return Request.serializeResponseData(response: response, data: data, error: error) + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter completionHandler: The code to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseData( + queue: DispatchQueue? = nil, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DataRequest.dataResponseSerializer(), + completionHandler: completionHandler + ) + } +} + +extension DownloadRequest { + /// Creates a response serializer that returns the associated data as-is. + /// + /// - returns: A data response serializer. + public static func dataResponseSerializer() -> DownloadResponseSerializer { + return DownloadResponseSerializer { _, response, fileURL, error in + guard error == nil else { return .failure(error!) } + + guard let fileURL = fileURL else { + return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) + } + + do { + let data = try Data(contentsOf: fileURL) + return Request.serializeResponseData(response: response, data: data, error: error) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) + } + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter completionHandler: The code to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseData( + queue: DispatchQueue? = nil, + completionHandler: @escaping (DownloadResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DownloadRequest.dataResponseSerializer(), + completionHandler: completionHandler + ) + } +} + +// MARK: - String + +extension Request { + /// Returns a result string type initialized from the response data with the specified string encoding. + /// + /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server + /// response, falling back to the default HTTP default character set, ISO-8859-1. + /// - parameter response: The response from the server. + /// - parameter data: The data returned from the server. + /// - parameter error: The error already encountered if it exists. + /// + /// - returns: The result data type. + public static func serializeResponseString( + encoding: String.Encoding?, + response: HTTPURLResponse?, + data: Data?, + error: Error?) + -> Result + { + guard error == nil else { return .failure(error!) } + + if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success("") } + + guard let validData = data else { + return .failure(AFError.responseSerializationFailed(reason: .inputDataNil)) + } + + var convertedEncoding = encoding + + if let encodingName = response?.textEncodingName as CFString!, convertedEncoding == nil { + convertedEncoding = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding( + CFStringConvertIANACharSetNameToEncoding(encodingName)) + ) + } + + let actualEncoding = convertedEncoding ?? String.Encoding.isoLatin1 + + if let string = String(data: validData, encoding: actualEncoding) { + return .success(string) + } else { + return .failure(AFError.responseSerializationFailed(reason: .stringSerializationFailed(encoding: actualEncoding))) + } + } +} + +extension DataRequest { + /// Creates a response serializer that returns a result string type initialized from the response data with + /// the specified string encoding. + /// + /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server + /// response, falling back to the default HTTP default character set, ISO-8859-1. + /// + /// - returns: A string response serializer. + public static func stringResponseSerializer(encoding: String.Encoding? = nil) -> DataResponseSerializer { + return DataResponseSerializer { _, response, data, error in + return Request.serializeResponseString(encoding: encoding, response: response, data: data, error: error) + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the + /// server response, falling back to the default HTTP default character set, + /// ISO-8859-1. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseString( + queue: DispatchQueue? = nil, + encoding: String.Encoding? = nil, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DataRequest.stringResponseSerializer(encoding: encoding), + completionHandler: completionHandler + ) + } +} + +extension DownloadRequest { + /// Creates a response serializer that returns a result string type initialized from the response data with + /// the specified string encoding. + /// + /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server + /// response, falling back to the default HTTP default character set, ISO-8859-1. + /// + /// - returns: A string response serializer. + public static func stringResponseSerializer(encoding: String.Encoding? = nil) -> DownloadResponseSerializer { + return DownloadResponseSerializer { _, response, fileURL, error in + guard error == nil else { return .failure(error!) } + + guard let fileURL = fileURL else { + return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) + } + + do { + let data = try Data(contentsOf: fileURL) + return Request.serializeResponseString(encoding: encoding, response: response, data: data, error: error) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) + } + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the + /// server response, falling back to the default HTTP default character set, + /// ISO-8859-1. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseString( + queue: DispatchQueue? = nil, + encoding: String.Encoding? = nil, + completionHandler: @escaping (DownloadResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DownloadRequest.stringResponseSerializer(encoding: encoding), + completionHandler: completionHandler + ) + } +} + +// MARK: - JSON + +extension Request { + /// Returns a JSON object contained in a result type constructed from the response data using `JSONSerialization` + /// with the specified reading options. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// - parameter response: The response from the server. + /// - parameter data: The data returned from the server. + /// - parameter error: The error already encountered if it exists. + /// + /// - returns: The result data type. + public static func serializeResponseJSON( + options: JSONSerialization.ReadingOptions, + response: HTTPURLResponse?, + data: Data?, + error: Error?) + -> Result + { + guard error == nil else { return .failure(error!) } + + if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(NSNull()) } + + guard let validData = data, validData.count > 0 else { + return .failure(AFError.responseSerializationFailed(reason: .inputDataNilOrZeroLength)) + } + + do { + let json = try JSONSerialization.jsonObject(with: validData, options: options) + return .success(json) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .jsonSerializationFailed(error: error))) + } + } +} + +extension DataRequest { + /// Creates a response serializer that returns a JSON object result type constructed from the response data using + /// `JSONSerialization` with the specified reading options. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// + /// - returns: A JSON object response serializer. + public static func jsonResponseSerializer( + options: JSONSerialization.ReadingOptions = .allowFragments) + -> DataResponseSerializer + { + return DataResponseSerializer { _, response, data, error in + return Request.serializeResponseJSON(options: options, response: response, data: data, error: error) + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseJSON( + queue: DispatchQueue? = nil, + options: JSONSerialization.ReadingOptions = .allowFragments, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DataRequest.jsonResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} + +extension DownloadRequest { + /// Creates a response serializer that returns a JSON object result type constructed from the response data using + /// `JSONSerialization` with the specified reading options. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// + /// - returns: A JSON object response serializer. + public static func jsonResponseSerializer( + options: JSONSerialization.ReadingOptions = .allowFragments) + -> DownloadResponseSerializer + { + return DownloadResponseSerializer { _, response, fileURL, error in + guard error == nil else { return .failure(error!) } + + guard let fileURL = fileURL else { + return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) + } + + do { + let data = try Data(contentsOf: fileURL) + return Request.serializeResponseJSON(options: options, response: response, data: data, error: error) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) + } + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseJSON( + queue: DispatchQueue? = nil, + options: JSONSerialization.ReadingOptions = .allowFragments, + completionHandler: @escaping (DownloadResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DownloadRequest.jsonResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} + +// MARK: - Property List + +extension Request { + /// Returns a plist object contained in a result type constructed from the response data using + /// `PropertyListSerialization` with the specified reading options. + /// + /// - parameter options: The property list reading options. Defaults to `[]`. + /// - parameter response: The response from the server. + /// - parameter data: The data returned from the server. + /// - parameter error: The error already encountered if it exists. + /// + /// - returns: The result data type. + public static func serializeResponsePropertyList( + options: PropertyListSerialization.ReadOptions, + response: HTTPURLResponse?, + data: Data?, + error: Error?) + -> Result + { + guard error == nil else { return .failure(error!) } + + if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(NSNull()) } + + guard let validData = data, validData.count > 0 else { + return .failure(AFError.responseSerializationFailed(reason: .inputDataNilOrZeroLength)) + } + + do { + let plist = try PropertyListSerialization.propertyList(from: validData, options: options, format: nil) + return .success(plist) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .propertyListSerializationFailed(error: error))) + } + } +} + +extension DataRequest { + /// Creates a response serializer that returns an object constructed from the response data using + /// `PropertyListSerialization` with the specified reading options. + /// + /// - parameter options: The property list reading options. Defaults to `[]`. + /// + /// - returns: A property list object response serializer. + public static func propertyListResponseSerializer( + options: PropertyListSerialization.ReadOptions = []) + -> DataResponseSerializer + { + return DataResponseSerializer { _, response, data, error in + return Request.serializeResponsePropertyList(options: options, response: response, data: data, error: error) + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter options: The property list reading options. Defaults to `[]`. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responsePropertyList( + queue: DispatchQueue? = nil, + options: PropertyListSerialization.ReadOptions = [], + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DataRequest.propertyListResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} + +extension DownloadRequest { + /// Creates a response serializer that returns an object constructed from the response data using + /// `PropertyListSerialization` with the specified reading options. + /// + /// - parameter options: The property list reading options. Defaults to `[]`. + /// + /// - returns: A property list object response serializer. + public static func propertyListResponseSerializer( + options: PropertyListSerialization.ReadOptions = []) + -> DownloadResponseSerializer + { + return DownloadResponseSerializer { _, response, fileURL, error in + guard error == nil else { return .failure(error!) } + + guard let fileURL = fileURL else { + return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) + } + + do { + let data = try Data(contentsOf: fileURL) + return Request.serializeResponsePropertyList(options: options, response: response, data: data, error: error) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) + } + } + } + + /// Adds a handler to be called once the request has finished. + /// + /// - parameter options: The property list reading options. Defaults to `[]`. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responsePropertyList( + queue: DispatchQueue? = nil, + options: PropertyListSerialization.ReadOptions = [], + completionHandler: @escaping (DownloadResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DownloadRequest.propertyListResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} + +/// A set of HTTP response status code that do not contain response data. +private let emptyDataStatusCodes: Set = [204, 205] diff --git a/Pods/Alamofire/Source/Result.swift b/Pods/Alamofire/Source/Result.swift new file mode 100644 index 0000000..2293308 --- /dev/null +++ b/Pods/Alamofire/Source/Result.swift @@ -0,0 +1,102 @@ +// +// Result.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Used to represent whether a request was successful or encountered an error. +/// +/// - success: The request and all post processing operations were successful resulting in the serialization of the +/// provided associated value. +/// +/// - failure: The request encountered an error resulting in a failure. The associated values are the original data +/// provided by the server as well as the error that caused the failure. +public enum Result { + case success(Value) + case failure(Error) + + /// Returns `true` if the result is a success, `false` otherwise. + public var isSuccess: Bool { + switch self { + case .success: + return true + case .failure: + return false + } + } + + /// Returns `true` if the result is a failure, `false` otherwise. + public var isFailure: Bool { + return !isSuccess + } + + /// Returns the associated value if the result is a success, `nil` otherwise. + public var value: Value? { + switch self { + case .success(let value): + return value + case .failure: + return nil + } + } + + /// Returns the associated error value if the result is a failure, `nil` otherwise. + public var error: Error? { + switch self { + case .success: + return nil + case .failure(let error): + return error + } + } +} + +// MARK: - CustomStringConvertible + +extension Result: CustomStringConvertible { + /// The textual representation used when written to an output stream, which includes whether the result was a + /// success or failure. + public var description: String { + switch self { + case .success: + return "SUCCESS" + case .failure: + return "FAILURE" + } + } +} + +// MARK: - CustomDebugStringConvertible + +extension Result: CustomDebugStringConvertible { + /// The debug textual representation used when written to an output stream, which includes whether the result was a + /// success or failure in addition to the value or error. + public var debugDescription: String { + switch self { + case .success(let value): + return "SUCCESS: \(value)" + case .failure(let error): + return "FAILURE: \(error)" + } + } +} diff --git a/Pods/Alamofire/Source/ServerTrustPolicy.swift b/Pods/Alamofire/Source/ServerTrustPolicy.swift new file mode 100644 index 0000000..9c0e7c8 --- /dev/null +++ b/Pods/Alamofire/Source/ServerTrustPolicy.swift @@ -0,0 +1,307 @@ +// +// ServerTrustPolicy.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Responsible for managing the mapping of `ServerTrustPolicy` objects to a given host. +open class ServerTrustPolicyManager { + /// The dictionary of policies mapped to a particular host. + open let policies: [String: ServerTrustPolicy] + + /// Initializes the `ServerTrustPolicyManager` instance with the given policies. + /// + /// Since different servers and web services can have different leaf certificates, intermediate and even root + /// certficates, it is important to have the flexibility to specify evaluation policies on a per host basis. This + /// allows for scenarios such as using default evaluation for host1, certificate pinning for host2, public key + /// pinning for host3 and disabling evaluation for host4. + /// + /// - parameter policies: A dictionary of all policies mapped to a particular host. + /// + /// - returns: The new `ServerTrustPolicyManager` instance. + public init(policies: [String: ServerTrustPolicy]) { + self.policies = policies + } + + /// Returns the `ServerTrustPolicy` for the given host if applicable. + /// + /// By default, this method will return the policy that perfectly matches the given host. Subclasses could override + /// this method and implement more complex mapping implementations such as wildcards. + /// + /// - parameter host: The host to use when searching for a matching policy. + /// + /// - returns: The server trust policy for the given host if found. + open func serverTrustPolicy(forHost host: String) -> ServerTrustPolicy? { + return policies[host] + } +} + +// MARK: - + +extension URLSession { + private struct AssociatedKeys { + static var managerKey = "URLSession.ServerTrustPolicyManager" + } + + var serverTrustPolicyManager: ServerTrustPolicyManager? { + get { + return objc_getAssociatedObject(self, &AssociatedKeys.managerKey) as? ServerTrustPolicyManager + } + set (manager) { + objc_setAssociatedObject(self, &AssociatedKeys.managerKey, manager, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } +} + +// MARK: - ServerTrustPolicy + +/// The `ServerTrustPolicy` evaluates the server trust generally provided by an `NSURLAuthenticationChallenge` when +/// connecting to a server over a secure HTTPS connection. The policy configuration then evaluates the server trust +/// with a given set of criteria to determine whether the server trust is valid and the connection should be made. +/// +/// Using pinned certificates or public keys for evaluation helps prevent man-in-the-middle (MITM) attacks and other +/// vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged +/// to route all communication over an HTTPS connection with pinning enabled. +/// +/// - performDefaultEvaluation: Uses the default server trust evaluation while allowing you to control whether to +/// validate the host provided by the challenge. Applications are encouraged to always +/// validate the host in production environments to guarantee the validity of the server's +/// certificate chain. +/// +/// - performRevokedEvaluation: Uses the default and revoked server trust evaluations allowing you to control whether to +/// validate the host provided by the challenge as well as specify the revocation flags for +/// testing for revoked certificates. Apple platforms did not start testing for revoked +/// certificates automatically until iOS 10.1, macOS 10.12 and tvOS 10.1 which is +/// demonstrated in our TLS tests. Applications are encouraged to always validate the host +/// in production environments to guarantee the validity of the server's certificate chain. +/// +/// - pinCertificates: Uses the pinned certificates to validate the server trust. The server trust is +/// considered valid if one of the pinned certificates match one of the server certificates. +/// By validating both the certificate chain and host, certificate pinning provides a very +/// secure form of server trust validation mitigating most, if not all, MITM attacks. +/// Applications are encouraged to always validate the host and require a valid certificate +/// chain in production environments. +/// +/// - pinPublicKeys: Uses the pinned public keys to validate the server trust. The server trust is considered +/// valid if one of the pinned public keys match one of the server certificate public keys. +/// By validating both the certificate chain and host, public key pinning provides a very +/// secure form of server trust validation mitigating most, if not all, MITM attacks. +/// Applications are encouraged to always validate the host and require a valid certificate +/// chain in production environments. +/// +/// - disableEvaluation: Disables all evaluation which in turn will always consider any server trust as valid. +/// +/// - customEvaluation: Uses the associated closure to evaluate the validity of the server trust. +public enum ServerTrustPolicy { + case performDefaultEvaluation(validateHost: Bool) + case performRevokedEvaluation(validateHost: Bool, revocationFlags: CFOptionFlags) + case pinCertificates(certificates: [SecCertificate], validateCertificateChain: Bool, validateHost: Bool) + case pinPublicKeys(publicKeys: [SecKey], validateCertificateChain: Bool, validateHost: Bool) + case disableEvaluation + case customEvaluation((_ serverTrust: SecTrust, _ host: String) -> Bool) + + // MARK: - Bundle Location + + /// Returns all certificates within the given bundle with a `.cer` file extension. + /// + /// - parameter bundle: The bundle to search for all `.cer` files. + /// + /// - returns: All certificates within the given bundle. + public static func certificates(in bundle: Bundle = Bundle.main) -> [SecCertificate] { + var certificates: [SecCertificate] = [] + + let paths = Set([".cer", ".CER", ".crt", ".CRT", ".der", ".DER"].map { fileExtension in + bundle.paths(forResourcesOfType: fileExtension, inDirectory: nil) + }.joined()) + + for path in paths { + if + let certificateData = try? Data(contentsOf: URL(fileURLWithPath: path)) as CFData, + let certificate = SecCertificateCreateWithData(nil, certificateData) + { + certificates.append(certificate) + } + } + + return certificates + } + + /// Returns all public keys within the given bundle with a `.cer` file extension. + /// + /// - parameter bundle: The bundle to search for all `*.cer` files. + /// + /// - returns: All public keys within the given bundle. + public static func publicKeys(in bundle: Bundle = Bundle.main) -> [SecKey] { + var publicKeys: [SecKey] = [] + + for certificate in certificates(in: bundle) { + if let publicKey = publicKey(for: certificate) { + publicKeys.append(publicKey) + } + } + + return publicKeys + } + + // MARK: - Evaluation + + /// Evaluates whether the server trust is valid for the given host. + /// + /// - parameter serverTrust: The server trust to evaluate. + /// - parameter host: The host of the challenge protection space. + /// + /// - returns: Whether the server trust is valid. + public func evaluate(_ serverTrust: SecTrust, forHost host: String) -> Bool { + var serverTrustIsValid = false + + switch self { + case let .performDefaultEvaluation(validateHost): + let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + SecTrustSetPolicies(serverTrust, policy) + + serverTrustIsValid = trustIsValid(serverTrust) + case let .performRevokedEvaluation(validateHost, revocationFlags): + let defaultPolicy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + let revokedPolicy = SecPolicyCreateRevocation(revocationFlags) + SecTrustSetPolicies(serverTrust, [defaultPolicy, revokedPolicy] as CFTypeRef) + + serverTrustIsValid = trustIsValid(serverTrust) + case let .pinCertificates(pinnedCertificates, validateCertificateChain, validateHost): + if validateCertificateChain { + let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + SecTrustSetPolicies(serverTrust, policy) + + SecTrustSetAnchorCertificates(serverTrust, pinnedCertificates as CFArray) + SecTrustSetAnchorCertificatesOnly(serverTrust, true) + + serverTrustIsValid = trustIsValid(serverTrust) + } else { + let serverCertificatesDataArray = certificateData(for: serverTrust) + let pinnedCertificatesDataArray = certificateData(for: pinnedCertificates) + + outerLoop: for serverCertificateData in serverCertificatesDataArray { + for pinnedCertificateData in pinnedCertificatesDataArray { + if serverCertificateData == pinnedCertificateData { + serverTrustIsValid = true + break outerLoop + } + } + } + } + case let .pinPublicKeys(pinnedPublicKeys, validateCertificateChain, validateHost): + var certificateChainEvaluationPassed = true + + if validateCertificateChain { + let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + SecTrustSetPolicies(serverTrust, policy) + + certificateChainEvaluationPassed = trustIsValid(serverTrust) + } + + if certificateChainEvaluationPassed { + outerLoop: for serverPublicKey in ServerTrustPolicy.publicKeys(for: serverTrust) as [AnyObject] { + for pinnedPublicKey in pinnedPublicKeys as [AnyObject] { + if serverPublicKey.isEqual(pinnedPublicKey) { + serverTrustIsValid = true + break outerLoop + } + } + } + } + case .disableEvaluation: + serverTrustIsValid = true + case let .customEvaluation(closure): + serverTrustIsValid = closure(serverTrust, host) + } + + return serverTrustIsValid + } + + // MARK: - Private - Trust Validation + + private func trustIsValid(_ trust: SecTrust) -> Bool { + var isValid = false + + var result = SecTrustResultType.invalid + let status = SecTrustEvaluate(trust, &result) + + if status == errSecSuccess { + let unspecified = SecTrustResultType.unspecified + let proceed = SecTrustResultType.proceed + + + isValid = result == unspecified || result == proceed + } + + return isValid + } + + // MARK: - Private - Certificate Data + + private func certificateData(for trust: SecTrust) -> [Data] { + var certificates: [SecCertificate] = [] + + for index in 0.. [Data] { + return certificates.map { SecCertificateCopyData($0) as Data } + } + + // MARK: - Private - Public Key Extraction + + private static func publicKeys(for trust: SecTrust) -> [SecKey] { + var publicKeys: [SecKey] = [] + + for index in 0.. SecKey? { + var publicKey: SecKey? + + let policy = SecPolicyCreateBasicX509() + var trust: SecTrust? + let trustCreationStatus = SecTrustCreateWithCertificates(certificate, policy, &trust) + + if let trust = trust, trustCreationStatus == errSecSuccess { + publicKey = SecTrustCopyPublicKey(trust) + } + + return publicKey + } +} diff --git a/Pods/Alamofire/Source/SessionDelegate.swift b/Pods/Alamofire/Source/SessionDelegate.swift new file mode 100644 index 0000000..15268c3 --- /dev/null +++ b/Pods/Alamofire/Source/SessionDelegate.swift @@ -0,0 +1,721 @@ +// +// SessionDelegate.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Responsible for handling all delegate callbacks for the underlying session. +open class SessionDelegate: NSObject { + + // MARK: URLSessionDelegate Overrides + + /// Overrides default behavior for URLSessionDelegate method `urlSession(_:didBecomeInvalidWithError:)`. + open var sessionDidBecomeInvalidWithError: ((URLSession, Error?) -> Void)? + + /// Overrides default behavior for URLSessionDelegate method `urlSession(_:didReceive:completionHandler:)`. + open var sessionDidReceiveChallenge: ((URLSession, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? + + /// Overrides all behavior for URLSessionDelegate method `urlSession(_:didReceive:completionHandler:)` and requires the caller to call the `completionHandler`. + open var sessionDidReceiveChallengeWithCompletion: ((URLSession, URLAuthenticationChallenge, (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Void)? + + /// Overrides default behavior for URLSessionDelegate method `urlSessionDidFinishEvents(forBackgroundURLSession:)`. + open var sessionDidFinishEventsForBackgroundURLSession: ((URLSession) -> Void)? + + // MARK: URLSessionTaskDelegate Overrides + + /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)`. + open var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> URLRequest?)? + + /// Overrides all behavior for URLSessionTaskDelegate method `urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)` and + /// requires the caller to call the `completionHandler`. + open var taskWillPerformHTTPRedirectionWithCompletion: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest, (URLRequest?) -> Void) -> Void)? + + /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:didReceive:completionHandler:)`. + open var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? + + /// Overrides all behavior for URLSessionTaskDelegate method `urlSession(_:task:didReceive:completionHandler:)` and + /// requires the caller to call the `completionHandler`. + open var taskDidReceiveChallengeWithCompletion: ((URLSession, URLSessionTask, URLAuthenticationChallenge, (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Void)? + + /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:needNewBodyStream:)`. + open var taskNeedNewBodyStream: ((URLSession, URLSessionTask) -> InputStream?)? + + /// Overrides all behavior for URLSessionTaskDelegate method `urlSession(_:task:needNewBodyStream:)` and + /// requires the caller to call the `completionHandler`. + open var taskNeedNewBodyStreamWithCompletion: ((URLSession, URLSessionTask, (InputStream?) -> Void) -> Void)? + + /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)`. + open var taskDidSendBodyData: ((URLSession, URLSessionTask, Int64, Int64, Int64) -> Void)? + + /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:didCompleteWithError:)`. + open var taskDidComplete: ((URLSession, URLSessionTask, Error?) -> Void)? + + // MARK: URLSessionDataDelegate Overrides + + /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didReceive:completionHandler:)`. + open var dataTaskDidReceiveResponse: ((URLSession, URLSessionDataTask, URLResponse) -> URLSession.ResponseDisposition)? + + /// Overrides all behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didReceive:completionHandler:)` and + /// requires caller to call the `completionHandler`. + open var dataTaskDidReceiveResponseWithCompletion: ((URLSession, URLSessionDataTask, URLResponse, (URLSession.ResponseDisposition) -> Void) -> Void)? + + /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didBecome:)`. + open var dataTaskDidBecomeDownloadTask: ((URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)? + + /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didReceive:)`. + open var dataTaskDidReceiveData: ((URLSession, URLSessionDataTask, Data) -> Void)? + + /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:willCacheResponse:completionHandler:)`. + open var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)? + + /// Overrides all behavior for URLSessionDataDelegate method `urlSession(_:dataTask:willCacheResponse:completionHandler:)` and + /// requires caller to call the `completionHandler`. + open var dataTaskWillCacheResponseWithCompletion: ((URLSession, URLSessionDataTask, CachedURLResponse, (CachedURLResponse?) -> Void) -> Void)? + + // MARK: URLSessionDownloadDelegate Overrides + + /// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didFinishDownloadingTo:)`. + open var downloadTaskDidFinishDownloadingToURL: ((URLSession, URLSessionDownloadTask, URL) -> Void)? + + /// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:)`. + open var downloadTaskDidWriteData: ((URLSession, URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? + + /// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:)`. + open var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)? + + // MARK: URLSessionStreamDelegate Overrides + +#if !os(watchOS) + + /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:readClosedFor:)`. + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + open var streamTaskReadClosed: ((URLSession, URLSessionStreamTask) -> Void)? { + get { + return _streamTaskReadClosed as? (URLSession, URLSessionStreamTask) -> Void + } + set { + _streamTaskReadClosed = newValue + } + } + + /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:writeClosedFor:)`. + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + open var streamTaskWriteClosed: ((URLSession, URLSessionStreamTask) -> Void)? { + get { + return _streamTaskWriteClosed as? (URLSession, URLSessionStreamTask) -> Void + } + set { + _streamTaskWriteClosed = newValue + } + } + + /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:betterRouteDiscoveredFor:)`. + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + open var streamTaskBetterRouteDiscovered: ((URLSession, URLSessionStreamTask) -> Void)? { + get { + return _streamTaskBetterRouteDiscovered as? (URLSession, URLSessionStreamTask) -> Void + } + set { + _streamTaskBetterRouteDiscovered = newValue + } + } + + /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:streamTask:didBecome:outputStream:)`. + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + open var streamTaskDidBecomeInputAndOutputStreams: ((URLSession, URLSessionStreamTask, InputStream, OutputStream) -> Void)? { + get { + return _streamTaskDidBecomeInputStream as? (URLSession, URLSessionStreamTask, InputStream, OutputStream) -> Void + } + set { + _streamTaskDidBecomeInputStream = newValue + } + } + + var _streamTaskReadClosed: Any? + var _streamTaskWriteClosed: Any? + var _streamTaskBetterRouteDiscovered: Any? + var _streamTaskDidBecomeInputStream: Any? + +#endif + + // MARK: Properties + + var retrier: RequestRetrier? + weak var sessionManager: SessionManager? + + private var requests: [Int: Request] = [:] + private let lock = NSLock() + + /// Access the task delegate for the specified task in a thread-safe manner. + open subscript(task: URLSessionTask) -> Request? { + get { + lock.lock() ; defer { lock.unlock() } + return requests[task.taskIdentifier] + } + set { + lock.lock() ; defer { lock.unlock() } + requests[task.taskIdentifier] = newValue + } + } + + // MARK: Lifecycle + + /// Initializes the `SessionDelegate` instance. + /// + /// - returns: The new `SessionDelegate` instance. + public override init() { + super.init() + } + + // MARK: NSObject Overrides + + /// Returns a `Bool` indicating whether the `SessionDelegate` implements or inherits a method that can respond + /// to a specified message. + /// + /// - parameter selector: A selector that identifies a message. + /// + /// - returns: `true` if the receiver implements or inherits a method that can respond to selector, otherwise `false`. + open override func responds(to selector: Selector) -> Bool { + #if !os(macOS) + if selector == #selector(URLSessionDelegate.urlSessionDidFinishEvents(forBackgroundURLSession:)) { + return sessionDidFinishEventsForBackgroundURLSession != nil + } + #endif + + #if !os(watchOS) + if #available(iOS 9.0, macOS 10.11, tvOS 9.0, *) { + switch selector { + case #selector(URLSessionStreamDelegate.urlSession(_:readClosedFor:)): + return streamTaskReadClosed != nil + case #selector(URLSessionStreamDelegate.urlSession(_:writeClosedFor:)): + return streamTaskWriteClosed != nil + case #selector(URLSessionStreamDelegate.urlSession(_:betterRouteDiscoveredFor:)): + return streamTaskBetterRouteDiscovered != nil + case #selector(URLSessionStreamDelegate.urlSession(_:streamTask:didBecome:outputStream:)): + return streamTaskDidBecomeInputAndOutputStreams != nil + default: + break + } + } + #endif + + switch selector { + case #selector(URLSessionDelegate.urlSession(_:didBecomeInvalidWithError:)): + return sessionDidBecomeInvalidWithError != nil + case #selector(URLSessionDelegate.urlSession(_:didReceive:completionHandler:)): + return (sessionDidReceiveChallenge != nil || sessionDidReceiveChallengeWithCompletion != nil) + case #selector(URLSessionTaskDelegate.urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)): + return (taskWillPerformHTTPRedirection != nil || taskWillPerformHTTPRedirectionWithCompletion != nil) + case #selector(URLSessionDataDelegate.urlSession(_:dataTask:didReceive:completionHandler:)): + return (dataTaskDidReceiveResponse != nil || dataTaskDidReceiveResponseWithCompletion != nil) + default: + return type(of: self).instancesRespond(to: selector) + } + } +} + +// MARK: - URLSessionDelegate + +extension SessionDelegate: URLSessionDelegate { + /// Tells the delegate that the session has been invalidated. + /// + /// - parameter session: The session object that was invalidated. + /// - parameter error: The error that caused invalidation, or nil if the invalidation was explicit. + open func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) { + sessionDidBecomeInvalidWithError?(session, error) + } + + /// Requests credentials from the delegate in response to a session-level authentication request from the + /// remote server. + /// + /// - parameter session: The session containing the task that requested authentication. + /// - parameter challenge: An object that contains the request for authentication. + /// - parameter completionHandler: A handler that your delegate method must call providing the disposition + /// and credential. + open func urlSession( + _ session: URLSession, + didReceive challenge: URLAuthenticationChallenge, + completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) + { + guard sessionDidReceiveChallengeWithCompletion == nil else { + sessionDidReceiveChallengeWithCompletion?(session, challenge, completionHandler) + return + } + + var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling + var credential: URLCredential? + + if let sessionDidReceiveChallenge = sessionDidReceiveChallenge { + (disposition, credential) = sessionDidReceiveChallenge(session, challenge) + } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { + let host = challenge.protectionSpace.host + + if + let serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicy(forHost: host), + let serverTrust = challenge.protectionSpace.serverTrust + { + if serverTrustPolicy.evaluate(serverTrust, forHost: host) { + disposition = .useCredential + credential = URLCredential(trust: serverTrust) + } else { + disposition = .cancelAuthenticationChallenge + } + } + } + + completionHandler(disposition, credential) + } + +#if !os(macOS) + + /// Tells the delegate that all messages enqueued for a session have been delivered. + /// + /// - parameter session: The session that no longer has any outstanding requests. + open func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession) { + sessionDidFinishEventsForBackgroundURLSession?(session) + } + +#endif +} + +// MARK: - URLSessionTaskDelegate + +extension SessionDelegate: URLSessionTaskDelegate { + /// Tells the delegate that the remote server requested an HTTP redirect. + /// + /// - parameter session: The session containing the task whose request resulted in a redirect. + /// - parameter task: The task whose request resulted in a redirect. + /// - parameter response: An object containing the server’s response to the original request. + /// - parameter request: A URL request object filled out with the new location. + /// - parameter completionHandler: A closure that your handler should call with either the value of the request + /// parameter, a modified URL request object, or NULL to refuse the redirect and + /// return the body of the redirect response. + open func urlSession( + _ session: URLSession, + task: URLSessionTask, + willPerformHTTPRedirection response: HTTPURLResponse, + newRequest request: URLRequest, + completionHandler: @escaping (URLRequest?) -> Void) + { + guard taskWillPerformHTTPRedirectionWithCompletion == nil else { + taskWillPerformHTTPRedirectionWithCompletion?(session, task, response, request, completionHandler) + return + } + + var redirectRequest: URLRequest? = request + + if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection { + redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request) + } + + completionHandler(redirectRequest) + } + + /// Requests credentials from the delegate in response to an authentication request from the remote server. + /// + /// - parameter session: The session containing the task whose request requires authentication. + /// - parameter task: The task whose request requires authentication. + /// - parameter challenge: An object that contains the request for authentication. + /// - parameter completionHandler: A handler that your delegate method must call providing the disposition + /// and credential. + open func urlSession( + _ session: URLSession, + task: URLSessionTask, + didReceive challenge: URLAuthenticationChallenge, + completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) + { + guard taskDidReceiveChallengeWithCompletion == nil else { + taskDidReceiveChallengeWithCompletion?(session, task, challenge, completionHandler) + return + } + + if let taskDidReceiveChallenge = taskDidReceiveChallenge { + let result = taskDidReceiveChallenge(session, task, challenge) + completionHandler(result.0, result.1) + } else if let delegate = self[task]?.delegate { + delegate.urlSession( + session, + task: task, + didReceive: challenge, + completionHandler: completionHandler + ) + } else { + urlSession(session, didReceive: challenge, completionHandler: completionHandler) + } + } + + /// Tells the delegate when a task requires a new request body stream to send to the remote server. + /// + /// - parameter session: The session containing the task that needs a new body stream. + /// - parameter task: The task that needs a new body stream. + /// - parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + open func urlSession( + _ session: URLSession, + task: URLSessionTask, + needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) + { + guard taskNeedNewBodyStreamWithCompletion == nil else { + taskNeedNewBodyStreamWithCompletion?(session, task, completionHandler) + return + } + + if let taskNeedNewBodyStream = taskNeedNewBodyStream { + completionHandler(taskNeedNewBodyStream(session, task)) + } else if let delegate = self[task]?.delegate { + delegate.urlSession(session, task: task, needNewBodyStream: completionHandler) + } + } + + /// Periodically informs the delegate of the progress of sending body content to the server. + /// + /// - parameter session: The session containing the data task. + /// - parameter task: The data task. + /// - parameter bytesSent: The number of bytes sent since the last time this delegate method was called. + /// - parameter totalBytesSent: The total number of bytes sent so far. + /// - parameter totalBytesExpectedToSend: The expected length of the body data. + open func urlSession( + _ session: URLSession, + task: URLSessionTask, + didSendBodyData bytesSent: Int64, + totalBytesSent: Int64, + totalBytesExpectedToSend: Int64) + { + if let taskDidSendBodyData = taskDidSendBodyData { + taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend) + } else if let delegate = self[task]?.delegate as? UploadTaskDelegate { + delegate.URLSession( + session, + task: task, + didSendBodyData: bytesSent, + totalBytesSent: totalBytesSent, + totalBytesExpectedToSend: totalBytesExpectedToSend + ) + } + } + +#if !os(watchOS) + + /// Tells the delegate that the session finished collecting metrics for the task. + /// + /// - parameter session: The session collecting the metrics. + /// - parameter task: The task whose metrics have been collected. + /// - parameter metrics: The collected metrics. + @available(iOS 10.0, macOS 10.12, tvOS 10.0, *) + @objc(URLSession:task:didFinishCollectingMetrics:) + open func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) { + self[task]?.delegate.metrics = metrics + } + +#endif + + /// Tells the delegate that the task finished transferring data. + /// + /// - parameter session: The session containing the task whose request finished transferring data. + /// - parameter task: The task whose request finished transferring data. + /// - parameter error: If an error occurred, an error object indicating how the transfer failed, otherwise nil. + open func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { + /// Executed after it is determined that the request is not going to be retried + let completeTask: (URLSession, URLSessionTask, Error?) -> Void = { [weak self] session, task, error in + guard let strongSelf = self else { return } + + if let taskDidComplete = strongSelf.taskDidComplete { + taskDidComplete(session, task, error) + } else if let delegate = strongSelf[task]?.delegate { + delegate.urlSession(session, task: task, didCompleteWithError: error) + } + + NotificationCenter.default.post( + name: Notification.Name.Task.DidComplete, + object: strongSelf, + userInfo: [Notification.Key.Task: task] + ) + + strongSelf[task] = nil + } + + guard let request = self[task], let sessionManager = sessionManager else { + completeTask(session, task, error) + return + } + + // Run all validations on the request before checking if an error occurred + request.validations.forEach { $0() } + + // Determine whether an error has occurred + var error: Error? = error + + if let taskDelegate = self[task]?.delegate, taskDelegate.error != nil { + error = taskDelegate.error + } + + /// If an error occurred and the retrier is set, asynchronously ask the retrier if the request + /// should be retried. Otherwise, complete the task by notifying the task delegate. + if let retrier = retrier, let error = error { + retrier.should(sessionManager, retry: request, with: error) { [weak self] shouldRetry, timeDelay in + guard shouldRetry else { completeTask(session, task, error) ; return } + + DispatchQueue.utility.after(timeDelay) { [weak self] in + guard let strongSelf = self else { return } + + let retrySucceeded = strongSelf.sessionManager?.retry(request) ?? false + + if retrySucceeded, let task = request.task { + strongSelf[task] = request + return + } else { + completeTask(session, task, error) + } + } + } + } else { + completeTask(session, task, error) + } + } +} + +// MARK: - URLSessionDataDelegate + +extension SessionDelegate: URLSessionDataDelegate { + /// Tells the delegate that the data task received the initial reply (headers) from the server. + /// + /// - parameter session: The session containing the data task that received an initial reply. + /// - parameter dataTask: The data task that received an initial reply. + /// - parameter response: A URL response object populated with headers. + /// - parameter completionHandler: A completion handler that your code calls to continue the transfer, passing a + /// constant to indicate whether the transfer should continue as a data task or + /// should become a download task. + open func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + didReceive response: URLResponse, + completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) + { + guard dataTaskDidReceiveResponseWithCompletion == nil else { + dataTaskDidReceiveResponseWithCompletion?(session, dataTask, response, completionHandler) + return + } + + var disposition: URLSession.ResponseDisposition = .allow + + if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse { + disposition = dataTaskDidReceiveResponse(session, dataTask, response) + } + + completionHandler(disposition) + } + + /// Tells the delegate that the data task was changed to a download task. + /// + /// - parameter session: The session containing the task that was replaced by a download task. + /// - parameter dataTask: The data task that was replaced by a download task. + /// - parameter downloadTask: The new download task that replaced the data task. + open func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + didBecome downloadTask: URLSessionDownloadTask) + { + if let dataTaskDidBecomeDownloadTask = dataTaskDidBecomeDownloadTask { + dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask) + } else { + self[downloadTask]?.delegate = DownloadTaskDelegate(task: downloadTask) + } + } + + /// Tells the delegate that the data task has received some of the expected data. + /// + /// - parameter session: The session containing the data task that provided data. + /// - parameter dataTask: The data task that provided data. + /// - parameter data: A data object containing the transferred data. + open func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { + if let dataTaskDidReceiveData = dataTaskDidReceiveData { + dataTaskDidReceiveData(session, dataTask, data) + } else if let delegate = self[dataTask]?.delegate as? DataTaskDelegate { + delegate.urlSession(session, dataTask: dataTask, didReceive: data) + } + } + + /// Asks the delegate whether the data (or upload) task should store the response in the cache. + /// + /// - parameter session: The session containing the data (or upload) task. + /// - parameter dataTask: The data (or upload) task. + /// - parameter proposedResponse: The default caching behavior. This behavior is determined based on the current + /// caching policy and the values of certain received headers, such as the Pragma + /// and Cache-Control headers. + /// - parameter completionHandler: A block that your handler must call, providing either the original proposed + /// response, a modified version of that response, or NULL to prevent caching the + /// response. If your delegate implements this method, it must call this completion + /// handler; otherwise, your app leaks memory. + open func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + willCacheResponse proposedResponse: CachedURLResponse, + completionHandler: @escaping (CachedURLResponse?) -> Void) + { + guard dataTaskWillCacheResponseWithCompletion == nil else { + dataTaskWillCacheResponseWithCompletion?(session, dataTask, proposedResponse, completionHandler) + return + } + + if let dataTaskWillCacheResponse = dataTaskWillCacheResponse { + completionHandler(dataTaskWillCacheResponse(session, dataTask, proposedResponse)) + } else if let delegate = self[dataTask]?.delegate as? DataTaskDelegate { + delegate.urlSession( + session, + dataTask: dataTask, + willCacheResponse: proposedResponse, + completionHandler: completionHandler + ) + } else { + completionHandler(proposedResponse) + } + } +} + +// MARK: - URLSessionDownloadDelegate + +extension SessionDelegate: URLSessionDownloadDelegate { + /// Tells the delegate that a download task has finished downloading. + /// + /// - parameter session: The session containing the download task that finished. + /// - parameter downloadTask: The download task that finished. + /// - parameter location: A file URL for the temporary file. Because the file is temporary, you must either + /// open the file for reading or move it to a permanent location in your app’s sandbox + /// container directory before returning from this delegate method. + open func urlSession( + _ session: URLSession, + downloadTask: URLSessionDownloadTask, + didFinishDownloadingTo location: URL) + { + if let downloadTaskDidFinishDownloadingToURL = downloadTaskDidFinishDownloadingToURL { + downloadTaskDidFinishDownloadingToURL(session, downloadTask, location) + } else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate { + delegate.urlSession(session, downloadTask: downloadTask, didFinishDownloadingTo: location) + } + } + + /// Periodically informs the delegate about the download’s progress. + /// + /// - parameter session: The session containing the download task. + /// - parameter downloadTask: The download task. + /// - parameter bytesWritten: The number of bytes transferred since the last time this delegate + /// method was called. + /// - parameter totalBytesWritten: The total number of bytes transferred so far. + /// - parameter totalBytesExpectedToWrite: The expected length of the file, as provided by the Content-Length + /// header. If this header was not provided, the value is + /// `NSURLSessionTransferSizeUnknown`. + open func urlSession( + _ session: URLSession, + downloadTask: URLSessionDownloadTask, + didWriteData bytesWritten: Int64, + totalBytesWritten: Int64, + totalBytesExpectedToWrite: Int64) + { + if let downloadTaskDidWriteData = downloadTaskDidWriteData { + downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) + } else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate { + delegate.urlSession( + session, + downloadTask: downloadTask, + didWriteData: bytesWritten, + totalBytesWritten: totalBytesWritten, + totalBytesExpectedToWrite: totalBytesExpectedToWrite + ) + } + } + + /// Tells the delegate that the download task has resumed downloading. + /// + /// - parameter session: The session containing the download task that finished. + /// - parameter downloadTask: The download task that resumed. See explanation in the discussion. + /// - parameter fileOffset: If the file's cache policy or last modified date prevents reuse of the + /// existing content, then this value is zero. Otherwise, this value is an + /// integer representing the number of bytes on disk that do not need to be + /// retrieved again. + /// - parameter expectedTotalBytes: The expected length of the file, as provided by the Content-Length header. + /// If this header was not provided, the value is NSURLSessionTransferSizeUnknown. + open func urlSession( + _ session: URLSession, + downloadTask: URLSessionDownloadTask, + didResumeAtOffset fileOffset: Int64, + expectedTotalBytes: Int64) + { + if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset { + downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes) + } else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate { + delegate.urlSession( + session, + downloadTask: downloadTask, + didResumeAtOffset: fileOffset, + expectedTotalBytes: expectedTotalBytes + ) + } + } +} + +// MARK: - URLSessionStreamDelegate + +#if !os(watchOS) + +@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) +extension SessionDelegate: URLSessionStreamDelegate { + /// Tells the delegate that the read side of the connection has been closed. + /// + /// - parameter session: The session. + /// - parameter streamTask: The stream task. + open func urlSession(_ session: URLSession, readClosedFor streamTask: URLSessionStreamTask) { + streamTaskReadClosed?(session, streamTask) + } + + /// Tells the delegate that the write side of the connection has been closed. + /// + /// - parameter session: The session. + /// - parameter streamTask: The stream task. + open func urlSession(_ session: URLSession, writeClosedFor streamTask: URLSessionStreamTask) { + streamTaskWriteClosed?(session, streamTask) + } + + /// Tells the delegate that the system has determined that a better route to the host is available. + /// + /// - parameter session: The session. + /// - parameter streamTask: The stream task. + open func urlSession(_ session: URLSession, betterRouteDiscoveredFor streamTask: URLSessionStreamTask) { + streamTaskBetterRouteDiscovered?(session, streamTask) + } + + /// Tells the delegate that the stream task has been completed and provides the unopened stream objects. + /// + /// - parameter session: The session. + /// - parameter streamTask: The stream task. + /// - parameter inputStream: The new input stream. + /// - parameter outputStream: The new output stream. + open func urlSession( + _ session: URLSession, + streamTask: URLSessionStreamTask, + didBecome inputStream: InputStream, + outputStream: OutputStream) + { + streamTaskDidBecomeInputAndOutputStreams?(session, streamTask, inputStream, outputStream) + } +} + +#endif diff --git a/Pods/Alamofire/Source/SessionManager.swift b/Pods/Alamofire/Source/SessionManager.swift new file mode 100644 index 0000000..450f750 --- /dev/null +++ b/Pods/Alamofire/Source/SessionManager.swift @@ -0,0 +1,891 @@ +// +// SessionManager.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Responsible for creating and managing `Request` objects, as well as their underlying `NSURLSession`. +open class SessionManager { + + // MARK: - Helper Types + + /// Defines whether the `MultipartFormData` encoding was successful and contains result of the encoding as + /// associated values. + /// + /// - Success: Represents a successful `MultipartFormData` encoding and contains the new `UploadRequest` along with + /// streaming information. + /// - Failure: Used to represent a failure in the `MultipartFormData` encoding and also contains the encoding + /// error. + public enum MultipartFormDataEncodingResult { + case success(request: UploadRequest, streamingFromDisk: Bool, streamFileURL: URL?) + case failure(Error) + } + + // MARK: - Properties + + /// A default instance of `SessionManager`, used by top-level Alamofire request methods, and suitable for use + /// directly for any ad hoc requests. + open static let `default`: SessionManager = { + let configuration = URLSessionConfiguration.default + configuration.httpAdditionalHeaders = SessionManager.defaultHTTPHeaders + + return SessionManager(configuration: configuration) + }() + + /// Creates default values for the "Accept-Encoding", "Accept-Language" and "User-Agent" headers. + open static let defaultHTTPHeaders: HTTPHeaders = { + // Accept-Encoding HTTP Header; see https://tools.ietf.org/html/rfc7230#section-4.2.3 + let acceptEncoding: String = "gzip;q=1.0, compress;q=0.5" + + // Accept-Language HTTP Header; see https://tools.ietf.org/html/rfc7231#section-5.3.5 + let acceptLanguage = Locale.preferredLanguages.prefix(6).enumerated().map { index, languageCode in + let quality = 1.0 - (Double(index) * 0.1) + return "\(languageCode);q=\(quality)" + }.joined(separator: ", ") + + // User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3 + // Example: `iOS Example/1.0 (org.alamofire.iOS-Example; build:1; iOS 10.0.0) Alamofire/4.0.0` + let userAgent: String = { + if let info = Bundle.main.infoDictionary { + let executable = info[kCFBundleExecutableKey as String] as? String ?? "Unknown" + let bundle = info[kCFBundleIdentifierKey as String] as? String ?? "Unknown" + let appVersion = info["CFBundleShortVersionString"] as? String ?? "Unknown" + let appBuild = info[kCFBundleVersionKey as String] as? String ?? "Unknown" + + let osNameVersion: String = { + let version = ProcessInfo.processInfo.operatingSystemVersion + let versionString = "\(version.majorVersion).\(version.minorVersion).\(version.patchVersion)" + + let osName: String = { + #if os(iOS) + return "iOS" + #elseif os(watchOS) + return "watchOS" + #elseif os(tvOS) + return "tvOS" + #elseif os(macOS) + return "OS X" + #elseif os(Linux) + return "Linux" + #else + return "Unknown" + #endif + }() + + return "\(osName) \(versionString)" + }() + + let alamofireVersion: String = { + guard + let afInfo = Bundle(for: SessionManager.self).infoDictionary, + let build = afInfo["CFBundleShortVersionString"] + else { return "Unknown" } + + return "Alamofire/\(build)" + }() + + return "\(executable)/\(appVersion) (\(bundle); build:\(appBuild); \(osNameVersion)) \(alamofireVersion)" + } + + return "Alamofire" + }() + + return [ + "Accept-Encoding": acceptEncoding, + "Accept-Language": acceptLanguage, + "User-Agent": userAgent + ] + }() + + /// Default memory threshold used when encoding `MultipartFormData` in bytes. + open static let multipartFormDataEncodingMemoryThreshold: UInt64 = 10_000_000 + + /// The underlying session. + open let session: URLSession + + /// The session delegate handling all the task and session delegate callbacks. + open let delegate: SessionDelegate + + /// Whether to start requests immediately after being constructed. `true` by default. + open var startRequestsImmediately: Bool = true + + /// The request adapter called each time a new request is created. + open var adapter: RequestAdapter? + + /// The request retrier called each time a request encounters an error to determine whether to retry the request. + open var retrier: RequestRetrier? { + get { return delegate.retrier } + set { delegate.retrier = newValue } + } + + /// The background completion handler closure provided by the UIApplicationDelegate + /// `application:handleEventsForBackgroundURLSession:completionHandler:` method. By setting the background + /// completion handler, the SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` closure implementation + /// will automatically call the handler. + /// + /// If you need to handle your own events before the handler is called, then you need to override the + /// SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` and manually call the handler when finished. + /// + /// `nil` by default. + open var backgroundCompletionHandler: (() -> Void)? + + let queue = DispatchQueue(label: "org.alamofire.session-manager." + UUID().uuidString) + + // MARK: - Lifecycle + + /// Creates an instance with the specified `configuration`, `delegate` and `serverTrustPolicyManager`. + /// + /// - parameter configuration: The configuration used to construct the managed session. + /// `URLSessionConfiguration.default` by default. + /// - parameter delegate: The delegate used when initializing the session. `SessionDelegate()` by + /// default. + /// - parameter serverTrustPolicyManager: The server trust policy manager to use for evaluating all server trust + /// challenges. `nil` by default. + /// + /// - returns: The new `SessionManager` instance. + public init( + configuration: URLSessionConfiguration = URLSessionConfiguration.default, + delegate: SessionDelegate = SessionDelegate(), + serverTrustPolicyManager: ServerTrustPolicyManager? = nil) + { + self.delegate = delegate + self.session = URLSession(configuration: configuration, delegate: delegate, delegateQueue: nil) + + commonInit(serverTrustPolicyManager: serverTrustPolicyManager) + } + + /// Creates an instance with the specified `session`, `delegate` and `serverTrustPolicyManager`. + /// + /// - parameter session: The URL session. + /// - parameter delegate: The delegate of the URL session. Must equal the URL session's delegate. + /// - parameter serverTrustPolicyManager: The server trust policy manager to use for evaluating all server trust + /// challenges. `nil` by default. + /// + /// - returns: The new `SessionManager` instance if the URL session's delegate matches; `nil` otherwise. + public init?( + session: URLSession, + delegate: SessionDelegate, + serverTrustPolicyManager: ServerTrustPolicyManager? = nil) + { + guard delegate === session.delegate else { return nil } + + self.delegate = delegate + self.session = session + + commonInit(serverTrustPolicyManager: serverTrustPolicyManager) + } + + private func commonInit(serverTrustPolicyManager: ServerTrustPolicyManager?) { + session.serverTrustPolicyManager = serverTrustPolicyManager + + delegate.sessionManager = self + + delegate.sessionDidFinishEventsForBackgroundURLSession = { [weak self] session in + guard let strongSelf = self else { return } + DispatchQueue.main.async { strongSelf.backgroundCompletionHandler?() } + } + } + + deinit { + session.invalidateAndCancel() + } + + // MARK: - Data Request + + /// Creates a `DataRequest` to retrieve the contents of the specified `url`, `method`, `parameters`, `encoding` + /// and `headers`. + /// + /// - parameter url: The URL. + /// - parameter method: The HTTP method. `.get` by default. + /// - parameter parameters: The parameters. `nil` by default. + /// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. + /// - parameter headers: The HTTP headers. `nil` by default. + /// + /// - returns: The created `DataRequest`. + @discardableResult + open func request( + _ url: URLConvertible, + method: HTTPMethod = .get, + parameters: Parameters? = nil, + encoding: ParameterEncoding = URLEncoding.default, + headers: HTTPHeaders? = nil) + -> DataRequest + { + var originalRequest: URLRequest? + + do { + originalRequest = try URLRequest(url: url, method: method, headers: headers) + let encodedURLRequest = try encoding.encode(originalRequest!, with: parameters) + return request(encodedURLRequest) + } catch { + return request(originalRequest, failedWith: error) + } + } + + /// Creates a `DataRequest` to retrieve the contents of a URL based on the specified `urlRequest`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter urlRequest: The URL request. + /// + /// - returns: The created `DataRequest`. + open func request(_ urlRequest: URLRequestConvertible) -> DataRequest { + var originalRequest: URLRequest? + + do { + originalRequest = try urlRequest.asURLRequest() + let originalTask = DataRequest.Requestable(urlRequest: originalRequest!) + + let task = try originalTask.task(session: session, adapter: adapter, queue: queue) + let request = DataRequest(session: session, requestTask: .data(originalTask, task)) + + delegate[task] = request + + if startRequestsImmediately { request.resume() } + + return request + } catch { + return request(originalRequest, failedWith: error) + } + } + + // MARK: Private - Request Implementation + + private func request(_ urlRequest: URLRequest?, failedWith error: Error) -> DataRequest { + var requestTask: Request.RequestTask = .data(nil, nil) + + if let urlRequest = urlRequest { + let originalTask = DataRequest.Requestable(urlRequest: urlRequest) + requestTask = .data(originalTask, nil) + } + + let underlyingError = error.underlyingAdaptError ?? error + let request = DataRequest(session: session, requestTask: requestTask, error: underlyingError) + + if let retrier = retrier, error is AdaptError { + allowRetrier(retrier, toRetry: request, with: underlyingError) + } else { + if startRequestsImmediately { request.resume() } + } + + return request + } + + // MARK: - Download Request + + // MARK: URL Request + + /// Creates a `DownloadRequest` to retrieve the contents the specified `url`, `method`, `parameters`, `encoding`, + /// `headers` and save them to the `destination`. + /// + /// If `destination` is not specified, the contents will remain in the temporary location determined by the + /// underlying URL session. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter url: The URL. + /// - parameter method: The HTTP method. `.get` by default. + /// - parameter parameters: The parameters. `nil` by default. + /// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. + /// - parameter headers: The HTTP headers. `nil` by default. + /// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. + /// + /// - returns: The created `DownloadRequest`. + @discardableResult + open func download( + _ url: URLConvertible, + method: HTTPMethod = .get, + parameters: Parameters? = nil, + encoding: ParameterEncoding = URLEncoding.default, + headers: HTTPHeaders? = nil, + to destination: DownloadRequest.DownloadFileDestination? = nil) + -> DownloadRequest + { + do { + let urlRequest = try URLRequest(url: url, method: method, headers: headers) + let encodedURLRequest = try encoding.encode(urlRequest, with: parameters) + return download(encodedURLRequest, to: destination) + } catch { + return download(nil, to: destination, failedWith: error) + } + } + + /// Creates a `DownloadRequest` to retrieve the contents of a URL based on the specified `urlRequest` and save + /// them to the `destination`. + /// + /// If `destination` is not specified, the contents will remain in the temporary location determined by the + /// underlying URL session. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter urlRequest: The URL request + /// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. + /// + /// - returns: The created `DownloadRequest`. + @discardableResult + open func download( + _ urlRequest: URLRequestConvertible, + to destination: DownloadRequest.DownloadFileDestination? = nil) + -> DownloadRequest + { + do { + let urlRequest = try urlRequest.asURLRequest() + return download(.request(urlRequest), to: destination) + } catch { + return download(nil, to: destination, failedWith: error) + } + } + + // MARK: Resume Data + + /// Creates a `DownloadRequest` from the `resumeData` produced from a previous request cancellation to retrieve + /// the contents of the original request and save them to the `destination`. + /// + /// If `destination` is not specified, the contents will remain in the temporary location determined by the + /// underlying URL session. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken + /// on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the + /// data is written incorrectly and will always fail to resume the download. For more information about the bug and + /// possible workarounds, please refer to the following Stack Overflow post: + /// + /// - http://stackoverflow.com/a/39347461/1342462 + /// + /// - parameter resumeData: The resume data. This is an opaque data blob produced by `URLSessionDownloadTask` + /// when a task is cancelled. See `URLSession -downloadTask(withResumeData:)` for + /// additional information. + /// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. + /// + /// - returns: The created `DownloadRequest`. + @discardableResult + open func download( + resumingWith resumeData: Data, + to destination: DownloadRequest.DownloadFileDestination? = nil) + -> DownloadRequest + { + return download(.resumeData(resumeData), to: destination) + } + + // MARK: Private - Download Implementation + + private func download( + _ downloadable: DownloadRequest.Downloadable, + to destination: DownloadRequest.DownloadFileDestination?) + -> DownloadRequest + { + do { + let task = try downloadable.task(session: session, adapter: adapter, queue: queue) + let download = DownloadRequest(session: session, requestTask: .download(downloadable, task)) + + download.downloadDelegate.destination = destination + + delegate[task] = download + + if startRequestsImmediately { download.resume() } + + return download + } catch { + return download(downloadable, to: destination, failedWith: error) + } + } + + private func download( + _ downloadable: DownloadRequest.Downloadable?, + to destination: DownloadRequest.DownloadFileDestination?, + failedWith error: Error) + -> DownloadRequest + { + var downloadTask: Request.RequestTask = .download(nil, nil) + + if let downloadable = downloadable { + downloadTask = .download(downloadable, nil) + } + + let underlyingError = error.underlyingAdaptError ?? error + + let download = DownloadRequest(session: session, requestTask: downloadTask, error: underlyingError) + download.downloadDelegate.destination = destination + + if let retrier = retrier, error is AdaptError { + allowRetrier(retrier, toRetry: download, with: underlyingError) + } else { + if startRequestsImmediately { download.resume() } + } + + return download + } + + // MARK: - Upload Request + + // MARK: File + + /// Creates an `UploadRequest` from the specified `url`, `method` and `headers` for uploading the `file`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter file: The file to upload. + /// - parameter url: The URL. + /// - parameter method: The HTTP method. `.post` by default. + /// - parameter headers: The HTTP headers. `nil` by default. + /// + /// - returns: The created `UploadRequest`. + @discardableResult + open func upload( + _ fileURL: URL, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil) + -> UploadRequest + { + do { + let urlRequest = try URLRequest(url: url, method: method, headers: headers) + return upload(fileURL, with: urlRequest) + } catch { + return upload(nil, failedWith: error) + } + } + + /// Creates a `UploadRequest` from the specified `urlRequest` for uploading the `file`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter file: The file to upload. + /// - parameter urlRequest: The URL request. + /// + /// - returns: The created `UploadRequest`. + @discardableResult + open func upload(_ fileURL: URL, with urlRequest: URLRequestConvertible) -> UploadRequest { + do { + let urlRequest = try urlRequest.asURLRequest() + return upload(.file(fileURL, urlRequest)) + } catch { + return upload(nil, failedWith: error) + } + } + + // MARK: Data + + /// Creates an `UploadRequest` from the specified `url`, `method` and `headers` for uploading the `data`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter data: The data to upload. + /// - parameter url: The URL. + /// - parameter method: The HTTP method. `.post` by default. + /// - parameter headers: The HTTP headers. `nil` by default. + /// + /// - returns: The created `UploadRequest`. + @discardableResult + open func upload( + _ data: Data, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil) + -> UploadRequest + { + do { + let urlRequest = try URLRequest(url: url, method: method, headers: headers) + return upload(data, with: urlRequest) + } catch { + return upload(nil, failedWith: error) + } + } + + /// Creates an `UploadRequest` from the specified `urlRequest` for uploading the `data`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter data: The data to upload. + /// - parameter urlRequest: The URL request. + /// + /// - returns: The created `UploadRequest`. + @discardableResult + open func upload(_ data: Data, with urlRequest: URLRequestConvertible) -> UploadRequest { + do { + let urlRequest = try urlRequest.asURLRequest() + return upload(.data(data, urlRequest)) + } catch { + return upload(nil, failedWith: error) + } + } + + // MARK: InputStream + + /// Creates an `UploadRequest` from the specified `url`, `method` and `headers` for uploading the `stream`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter stream: The stream to upload. + /// - parameter url: The URL. + /// - parameter method: The HTTP method. `.post` by default. + /// - parameter headers: The HTTP headers. `nil` by default. + /// + /// - returns: The created `UploadRequest`. + @discardableResult + open func upload( + _ stream: InputStream, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil) + -> UploadRequest + { + do { + let urlRequest = try URLRequest(url: url, method: method, headers: headers) + return upload(stream, with: urlRequest) + } catch { + return upload(nil, failedWith: error) + } + } + + /// Creates an `UploadRequest` from the specified `urlRequest` for uploading the `stream`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter stream: The stream to upload. + /// - parameter urlRequest: The URL request. + /// + /// - returns: The created `UploadRequest`. + @discardableResult + open func upload(_ stream: InputStream, with urlRequest: URLRequestConvertible) -> UploadRequest { + do { + let urlRequest = try urlRequest.asURLRequest() + return upload(.stream(stream, urlRequest)) + } catch { + return upload(nil, failedWith: error) + } + } + + // MARK: MultipartFormData + + /// Encodes `multipartFormData` using `encodingMemoryThreshold` and calls `encodingCompletion` with new + /// `UploadRequest` using the `url`, `method` and `headers`. + /// + /// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative + /// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most + /// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to + /// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory + /// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be + /// used for larger payloads such as video content. + /// + /// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory + /// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, + /// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk + /// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding + /// technique was used. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. + /// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. + /// `multipartFormDataEncodingMemoryThreshold` by default. + /// - parameter url: The URL. + /// - parameter method: The HTTP method. `.post` by default. + /// - parameter headers: The HTTP headers. `nil` by default. + /// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. + open func upload( + multipartFormData: @escaping (MultipartFormData) -> Void, + usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, + to url: URLConvertible, + method: HTTPMethod = .post, + headers: HTTPHeaders? = nil, + encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?) + { + do { + let urlRequest = try URLRequest(url: url, method: method, headers: headers) + + return upload( + multipartFormData: multipartFormData, + usingThreshold: encodingMemoryThreshold, + with: urlRequest, + encodingCompletion: encodingCompletion + ) + } catch { + DispatchQueue.main.async { encodingCompletion?(.failure(error)) } + } + } + + /// Encodes `multipartFormData` using `encodingMemoryThreshold` and calls `encodingCompletion` with new + /// `UploadRequest` using the `urlRequest`. + /// + /// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative + /// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most + /// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to + /// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory + /// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be + /// used for larger payloads such as video content. + /// + /// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory + /// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, + /// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk + /// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding + /// technique was used. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. + /// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. + /// `multipartFormDataEncodingMemoryThreshold` by default. + /// - parameter urlRequest: The URL request. + /// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. + open func upload( + multipartFormData: @escaping (MultipartFormData) -> Void, + usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, + with urlRequest: URLRequestConvertible, + encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?) + { + DispatchQueue.global(qos: .utility).async { + let formData = MultipartFormData() + multipartFormData(formData) + + var tempFileURL: URL? + + do { + var urlRequestWithContentType = try urlRequest.asURLRequest() + urlRequestWithContentType.setValue(formData.contentType, forHTTPHeaderField: "Content-Type") + + let isBackgroundSession = self.session.configuration.identifier != nil + + if formData.contentLength < encodingMemoryThreshold && !isBackgroundSession { + let data = try formData.encode() + + let encodingResult = MultipartFormDataEncodingResult.success( + request: self.upload(data, with: urlRequestWithContentType), + streamingFromDisk: false, + streamFileURL: nil + ) + + DispatchQueue.main.async { encodingCompletion?(encodingResult) } + } else { + let fileManager = FileManager.default + let tempDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory()) + let directoryURL = tempDirectoryURL.appendingPathComponent("org.alamofire.manager/multipart.form.data") + let fileName = UUID().uuidString + let fileURL = directoryURL.appendingPathComponent(fileName) + + tempFileURL = fileURL + + var directoryError: Error? + + // Create directory inside serial queue to ensure two threads don't do this in parallel + self.queue.sync { + do { + try fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: nil) + } catch { + directoryError = error + } + } + + if let directoryError = directoryError { throw directoryError } + + try formData.writeEncodedData(to: fileURL) + + let upload = self.upload(fileURL, with: urlRequestWithContentType) + + // Cleanup the temp file once the upload is complete + upload.delegate.queue.addOperation { + do { + try FileManager.default.removeItem(at: fileURL) + } catch { + // No-op + } + } + + DispatchQueue.main.async { + let encodingResult = MultipartFormDataEncodingResult.success( + request: upload, + streamingFromDisk: true, + streamFileURL: fileURL + ) + + encodingCompletion?(encodingResult) + } + } + } catch { + // Cleanup the temp file in the event that the multipart form data encoding failed + if let tempFileURL = tempFileURL { + do { + try FileManager.default.removeItem(at: tempFileURL) + } catch { + // No-op + } + } + + DispatchQueue.main.async { encodingCompletion?(.failure(error)) } + } + } + } + + // MARK: Private - Upload Implementation + + private func upload(_ uploadable: UploadRequest.Uploadable) -> UploadRequest { + do { + let task = try uploadable.task(session: session, adapter: adapter, queue: queue) + let upload = UploadRequest(session: session, requestTask: .upload(uploadable, task)) + + if case let .stream(inputStream, _) = uploadable { + upload.delegate.taskNeedNewBodyStream = { _, _ in inputStream } + } + + delegate[task] = upload + + if startRequestsImmediately { upload.resume() } + + return upload + } catch { + return upload(uploadable, failedWith: error) + } + } + + private func upload(_ uploadable: UploadRequest.Uploadable?, failedWith error: Error) -> UploadRequest { + var uploadTask: Request.RequestTask = .upload(nil, nil) + + if let uploadable = uploadable { + uploadTask = .upload(uploadable, nil) + } + + let underlyingError = error.underlyingAdaptError ?? error + let upload = UploadRequest(session: session, requestTask: uploadTask, error: underlyingError) + + if let retrier = retrier, error is AdaptError { + allowRetrier(retrier, toRetry: upload, with: underlyingError) + } else { + if startRequestsImmediately { upload.resume() } + } + + return upload + } + +#if !os(watchOS) + + // MARK: - Stream Request + + // MARK: Hostname and Port + + /// Creates a `StreamRequest` for bidirectional streaming using the `hostname` and `port`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter hostName: The hostname of the server to connect to. + /// - parameter port: The port of the server to connect to. + /// + /// - returns: The created `StreamRequest`. + @discardableResult + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + open func stream(withHostName hostName: String, port: Int) -> StreamRequest { + return stream(.stream(hostName: hostName, port: port)) + } + + // MARK: NetService + + /// Creates a `StreamRequest` for bidirectional streaming using the `netService`. + /// + /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + /// + /// - parameter netService: The net service used to identify the endpoint. + /// + /// - returns: The created `StreamRequest`. + @discardableResult + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + open func stream(with netService: NetService) -> StreamRequest { + return stream(.netService(netService)) + } + + // MARK: Private - Stream Implementation + + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + private func stream(_ streamable: StreamRequest.Streamable) -> StreamRequest { + do { + let task = try streamable.task(session: session, adapter: adapter, queue: queue) + let request = StreamRequest(session: session, requestTask: .stream(streamable, task)) + + delegate[task] = request + + if startRequestsImmediately { request.resume() } + + return request + } catch { + return stream(failedWith: error) + } + } + + @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) + private func stream(failedWith error: Error) -> StreamRequest { + let stream = StreamRequest(session: session, requestTask: .stream(nil, nil), error: error) + if startRequestsImmediately { stream.resume() } + return stream + } + +#endif + + // MARK: - Internal - Retry Request + + func retry(_ request: Request) -> Bool { + guard let originalTask = request.originalTask else { return false } + + do { + let task = try originalTask.task(session: session, adapter: adapter, queue: queue) + + request.delegate.task = task // resets all task delegate data + + request.retryCount += 1 + request.startTime = CFAbsoluteTimeGetCurrent() + request.endTime = nil + + task.resume() + + return true + } catch { + request.delegate.error = error.underlyingAdaptError ?? error + return false + } + } + + private func allowRetrier(_ retrier: RequestRetrier, toRetry request: Request, with error: Error) { + DispatchQueue.utility.async { [weak self] in + guard let strongSelf = self else { return } + + retrier.should(strongSelf, retry: request, with: error) { shouldRetry, timeDelay in + guard let strongSelf = self else { return } + + guard shouldRetry else { + if strongSelf.startRequestsImmediately { request.resume() } + return + } + + DispatchQueue.utility.after(timeDelay) { + guard let strongSelf = self else { return } + + let retrySucceeded = strongSelf.retry(request) + + if retrySucceeded, let task = request.task { + strongSelf.delegate[task] = request + } else { + if strongSelf.startRequestsImmediately { request.resume() } + } + } + } + } + } +} diff --git a/Pods/Alamofire/Source/TaskDelegate.swift b/Pods/Alamofire/Source/TaskDelegate.swift new file mode 100644 index 0000000..d4fd216 --- /dev/null +++ b/Pods/Alamofire/Source/TaskDelegate.swift @@ -0,0 +1,453 @@ +// +// TaskDelegate.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// The task delegate is responsible for handling all delegate callbacks for the underlying task as well as +/// executing all operations attached to the serial operation queue upon task completion. +open class TaskDelegate: NSObject { + + // MARK: Properties + + /// The serial operation queue used to execute all operations after the task completes. + open let queue: OperationQueue + + /// The data returned by the server. + public var data: Data? { return nil } + + /// The error generated throughout the lifecyle of the task. + public var error: Error? + + var task: URLSessionTask? { + didSet { reset() } + } + + var initialResponseTime: CFAbsoluteTime? + var credential: URLCredential? + var metrics: AnyObject? // URLSessionTaskMetrics + + // MARK: Lifecycle + + init(task: URLSessionTask?) { + self.task = task + + self.queue = { + let operationQueue = OperationQueue() + + operationQueue.maxConcurrentOperationCount = 1 + operationQueue.isSuspended = true + operationQueue.qualityOfService = .utility + + return operationQueue + }() + } + + func reset() { + error = nil + initialResponseTime = nil + } + + // MARK: URLSessionTaskDelegate + + var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> URLRequest?)? + var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? + var taskNeedNewBodyStream: ((URLSession, URLSessionTask) -> InputStream?)? + var taskDidCompleteWithError: ((URLSession, URLSessionTask, Error?) -> Void)? + + @objc(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:) + func urlSession( + _ session: URLSession, + task: URLSessionTask, + willPerformHTTPRedirection response: HTTPURLResponse, + newRequest request: URLRequest, + completionHandler: @escaping (URLRequest?) -> Void) + { + var redirectRequest: URLRequest? = request + + if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection { + redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request) + } + + completionHandler(redirectRequest) + } + + @objc(URLSession:task:didReceiveChallenge:completionHandler:) + func urlSession( + _ session: URLSession, + task: URLSessionTask, + didReceive challenge: URLAuthenticationChallenge, + completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) + { + var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling + var credential: URLCredential? + + if let taskDidReceiveChallenge = taskDidReceiveChallenge { + (disposition, credential) = taskDidReceiveChallenge(session, task, challenge) + } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { + let host = challenge.protectionSpace.host + + if + let serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicy(forHost: host), + let serverTrust = challenge.protectionSpace.serverTrust + { + if serverTrustPolicy.evaluate(serverTrust, forHost: host) { + disposition = .useCredential + credential = URLCredential(trust: serverTrust) + } else { + disposition = .cancelAuthenticationChallenge + } + } + } else { + if challenge.previousFailureCount > 0 { + disposition = .rejectProtectionSpace + } else { + credential = self.credential ?? session.configuration.urlCredentialStorage?.defaultCredential(for: challenge.protectionSpace) + + if credential != nil { + disposition = .useCredential + } + } + } + + completionHandler(disposition, credential) + } + + @objc(URLSession:task:needNewBodyStream:) + func urlSession( + _ session: URLSession, + task: URLSessionTask, + needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) + { + var bodyStream: InputStream? + + if let taskNeedNewBodyStream = taskNeedNewBodyStream { + bodyStream = taskNeedNewBodyStream(session, task) + } + + completionHandler(bodyStream) + } + + @objc(URLSession:task:didCompleteWithError:) + func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { + if let taskDidCompleteWithError = taskDidCompleteWithError { + taskDidCompleteWithError(session, task, error) + } else { + if let error = error { + if self.error == nil { self.error = error } + + if + let downloadDelegate = self as? DownloadTaskDelegate, + let resumeData = (error as NSError).userInfo[NSURLSessionDownloadTaskResumeData] as? Data + { + downloadDelegate.resumeData = resumeData + } + } + + queue.isSuspended = false + } + } +} + +// MARK: - + +class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate { + + // MARK: Properties + + var dataTask: URLSessionDataTask { return task as! URLSessionDataTask } + + override var data: Data? { + if dataStream != nil { + return nil + } else { + return mutableData + } + } + + var progress: Progress + var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)? + + var dataStream: ((_ data: Data) -> Void)? + + private var totalBytesReceived: Int64 = 0 + private var mutableData: Data + + private var expectedContentLength: Int64? + + // MARK: Lifecycle + + override init(task: URLSessionTask?) { + mutableData = Data() + progress = Progress(totalUnitCount: 0) + + super.init(task: task) + } + + override func reset() { + super.reset() + + progress = Progress(totalUnitCount: 0) + totalBytesReceived = 0 + mutableData = Data() + expectedContentLength = nil + } + + // MARK: URLSessionDataDelegate + + var dataTaskDidReceiveResponse: ((URLSession, URLSessionDataTask, URLResponse) -> URLSession.ResponseDisposition)? + var dataTaskDidBecomeDownloadTask: ((URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)? + var dataTaskDidReceiveData: ((URLSession, URLSessionDataTask, Data) -> Void)? + var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)? + + func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + didReceive response: URLResponse, + completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) + { + var disposition: URLSession.ResponseDisposition = .allow + + expectedContentLength = response.expectedContentLength + + if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse { + disposition = dataTaskDidReceiveResponse(session, dataTask, response) + } + + completionHandler(disposition) + } + + func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + didBecome downloadTask: URLSessionDownloadTask) + { + dataTaskDidBecomeDownloadTask?(session, dataTask, downloadTask) + } + + func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { + if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() } + + if let dataTaskDidReceiveData = dataTaskDidReceiveData { + dataTaskDidReceiveData(session, dataTask, data) + } else { + if let dataStream = dataStream { + dataStream(data) + } else { + mutableData.append(data) + } + + let bytesReceived = Int64(data.count) + totalBytesReceived += bytesReceived + let totalBytesExpected = dataTask.response?.expectedContentLength ?? NSURLSessionTransferSizeUnknown + + progress.totalUnitCount = totalBytesExpected + progress.completedUnitCount = totalBytesReceived + + if let progressHandler = progressHandler { + progressHandler.queue.async { progressHandler.closure(self.progress) } + } + } + } + + func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + willCacheResponse proposedResponse: CachedURLResponse, + completionHandler: @escaping (CachedURLResponse?) -> Void) + { + var cachedResponse: CachedURLResponse? = proposedResponse + + if let dataTaskWillCacheResponse = dataTaskWillCacheResponse { + cachedResponse = dataTaskWillCacheResponse(session, dataTask, proposedResponse) + } + + completionHandler(cachedResponse) + } +} + +// MARK: - + +class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate { + + // MARK: Properties + + var downloadTask: URLSessionDownloadTask { return task as! URLSessionDownloadTask } + + var progress: Progress + var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)? + + var resumeData: Data? + override var data: Data? { return resumeData } + + var destination: DownloadRequest.DownloadFileDestination? + + var temporaryURL: URL? + var destinationURL: URL? + + var fileURL: URL? { return destination != nil ? destinationURL : temporaryURL } + + // MARK: Lifecycle + + override init(task: URLSessionTask?) { + progress = Progress(totalUnitCount: 0) + super.init(task: task) + } + + override func reset() { + super.reset() + + progress = Progress(totalUnitCount: 0) + resumeData = nil + } + + // MARK: URLSessionDownloadDelegate + + var downloadTaskDidFinishDownloadingToURL: ((URLSession, URLSessionDownloadTask, URL) -> URL)? + var downloadTaskDidWriteData: ((URLSession, URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? + var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)? + + func urlSession( + _ session: URLSession, + downloadTask: URLSessionDownloadTask, + didFinishDownloadingTo location: URL) + { + temporaryURL = location + + guard + let destination = destination, + let response = downloadTask.response as? HTTPURLResponse + else { return } + + let result = destination(location, response) + let destinationURL = result.destinationURL + let options = result.options + + self.destinationURL = destinationURL + + do { + if options.contains(.removePreviousFile), FileManager.default.fileExists(atPath: destinationURL.path) { + try FileManager.default.removeItem(at: destinationURL) + } + + if options.contains(.createIntermediateDirectories) { + let directory = destinationURL.deletingLastPathComponent() + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + } + + try FileManager.default.moveItem(at: location, to: destinationURL) + } catch { + self.error = error + } + } + + func urlSession( + _ session: URLSession, + downloadTask: URLSessionDownloadTask, + didWriteData bytesWritten: Int64, + totalBytesWritten: Int64, + totalBytesExpectedToWrite: Int64) + { + if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() } + + if let downloadTaskDidWriteData = downloadTaskDidWriteData { + downloadTaskDidWriteData( + session, + downloadTask, + bytesWritten, + totalBytesWritten, + totalBytesExpectedToWrite + ) + } else { + progress.totalUnitCount = totalBytesExpectedToWrite + progress.completedUnitCount = totalBytesWritten + + if let progressHandler = progressHandler { + progressHandler.queue.async { progressHandler.closure(self.progress) } + } + } + } + + func urlSession( + _ session: URLSession, + downloadTask: URLSessionDownloadTask, + didResumeAtOffset fileOffset: Int64, + expectedTotalBytes: Int64) + { + if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset { + downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes) + } else { + progress.totalUnitCount = expectedTotalBytes + progress.completedUnitCount = fileOffset + } + } +} + +// MARK: - + +class UploadTaskDelegate: DataTaskDelegate { + + // MARK: Properties + + var uploadTask: URLSessionUploadTask { return task as! URLSessionUploadTask } + + var uploadProgress: Progress + var uploadProgressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)? + + // MARK: Lifecycle + + override init(task: URLSessionTask?) { + uploadProgress = Progress(totalUnitCount: 0) + super.init(task: task) + } + + override func reset() { + super.reset() + uploadProgress = Progress(totalUnitCount: 0) + } + + // MARK: URLSessionTaskDelegate + + var taskDidSendBodyData: ((URLSession, URLSessionTask, Int64, Int64, Int64) -> Void)? + + func URLSession( + _ session: URLSession, + task: URLSessionTask, + didSendBodyData bytesSent: Int64, + totalBytesSent: Int64, + totalBytesExpectedToSend: Int64) + { + if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() } + + if let taskDidSendBodyData = taskDidSendBodyData { + taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend) + } else { + uploadProgress.totalUnitCount = totalBytesExpectedToSend + uploadProgress.completedUnitCount = totalBytesSent + + if let uploadProgressHandler = uploadProgressHandler { + uploadProgressHandler.queue.async { uploadProgressHandler.closure(self.uploadProgress) } + } + } + } +} diff --git a/Pods/Alamofire/Source/Timeline.swift b/Pods/Alamofire/Source/Timeline.swift new file mode 100644 index 0000000..1440989 --- /dev/null +++ b/Pods/Alamofire/Source/Timeline.swift @@ -0,0 +1,136 @@ +// +// Timeline.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// Responsible for computing the timing metrics for the complete lifecycle of a `Request`. +public struct Timeline { + /// The time the request was initialized. + public let requestStartTime: CFAbsoluteTime + + /// The time the first bytes were received from or sent to the server. + public let initialResponseTime: CFAbsoluteTime + + /// The time when the request was completed. + public let requestCompletedTime: CFAbsoluteTime + + /// The time when the response serialization was completed. + public let serializationCompletedTime: CFAbsoluteTime + + /// The time interval in seconds from the time the request started to the initial response from the server. + public let latency: TimeInterval + + /// The time interval in seconds from the time the request started to the time the request completed. + public let requestDuration: TimeInterval + + /// The time interval in seconds from the time the request completed to the time response serialization completed. + public let serializationDuration: TimeInterval + + /// The time interval in seconds from the time the request started to the time response serialization completed. + public let totalDuration: TimeInterval + + /// Creates a new `Timeline` instance with the specified request times. + /// + /// - parameter requestStartTime: The time the request was initialized. Defaults to `0.0`. + /// - parameter initialResponseTime: The time the first bytes were received from or sent to the server. + /// Defaults to `0.0`. + /// - parameter requestCompletedTime: The time when the request was completed. Defaults to `0.0`. + /// - parameter serializationCompletedTime: The time when the response serialization was completed. Defaults + /// to `0.0`. + /// + /// - returns: The new `Timeline` instance. + public init( + requestStartTime: CFAbsoluteTime = 0.0, + initialResponseTime: CFAbsoluteTime = 0.0, + requestCompletedTime: CFAbsoluteTime = 0.0, + serializationCompletedTime: CFAbsoluteTime = 0.0) + { + self.requestStartTime = requestStartTime + self.initialResponseTime = initialResponseTime + self.requestCompletedTime = requestCompletedTime + self.serializationCompletedTime = serializationCompletedTime + + self.latency = initialResponseTime - requestStartTime + self.requestDuration = requestCompletedTime - requestStartTime + self.serializationDuration = serializationCompletedTime - requestCompletedTime + self.totalDuration = serializationCompletedTime - requestStartTime + } +} + +// MARK: - CustomStringConvertible + +extension Timeline: CustomStringConvertible { + /// The textual representation used when written to an output stream, which includes the latency, the request + /// duration and the total duration. + public var description: String { + let latency = String(format: "%.3f", self.latency) + let requestDuration = String(format: "%.3f", self.requestDuration) + let serializationDuration = String(format: "%.3f", self.serializationDuration) + let totalDuration = String(format: "%.3f", self.totalDuration) + + // NOTE: Had to move to string concatenation due to memory leak filed as rdar://26761490. Once memory leak is + // fixed, we should move back to string interpolation by reverting commit 7d4a43b1. + let timings = [ + "\"Latency\": " + latency + " secs", + "\"Request Duration\": " + requestDuration + " secs", + "\"Serialization Duration\": " + serializationDuration + " secs", + "\"Total Duration\": " + totalDuration + " secs" + ] + + return "Timeline: { " + timings.joined(separator: ", ") + " }" + } +} + +// MARK: - CustomDebugStringConvertible + +extension Timeline: CustomDebugStringConvertible { + /// The textual representation used when written to an output stream, which includes the request start time, the + /// initial response time, the request completed time, the serialization completed time, the latency, the request + /// duration and the total duration. + public var debugDescription: String { + let requestStartTime = String(format: "%.3f", self.requestStartTime) + let initialResponseTime = String(format: "%.3f", self.initialResponseTime) + let requestCompletedTime = String(format: "%.3f", self.requestCompletedTime) + let serializationCompletedTime = String(format: "%.3f", self.serializationCompletedTime) + let latency = String(format: "%.3f", self.latency) + let requestDuration = String(format: "%.3f", self.requestDuration) + let serializationDuration = String(format: "%.3f", self.serializationDuration) + let totalDuration = String(format: "%.3f", self.totalDuration) + + // NOTE: Had to move to string concatenation due to memory leak filed as rdar://26761490. Once memory leak is + // fixed, we should move back to string interpolation by reverting commit 7d4a43b1. + let timings = [ + "\"Request Start Time\": " + requestStartTime, + "\"Initial Response Time\": " + initialResponseTime, + "\"Request Completed Time\": " + requestCompletedTime, + "\"Serialization Completed Time\": " + serializationCompletedTime, + "\"Latency\": " + latency + " secs", + "\"Request Duration\": " + requestDuration + " secs", + "\"Serialization Duration\": " + serializationDuration + " secs", + "\"Total Duration\": " + totalDuration + " secs" + ] + + return "Timeline: { " + timings.joined(separator: ", ") + " }" + } +} diff --git a/Pods/Alamofire/Source/Validation.swift b/Pods/Alamofire/Source/Validation.swift new file mode 100644 index 0000000..c405d02 --- /dev/null +++ b/Pods/Alamofire/Source/Validation.swift @@ -0,0 +1,309 @@ +// +// Validation.swift +// +// Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +extension Request { + + // MARK: Helper Types + + fileprivate typealias ErrorReason = AFError.ResponseValidationFailureReason + + /// Used to represent whether validation was successful or encountered an error resulting in a failure. + /// + /// - success: The validation was successful. + /// - failure: The validation failed encountering the provided error. + public enum ValidationResult { + case success + case failure(Error) + } + + fileprivate struct MIMEType { + let type: String + let subtype: String + + var isWildcard: Bool { return type == "*" && subtype == "*" } + + init?(_ string: String) { + let components: [String] = { + let stripped = string.trimmingCharacters(in: .whitespacesAndNewlines) + let split = stripped.substring(to: stripped.range(of: ";")?.lowerBound ?? stripped.endIndex) + return split.components(separatedBy: "/") + }() + + if let type = components.first, let subtype = components.last { + self.type = type + self.subtype = subtype + } else { + return nil + } + } + + func matches(_ mime: MIMEType) -> Bool { + switch (type, subtype) { + case (mime.type, mime.subtype), (mime.type, "*"), ("*", mime.subtype), ("*", "*"): + return true + default: + return false + } + } + } + + // MARK: Properties + + fileprivate var acceptableStatusCodes: [Int] { return Array(200..<300) } + + fileprivate var acceptableContentTypes: [String] { + if let accept = request?.value(forHTTPHeaderField: "Accept") { + return accept.components(separatedBy: ",") + } + + return ["*/*"] + } + + // MARK: Status Code + + fileprivate func validate( + statusCode acceptableStatusCodes: S, + response: HTTPURLResponse) + -> ValidationResult + where S.Iterator.Element == Int + { + if acceptableStatusCodes.contains(response.statusCode) { + return .success + } else { + let reason: ErrorReason = .unacceptableStatusCode(code: response.statusCode) + return .failure(AFError.responseValidationFailed(reason: reason)) + } + } + + // MARK: Content Type + + fileprivate func validate( + contentType acceptableContentTypes: S, + response: HTTPURLResponse, + data: Data?) + -> ValidationResult + where S.Iterator.Element == String + { + guard let data = data, data.count > 0 else { return .success } + + guard + let responseContentType = response.mimeType, + let responseMIMEType = MIMEType(responseContentType) + else { + for contentType in acceptableContentTypes { + if let mimeType = MIMEType(contentType), mimeType.isWildcard { + return .success + } + } + + let error: AFError = { + let reason: ErrorReason = .missingContentType(acceptableContentTypes: Array(acceptableContentTypes)) + return AFError.responseValidationFailed(reason: reason) + }() + + return .failure(error) + } + + for contentType in acceptableContentTypes { + if let acceptableMIMEType = MIMEType(contentType), acceptableMIMEType.matches(responseMIMEType) { + return .success + } + } + + let error: AFError = { + let reason: ErrorReason = .unacceptableContentType( + acceptableContentTypes: Array(acceptableContentTypes), + responseContentType: responseContentType + ) + + return AFError.responseValidationFailed(reason: reason) + }() + + return .failure(error) + } +} + +// MARK: - + +extension DataRequest { + /// A closure used to validate a request that takes a URL request, a URL response and data, and returns whether the + /// request was valid. + public typealias Validation = (URLRequest?, HTTPURLResponse, Data?) -> ValidationResult + + /// Validates the request, using the specified closure. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - parameter validation: A closure to validate the request. + /// + /// - returns: The request. + @discardableResult + public func validate(_ validation: @escaping Validation) -> Self { + let validationExecution: () -> Void = { [unowned self] in + if + let response = self.response, + self.delegate.error == nil, + case let .failure(error) = validation(self.request, response, self.delegate.data) + { + self.delegate.error = error + } + } + + validations.append(validationExecution) + + return self + } + + /// Validates that the response has a status code in the specified sequence. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - parameter range: The range of acceptable status codes. + /// + /// - returns: The request. + @discardableResult + public func validate(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int { + return validate { [unowned self] _, response, _ in + return self.validate(statusCode: acceptableStatusCodes, response: response) + } + } + + /// Validates that the response has a content type in the specified sequence. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes. + /// + /// - returns: The request. + @discardableResult + public func validate(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String { + return validate { [unowned self] _, response, data in + return self.validate(contentType: acceptableContentTypes, response: response, data: data) + } + } + + /// Validates that the response has a status code in the default acceptable range of 200...299, and that the content + /// type matches any specified in the Accept HTTP header field. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - returns: The request. + @discardableResult + public func validate() -> Self { + return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes) + } +} + +// MARK: - + +extension DownloadRequest { + /// A closure used to validate a request that takes a URL request, a URL response, a temporary URL and a + /// destination URL, and returns whether the request was valid. + public typealias Validation = ( + _ request: URLRequest?, + _ response: HTTPURLResponse, + _ temporaryURL: URL?, + _ destinationURL: URL?) + -> ValidationResult + + /// Validates the request, using the specified closure. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - parameter validation: A closure to validate the request. + /// + /// - returns: The request. + @discardableResult + public func validate(_ validation: @escaping Validation) -> Self { + let validationExecution: () -> Void = { [unowned self] in + let request = self.request + let temporaryURL = self.downloadDelegate.temporaryURL + let destinationURL = self.downloadDelegate.destinationURL + + if + let response = self.response, + self.delegate.error == nil, + case let .failure(error) = validation(request, response, temporaryURL, destinationURL) + { + self.delegate.error = error + } + } + + validations.append(validationExecution) + + return self + } + + /// Validates that the response has a status code in the specified sequence. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - parameter range: The range of acceptable status codes. + /// + /// - returns: The request. + @discardableResult + public func validate(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int { + return validate { [unowned self] _, response, _, _ in + return self.validate(statusCode: acceptableStatusCodes, response: response) + } + } + + /// Validates that the response has a content type in the specified sequence. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes. + /// + /// - returns: The request. + @discardableResult + public func validate(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String { + return validate { [unowned self] _, response, _, _ in + let fileURL = self.downloadDelegate.fileURL + + guard let validFileURL = fileURL else { + return .failure(AFError.responseValidationFailed(reason: .dataFileNil)) + } + + do { + let data = try Data(contentsOf: validFileURL) + return self.validate(contentType: acceptableContentTypes, response: response, data: data) + } catch { + return .failure(AFError.responseValidationFailed(reason: .dataFileReadFailed(at: validFileURL))) + } + } + } + + /// Validates that the response has a status code in the default acceptable range of 200...299, and that the content + /// type matches any specified in the Accept HTTP header field. + /// + /// If validation fails, subsequent calls to response handlers will have an associated error. + /// + /// - returns: The request. + @discardableResult + public func validate() -> Self { + return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes) + } +} diff --git a/Pods/FDFullscreenPopGesture/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h b/Pods/FDFullscreenPopGesture/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h new file mode 100644 index 0000000..d537d14 --- /dev/null +++ b/Pods/FDFullscreenPopGesture/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h @@ -0,0 +1,58 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015-2016 forkingdog ( https://github.com/forkingdog ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import + +/// "UINavigation+FDFullscreenPopGesture" extends UINavigationController's swipe- +/// to-pop behavior in iOS 7+ by supporting fullscreen pan gesture. Instead of +/// screen edge, you can now swipe from any place on the screen and the onboard +/// interactive pop transition works seamlessly. +/// +/// Adding the implementation file of this category to your target will +/// automatically patch UINavigationController with this feature. +@interface UINavigationController (FDFullscreenPopGesture) + +/// The gesture recognizer that actually handles interactive pop. +@property (nonatomic, strong, readonly) UIPanGestureRecognizer *fd_fullscreenPopGestureRecognizer; + +/// A view controller is able to control navigation bar's appearance by itself, +/// rather than a global way, checking "fd_prefersNavigationBarHidden" property. +/// Default to YES, disable it if you don't want so. +@property (nonatomic, assign) BOOL fd_viewControllerBasedNavigationBarAppearanceEnabled; + +@end + +/// Allows any view controller to disable interactive pop gesture, which might +/// be necessary when the view controller itself handles pan gesture in some +/// cases. +@interface UIViewController (FDFullscreenPopGesture) + +/// Whether the interactive pop gesture is disabled when contained in a navigation +/// stack. +@property (nonatomic, assign) BOOL fd_interactivePopDisabled; + +/// Indicate this view controller prefers its navigation bar hidden or not, +/// checked when view controller based navigation bar's appearance is enabled. +/// Default to NO, bars are more likely to show. +@property (nonatomic, assign) BOOL fd_prefersNavigationBarHidden; + +@end diff --git a/Pods/FDFullscreenPopGesture/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m b/Pods/FDFullscreenPopGesture/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m new file mode 100644 index 0000000..ac8cb26 --- /dev/null +++ b/Pods/FDFullscreenPopGesture/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m @@ -0,0 +1,227 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015-2016 forkingdog ( https://github.com/forkingdog ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import "UINavigationController+FDFullscreenPopGesture.h" +#import + +@interface _FDFullscreenPopGestureRecognizerDelegate : NSObject + +@property (nonatomic, weak) UINavigationController *navigationController; + +@end + +@implementation _FDFullscreenPopGestureRecognizerDelegate + +- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer +{ + // Ignore when no view controller is pushed into the navigation stack. + if (self.navigationController.viewControllers.count <= 1) { + return NO; + } + + // Disable when the active view controller doesn't allow interactive pop. + UIViewController *topViewController = self.navigationController.viewControllers.lastObject; + if (topViewController.fd_interactivePopDisabled) { + return NO; + } + + // Ignore pan gesture when the navigation controller is currently in transition. + if ([[self.navigationController valueForKey:@"_isTransitioning"] boolValue]) { + return NO; + } + + // Prevent calling the handler when the gesture begins in an opposite direction. + CGPoint translation = [gestureRecognizer translationInView:gestureRecognizer.view]; + if (translation.x <= 0) { + return NO; + } + + return YES; +} + +@end + +typedef void (^_FDViewControllerWillAppearInjectBlock)(UIViewController *viewController, BOOL animated); + +@interface UIViewController (FDFullscreenPopGesturePrivate) + +@property (nonatomic, copy) _FDViewControllerWillAppearInjectBlock fd_willAppearInjectBlock; + +@end + +@implementation UIViewController (FDFullscreenPopGesturePrivate) + ++ (void)load +{ + Method originalMethod = class_getInstanceMethod(self, @selector(viewWillAppear:)); + Method swizzledMethod = class_getInstanceMethod(self, @selector(fd_viewWillAppear:)); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +- (void)fd_viewWillAppear:(BOOL)animated +{ + // Forward to primary implementation. + [self fd_viewWillAppear:animated]; + + if (self.fd_willAppearInjectBlock) { + self.fd_willAppearInjectBlock(self, animated); + } +} + +- (_FDViewControllerWillAppearInjectBlock)fd_willAppearInjectBlock +{ + return objc_getAssociatedObject(self, _cmd); +} + +- (void)setFd_willAppearInjectBlock:(_FDViewControllerWillAppearInjectBlock)block +{ + objc_setAssociatedObject(self, @selector(fd_willAppearInjectBlock), block, OBJC_ASSOCIATION_COPY_NONATOMIC); +} + +@end + +@implementation UINavigationController (FDFullscreenPopGesture) + ++ (void)load +{ + // Inject "-pushViewController:animated:" + Method originalMethod = class_getInstanceMethod(self, @selector(pushViewController:animated:)); + Method swizzledMethod = class_getInstanceMethod(self, @selector(fd_pushViewController:animated:)); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +- (void)fd_pushViewController:(UIViewController *)viewController animated:(BOOL)animated +{ + if (![self.interactivePopGestureRecognizer.view.gestureRecognizers containsObject:self.fd_fullscreenPopGestureRecognizer]) { + + // Add our own gesture recognizer to where the onboard screen edge pan gesture recognizer is attached to. + [self.interactivePopGestureRecognizer.view addGestureRecognizer:self.fd_fullscreenPopGestureRecognizer]; + + // Forward the gesture events to the private handler of the onboard gesture recognizer. + NSArray *internalTargets = [self.interactivePopGestureRecognizer valueForKey:@"targets"]; + id internalTarget = [internalTargets.firstObject valueForKey:@"target"]; + SEL internalAction = NSSelectorFromString(@"handleNavigationTransition:"); + self.fd_fullscreenPopGestureRecognizer.delegate = self.fd_popGestureRecognizerDelegate; + [self.fd_fullscreenPopGestureRecognizer addTarget:internalTarget action:internalAction]; + + // Disable the onboard gesture recognizer. + self.interactivePopGestureRecognizer.enabled = NO; + } + + // Handle perferred navigation bar appearance. + [self fd_setupViewControllerBasedNavigationBarAppearanceIfNeeded:viewController]; + + // Forward to primary implementation. + [self fd_pushViewController:viewController animated:animated]; +} + +- (void)fd_setupViewControllerBasedNavigationBarAppearanceIfNeeded:(UIViewController *)appearingViewController +{ + if (!self.fd_viewControllerBasedNavigationBarAppearanceEnabled) { + return; + } + + __weak typeof(self) weakSelf = self; + _FDViewControllerWillAppearInjectBlock block = ^(UIViewController *viewController, BOOL animated) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (strongSelf) { + [strongSelf setNavigationBarHidden:viewController.fd_prefersNavigationBarHidden animated:animated]; + } + }; + + // Setup will appear inject block to appearing view controller. + // Setup disappearing view controller as well, because not every view controller is added into + // stack by pushing, maybe by "-setViewControllers:". + appearingViewController.fd_willAppearInjectBlock = block; + UIViewController *disappearingViewController = self.viewControllers.lastObject; + if (disappearingViewController && !disappearingViewController.fd_willAppearInjectBlock) { + disappearingViewController.fd_willAppearInjectBlock = block; + } +} + +- (_FDFullscreenPopGestureRecognizerDelegate *)fd_popGestureRecognizerDelegate +{ + _FDFullscreenPopGestureRecognizerDelegate *delegate = objc_getAssociatedObject(self, _cmd); + + if (!delegate) { + delegate = [[_FDFullscreenPopGestureRecognizerDelegate alloc] init]; + delegate.navigationController = self; + + objc_setAssociatedObject(self, _cmd, delegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return delegate; +} + +- (UIPanGestureRecognizer *)fd_fullscreenPopGestureRecognizer +{ + UIPanGestureRecognizer *panGestureRecognizer = objc_getAssociatedObject(self, _cmd); + + if (!panGestureRecognizer) { + panGestureRecognizer = [[UIPanGestureRecognizer alloc] init]; + panGestureRecognizer.maximumNumberOfTouches = 1; + + objc_setAssociatedObject(self, _cmd, panGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return panGestureRecognizer; +} + +- (BOOL)fd_viewControllerBasedNavigationBarAppearanceEnabled +{ + NSNumber *number = objc_getAssociatedObject(self, _cmd); + if (number) { + return number.boolValue; + } + self.fd_viewControllerBasedNavigationBarAppearanceEnabled = YES; + return YES; +} + +- (void)setFd_viewControllerBasedNavigationBarAppearanceEnabled:(BOOL)enabled +{ + SEL key = @selector(fd_viewControllerBasedNavigationBarAppearanceEnabled); + objc_setAssociatedObject(self, key, @(enabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +@implementation UIViewController (FDFullscreenPopGesture) + +- (BOOL)fd_interactivePopDisabled +{ + return [objc_getAssociatedObject(self, _cmd) boolValue]; +} + +- (void)setFd_interactivePopDisabled:(BOOL)disabled +{ + objc_setAssociatedObject(self, @selector(fd_interactivePopDisabled), @(disabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)fd_prefersNavigationBarHidden +{ + return [objc_getAssociatedObject(self, _cmd) boolValue]; +} + +- (void)setFd_prefersNavigationBarHidden:(BOOL)hidden +{ + objc_setAssociatedObject(self, @selector(fd_prefersNavigationBarHidden), @(hidden), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end diff --git a/Pods/FDFullscreenPopGesture/LICENSE b/Pods/FDFullscreenPopGesture/LICENSE new file mode 100644 index 0000000..20efd1b --- /dev/null +++ b/Pods/FDFullscreenPopGesture/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Pods/FDFullscreenPopGesture/README.md b/Pods/FDFullscreenPopGesture/README.md new file mode 100644 index 0000000..0cc4217 --- /dev/null +++ b/Pods/FDFullscreenPopGesture/README.md @@ -0,0 +1,62 @@ +# FDFullscreenPopGesture +An UINavigationController's category to enable fullscreen pop gesture in an iOS7+ system style with AOP. + +# Overview + +![snapshot](https://raw.githubusercontent.com/forkingdog/FDFullscreenPopGesture/master/Snapshots/snapshot0.gif) + +这个扩展来自 @J_雨 同学的这个很天才的思路,他的文章地址:[http://www.jianshu.com/p/d39f7d22db6c](http://www.jianshu.com/p/d39f7d22db6c) + +# Usage + +**AOP**, just add 2 files and **no need** for any setups, all navigation controllers will be able to use fullscreen pop gesture automatically. + +To disable this pop gesture of a navigation controller: + +``` objc +navigationController.fd_fullscreenPopGestureRecognizer.enabled = NO; +``` + +To disable this pop gesture of a view controller: + +``` objc +viewController.fd_interactivePopDisabled = YES; +``` + +Require at least iOS **7.0**. + +# View Controller Based Navigation Bar Appearance + +It handles navigation bar transition properly when using fullscreen gesture to push or pop a view controller: + +- with bar -> without bar +- without bar -> with bar +- without bar -> without bar + +![snapshot with bar states](https://raw.githubusercontent.com/forkingdog/FDFullscreenPopGesture/master/Snapshots/snapshot1.gif) + +This opmiziation is enabled by default, from now on you don't need to call **UINavigationController**'s `-setNavigationBarHidden:animated:` method, instead, use view controller's specific API to hide its bar: + +``` objc +- (void)viewDidLoad { + [super viewDidLoad]; + self.fd_prefersNavigationBarHidden = NO; +} +``` + +And this property is **YES** by default. + +# Installation + +Use cocoapods + +``` ruby +pod 'FDFullscreenPopGesture', '1.1' +``` +# Release Notes + +**1.1** - View controller based navigation bar appearance and transition. +**1.0** - Fullscreen pop gesture. + +# License +MIT diff --git a/Pods/Kingfisher/LICENSE b/Pods/Kingfisher/LICENSE new file mode 100644 index 0000000..79da75d --- /dev/null +++ b/Pods/Kingfisher/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2017 Wei Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Pods/Kingfisher/README.md b/Pods/Kingfisher/README.md new file mode 100644 index 0000000..a9b5214 --- /dev/null +++ b/Pods/Kingfisher/README.md @@ -0,0 +1,86 @@ +

+ +Kingfisher + +

+ +

+ + + + + + + + + + + + + +codebeat badge + + + + +

+ +Kingfisher is a lightweight, pure-Swift library for downloading and caching images from the web. This project is heavily inspired by the popular [SDWebImage](https://github.com/rs/SDWebImage). It provides you a chance to use a pure-Swift alternative in your next app. + +## Features + +- [x] Asynchronous image downloading and caching. +- [x] `URLSession`-based networking. Basic image processors and filters supplied. +- [x] Multiple-layer cache for both memory and disk. +- [x] Cancelable downloading and processing tasks to improve performance. +- [x] Independent components. Use the downloader or caching system separately as you need. +- [x] Prefetching images and showing them from cache later when necessary. +- [x] Extensions for `UIImageView`, `NSImage` and `UIButton` to directly set an image from a URL. +- [x] Built-in transition animation when setting images. +- [x] Extensible image processing and image format support. + +The simplest use-case is setting an image to an image view with the `UIImageView` extension: + +```swift +let url = URL(string: "url_of_your_image") +imageView.kf.setImage(with: url) +``` + +Kingfisher will download the image from `url`, send it to both the memory cache and the disk cache, and display it in `imageView`. When you use the same code later, the image will be retrieved from cache and shown immediately. + +## Requirements + +- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ +- Swift 3 (Kingfisher 3.x), Swift 2.3 (Kingfisher 2.x) + +Main development of Kingfisher will support Swift 3. Only critical bug fixes will be made for Kingfisher 2.x. + +[Kingfisher 3.0 Migration Guide](https://github.com/onevcat/Kingfisher/wiki/Kingfisher-3.0-Migration-Guide) - If you are upgrading to Kingfisher 3.x from an earlier version, please read this for more information. + +## Next Steps + +We prepared a [wiki page](https://github.com/onevcat/Kingfisher/wiki). You can find tons of useful things there. + +* [Installation Guide](https://github.com/onevcat/Kingfisher/wiki/Installation-Guide) - Follow it to integrate Kingfisher into your project. +* [Cheat Sheet](https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet)- Curious about what Kingfisher could do and how would it look like when used in your project? See this page for useful code snippets. If you are already familiar with Kingfisher, you could also learn new tricks to improve the way you use Kingfisher! +* [API Reference](http://cocoadocs.org/docsets/Kingfisher/) - Lastly, please remember to read the full whenever you may need a more detailed reference. + +## Other + +### Future of Kingfisher + +I want to keep Kingfisher lightweight. This framework will focus on providing a simple solution for downloading and caching images. This doesn’t mean the framework can’t be improved. Kingfisher is far from perfect, so necessary and useful updates will be made to make it better. + +### About the logo + +The logo of Kingfisher is inspired by [Tangram (七巧板)](http://en.wikipedia.org/wiki/Tangram), a dissection puzzle consisting of seven flat shapes from China. I believe she's a kingfisher bird instead of a swift, but someone insists that she is a pigeon. I guess I should give her a name. Hi, guys, do you have any suggestions? + +### Contact + +Follow and contact me on [Twitter](http://twitter.com/onevcat) or [Sina Weibo](http://weibo.com/onevcat). If you find an issue, just [open a ticket](https://github.com/onevcat/Kingfisher/issues/new). Pull requests are warmly welcome as well. + +### License + +Kingfisher is released under the MIT license. See LICENSE for details. + + diff --git a/Pods/Kingfisher/Sources/AnimatedImageView.swift b/Pods/Kingfisher/Sources/AnimatedImageView.swift new file mode 100755 index 0000000..9b4174f --- /dev/null +++ b/Pods/Kingfisher/Sources/AnimatedImageView.swift @@ -0,0 +1,351 @@ +// +// AnimatableImageView.swift +// Kingfisher +// +// Created by bl4ckra1sond3tre on 4/22/16. +// +// The AnimatableImageView, AnimatedFrame and Animator is a modified version of +// some classes from kaishin's Gifu project (https://github.com/kaishin/Gifu) +// +// The MIT License (MIT) +// +// Copyright (c) 2017 Reda Lemeden. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// The name and characters used in the demo of this software are property of their +// respective owners. + +import UIKit +import ImageIO + +/// `AnimatedImageView` is a subclass of `UIImageView` for displaying animated image. +open class AnimatedImageView: UIImageView { + + /// Proxy object for prevending a reference cycle between the CADDisplayLink and AnimatedImageView. + class TargetProxy { + private weak var target: AnimatedImageView? + + init(target: AnimatedImageView) { + self.target = target + } + + @objc func onScreenUpdate() { + target?.updateFrame() + } + } + + // MARK: - Public property + /// Whether automatically play the animation when the view become visible. Default is true. + public var autoPlayAnimatedImage = true + + /// The size of the frame cache. + public var framePreloadCount = 10 + + /// Specifies whether the GIF frames should be pre-scaled to save memory. Default is true. + public var needsPrescaling = true + + /// The animation timer's run loop mode. Default is `NSRunLoopCommonModes`. Set this property to `NSDefaultRunLoopMode` will make the animation pause during UIScrollView scrolling. + public var runLoopMode = RunLoopMode.commonModes { + willSet { + if runLoopMode == newValue { + return + } else { + stopAnimating() + displayLink.remove(from: .main, forMode: runLoopMode) + displayLink.add(to: .main, forMode: newValue) + startAnimating() + } + } + } + + // MARK: - Private property + /// `Animator` instance that holds the frames of a specific image in memory. + private var animator: Animator? + + /// A flag to avoid invalidating the displayLink on deinit if it was never created, because displayLink is so lazy. :D + private var isDisplayLinkInitialized: Bool = false + + /// A display link that keeps calling the `updateFrame` method on every screen refresh. + private lazy var displayLink: CADisplayLink = { + self.isDisplayLinkInitialized = true + let displayLink = CADisplayLink(target: TargetProxy(target: self), selector: #selector(TargetProxy.onScreenUpdate)) + displayLink.add(to: .main, forMode: self.runLoopMode) + displayLink.isPaused = true + return displayLink + }() + + // MARK: - Override + override open var image: Image? { + didSet { + if image != oldValue { + reset() + } + setNeedsDisplay() + layer.setNeedsDisplay() + } + } + + deinit { + if isDisplayLinkInitialized { + displayLink.invalidate() + } + } + + override open var isAnimating: Bool { + if isDisplayLinkInitialized { + return !displayLink.isPaused + } else { + return super.isAnimating + } + } + + /// Starts the animation. + override open func startAnimating() { + if self.isAnimating { + return + } else { + displayLink.isPaused = false + } + } + + /// Stops the animation. + override open func stopAnimating() { + super.stopAnimating() + if isDisplayLinkInitialized { + displayLink.isPaused = true + } + } + + override open func display(_ layer: CALayer) { + if let currentFrame = animator?.currentFrame { + layer.contents = currentFrame.cgImage + } else { + layer.contents = image?.cgImage + } + } + + override open func didMoveToWindow() { + super.didMoveToWindow() + didMove() + } + + override open func didMoveToSuperview() { + super.didMoveToSuperview() + didMove() + } + + // This is for back compatibility that using regular UIImageView to show GIF. + override func shouldPreloadAllGIF() -> Bool { + return false + } + + // MARK: - Private method + /// Reset the animator. + private func reset() { + animator = nil + if let imageSource = image?.kf.imageSource?.imageRef { + animator = Animator(imageSource: imageSource, contentMode: contentMode, size: bounds.size, framePreloadCount: framePreloadCount) + animator?.needsPrescaling = needsPrescaling + animator?.prepareFramesAsynchronously() + } + didMove() + } + + private func didMove() { + if autoPlayAnimatedImage && animator != nil { + if let _ = superview, let _ = window { + startAnimating() + } else { + stopAnimating() + } + } + } + + /// Update the current frame with the displayLink duration. + private func updateFrame() { + if animator?.updateCurrentFrame(duration: displayLink.duration) ?? false { + layer.setNeedsDisplay() + } + } +} + +/// Keeps a reference to an `Image` instance and its duration as a GIF frame. +struct AnimatedFrame { + var image: Image? + let duration: TimeInterval + + static let null: AnimatedFrame = AnimatedFrame(image: .none, duration: 0.0) +} + +// MARK: - Animator +class Animator { + // MARK: Private property + fileprivate let size: CGSize + fileprivate let maxFrameCount: Int + fileprivate let imageSource: CGImageSource + + fileprivate var animatedFrames = [AnimatedFrame]() + fileprivate let maxTimeStep: TimeInterval = 1.0 + fileprivate var frameCount = 0 + fileprivate var currentFrameIndex = 0 + fileprivate var currentPreloadIndex = 0 + fileprivate var timeSinceLastFrameChange: TimeInterval = 0.0 + fileprivate var needsPrescaling = true + + /// Loop count of animatd image. + private var loopCount = 0 + + var currentFrame: UIImage? { + return frame(at: currentFrameIndex) + } + + var contentMode = UIViewContentMode.scaleToFill + + private lazy var preloadQueue: DispatchQueue = { + return DispatchQueue(label: "com.onevcat.Kingfisher.Animator.preloadQueue") + }() + + /** + Init an animator with image source reference. + + - parameter imageSource: The reference of animated image. + - parameter contentMode: Content mode of AnimatedImageView. + - parameter size: Size of AnimatedImageView. + - parameter framePreloadCount: Frame cache size. + + - returns: The animator object. + */ + init(imageSource source: CGImageSource, contentMode mode: UIViewContentMode, size: CGSize, framePreloadCount count: Int) { + self.imageSource = source + self.contentMode = mode + self.size = size + self.maxFrameCount = count + } + + func frame(at index: Int) -> Image? { + return animatedFrames[safe: index]?.image + } + + func prepareFramesAsynchronously() { + preloadQueue.async { [weak self] in + self?.prepareFrames() + } + } + + private func prepareFrames() { + frameCount = CGImageSourceGetCount(imageSource) + + if let properties = CGImageSourceCopyProperties(imageSource, nil), + let gifInfo = (properties as NSDictionary)[kCGImagePropertyGIFDictionary as String] as? NSDictionary, + let loopCount = gifInfo[kCGImagePropertyGIFLoopCount as String] as? Int + { + self.loopCount = loopCount + } + + let frameToProcess = min(frameCount, maxFrameCount) + animatedFrames.reserveCapacity(frameToProcess) + animatedFrames = (0.. AnimatedFrame { + guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, index, nil) else { + return AnimatedFrame.null + } + + let frameDuration = imageSource.kf.gifProperties(at: index).flatMap { + gifInfo -> Double? in + + let unclampedDelayTime = gifInfo[kCGImagePropertyGIFUnclampedDelayTime as String] as Double? + let delayTime = gifInfo[kCGImagePropertyGIFDelayTime as String] as Double? + let duration = unclampedDelayTime ?? delayTime ?? 0.0 + + /** + http://opensource.apple.com/source/WebCore/WebCore-7600.1.25/platform/graphics/cg/ImageSourceCG.cpp + Many annoying ads specify a 0 duration to make an image flash as quickly as + possible. We follow Safari and Firefox's behavior and use a duration of 100 ms + for any frames that specify a duration of <= 10 ms. + See and for more information. + + See also: http://nullsleep.tumblr.com/post/16524517190/animated-gif-minimum-frame-delay-browser. + */ + return duration > 0.011 ? duration : 0.100 + } + + let image = Image(cgImage: imageRef) + let scaledImage: Image? + + if needsPrescaling { + scaledImage = image.kf.resize(to: size, for: contentMode) + } else { + scaledImage = image + } + + return AnimatedFrame(image: scaledImage, duration: frameDuration ?? 0.0) + } + + /** + Updates the current frame if necessary using the frame timer and the duration of each frame in `animatedFrames`. + */ + func updateCurrentFrame(duration: CFTimeInterval) -> Bool { + timeSinceLastFrameChange += min(maxTimeStep, duration) + guard let frameDuration = animatedFrames[safe: currentFrameIndex]?.duration, frameDuration <= timeSinceLastFrameChange else { + return false + } + + timeSinceLastFrameChange -= frameDuration + let lastFrameIndex = currentFrameIndex + currentFrameIndex += 1 + currentFrameIndex = currentFrameIndex % animatedFrames.count + + if animatedFrames.count < frameCount { + preloadFrameAsynchronously(at: lastFrameIndex) + } + return true + } + + private func preloadFrameAsynchronously(at index: Int) { + preloadQueue.async { [weak self] in + self?.preloadFrame(at: index) + } + } + + private func preloadFrame(at index: Int) { + animatedFrames[index] = prepareFrame(at: currentPreloadIndex) + currentPreloadIndex += 1 + currentPreloadIndex = currentPreloadIndex % frameCount + } +} + +extension CGImageSource: KingfisherCompatible { } +extension Kingfisher where Base: CGImageSource { + func gifProperties(at index: Int) -> [String: Double]? { + let properties = CGImageSourceCopyPropertiesAtIndex(base, index, nil) as Dictionary? + return properties?[kCGImagePropertyGIFDictionary] as? [String: Double] + } +} + +extension Array { + subscript(safe index: Int) -> Element? { + return indices ~= index ? self[index] : nil + } +} + +private func pure(_ value: T) -> [T] { + return [value] +} diff --git a/Pods/Kingfisher/Sources/Box.swift b/Pods/Kingfisher/Sources/Box.swift new file mode 100644 index 0000000..7076add --- /dev/null +++ b/Pods/Kingfisher/Sources/Box.swift @@ -0,0 +1,16 @@ +// +// Box.swift +// Kingfisher +// +// Created by WANG WEI on 2016/09/12. +// Copyright © 2016年 Wei Wang. All rights reserved. +// + +import Foundation + +class Box { + let value: T + init(value: T) { + self.value = value + } +} diff --git a/Pods/Kingfisher/Sources/CacheSerializer.swift b/Pods/Kingfisher/Sources/CacheSerializer.swift new file mode 100644 index 0000000..f9391ab --- /dev/null +++ b/Pods/Kingfisher/Sources/CacheSerializer.swift @@ -0,0 +1,85 @@ +// +// CacheSerializer.swift +// Kingfisher +// +// Created by Wei Wang on 2016/09/02. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/// An `CacheSerializer` would be used to convert some data to an image object for +/// retrieving from disk cache and vice versa for storing to disk cache. +public protocol CacheSerializer { + + /// Get the serialized data from a provided image + /// and optional original data for caching to disk. + /// + /// + /// - parameter image: The image needed to be serialized. + /// - parameter original: The original data which is just downloaded. + /// If the image is retrieved from cache instead of + /// downloaded, it will be `nil`. + /// + /// - returns: A data which will be stored to cache, or `nil` when no valid + /// data could be serialized. + func data(with image: Image, original: Data?) -> Data? + + /// Get an image deserialized from provided data. + /// + /// - parameter data: The data from which an image should be deserialized. + /// - parameter options: Options for deserialization. + /// + /// - returns: An image deserialized or `nil` when no valid image + /// could be deserialized. + func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? +} + + +/// `DefaultCacheSerializer` is a basic `CacheSerializer` used in default cache of +/// Kingfisher. It could serialize and deserialize PNG, JEPG and GIF images. For +/// image other than these formats, a normalized `pngRepresentation` will be used. +public struct DefaultCacheSerializer: CacheSerializer { + + public static let `default` = DefaultCacheSerializer() + private init() {} + + public func data(with image: Image, original: Data?) -> Data? { + let imageFormat = original?.kf.imageFormat ?? .unknown + + let data: Data? + switch imageFormat { + case .PNG: data = image.kf.pngRepresentation() + case .JPEG: data = image.kf.jpegRepresentation(compressionQuality: 1.0) + case .GIF: data = image.kf.gifRepresentation() + case .unknown: data = original ?? image.kf.normalized.kf.pngRepresentation() + } + + return data + } + + public func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? { + let scale = (options ?? KingfisherEmptyOptionsInfo).scaleFactor + let preloadAllGIFData = (options ?? KingfisherEmptyOptionsInfo).preloadAllGIFData + + return Kingfisher.image(data: data, scale: scale, preloadAllGIFData: preloadAllGIFData) + } +} diff --git a/Pods/Kingfisher/Sources/Filter.swift b/Pods/Kingfisher/Sources/Filter.swift new file mode 100644 index 0000000..5f20987 --- /dev/null +++ b/Pods/Kingfisher/Sources/Filter.swift @@ -0,0 +1,145 @@ +// +// Filter.swift +// Kingfisher +// +// Created by Wei Wang on 2016/08/31. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + + +import CoreImage +import Accelerate + +// Reuse the same CI Context for all CI drawing. +private let ciContext = CIContext(options: nil) + +/// Transformer method which will be used in to provide a `Filter`. +public typealias Transformer = (CIImage) -> CIImage? + +/// Supply a filter to create an `ImageProcessor`. +public protocol CIImageProcessor: ImageProcessor { + var filter: Filter { get } +} + +extension CIImageProcessor { + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.apply(filter) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Wrapper for a `Transformer` of CIImage filters. +public struct Filter { + + let transform: Transformer + + public init(tranform: @escaping Transformer) { + self.transform = tranform + } + + /// Tint filter which will apply a tint color to images. + public static var tint: (Color) -> Filter = { + color in + Filter { input in + let colorFilter = CIFilter(name: "CIConstantColorGenerator")! + colorFilter.setValue(CIColor(color: color), forKey: kCIInputColorKey) + + let colorImage = colorFilter.outputImage + let filter = CIFilter(name: "CISourceOverCompositing")! + filter.setValue(colorImage, forKey: kCIInputImageKey) + filter.setValue(input, forKey: kCIInputBackgroundImageKey) + return filter.outputImage?.cropping(to: input.extent) + } + } + + public typealias ColorElement = (CGFloat, CGFloat, CGFloat, CGFloat) + + /// Color control filter which will apply color control change to images. + public static var colorControl: (ColorElement) -> Filter = { + brightness, contrast, saturation, inputEV in + Filter { input in + let paramsColor = [kCIInputBrightnessKey: brightness, + kCIInputContrastKey: contrast, + kCIInputSaturationKey: saturation] + + let blackAndWhite = input.applyingFilter("CIColorControls", withInputParameters: paramsColor) + let paramsExposure = [kCIInputEVKey: inputEV] + return blackAndWhite.applyingFilter("CIExposureAdjust", withInputParameters: paramsExposure) + } + + } +} + +extension Kingfisher where Base: Image { + /// Apply a `Filter` containing `CIImage` transformer to `self`. + /// + /// - parameter filter: The filter used to transform `self`. + /// + /// - returns: A transformed image by input `Filter`. + /// + /// - Note: Only CG-based images are supported. If any error happens during transforming, `self` will be returned. + public func apply(_ filter: Filter) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Tint image only works for CG-based image.") + return base + } + + let inputImage = CIImage(cgImage: cgImage) + guard let outputImage = filter.transform(inputImage) else { + return base + } + + guard let result = ciContext.createCGImage(outputImage, from: outputImage.extent) else { + assertionFailure("[Kingfisher] Can not make an tint image within context.") + return base + } + + #if os(macOS) + return fixedForRetinaPixel(cgImage: result, to: size) + #else + return Image(cgImage: result, scale: base.scale, orientation: base.imageOrientation) + #endif + } + +} + +public extension Image { + + /// Apply a `Filter` containing `CIImage` transformer to `self`. + /// + /// - parameter filter: The filter used to transform `self`. + /// + /// - returns: A transformed image by input `Filter`. + /// + /// - Note: Only CG-based images are supported. If any error happens during transforming, `self` will be returned. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.apply` instead.", + renamed: "kf.apply") + public func kf_apply(_ filter: Filter) -> Image { + return kf.apply(filter) + } +} diff --git a/Pods/Kingfisher/Sources/Image.swift b/Pods/Kingfisher/Sources/Image.swift new file mode 100755 index 0000000..3759de7 --- /dev/null +++ b/Pods/Kingfisher/Sources/Image.swift @@ -0,0 +1,923 @@ +// +// Image.swift +// Kingfisher +// +// Created by Wei Wang on 16/1/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#if os(macOS) +import AppKit +private var imagesKey: Void? +private var durationKey: Void? +#else +import UIKit +import MobileCoreServices +private var imageSourceKey: Void? +private var animatedImageDataKey: Void? +#endif + +import ImageIO +import CoreGraphics + +#if !os(watchOS) +import Accelerate +import CoreImage +#endif + +// MARK: - Image Properties +extension Kingfisher where Base: Image { + #if os(macOS) + var cgImage: CGImage? { + return base.cgImage(forProposedRect: nil, context: nil, hints: nil) + } + + var scale: CGFloat { + return 1.0 + } + + fileprivate(set) var images: [Image]? { + get { + return objc_getAssociatedObject(base, &imagesKey) as? [Image] + } + set { + objc_setAssociatedObject(base, &imagesKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + fileprivate(set) var duration: TimeInterval { + get { + return objc_getAssociatedObject(base, &durationKey) as? TimeInterval ?? 0.0 + } + set { + objc_setAssociatedObject(base, &durationKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + var size: CGSize { + return base.representations.reduce(CGSize.zero, { size, rep in + return CGSize(width: max(size.width, CGFloat(rep.pixelsWide)), height: max(size.height, CGFloat(rep.pixelsHigh))) + }) + } + + #else + var cgImage: CGImage? { + return base.cgImage + } + + var scale: CGFloat { + return base.scale + } + + var images: [Image]? { + return base.images + } + + var duration: TimeInterval { + return base.duration + } + + fileprivate(set) var imageSource: ImageSource? { + get { + return objc_getAssociatedObject(base, &imageSourceKey) as? ImageSource + } + set { + objc_setAssociatedObject(base, &imageSourceKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + fileprivate(set) var animatedImageData: Data? { + get { + return objc_getAssociatedObject(base, &animatedImageDataKey) as? Data + } + set { + objc_setAssociatedObject(base, &animatedImageDataKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + var size: CGSize { + return base.size + } + #endif +} + +// MARK: - Image Conversion +extension Kingfisher where Base: Image { + #if os(macOS) + static func image(cgImage: CGImage, scale: CGFloat, refImage: Image?) -> Image { + return Image(cgImage: cgImage, size: CGSize.zero) + } + + /** + Normalize the image. This method does nothing in OS X. + + - returns: The image itself. + */ + public var normalized: Image { + return base + } + + static func animated(with images: [Image], forDuration forDurationduration: TimeInterval) -> Image? { + return nil + } + #else + static func image(cgImage: CGImage, scale: CGFloat, refImage: Image?) -> Image { + if let refImage = refImage { + return Image(cgImage: cgImage, scale: scale, orientation: refImage.imageOrientation) + } else { + return Image(cgImage: cgImage, scale: scale, orientation: .up) + } + } + + /** + Normalize the image. This method will try to redraw an image with orientation and scale considered. + + - returns: The normalized image with orientation set to up and correct scale. + */ + public var normalized: Image { + // prevent animated image (GIF) lose it's images + guard images == nil else { return base } + // No need to do anything if already up + guard base.imageOrientation != .up else { return base } + + return draw(cgImage: nil, to: size) { + base.draw(in: CGRect(origin: CGPoint.zero, size: size)) + } + } + + static func animated(with images: [Image], forDuration duration: TimeInterval) -> Image? { + return .animatedImage(with: images, duration: duration) + } + #endif +} + +// MARK: - Image Representation +extension Kingfisher where Base: Image { + // MARK: - PNG + public func pngRepresentation() -> Data? { + #if os(macOS) + guard let cgimage = cgImage else { + return nil + } + let rep = NSBitmapImageRep(cgImage: cgimage) + return rep.representation(using: .PNG, properties: [:]) + #else + return UIImagePNGRepresentation(base) + #endif + } + + // MARK: - JPEG + public func jpegRepresentation(compressionQuality: CGFloat) -> Data? { + #if os(macOS) + guard let cgImage = cgImage else { + return nil + } + let rep = NSBitmapImageRep(cgImage: cgImage) + return rep.representation(using:.JPEG, properties: [NSImageCompressionFactor: compressionQuality]) + #else + return UIImageJPEGRepresentation(base, compressionQuality) + #endif + } + + // MARK: - GIF + public func gifRepresentation() -> Data? { + #if os(macOS) + return gifRepresentation(duration: 0.0, repeatCount: 0) + #else + return animatedImageData + #endif + } + + #if os(macOS) + func gifRepresentation(duration: TimeInterval, repeatCount: Int) -> Data? { + guard let images = images else { + return nil + } + + let frameCount = images.count + let gifDuration = duration <= 0.0 ? duration / Double(frameCount) : duration / Double(frameCount) + + let frameProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: gifDuration]] + let imageProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: repeatCount]] + + let data = NSMutableData() + + guard let destination = CGImageDestinationCreateWithData(data, kUTTypeGIF, frameCount, nil) else { + return nil + } + CGImageDestinationSetProperties(destination, imageProperties as CFDictionary) + + for image in images { + CGImageDestinationAddImage(destination, image.kf.cgImage!, frameProperties as CFDictionary) + } + + return CGImageDestinationFinalize(destination) ? data.copy() as? Data : nil + } + #endif +} + +// MARK: - Create images from data +extension Kingfisher where Base: Image { + static func animated(with data: Data, scale: CGFloat = 1.0, duration: TimeInterval = 0.0, preloadAll: Bool) -> Image? { + + func decode(from imageSource: CGImageSource, for options: NSDictionary) -> ([Image], TimeInterval)? { + + //Calculates frame duration for a gif frame out of the kCGImagePropertyGIFDictionary dictionary + func frameDuration(from gifInfo: NSDictionary) -> Double { + let gifDefaultFrameDuration = 0.100 + + let unclampedDelayTime = gifInfo[kCGImagePropertyGIFUnclampedDelayTime as String] as? NSNumber + let delayTime = gifInfo[kCGImagePropertyGIFDelayTime as String] as? NSNumber + let duration = unclampedDelayTime ?? delayTime + + guard let frameDuration = duration else { return gifDefaultFrameDuration } + + return frameDuration.doubleValue > 0.011 ? frameDuration.doubleValue : gifDefaultFrameDuration + } + + let frameCount = CGImageSourceGetCount(imageSource) + var images = [Image]() + var gifDuration = 0.0 + for i in 0 ..< frameCount { + + guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, i, options) else { + return nil + } + + if frameCount == 1 { + // Single frame + gifDuration = Double.infinity + } else { + // Animated GIF + guard let properties = CGImageSourceCopyPropertiesAtIndex(imageSource, i, nil), + let gifInfo = (properties as NSDictionary)[kCGImagePropertyGIFDictionary as String] as? NSDictionary else + { + return nil + } + gifDuration += frameDuration(from: gifInfo) + } + + images.append(Kingfisher.image(cgImage: imageRef, scale: scale, refImage: nil)) + } + + return (images, gifDuration) + } + + // Start of kf.animatedImageWithGIFData + let options: NSDictionary = [kCGImageSourceShouldCache as String: true, kCGImageSourceTypeIdentifierHint as String: kUTTypeGIF] + guard let imageSource = CGImageSourceCreateWithData(data as CFData, options) else { + return nil + } + + #if os(macOS) + guard let (images, gifDuration) = decode(from: imageSource, for: options) else { + return nil + } + let image = Image(data: data) + image?.kf.images = images + image?.kf.duration = gifDuration + + return image + #else + + if preloadAll { + guard let (images, gifDuration) = decode(from: imageSource, for: options) else { + return nil + } + let image = Kingfisher.animated(with: images, forDuration: duration <= 0.0 ? gifDuration : duration) + image?.kf.animatedImageData = data + return image + } else { + let image = Image(data: data) + image?.kf.animatedImageData = data + image?.kf.imageSource = ImageSource(ref: imageSource) + return image + } + #endif + } + + static func image(data: Data, scale: CGFloat, preloadAllGIFData: Bool) -> Image? { + var image: Image? + + #if os(macOS) + switch data.kf.imageFormat { + case .JPEG: image = Image(data: data) + case .PNG: image = Image(data: data) + case .GIF: image = Kingfisher.animated(with: data, scale: scale, duration: 0.0, preloadAll: preloadAllGIFData) + case .unknown: image = Image(data: data) + } + #else + switch data.kf.imageFormat { + case .JPEG: image = Image(data: data, scale: scale) + case .PNG: image = Image(data: data, scale: scale) + case .GIF: image = Kingfisher.animated(with: data, scale: scale, duration: 0.0, preloadAll: preloadAllGIFData) + case .unknown: image = Image(data: data, scale: scale) + } + #endif + + return image + } +} + +// MARK: - Image Transforming +extension Kingfisher where Base: Image { + + // MARK: - Round Corner + /// Create a round corner image based on `self`. + /// + /// - parameter radius: The round corner radius of creating image. + /// - parameter size: The target size of creating image. + /// + /// - returns: An image with round corner of `self`. + /// + /// - Note: This method only works for CG-based image. + public func image(withRoundRadius radius: CGFloat, fit size: CGSize) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Round corder image only works for CG-based image.") + return base + } + + let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size) + return draw(cgImage: cgImage, to: size) { + #if os(macOS) + let path = NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius) + path.windingRule = .evenOddWindingRule + path.addClip() + base.draw(in: rect) + #else + guard let context = UIGraphicsGetCurrentContext() else { + assertionFailure("[Kingfisher] Failed to create CG context for image.") + return + } + let path = UIBezierPath(roundedRect: rect, byRoundingCorners: .allCorners, cornerRadii: CGSize(width: radius, height: radius)).cgPath + context.addPath(path) + context.clip() + base.draw(in: rect) + #endif + } + } + + #if os(iOS) || os(tvOS) + func resize(to size: CGSize, for contentMode: UIViewContentMode) -> Image { + switch contentMode { + case .scaleAspectFit: + let newSize = self.size.kf.constrained(size) + return resize(to: newSize) + case .scaleAspectFill: + let newSize = self.size.kf.filling(size) + return resize(to: newSize) + default: + return resize(to: size) + } + } + #endif + + // MARK: - Resize + + /// Resize `self` to an image of new size. + /// + /// - parameter size: The target size. + /// + /// - returns: An image with new size. + /// + /// - Note: This method only works for CG-based image. + public func resize(to size: CGSize) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Resize only works for CG-based image.") + return base + } + + let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size) + return draw(cgImage: cgImage, to: size) { + #if os(macOS) + base.draw(in: rect, from: NSRect.zero, operation: .copy, fraction: 1.0) + #else + base.draw(in: rect) + #endif + } + } + + // MARK: - Blur + + /// Create an image with blur effect based on `self`. + /// + /// - parameter radius: The blur radius should be used when creating blue. + /// + /// - returns: An image with blur effect applied. + /// + /// - Note: This method only works for CG-based image. + public func blurred(withRadius radius: CGFloat) -> Image { + #if os(watchOS) + return base + #else + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Blur only works for CG-based image.") + return base + } + + // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement + // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) + // if d is odd, use three box-blurs of size 'd', centered on the output pixel. + let s = Float(max(radius, 2.0)) + // We will do blur on a resized image (*0.5), so the blur radius could be half as well. + var targetRadius = floor(s * 3.0 * sqrt(2 * Float.pi) / 4.0 + 0.5) + + if targetRadius.isEven { + targetRadius += 1 + } + + let iterations: Int + if radius < 0.5 { + iterations = 1 + } else if radius < 1.5 { + iterations = 2 + } else { + iterations = 3 + } + + let w = Int(size.width) + let h = Int(size.height) + let rowBytes = Int(CGFloat(cgImage.bytesPerRow)) + + func createEffectBuffer(_ context: CGContext) -> vImage_Buffer { + let data = context.data + let width = vImagePixelCount(context.width) + let height = vImagePixelCount(context.height) + let rowBytes = context.bytesPerRow + + return vImage_Buffer(data: data, height: height, width: width, rowBytes: rowBytes) + } + + guard let context = beginContext() else { + assertionFailure("[Kingfisher] Failed to create CG context for blurring image.") + return base + } + defer { endContext() } + + context.draw(cgImage, in: CGRect(x: 0, y: 0, width: w, height: h)) + + var inBuffer = createEffectBuffer(context) + + guard let outContext = beginContext() else { + assertionFailure("[Kingfisher] Failed to create CG context for blurring image.") + return base + } + defer { endContext() } + var outBuffer = createEffectBuffer(outContext) + + for _ in 0 ..< iterations { + vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, nil, 0, 0, UInt32(targetRadius), UInt32(targetRadius), nil, vImage_Flags(kvImageEdgeExtend)) + (inBuffer, outBuffer) = (outBuffer, inBuffer) + } + + #if os(macOS) + let result = outContext.makeImage().flatMap { fixedForRetinaPixel(cgImage: $0, to: size) } + #else + let result = outContext.makeImage().flatMap { Image(cgImage: $0, scale: base.scale, orientation: base.imageOrientation) } + #endif + guard let blurredImage = result else { + assertionFailure("[Kingfisher] Can not make an blurred image within this context.") + return base + } + + return blurredImage + #endif + } + + // MARK: - Overlay + + /// Create an image from `self` with a color overlay layer. + /// + /// - parameter color: The color should be use to overlay. + /// - parameter fraction: Fraction of input color. From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay. + /// + /// - returns: An image with a color overlay applied. + /// + /// - Note: This method only works for CG-based image. + public func overlaying(with color: Color, fraction: CGFloat) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Overlaying only works for CG-based image.") + return base + } + + let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) + return draw(cgImage: cgImage, to: rect.size) { + #if os(macOS) + base.draw(in: rect) + if fraction > 0 { + color.withAlphaComponent(1 - fraction).set() + NSRectFillUsingOperation(rect, .sourceAtop) + } + #else + color.set() + UIRectFill(rect) + base.draw(in: rect, blendMode: .destinationIn, alpha: 1.0) + + if fraction > 0 { + base.draw(in: rect, blendMode: .sourceAtop, alpha: fraction) + } + #endif + } + } + + // MARK: - Tint + + /// Create an image from `self` with a color tint. + /// + /// - parameter color: The color should be used to tint `self` + /// + /// - returns: An image with a color tint applied. + public func tinted(with color: Color) -> Image { + #if os(watchOS) + return base + #else + return apply(.tint(color)) + #endif + } + + // MARK: - Color Control + + /// Create an image from `self` with color control. + /// + /// - parameter brightness: Brightness changing to image. + /// - parameter contrast: Contrast changing to image. + /// - parameter saturation: Saturation changing to image. + /// - parameter inputEV: InputEV changing to image. + /// + /// - returns: An image with color control applied. + public func adjusted(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) -> Image { + #if os(watchOS) + return base + #else + return apply(.colorControl(brightness, contrast, saturation, inputEV)) + #endif + } +} + +// MARK: - Decode +extension Kingfisher where Base: Image { + var decoded: Image? { + return decoded(scale: scale) + } + + func decoded(scale: CGFloat) -> Image { + // prevent animated image (GIF) lose it's images + #if os(iOS) + if imageSource != nil { return base } + #else + if images != nil { return base } + #endif + + guard let imageRef = self.cgImage else { + assertionFailure("[Kingfisher] Decoding only works for CG-based image.") + return base + } + let colorSpace = CGColorSpaceCreateDeviceRGB() + guard let context = beginContext() else { + assertionFailure("[Kingfisher] Decoding fails to create a valid context.") + return base + } + + defer { endContext() } + + let rect = CGRect(x: 0, y: 0, width: imageRef.width, height: imageRef.height) + context.draw(imageRef, in: rect) + let decompressedImageRef = context.makeImage() + return Kingfisher.image(cgImage: decompressedImageRef!, scale: scale, refImage: base) + } +} + +/// Reference the source image reference +class ImageSource { + var imageRef: CGImageSource? + init(ref: CGImageSource) { + self.imageRef = ref + } +} + +// MARK: - Image format +private struct ImageHeaderData { + static var PNG: [UInt8] = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A] + static var JPEG_SOI: [UInt8] = [0xFF, 0xD8] + static var JPEG_IF: [UInt8] = [0xFF] + static var GIF: [UInt8] = [0x47, 0x49, 0x46] +} + +enum ImageFormat { + case unknown, PNG, JPEG, GIF +} + + +// MARK: - Misc Helpers +public struct DataProxy { + fileprivate let base: Data + init(proxy: Data) { + base = proxy + } +} + +extension Data: KingfisherCompatible { + public typealias CompatibleType = DataProxy + public var kf: DataProxy { + return DataProxy(proxy: self) + } +} + +extension DataProxy { + var imageFormat: ImageFormat { + var buffer = [UInt8](repeating: 0, count: 8) + (base as NSData).getBytes(&buffer, length: 8) + if buffer == ImageHeaderData.PNG { + return .PNG + } else if buffer[0] == ImageHeaderData.JPEG_SOI[0] && + buffer[1] == ImageHeaderData.JPEG_SOI[1] && + buffer[2] == ImageHeaderData.JPEG_IF[0] + { + return .JPEG + } else if buffer[0] == ImageHeaderData.GIF[0] && + buffer[1] == ImageHeaderData.GIF[1] && + buffer[2] == ImageHeaderData.GIF[2] + { + return .GIF + } + + return .unknown + } +} + +public struct CGSizeProxy { + fileprivate let base: CGSize + init(proxy: CGSize) { + base = proxy + } +} + +extension CGSize: KingfisherCompatible { + public typealias CompatibleType = CGSizeProxy + public var kf: CGSizeProxy { + return CGSizeProxy(proxy: self) + } +} + +extension CGSizeProxy { + func constrained(_ size: CGSize) -> CGSize { + let aspectWidth = round(aspectRatio * size.height) + let aspectHeight = round(size.width / aspectRatio) + + return aspectWidth > size.width ? CGSize(width: size.width, height: aspectHeight) : CGSize(width: aspectWidth, height: size.height) + } + + func filling(_ size: CGSize) -> CGSize { + let aspectWidth = round(aspectRatio * size.height) + let aspectHeight = round(size.width / aspectRatio) + + return aspectWidth < size.width ? CGSize(width: size.width, height: aspectHeight) : CGSize(width: aspectWidth, height: size.height) + } + + private var aspectRatio: CGFloat { + return base.height == 0.0 ? 1.0 : base.width / base.height + } +} + +extension Kingfisher where Base: Image { + + func beginContext() -> CGContext? { + #if os(macOS) + guard let rep = NSBitmapImageRep( + bitmapDataPlanes: nil, + pixelsWide: Int(size.width), + pixelsHigh: Int(size.height), + bitsPerSample: cgImage?.bitsPerComponent ?? 8, + samplesPerPixel: 4, + hasAlpha: true, + isPlanar: false, + colorSpaceName: NSCalibratedRGBColorSpace, + bytesPerRow: 0, + bitsPerPixel: 0) else + { + assertionFailure("[Kingfisher] Image representation cannot be created.") + return nil + } + rep.size = size + NSGraphicsContext.saveGraphicsState() + guard let context = NSGraphicsContext(bitmapImageRep: rep) else { + assertionFailure("[Kingfisher] Image contenxt cannot be created.") + return nil + } + + NSGraphicsContext.setCurrent(context) + return context.cgContext + #else + UIGraphicsBeginImageContextWithOptions(size, false, scale) + let context = UIGraphicsGetCurrentContext() + context?.scaleBy(x: 1.0, y: -1.0) + context?.translateBy(x: 0, y: -size.height) + return context + #endif + } + + func endContext() { + #if os(macOS) + NSGraphicsContext.restoreGraphicsState() + #else + UIGraphicsEndImageContext() + #endif + } + + func draw(cgImage: CGImage?, to size: CGSize, draw: ()->()) -> Image { + #if os(macOS) + guard let rep = NSBitmapImageRep( + bitmapDataPlanes: nil, + pixelsWide: Int(size.width), + pixelsHigh: Int(size.height), + bitsPerSample: cgImage?.bitsPerComponent ?? 8, + samplesPerPixel: 4, + hasAlpha: true, + isPlanar: false, + colorSpaceName: NSCalibratedRGBColorSpace, + bytesPerRow: 0, + bitsPerPixel: 0) else + { + assertionFailure("[Kingfisher] Image representation cannot be created.") + return base + } + rep.size = size + + NSGraphicsContext.saveGraphicsState() + + let context = NSGraphicsContext(bitmapImageRep: rep) + NSGraphicsContext.setCurrent(context) + draw() + NSGraphicsContext.restoreGraphicsState() + + let outputImage = Image(size: size) + outputImage.addRepresentation(rep) + return outputImage + #else + + UIGraphicsBeginImageContextWithOptions(size, false, scale) + defer { UIGraphicsEndImageContext() } + draw() + return UIGraphicsGetImageFromCurrentImageContext() ?? base + + #endif + } + + #if os(macOS) + func fixedForRetinaPixel(cgImage: CGImage, to size: CGSize) -> Image { + + let image = Image(cgImage: cgImage, size: base.size) + let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size) + + return draw(cgImage: cgImage, to: self.size) { + image.draw(in: rect, from: NSRect.zero, operation: .copy, fraction: 1.0) + } + } + #endif +} + +extension Float { + var isEven: Bool { + return truncatingRemainder(dividingBy: 2.0) == 0 + } +} + +// MARK: - Deprecated. Only for back compatibility. +extension Image { + /** + Normalize the image. This method does nothing in OS X. + + - returns: The image itself. + */ + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.normalized` instead.", + renamed: "kf.normalized") + public func kf_normalized() -> Image { + return kf.normalized + } + + // MARK: - Round Corner + + /// Create a round corner image based on `self`. + /// + /// - parameter radius: The round corner radius of creating image. + /// - parameter size: The target size of creating image. + /// - parameter scale: The image scale of creating image. + /// + /// - returns: An image with round corner of `self`. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.image(withRoundRadius:fit:scale:)` instead.", + renamed: "kf.image") + public func kf_image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image { + return kf.image(withRoundRadius: radius, fit: size) + } + + // MARK: - Resize + /// Resize `self` to an image of new size. + /// + /// - parameter size: The target size. + /// + /// - returns: An image with new size. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.resize(to:)` instead.", + renamed: "kf.resize") + public func kf_resize(to size: CGSize) -> Image { + return kf.resize(to: size) + } + + // MARK: - Blur + /// Create an image with blur effect based on `self`. + /// + /// - parameter radius: The blur radius should be used when creating blue. + /// + /// - returns: An image with blur effect applied. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.blurred(withRadius:)` instead.", + renamed: "kf.blurred") + public func kf_blurred(withRadius radius: CGFloat) -> Image { + return kf.blurred(withRadius: radius) + } + + // MARK: - Overlay + /// Create an image from `self` with a color overlay layer. + /// + /// - parameter color: The color should be use to overlay. + /// - parameter fraction: Fraction of input color. From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay. + /// + /// - returns: An image with a color overlay applied. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.overlaying(with:fraction:)` instead.", + renamed: "kf.overlaying") + public func kf_overlaying(with color: Color, fraction: CGFloat) -> Image { + return kf.overlaying(with: color, fraction: fraction) + } + + // MARK: - Tint + + /// Create an image from `self` with a color tint. + /// + /// - parameter color: The color should be used to tint `self` + /// + /// - returns: An image with a color tint applied. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.tinted(with:)` instead.", + renamed: "kf.tinted") + public func kf_tinted(with color: Color) -> Image { + return kf.tinted(with: color) + } + + // MARK: - Color Control + + /// Create an image from `self` with color control. + /// + /// - parameter brightness: Brightness changing to image. + /// - parameter contrast: Contrast changing to image. + /// - parameter saturation: Saturation changing to image. + /// - parameter inputEV: InputEV changing to image. + /// + /// - returns: An image with color control applied. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.adjusted` instead.", + renamed: "kf.adjusted") + public func kf_adjusted(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) -> Image { + return kf.adjusted(brightness: brightness, contrast: contrast, saturation: saturation, inputEV: inputEV) + } +} + +extension Kingfisher where Base: Image { + @available(*, deprecated, + message: "`scale` is not used. Use the version without scale instead. (Remove the `scale` argument)") + public func image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image { + return image(withRoundRadius: radius, fit: size) + } +} diff --git a/Pods/Kingfisher/Sources/ImageCache.swift b/Pods/Kingfisher/Sources/ImageCache.swift new file mode 100755 index 0000000..19f92ef --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageCache.swift @@ -0,0 +1,693 @@ +// +// ImageCache.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +public extension Notification.Name { + /** + This notification will be sent when the disk cache got cleaned either there are cached files expired or the total size exceeding the max allowed size. The manually invoking of `clearDiskCache` method will not trigger this notification. + + The `object` of this notification is the `ImageCache` object which sends the notification. + + A list of removed hashes (files) could be retrieved by accessing the array under `KingfisherDiskCacheCleanedHashKey` key in `userInfo` of the notification object you received. By checking the array, you could know the hash codes of files are removed. + + The main purpose of this notification is supplying a chance to maintain some necessary information on the cached files. See [this wiki](https://github.com/onevcat/Kingfisher/wiki/How-to-implement-ETag-based-304-(Not-Modified)-handling-in-Kingfisher) for a use case on it. + */ + public static var KingfisherDidCleanDiskCache = Notification.Name.init("com.onevcat.Kingfisher.KingfisherDidCleanDiskCache") +} + +/** +Key for array of cleaned hashes in `userInfo` of `KingfisherDidCleanDiskCacheNotification`. +*/ +public let KingfisherDiskCacheCleanedHashKey = "com.onevcat.Kingfisher.cleanedHash" + +/// It represents a task of retrieving image. You can call `cancel` on it to stop the process. +public typealias RetrieveImageDiskTask = DispatchWorkItem + +/** +Cache type of a cached image. + +- None: The image is not cached yet when retrieving it. +- Memory: The image is cached in memory. +- Disk: The image is cached in disk. +*/ +public enum CacheType { + case none, memory, disk +} + +/// `ImageCache` represents both the memory and disk cache system of Kingfisher. +/// While a default image cache object will be used if you prefer the extension methods of Kingfisher, +/// you can create your own cache object and configure it as your need. You could use an `ImageCache` +/// object to manipulate memory and disk cache for Kingfisher. +open class ImageCache { + + //Memory + fileprivate let memoryCache = NSCache() + + /// The largest cache cost of memory cache. The total cost is pixel count of + /// all cached images in memory. + /// Default is unlimited. Memory cache will be purged automatically when a + /// memory warning notification is received. + open var maxMemoryCost: UInt = 0 { + didSet { + self.memoryCache.totalCostLimit = Int(maxMemoryCost) + } + } + + //Disk + fileprivate let ioQueue: DispatchQueue + fileprivate var fileManager: FileManager! + + ///The disk cache location. + open let diskCachePath: String + + /// The default file extension appended to cached files. + open var pathExtension: String? + + /// The longest time duration in second of the cache being stored in disk. + /// Default is 1 week (60 * 60 * 24 * 7 seconds). + /// Setting this to a negative value will make the disk cache never expiring. + open var maxCachePeriodInSecond: TimeInterval = 60 * 60 * 24 * 7 //Cache exists for 1 week + + /// The largest disk size can be taken for the cache. It is the total + /// allocated size of cached files in bytes. + /// Default is no limit. + open var maxDiskCacheSize: UInt = 0 + + fileprivate let processQueue: DispatchQueue + + /// The default cache. + public static let `default` = ImageCache(name: "default") + + /// Closure that defines the disk cache path from a given path and cacheName. + public typealias DiskCachePathClosure = (String?, String) -> String + + /// The default DiskCachePathClosure + public final class func defaultDiskCachePathClosure(path: String?, cacheName: String) -> String { + let dstPath = path ?? NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first! + return (dstPath as NSString).appendingPathComponent(cacheName) + } + + /** + Init method. Passing a name for the cache. It represents a cache folder in the memory and disk. + + - parameter name: Name of the cache. It will be used as the memory cache name and the disk cache folder name + appending to the cache path. This value should not be an empty string. + - parameter path: Optional - Location of cache path on disk. If `nil` is passed in (the default value), + the `.cachesDirectory` in of your app will be used. + - parameter diskCachePathClosure: Closure that takes in an optional initial path string and generates + the final disk cache path. You could use it to fully customize your cache path. + + - returns: The cache object. + */ + public init(name: String, + path: String? = nil, + diskCachePathClosure: DiskCachePathClosure = ImageCache.defaultDiskCachePathClosure) + { + + if name.isEmpty { + fatalError("[Kingfisher] You should specify a name for the cache. A cache with empty name is not permitted.") + } + + let cacheName = "com.onevcat.Kingfisher.ImageCache.\(name)" + memoryCache.name = cacheName + + diskCachePath = diskCachePathClosure(path, cacheName) + + let ioQueueName = "com.onevcat.Kingfisher.ImageCache.ioQueue.\(name)" + ioQueue = DispatchQueue(label: ioQueueName) + + let processQueueName = "com.onevcat.Kingfisher.ImageCache.processQueue.\(name)" + processQueue = DispatchQueue(label: processQueueName, attributes: .concurrent) + + ioQueue.sync { fileManager = FileManager() } + +#if !os(macOS) && !os(watchOS) + NotificationCenter.default.addObserver( + self, selector: #selector(clearMemoryCache), name: .UIApplicationDidReceiveMemoryWarning, object: nil) + NotificationCenter.default.addObserver( + self, selector: #selector(cleanExpiredDiskCache), name: .UIApplicationWillTerminate, object: nil) + NotificationCenter.default.addObserver( + self, selector: #selector(backgroundCleanExpiredDiskCache), name: .UIApplicationDidEnterBackground, object: nil) +#endif + } + + deinit { + NotificationCenter.default.removeObserver(self) + } + + + // MARK: - Store & Remove + + /** + Store an image to cache. It will be saved to both memory and disk. It is an async operation. + + - parameter image: The image to be stored. + - parameter original: The original data of the image. + Kingfisher will use it to check the format of the image and optimize cache size on disk. + If `nil` is supplied, the image data will be saved as a normalized PNG file. + It is strongly suggested to supply it whenever possible, to get a better performance and disk usage. + - parameter key: Key for the image. + - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of + processor to it. + This identifier will be used to generate a corresponding key for the combination of `key` and processor. + - parameter toDisk: Whether this image should be cached to disk or not. If false, the image will be only cached in memory. + - parameter completionHandler: Called when store operation completes. + */ + open func store(_ image: Image, + original: Data? = nil, + forKey key: String, + processorIdentifier identifier: String = "", + cacheSerializer serializer: CacheSerializer = DefaultCacheSerializer.default, + toDisk: Bool = true, + completionHandler: (() -> Void)? = nil) + { + + let computedKey = key.computedKey(with: identifier) + memoryCache.setObject(image, forKey: computedKey as NSString, cost: image.kf.imageCost) + + func callHandlerInMainQueue() { + if let handler = completionHandler { + DispatchQueue.main.async { + handler() + } + } + } + + if toDisk { + ioQueue.async { + + if let data = serializer.data(with: image, original: original) { + if !self.fileManager.fileExists(atPath: self.diskCachePath) { + do { + try self.fileManager.createDirectory(atPath: self.diskCachePath, withIntermediateDirectories: true, attributes: nil) + } catch _ {} + } + + self.fileManager.createFile(atPath: self.cachePath(forComputedKey: computedKey), contents: data, attributes: nil) + } + callHandlerInMainQueue() + } + } else { + callHandlerInMainQueue() + } + } + + /** + Remove the image for key for the cache. It will be opted out from both memory and disk. + It is an async operation. + + - parameter key: Key for the image. + - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it. + This identifier will be used to generate a corresponding key for the combination of `key` and processor. + - parameter fromDisk: Whether this image should be removed from disk or not. If false, the image will be only removed from memory. + - parameter completionHandler: Called when removal operation completes. + */ + open func removeImage(forKey key: String, + processorIdentifier identifier: String = "", + fromDisk: Bool = true, + completionHandler: (() -> Void)? = nil) + { + let computedKey = key.computedKey(with: identifier) + memoryCache.removeObject(forKey: computedKey as NSString) + + func callHandlerInMainQueue() { + if let handler = completionHandler { + DispatchQueue.main.async { + handler() + } + } + } + + if fromDisk { + ioQueue.async{ + do { + try self.fileManager.removeItem(atPath: self.cachePath(forComputedKey: computedKey)) + } catch _ {} + callHandlerInMainQueue() + } + } else { + callHandlerInMainQueue() + } + } + + // MARK: - Get data from cache + + /** + Get an image for a key from memory or disk. + + - parameter key: Key for the image. + - parameter options: Options of retrieving image. If you need to retrieve an image which was + stored with a specified `ImageProcessor`, pass the processor in the option too. + - parameter completionHandler: Called when getting operation completes with image result and cached type of + this image. If there is no such key cached, the image will be `nil`. + + - returns: The retrieving task. + */ + @discardableResult + open func retrieveImage(forKey key: String, + options: KingfisherOptionsInfo?, + completionHandler: ((Image?, CacheType) -> ())?) -> RetrieveImageDiskTask? + { + // No completion handler. Not start working and early return. + guard let completionHandler = completionHandler else { + return nil + } + + var block: RetrieveImageDiskTask? + let options = options ?? KingfisherEmptyOptionsInfo + + if let image = self.retrieveImageInMemoryCache(forKey: key, options: options) { + options.callbackDispatchQueue.safeAsync { + completionHandler(image, .memory) + } + } else { + var sSelf: ImageCache! = self + block = DispatchWorkItem(block: { + // Begin to load image from disk + if let image = sSelf.retrieveImageInDiskCache(forKey: key, options: options) { + if options.backgroundDecode { + sSelf.processQueue.async { + let result = image.kf.decoded(scale: options.scaleFactor) + + sSelf.store(result, + forKey: key, + processorIdentifier: options.processor.identifier, + cacheSerializer: options.cacheSerializer, + toDisk: false, + completionHandler: nil) + + options.callbackDispatchQueue.safeAsync { + completionHandler(result, .memory) + sSelf = nil + } + } + } else { + sSelf.store(image, + forKey: key, + processorIdentifier: options.processor.identifier, + cacheSerializer: options.cacheSerializer, + toDisk: false, + completionHandler: nil + ) + options.callbackDispatchQueue.safeAsync { + completionHandler(image, .disk) + sSelf = nil + } + } + } else { + // No image found from either memory or disk + options.callbackDispatchQueue.safeAsync { + completionHandler(nil, .none) + sSelf = nil + } + } + }) + + sSelf.ioQueue.async(execute: block!) + } + + return block + } + + /** + Get an image for a key from memory. + + - parameter key: Key for the image. + - parameter options: Options of retrieving image. If you need to retrieve an image which was + stored with a specified `ImageProcessor`, pass the processor in the option too. + - returns: The image object if it is cached, or `nil` if there is no such key in the cache. + */ + open func retrieveImageInMemoryCache(forKey key: String, options: KingfisherOptionsInfo? = nil) -> Image? { + + let options = options ?? KingfisherEmptyOptionsInfo + let computedKey = key.computedKey(with: options.processor.identifier) + + return memoryCache.object(forKey: computedKey as NSString) as? Image + } + + /** + Get an image for a key from disk. + + - parameter key: Key for the image. + - parameter options: Options of retrieving image. If you need to retrieve an image which was + stored with a specified `ImageProcessor`, pass the processor in the option too. + + - returns: The image object if it is cached, or `nil` if there is no such key in the cache. + */ + open func retrieveImageInDiskCache(forKey key: String, options: KingfisherOptionsInfo? = nil) -> Image? { + + let options = options ?? KingfisherEmptyOptionsInfo + let computedKey = key.computedKey(with: options.processor.identifier) + + return diskImage(forComputedKey: computedKey, serializer: options.cacheSerializer, options: options) + } + + + // MARK: - Clear & Clean + + /** + Clear memory cache. + */ + @objc public func clearMemoryCache() { + memoryCache.removeAllObjects() + } + + /** + Clear disk cache. This is an async operation. + + - parameter completionHander: Called after the operation completes. + */ + open func clearDiskCache(completion handler: (()->())? = nil) { + ioQueue.async { + do { + try self.fileManager.removeItem(atPath: self.diskCachePath) + try self.fileManager.createDirectory(atPath: self.diskCachePath, withIntermediateDirectories: true, attributes: nil) + } catch _ { } + + if let handler = handler { + DispatchQueue.main.async { + handler() + } + } + } + } + + /** + Clean expired disk cache. This is an async operation. + */ + @objc fileprivate func cleanExpiredDiskCache() { + cleanExpiredDiskCache(completion: nil) + } + + /** + Clean expired disk cache. This is an async operation. + + - parameter completionHandler: Called after the operation completes. + */ + open func cleanExpiredDiskCache(completion handler: (()->())? = nil) { + + // Do things in cocurrent io queue + ioQueue.async { + + var (URLsToDelete, diskCacheSize, cachedFiles) = self.travelCachedFiles(onlyForCacheSize: false) + + for fileURL in URLsToDelete { + do { + try self.fileManager.removeItem(at: fileURL) + } catch _ { } + } + + if self.maxDiskCacheSize > 0 && diskCacheSize > self.maxDiskCacheSize { + let targetSize = self.maxDiskCacheSize / 2 + + // Sort files by last modify date. We want to clean from the oldest files. + let sortedFiles = cachedFiles.keysSortedByValue { + resourceValue1, resourceValue2 -> Bool in + + if let date1 = resourceValue1.contentAccessDate, + let date2 = resourceValue2.contentAccessDate + { + return date1.compare(date2) == .orderedAscending + } + + // Not valid date information. This should not happen. Just in case. + return true + } + + for fileURL in sortedFiles { + + do { + try self.fileManager.removeItem(at: fileURL) + } catch { } + + URLsToDelete.append(fileURL) + + if let fileSize = cachedFiles[fileURL]?.totalFileAllocatedSize { + diskCacheSize -= UInt(fileSize) + } + + if diskCacheSize < targetSize { + break + } + } + } + + DispatchQueue.main.async { + + if URLsToDelete.count != 0 { + let cleanedHashes = URLsToDelete.map { $0.lastPathComponent } + NotificationCenter.default.post(name: .KingfisherDidCleanDiskCache, object: self, userInfo: [KingfisherDiskCacheCleanedHashKey: cleanedHashes]) + } + + handler?() + } + } + } + + fileprivate func travelCachedFiles(onlyForCacheSize: Bool) -> (urlsToDelete: [URL], diskCacheSize: UInt, cachedFiles: [URL: URLResourceValues]) { + + let diskCacheURL = URL(fileURLWithPath: diskCachePath) + let resourceKeys: Set = [.isDirectoryKey, .contentAccessDateKey, .totalFileAllocatedSizeKey] + let expiredDate: Date? = (maxCachePeriodInSecond < 0) ? nil : Date(timeIntervalSinceNow: -maxCachePeriodInSecond) + + var cachedFiles = [URL: URLResourceValues]() + var urlsToDelete = [URL]() + var diskCacheSize: UInt = 0 + + if let fileEnumerator = self.fileManager.enumerator(at: diskCacheURL, includingPropertiesForKeys: Array(resourceKeys), options: FileManager.DirectoryEnumerationOptions.skipsHiddenFiles, errorHandler: nil), + let urls = fileEnumerator.allObjects as? [URL] + { + for fileUrl in urls { + + do { + let resourceValues = try fileUrl.resourceValues(forKeys: resourceKeys) + // If it is a Directory. Continue to next file URL. + if resourceValues.isDirectory == true { + continue + } + + // If this file is expired, add it to URLsToDelete + if !onlyForCacheSize, + let expiredDate = expiredDate, + let lastAccessData = resourceValues.contentAccessDate, + (lastAccessData as NSDate).laterDate(expiredDate) == expiredDate + { + urlsToDelete.append(fileUrl) + continue + } + + if let fileSize = resourceValues.totalFileAllocatedSize { + diskCacheSize += UInt(fileSize) + if !onlyForCacheSize { + cachedFiles[fileUrl] = resourceValues + } + } + } catch _ { } + } + } + + return (urlsToDelete, diskCacheSize, cachedFiles) + } + +#if !os(macOS) && !os(watchOS) + /** + Clean expired disk cache when app in background. This is an async operation. + In most cases, you should not call this method explicitly. + It will be called automatically when `UIApplicationDidEnterBackgroundNotification` received. + */ + @objc public func backgroundCleanExpiredDiskCache() { + // if 'sharedApplication()' is unavailable, then return + guard let sharedApplication = Kingfisher.shared else { return } + + func endBackgroundTask(_ task: inout UIBackgroundTaskIdentifier) { + sharedApplication.endBackgroundTask(task) + task = UIBackgroundTaskInvalid + } + + var backgroundTask: UIBackgroundTaskIdentifier! + backgroundTask = sharedApplication.beginBackgroundTask { + endBackgroundTask(&backgroundTask!) + } + + cleanExpiredDiskCache { + endBackgroundTask(&backgroundTask!) + } + } +#endif + + + // MARK: - Check cache status + + /** + * Cache result for checking whether an image is cached for a key. + */ + public struct CacheCheckResult { + public let cached: Bool + public let cacheType: CacheType? + } + + /** + Check whether an image is cached for a key. + + - parameter key: Key for the image. + + - returns: The check result. + */ + open func isImageCached(forKey key: String, processorIdentifier identifier: String = "") -> CacheCheckResult { + + let computedKey = key.computedKey(with: identifier) + + if memoryCache.object(forKey: computedKey as NSString) != nil { + return CacheCheckResult(cached: true, cacheType: .memory) + } + + let filePath = cachePath(forComputedKey: computedKey) + + var diskCached = false + ioQueue.sync { + diskCached = fileManager.fileExists(atPath: filePath) + } + + if diskCached { + return CacheCheckResult(cached: true, cacheType: .disk) + } + + return CacheCheckResult(cached: false, cacheType: nil) + } + + /** + Get the hash for the key. This could be used for matching files. + + - parameter key: The key which is used for caching. + - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it. + + - returns: Corresponding hash. + */ + open func hash(forKey key: String, processorIdentifier identifier: String = "") -> String { + let computedKey = key.computedKey(with: identifier) + return cacheFileName(forComputedKey: computedKey) + } + + /** + Calculate the disk size taken by cache. + It is the total allocated size of the cached files in bytes. + + - parameter completionHandler: Called with the calculated size when finishes. + */ + open func calculateDiskCacheSize(completion handler: @escaping ((_ size: UInt) -> ())) { + ioQueue.async { + let (_, diskCacheSize, _) = self.travelCachedFiles(onlyForCacheSize: true) + DispatchQueue.main.async { + handler(diskCacheSize) + } + } + } + + /** + Get the cache path for the key. + It is useful for projects with UIWebView or anyone that needs access to the local file path. + + i.e. Replace the `` tag in your HTML. + + - Note: This method does not guarantee there is an image already cached in the path. It just returns the path + that the image should be. + You could use `isImageCached(forKey:)` method to check whether the image is cached under that key. + */ + open func cachePath(forKey key: String, processorIdentifier identifier: String = "") -> String { + let computedKey = key.computedKey(with: identifier) + return cachePath(forComputedKey: computedKey) + } + + open func cachePath(forComputedKey key: String) -> String { + let fileName = cacheFileName(forComputedKey: key) + return (diskCachePath as NSString).appendingPathComponent(fileName) + } +} + +// MARK: - Internal Helper +extension ImageCache { + + func diskImage(forComputedKey key: String, serializer: CacheSerializer, options: KingfisherOptionsInfo) -> Image? { + if let data = diskImageData(forComputedKey: key) { + return serializer.image(with: data, options: options) + } else { + return nil + } + } + + func diskImageData(forComputedKey key: String) -> Data? { + let filePath = cachePath(forComputedKey: key) + return (try? Data(contentsOf: URL(fileURLWithPath: filePath))) + } + + func cacheFileName(forComputedKey key: String) -> String { + if let ext = self.pathExtension { + return (key.kf.md5 as NSString).appendingPathExtension(ext)! + } + return key.kf.md5 + } +} + +extension Kingfisher where Base: Image { + var imageCost: Int { + return images == nil ? + Int(size.height * size.width * scale * scale) : + Int(size.height * size.width * scale * scale) * images!.count + } +} + +extension Dictionary { + func keysSortedByValue(_ isOrderedBefore: (Value, Value) -> Bool) -> [Key] { + return Array(self).sorted{ isOrderedBefore($0.1, $1.1) }.map{ $0.0 } + } +} + +#if !os(macOS) && !os(watchOS) +// MARK: - For App Extensions +extension UIApplication: KingfisherCompatible { } +extension Kingfisher where Base: UIApplication { + public static var shared: UIApplication? { + let selector = NSSelectorFromString("sharedApplication") + guard Base.responds(to: selector) else { return nil } + return Base.perform(selector).takeUnretainedValue() as? UIApplication + } +} +#endif + +extension String { + func computedKey(with identifier: String) -> String { + if identifier.isEmpty { + return self + } else { + return appending("@\(identifier)") + } + } +} diff --git a/Pods/Kingfisher/Sources/ImageDownloader.swift b/Pods/Kingfisher/Sources/ImageDownloader.swift new file mode 100755 index 0000000..46039b4 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageDownloader.swift @@ -0,0 +1,532 @@ +// +// ImageDownloader.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +/// Progress update block of downloader. +public typealias ImageDownloaderProgressBlock = DownloadProgressBlock + +/// Completion block of downloader. +public typealias ImageDownloaderCompletionHandler = ((_ image: Image?, _ error: NSError?, _ url: URL?, _ originalData: Data?) -> ()) + +/// Download task. +public struct RetrieveImageDownloadTask { + let internalTask: URLSessionDataTask + + /// Downloader by which this task is intialized. + public private(set) weak var ownerDownloader: ImageDownloader? + + /** + Cancel this download task. It will trigger the completion handler with an NSURLErrorCancelled error. + */ + public func cancel() { + ownerDownloader?.cancelDownloadingTask(self) + } + + /// The original request URL of this download task. + public var url: URL? { + return internalTask.originalRequest?.url + } + + /// The relative priority of this download task. + /// It represents the `priority` property of the internal `NSURLSessionTask` of this download task. + /// The value for it is between 0.0~1.0. Default priority is value of 0.5. + /// See documentation on `priority` of `NSURLSessionTask` for more about it. + public var priority: Float { + get { + return internalTask.priority + } + set { + internalTask.priority = newValue + } + } +} + +///The code of errors which `ImageDownloader` might encountered. +public enum KingfisherError: Int { + + /// badData: The downloaded data is not an image or the data is corrupted. + case badData = 10000 + + /// notModified: The remote server responsed a 304 code. No image data downloaded. + case notModified = 10001 + + /// The HTTP status code in response is not valid. If an invalid + /// code error received, you could check the value under `KingfisherErrorStatusCodeKey` + /// in `userInfo` to see the code. + case invalidStatusCode = 10002 + + /// notCached: The image rquested is not in cache but .onlyFromCache is activated. + case notCached = 10003 + + /// The URL is invalid. + case invalidURL = 20000 + + /// The downloading task is cancelled before started. + case downloadCancelledBeforeStarting = 30000 +} + +/// Key will be used in the `userInfo` of `.invalidStatusCode` +public let KingfisherErrorStatusCodeKey = "statusCode" + +/// Protocol of `ImageDownloader`. +public protocol ImageDownloaderDelegate: class { + /** + Called when the `ImageDownloader` object successfully downloaded an image from specified URL. + + - parameter downloader: The `ImageDownloader` object finishes the downloading. + - parameter image: Downloaded image. + - parameter url: URL of the original request URL. + - parameter response: The response object of the downloading process. + */ + func imageDownloader(_ downloader: ImageDownloader, didDownload image: Image, for url: URL, with response: URLResponse?) + + + /** + Check if a received HTTP status code is valid or not. + By default, a status code between 200 to 400 (excluded) is considered as valid. + If an invalid code is received, the downloader will raise an .invalidStatusCode error. + It has a `userInfo` which includes this statusCode and localizedString error message. + + - parameter code: The received HTTP status code. + - parameter downloader: The `ImageDownloader` object asking for validate status code. + + - returns: Whether this HTTP status code is valid or not. + + - Note: If the default 200 to 400 valid code does not suit your need, + you can implement this method to change that behavior. + */ + func isValidStatusCode(_ code: Int, for downloader: ImageDownloader) -> Bool +} + +extension ImageDownloaderDelegate { + public func imageDownloader(_ downloader: ImageDownloader, didDownload image: Image, for url: URL, with response: URLResponse?) {} + + public func isValidStatusCode(_ code: Int, for downloader: ImageDownloader) -> Bool { + return (200..<400).contains(code) + } +} + +/// Protocol indicates that an authentication challenge could be handled. +public protocol AuthenticationChallengeResponsable: class { + /** + Called when an session level authentication challenge is received. + This method provide a chance to handle and response to the authentication challenge before downloading could start. + + - parameter downloader: The downloader which receives this challenge. + - parameter challenge: An object that contains the request for authentication. + - parameter completionHandler: A handler that your delegate method must call. + + - Note: This method is a forward from `URLSession(:didReceiveChallenge:completionHandler:)`. Please refer to the document of it in `NSURLSessionDelegate`. + */ + func downloader(_ downloader: ImageDownloader, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) +} + +extension AuthenticationChallengeResponsable { + + func downloader(_ downloader: ImageDownloader, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { + + if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { + if let trustedHosts = downloader.trustedHosts, trustedHosts.contains(challenge.protectionSpace.host) { + let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!) + completionHandler(.useCredential, credential) + return + } + } + + completionHandler(.performDefaultHandling, nil) + } +} + +/// `ImageDownloader` represents a downloading manager for requesting the image with a URL from server. +open class ImageDownloader { + + class ImageFetchLoad { + var contents = [(callback: CallbackPair, options: KingfisherOptionsInfo)]() + var responseData = NSMutableData() + + var downloadTaskCount = 0 + var downloadTask: RetrieveImageDownloadTask? + } + + // MARK: - Public property + /// The duration before the download is timeout. Default is 15 seconds. + open var downloadTimeout: TimeInterval = 15.0 + + /// A set of trusted hosts when receiving server trust challenges. A challenge with host name contained in this set will be ignored. + /// You can use this set to specify the self-signed site. It only will be used if you don't specify the `authenticationChallengeResponder`. + /// If `authenticationChallengeResponder` is set, this property will be ignored and the implemention of `authenticationChallengeResponder` will be used instead. + open var trustedHosts: Set? + + /// Use this to set supply a configuration for the downloader. By default, NSURLSessionConfiguration.ephemeralSessionConfiguration() will be used. + /// You could change the configuration before a downloaing task starts. A configuration without persistent storage for caches is requsted for downloader working correctly. + open var sessionConfiguration = URLSessionConfiguration.ephemeral { + didSet { + session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: OperationQueue.main) + } + } + + /// Whether the download requests should use pipeling or not. Default is false. + open var requestsUsePipeling = false + + fileprivate let sessionHandler: ImageDownloaderSessionHandler + fileprivate var session: URLSession? + + /// Delegate of this `ImageDownloader` object. See `ImageDownloaderDelegate` protocol for more. + open weak var delegate: ImageDownloaderDelegate? + + /// A responder for authentication challenge. + /// Downloader will forward the received authentication challenge for the downloading session to this responder. + open weak var authenticationChallengeResponder: AuthenticationChallengeResponsable? + + // MARK: - Internal property + let barrierQueue: DispatchQueue + let processQueue: DispatchQueue + + typealias CallbackPair = (progressBlock: ImageDownloaderProgressBlock?, completionHandler: ImageDownloaderCompletionHandler?) + + var fetchLoads = [URL: ImageFetchLoad]() + + // MARK: - Public method + /// The default downloader. + public static let `default` = ImageDownloader(name: "default") + + /** + Init a downloader with name. + + - parameter name: The name for the downloader. It should not be empty. + + - returns: The downloader object. + */ + public init(name: String) { + if name.isEmpty { + fatalError("[Kingfisher] You should specify a name for the downloader. A downloader with empty name is not permitted.") + } + + barrierQueue = DispatchQueue(label: "com.onevcat.Kingfisher.ImageDownloader.Barrier.\(name)", attributes: .concurrent) + processQueue = DispatchQueue(label: "com.onevcat.Kingfisher.ImageDownloader.Process.\(name)", attributes: .concurrent) + + sessionHandler = ImageDownloaderSessionHandler() + + // Provide a default implement for challenge responder. + authenticationChallengeResponder = sessionHandler + session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: .main) + } + + func fetchLoad(for url: URL) -> ImageFetchLoad? { + var fetchLoad: ImageFetchLoad? + barrierQueue.sync { fetchLoad = fetchLoads[url] } + return fetchLoad + } + + /** + Download an image with a URL and option. + + - parameter url: Target URL. + - parameter options: The options could control download behavior. See `KingfisherOptionsInfo`. + - parameter progressBlock: Called when the download progress updated. + - parameter completionHandler: Called when the download progress finishes. + + - returns: A downloading task. You could call `cancel` on it to stop the downloading process. + */ + @discardableResult + open func downloadImage(with url: URL, + options: KingfisherOptionsInfo? = nil, + progressBlock: ImageDownloaderProgressBlock? = nil, + completionHandler: ImageDownloaderCompletionHandler? = nil) -> RetrieveImageDownloadTask? + { + return downloadImage(with: url, + retrieveImageTask: nil, + options: options, + progressBlock: progressBlock, + completionHandler: completionHandler) + } +} + +// MARK: - Download method +extension ImageDownloader { + func downloadImage(with url: URL, + retrieveImageTask: RetrieveImageTask?, + options: KingfisherOptionsInfo?, + progressBlock: ImageDownloaderProgressBlock?, + completionHandler: ImageDownloaderCompletionHandler?) -> RetrieveImageDownloadTask? + { + if let retrieveImageTask = retrieveImageTask, retrieveImageTask.cancelledBeforeDownloadStarting { + completionHandler?(nil, NSError(domain: KingfisherErrorDomain, code: KingfisherError.downloadCancelledBeforeStarting.rawValue, userInfo: nil), nil, nil) + return nil + } + + let timeout = self.downloadTimeout == 0.0 ? 15.0 : self.downloadTimeout + + // We need to set the URL as the load key. So before setup progress, we need to ask the `requestModifier` for a final URL. + var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: timeout) + request.httpShouldUsePipelining = requestsUsePipeling + + if let modifier = options?.modifier { + guard let r = modifier.modified(for: request) else { + completionHandler?(nil, NSError(domain: KingfisherErrorDomain, code: KingfisherError.downloadCancelledBeforeStarting.rawValue, userInfo: nil), nil, nil) + return nil + } + request = r + } + + // There is a possiblility that request modifier changed the url to `nil` or empty. + guard let url = request.url, !url.absoluteString.isEmpty else { + completionHandler?(nil, NSError(domain: KingfisherErrorDomain, code: KingfisherError.invalidURL.rawValue, userInfo: nil), nil, nil) + return nil + } + + var downloadTask: RetrieveImageDownloadTask? + setup(progressBlock: progressBlock, with: completionHandler, for: url, options: options) {(session, fetchLoad) -> Void in + if fetchLoad.downloadTask == nil { + let dataTask = session.dataTask(with: request) + + fetchLoad.downloadTask = RetrieveImageDownloadTask(internalTask: dataTask, ownerDownloader: self) + + dataTask.priority = options?.downloadPriority ?? URLSessionTask.defaultPriority + dataTask.resume() + + // Hold self while the task is executing. + self.sessionHandler.downloadHolder = self + } + + fetchLoad.downloadTaskCount += 1 + downloadTask = fetchLoad.downloadTask + + retrieveImageTask?.downloadTask = downloadTask + } + return downloadTask + } + + // A single key may have multiple callbacks. Only download once. + func setup(progressBlock: ImageDownloaderProgressBlock?, with completionHandler: ImageDownloaderCompletionHandler?, for url: URL, options: KingfisherOptionsInfo?, started: ((URLSession, ImageFetchLoad) -> Void)) { + + barrierQueue.sync(flags: .barrier) { + let loadObjectForURL = fetchLoads[url] ?? ImageFetchLoad() + let callbackPair = (progressBlock: progressBlock, completionHandler: completionHandler) + + loadObjectForURL.contents.append((callbackPair, options ?? KingfisherEmptyOptionsInfo)) + + fetchLoads[url] = loadObjectForURL + + if let session = session { + started(session, loadObjectForURL) + } + } + } + + func cancelDownloadingTask(_ task: RetrieveImageDownloadTask) { + barrierQueue.sync { + if let URL = task.internalTask.originalRequest?.url, let imageFetchLoad = self.fetchLoads[URL] { + imageFetchLoad.downloadTaskCount -= 1 + if imageFetchLoad.downloadTaskCount == 0 { + task.internalTask.cancel() + } + } + } + } + + func clean(for url: URL) { + barrierQueue.sync(flags: .barrier) { + fetchLoads.removeValue(forKey: url) + return + } + } +} + +// MARK: - NSURLSessionDataDelegate + +/// Delegate class for `NSURLSessionTaskDelegate`. +/// The session object will hold its delegate until it gets invalidated. +/// If we use `ImageDownloader` as the session delegate, it will not be released. +/// So we need an additional handler to break the retain cycle. +// See https://github.com/onevcat/Kingfisher/issues/235 +class ImageDownloaderSessionHandler: NSObject, URLSessionDataDelegate, AuthenticationChallengeResponsable { + + // The holder will keep downloader not released while a data task is being executed. + // It will be set when the task started, and reset when the task finished. + var downloadHolder: ImageDownloader? + + func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) { + + guard let downloader = downloadHolder else { + completionHandler(.cancel) + return + } + + if let statusCode = (response as? HTTPURLResponse)?.statusCode, + let url = dataTask.originalRequest?.url, + !(downloader.delegate ?? downloader).isValidStatusCode(statusCode, for: downloader) + { + let error = NSError(domain: KingfisherErrorDomain, + code: KingfisherError.invalidStatusCode.rawValue, + userInfo: [KingfisherErrorStatusCodeKey: statusCode, NSLocalizedDescriptionKey: HTTPURLResponse.localizedString(forStatusCode: statusCode)]) + callCompletionHandlerFailure(error: error, url: url) + } + + completionHandler(.allow) + } + + func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { + + guard let downloader = downloadHolder else { + return + } + + if let url = dataTask.originalRequest?.url, let fetchLoad = downloader.fetchLoad(for: url) { + fetchLoad.responseData.append(data) + + if let expectedLength = dataTask.response?.expectedContentLength { + for content in fetchLoad.contents { + DispatchQueue.main.async { + content.callback.progressBlock?(Int64(fetchLoad.responseData.length), expectedLength) + } + } + } + } + } + + func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { + + guard let url = task.originalRequest?.url else { + return + } + + guard error == nil else { + callCompletionHandlerFailure(error: error!, url: url) + return + } + + processImage(for: task, url: url) + } + + /** + This method is exposed since the compiler requests. Do not call it. + */ + func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { + guard let downloader = downloadHolder else { + return + } + + downloader.authenticationChallengeResponder?.downloader(downloader, didReceive: challenge, completionHandler: completionHandler) + } + + private func cleanFetchLoad(for url: URL) { + guard let downloader = downloadHolder else { + return + } + + downloader.clean(for: url) + + if downloader.fetchLoads.isEmpty { + downloadHolder = nil + } + } + + private func callCompletionHandlerFailure(error: Error, url: URL) { + guard let downloader = downloadHolder, let fetchLoad = downloader.fetchLoad(for: url) else { + return + } + + // We need to clean the fetch load first, before actually calling completion handler. + cleanFetchLoad(for: url) + + for content in fetchLoad.contents { + content.options.callbackDispatchQueue.safeAsync { + content.callback.completionHandler?(nil, error as NSError, url, nil) + } + } + } + + private func processImage(for task: URLSessionTask, url: URL) { + + guard let downloader = downloadHolder else { + return + } + + // We are on main queue when receiving this. + downloader.processQueue.async { + + guard let fetchLoad = downloader.fetchLoad(for: url) else { + return + } + + self.cleanFetchLoad(for: url) + + let data = fetchLoad.responseData as Data + + // Cache the processed images. So we do not need to re-process the image if using the same processor. + // Key is the identifier of processor. + var imageCache: [String: Image] = [:] + for content in fetchLoad.contents { + + let options = content.options + let completionHandler = content.callback.completionHandler + let callbackQueue = options.callbackDispatchQueue + + let processor = options.processor + + var image = imageCache[processor.identifier] + if image == nil { + image = processor.process(item: .data(data), options: options) + + // Add the processed image to cache. + // If `image` is nil, nothing will happen (since the key is not existing before). + imageCache[processor.identifier] = image + } + + if let image = image { + + downloader.delegate?.imageDownloader(downloader, didDownload: image, for: url, with: task.response) + + if options.backgroundDecode { + let decodedImage = image.kf.decoded(scale: options.scaleFactor) + callbackQueue.safeAsync { completionHandler?(decodedImage, nil, url, data) } + } else { + callbackQueue.safeAsync { completionHandler?(image, nil, url, data) } + } + + } else { + if let res = task.response as? HTTPURLResponse , res.statusCode == 304 { + let notModified = NSError(domain: KingfisherErrorDomain, code: KingfisherError.notModified.rawValue, userInfo: nil) + completionHandler?(nil, notModified, url, nil) + continue + } + + let badData = NSError(domain: KingfisherErrorDomain, code: KingfisherError.badData.rawValue, userInfo: nil) + callbackQueue.safeAsync { completionHandler?(nil, badData, url, nil) } + } + } + } + } +} + +// Placeholder. For retrieving extension methods of ImageDownloaderDelegate +extension ImageDownloader: ImageDownloaderDelegate {} diff --git a/Pods/Kingfisher/Sources/ImagePrefetcher.swift b/Pods/Kingfisher/Sources/ImagePrefetcher.swift new file mode 100755 index 0000000..5eaed9f --- /dev/null +++ b/Pods/Kingfisher/Sources/ImagePrefetcher.swift @@ -0,0 +1,267 @@ +// +// ImagePrefetcher.swift +// Kingfisher +// +// Created by Claire Knight on 24/02/2016 +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#if os(macOS) + import AppKit +#else + import UIKit +#endif + + +/// Progress update block of prefetcher. +/// +/// - `skippedResources`: An array of resources that are already cached before the prefetching starting. +/// - `failedResources`: An array of resources that fail to be downloaded. It could because of being cancelled while downloading, encountered an error when downloading or the download not being started at all. +/// - `completedResources`: An array of resources that are downloaded and cached successfully. +public typealias PrefetcherProgressBlock = ((_ skippedResources: [Resource], _ failedResources: [Resource], _ completedResources: [Resource]) -> ()) + +/// Completion block of prefetcher. +/// +/// - `skippedResources`: An array of resources that are already cached before the prefetching starting. +/// - `failedResources`: An array of resources that fail to be downloaded. It could because of being cancelled while downloading, encountered an error when downloading or the download not being started at all. +/// - `completedResources`: An array of resources that are downloaded and cached successfully. +public typealias PrefetcherCompletionHandler = ((_ skippedResources: [Resource], _ failedResources: [Resource], _ completedResources: [Resource]) -> ()) + +/// `ImagePrefetcher` represents a downloading manager for requesting many images via URLs, then caching them. +/// This is useful when you know a list of image resources and want to download them before showing. +public class ImagePrefetcher { + + /// The maximum concurrent downloads to use when prefetching images. Default is 5. + public var maxConcurrentDownloads = 5 + + private let prefetchResources: [Resource] + private let optionsInfo: KingfisherOptionsInfo + private var progressBlock: PrefetcherProgressBlock? + private var completionHandler: PrefetcherCompletionHandler? + + private var tasks = [URL: RetrieveImageDownloadTask]() + + private var pendingResources: ArraySlice + private var skippedResources = [Resource]() + private var completedResources = [Resource]() + private var failedResources = [Resource]() + + private var stopped = false + + // The created manager used for prefetch. We will use the helper method in manager. + private let manager: KingfisherManager + + private var finished: Bool { + return failedResources.count + skippedResources.count + completedResources.count == prefetchResources.count && self.tasks.isEmpty + } + + /** + Init an image prefetcher with an array of URLs. + + The prefetcher should be initiated with a list of prefetching targets. The URLs list is immutable. + After you get a valid `ImagePrefetcher` object, you could call `start()` on it to begin the prefetching process. + The images already cached will be skipped without downloading again. + + - parameter urls: The URLs which should be prefetched. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called every time an resource is downloaded, skipped or cancelled. + - parameter completionHandler: Called when the whole prefetching process finished. + + - returns: An `ImagePrefetcher` object. + + - Note: By default, the `ImageDownloader.defaultDownloader` and `ImageCache.defaultCache` will be used as + the downloader and cache target respectively. You can specify another downloader or cache by using a customized `KingfisherOptionsInfo`. + Both the progress and completion block will be invoked in main thread. The `CallbackDispatchQueue` in `optionsInfo` will be ignored in this method. + */ + public convenience init(urls: [URL], + options: KingfisherOptionsInfo? = nil, + progressBlock: PrefetcherProgressBlock? = nil, + completionHandler: PrefetcherCompletionHandler? = nil) + { + let resources: [Resource] = urls.map { $0 } + self.init(resources: resources, options: options, progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Init an image prefetcher with an array of resources. + + The prefetcher should be initiated with a list of prefetching targets. The resources list is immutable. + After you get a valid `ImagePrefetcher` object, you could call `start()` on it to begin the prefetching process. + The images already cached will be skipped without downloading again. + + - parameter resources: The resources which should be prefetched. See `Resource` type for more. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called every time an resource is downloaded, skipped or cancelled. + - parameter completionHandler: Called when the whole prefetching process finished. + + - returns: An `ImagePrefetcher` object. + + - Note: By default, the `ImageDownloader.defaultDownloader` and `ImageCache.defaultCache` will be used as + the downloader and cache target respectively. You can specify another downloader or cache by using a customized `KingfisherOptionsInfo`. + Both the progress and completion block will be invoked in main thread. The `CallbackDispatchQueue` in `optionsInfo` will be ignored in this method. + */ + public init(resources: [Resource], + options: KingfisherOptionsInfo? = nil, + progressBlock: PrefetcherProgressBlock? = nil, + completionHandler: PrefetcherCompletionHandler? = nil) + { + prefetchResources = resources + pendingResources = ArraySlice(resources) + + // We want all callbacks from main queue, so we ignore the call back queue in options + let optionsInfoWithoutQueue = options?.removeAllMatchesIgnoringAssociatedValue(.callbackDispatchQueue(nil)) + self.optionsInfo = optionsInfoWithoutQueue ?? KingfisherEmptyOptionsInfo + + let cache = self.optionsInfo.targetCache + let downloader = self.optionsInfo.downloader + manager = KingfisherManager(downloader: downloader, cache: cache) + + self.progressBlock = progressBlock + self.completionHandler = completionHandler + } + + /** + Start to download the resources and cache them. This can be useful for background downloading + of assets that are required for later use in an app. This code will not try and update any UI + with the results of the process. + */ + public func start() + { + // Since we want to handle the resources cancellation in main thread only. + DispatchQueue.main.safeAsync { + + guard !self.stopped else { + assertionFailure("You can not restart the same prefetcher. Try to create a new prefetcher.") + self.handleComplete() + return + } + + guard self.maxConcurrentDownloads > 0 else { + assertionFailure("There should be concurrent downloads value should be at least 1.") + self.handleComplete() + return + } + + guard self.prefetchResources.count > 0 else { + self.handleComplete() + return + } + + let initialConcurentDownloads = min(self.prefetchResources.count, self.maxConcurrentDownloads) + for _ in 0 ..< initialConcurentDownloads { + if let resource = self.pendingResources.popFirst() { + self.startPrefetching(resource) + } + } + } + } + + + /** + Stop current downloading progress, and cancel any future prefetching activity that might be occuring. + */ + public func stop() { + DispatchQueue.main.safeAsync { + + if self.finished { return } + + self.stopped = true + self.tasks.forEach { (_, task) -> () in + task.cancel() + } + } + } + + func downloadAndCache(_ resource: Resource) { + + let downloadTaskCompletionHandler: CompletionHandler = { (image, error, _, _) -> () in + self.tasks.removeValue(forKey: resource.downloadURL) + if let _ = error { + self.failedResources.append(resource) + } else { + self.completedResources.append(resource) + } + + self.reportProgress() + if self.stopped { + if self.tasks.isEmpty { + self.failedResources.append(contentsOf: self.pendingResources) + self.handleComplete() + } + } else { + self.reportCompletionOrStartNext() + } + } + + let downloadTask = manager.downloadAndCacheImage( + with: resource.downloadURL, + forKey: resource.cacheKey, + retrieveImageTask: RetrieveImageTask(), + progressBlock: nil, + completionHandler: downloadTaskCompletionHandler, + options: optionsInfo) + + if let downloadTask = downloadTask { + tasks[resource.downloadURL] = downloadTask + } + } + + func append(cached resource: Resource) { + skippedResources.append(resource) + + reportProgress() + reportCompletionOrStartNext() + } + + func startPrefetching(_ resource: Resource) + { + if optionsInfo.forceRefresh { + downloadAndCache(resource) + } else { + let alreadyInCache = manager.cache.isImageCached(forKey: resource.cacheKey).cached + if alreadyInCache { + append(cached: resource) + } else { + downloadAndCache(resource) + } + } + } + + func reportProgress() { + progressBlock?(skippedResources, failedResources, completedResources) + } + + func reportCompletionOrStartNext() { + if let resource = pendingResources.popFirst() { + startPrefetching(resource) + } else { + guard tasks.isEmpty else { return } + handleComplete() + } + } + + func handleComplete() { + completionHandler?(skippedResources, failedResources, completedResources) + completionHandler = nil + progressBlock = nil + } +} diff --git a/Pods/Kingfisher/Sources/ImageProcessor.swift b/Pods/Kingfisher/Sources/ImageProcessor.swift new file mode 100644 index 0000000..80b7476 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageProcessor.swift @@ -0,0 +1,370 @@ +// +// ImageProcessor.swift +// Kingfisher +// +// Created by Wei Wang on 2016/08/26. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import CoreGraphics + + +/// The item which could be processed by an `ImageProcessor` +/// +/// - image: Input image +/// - data: Input data +public enum ImageProcessItem { + case image(Image) + case data(Data) +} + +/// An `ImageProcessor` would be used to convert some downloaded data to an image. +public protocol ImageProcessor { + /// Identifier of the processor. It will be used to identify the processor when + /// caching and retriving an image. You might want to make sure that processors with + /// same properties/functionality have the same identifiers, so correct processed images + /// could be retrived with proper key. + /// + /// - Note: Do not supply an empty string for a customized processor, which is already taken by + /// the `DefaultImageProcessor`. It is recommended to use a reverse domain name notation + /// string of your own for the identifier. + var identifier: String { get } + + /// Process an input `ImageProcessItem` item to an image for this processor. + /// + /// - parameter item: Input item which will be processed by `self` + /// - parameter options: Options when processing the item. + /// + /// - returns: The processed image. + /// + /// - Note: The return value will be `nil` if processing failed while converting data to image. + /// If input item is already an image and there is any errors in processing, the input + /// image itself will be returned. + /// - Note: Most processor only supports CG-based images. + /// watchOS is not supported for processers containing filter, the input image will be returned directly on watchOS. + func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? +} + +typealias ProcessorImp = ((ImageProcessItem, KingfisherOptionsInfo) -> Image?) + +public extension ImageProcessor { + + /// Append an `ImageProcessor` to another. The identifier of the new `ImageProcessor` + /// will be "\(self.identifier)|>\(another.identifier)". + /// + /// - parameter another: An `ImageProcessor` you want to append to `self`. + /// + /// - returns: The new `ImageProcessor`. It will process the image in the order + /// of the two processors concatenated. + public func append(another: ImageProcessor) -> ImageProcessor { + let newIdentifier = identifier.appending("|>\(another.identifier)") + return GeneralProcessor(identifier: newIdentifier) { + item, options in + if let image = self.process(item: item, options: options) { + return another.process(item: .image(image), options: options) + } else { + return nil + } + } + } +} + +fileprivate struct GeneralProcessor: ImageProcessor { + let identifier: String + let p: ProcessorImp + func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + return p(item, options) + } +} + +/// The default processor. It convert the input data to a valid image. +/// Images of .PNG, .JPEG and .GIF format are supported. +/// If an image is given, `DefaultImageProcessor` will do nothing on it and just return that image. +public struct DefaultImageProcessor: ImageProcessor { + + /// A default `DefaultImageProcessor` could be used across. + public static let `default` = DefaultImageProcessor() + + public let identifier = "" + + /// Initialize a `DefaultImageProcessor` + /// + /// - returns: An initialized `DefaultImageProcessor`. + public init() {} + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image + case .data(let data): + return Kingfisher.image(data: data, scale: options.scaleFactor, preloadAllGIFData: options.preloadAllGIFData) + } + } +} + +/// Processor for making round corner images. Only CG-based images are supported in macOS, +/// if a non-CG image passed in, the processor will do nothing. +public struct RoundCornerImageProcessor: ImageProcessor { + public let identifier: String + + /// Corner radius will be applied in processing. + public let cornerRadius: CGFloat + + /// Target size of output image should be. If `nil`, the image will keep its original size after processing. + public let targetSize: CGSize? + + /// Initialize a `RoundCornerImageProcessor` + /// + /// - parameter cornerRadius: Corner radius will be applied in processing. + /// - parameter targetSize: Target size of output image should be. If `nil`, + /// the image will keep its original size after processing. + /// Default is `nil`. + /// + /// - returns: An initialized `RoundCornerImageProcessor`. + public init(cornerRadius: CGFloat, targetSize: CGSize? = nil) { + self.cornerRadius = cornerRadius + self.targetSize = targetSize + if let size = targetSize { + self.identifier = "com.onevcat.Kingfisher.RoundCornerImageProcessor(\(cornerRadius)_\(size))" + } else { + self.identifier = "com.onevcat.Kingfisher.RoundCornerImageProcessor(\(cornerRadius))" + } + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + let size = targetSize ?? image.kf.size + return image.kf.image(withRoundRadius: cornerRadius, fit: size) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Processor for resizing images. Only CG-based images are supported in macOS. +public struct ResizingImageProcessor: ImageProcessor { + public let identifier: String + + /// Target size of output image should be. + public let targetSize: CGSize + + /// Initialize a `ResizingImageProcessor` + /// + /// - parameter targetSize: Target size of output image should be. + /// + /// - returns: An initialized `ResizingImageProcessor`. + public init(targetSize: CGSize) { + self.targetSize = targetSize + self.identifier = "com.onevcat.Kingfisher.ResizingImageProcessor(\(targetSize))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.resize(to: targetSize) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Processor for adding blur effect to images. `Accelerate.framework` is used underhood for +/// a better performance. A simulated Gaussian blur with specified blur radius will be applied. +public struct BlurImageProcessor: ImageProcessor { + public let identifier: String + + /// Blur radius for the simulated Gaussian blur. + public let blurRadius: CGFloat + + /// Initialize a `BlurImageProcessor` + /// + /// - parameter blurRadius: Blur radius for the simulated Gaussian blur. + /// + /// - returns: An initialized `BlurImageProcessor`. + public init(blurRadius: CGFloat) { + self.blurRadius = blurRadius + self.identifier = "com.onevcat.Kingfisher.BlurImageProcessor(\(blurRadius))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + let radius = blurRadius * options.scaleFactor + return image.kf.blurred(withRadius: radius) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Processor for adding an overlay to images. Only CG-based images are supported in macOS. +public struct OverlayImageProcessor: ImageProcessor { + + public var identifier: String + + /// Overlay color will be used to overlay the input image. + public let overlay: Color + + /// Fraction will be used when overlay the color to image. + public let fraction: CGFloat + + /// Initialize an `OverlayImageProcessor` + /// + /// - parameter overlay: Overlay color will be used to overlay the input image. + /// - parameter fraction: Fraction will be used when overlay the color to image. + /// From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay. + /// + /// - returns: An initialized `OverlayImageProcessor`. + public init(overlay: Color, fraction: CGFloat = 0.5) { + self.overlay = overlay + self.fraction = fraction + self.identifier = "com.onevcat.Kingfisher.OverlayImageProcessor(\(overlay.hex)_\(fraction))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.overlaying(with: overlay, fraction: fraction) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Processor for tint images with color. Only CG-based images are supported. +public struct TintImageProcessor: ImageProcessor { + + public let identifier: String + + /// Tint color will be used to tint the input image. + public let tint: Color + + /// Initialize a `TintImageProcessor` + /// + /// - parameter tint: Tint color will be used to tint the input image. + /// + /// - returns: An initialized `TintImageProcessor`. + public init(tint: Color) { + self.tint = tint + self.identifier = "com.onevcat.Kingfisher.TintImageProcessor(\(tint.hex))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.tinted(with: tint) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Processor for applying some color control to images. Only CG-based images are supported. +/// watchOS is not supported. +public struct ColorControlsProcessor: ImageProcessor { + + public let identifier: String + + /// Brightness changing to image. + public let brightness: CGFloat + + /// Contrast changing to image. + public let contrast: CGFloat + + /// Saturation changing to image. + public let saturation: CGFloat + + /// InputEV changing to image. + public let inputEV: CGFloat + + /// Initialize a `ColorControlsProcessor` + /// + /// - parameter brightness: Brightness changing to image. + /// - parameter contrast: Contrast changing to image. + /// - parameter saturation: Saturation changing to image. + /// - parameter inputEV: InputEV changing to image. + /// + /// - returns: An initialized `ColorControlsProcessor` + public init(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) { + self.brightness = brightness + self.contrast = contrast + self.saturation = saturation + self.inputEV = inputEV + self.identifier = "com.onevcat.Kingfisher.ColorControlsProcessor(\(brightness)_\(contrast)_\(saturation)_\(inputEV))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.adjusted(brightness: brightness, contrast: contrast, saturation: saturation, inputEV: inputEV) + case .data(_): + return (DefaultImageProcessor.default >> self).process(item: item, options: options) + } + } +} + +/// Processor for applying black and white effect to images. Only CG-based images are supported. +/// watchOS is not supported. +public struct BlackWhiteProcessor: ImageProcessor { + public let identifier = "com.onevcat.Kingfisher.BlackWhiteProcessor" + + /// Initialize a `BlackWhiteProcessor` + /// + /// - returns: An initialized `BlackWhiteProcessor` + public init() {} + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + return ColorControlsProcessor(brightness: 0.0, contrast: 1.0, saturation: 0.0, inputEV: 0.7) + .process(item: item, options: options) + } +} + +/// Concatenate two `ImageProcessor`s. `ImageProcessor.appen(another:)` is used internally. +/// +/// - parameter left: First processor. +/// - parameter right: Second processor. +/// +/// - returns: The concatenated processor. +public func >>(left: ImageProcessor, right: ImageProcessor) -> ImageProcessor { + return left.append(another: right) +} + +fileprivate extension Color { + var hex: String { + var r: CGFloat = 0 + var g: CGFloat = 0 + var b: CGFloat = 0 + var a: CGFloat = 0 + + getRed(&r, green: &g, blue: &b, alpha: &a) + + let rInt = Int(r * 255) << 24 + let gInt = Int(g * 255) << 16 + let bInt = Int(b * 255) << 8 + let aInt = Int(a * 255) + + let rgba = rInt | gInt | bInt | aInt + + return String(format:"#%08x", rgba) + } +} diff --git a/Pods/Kingfisher/Sources/ImageTransition.swift b/Pods/Kingfisher/Sources/ImageTransition.swift new file mode 100755 index 0000000..8ce42e8 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageTransition.swift @@ -0,0 +1,128 @@ +// +// ImageTransition.swift +// Kingfisher +// +// Created by Wei Wang on 15/9/18. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(macOS) +// Not implemented for macOS and watchOS yet. + +import AppKit + +/// Image transition is not supported on macOS. +public enum ImageTransition { + case none + var duration: TimeInterval { + return 0 + } +} + +#elseif os(watchOS) +import UIKit +/// Image transition is not supported on watchOS. +public enum ImageTransition { + case none + var duration: TimeInterval { + return 0 + } +} +#else +import UIKit + +/** +Transition effect which will be used when an image downloaded and set by `UIImageView` extension API in Kingfisher. +You can assign an enum value with transition duration as an item in `KingfisherOptionsInfo` +to enable the animation transition. + +Apple's UIViewAnimationOptions is used under the hood. +For custom transition, you should specified your own transition options, animations and +comletion handler as well. +*/ +public enum ImageTransition { + /// No animation transistion. + case none + + /// Fade in the loaded image. + case fade(TimeInterval) + + /// Flip from left transition. + case flipFromLeft(TimeInterval) + + /// Flip from right transition. + case flipFromRight(TimeInterval) + + /// Flip from top transition. + case flipFromTop(TimeInterval) + + /// Flip from bottom transition. + case flipFromBottom(TimeInterval) + + /// Custom transition. + case custom(duration: TimeInterval, + options: UIViewAnimationOptions, + animations: ((UIImageView, UIImage) -> Void)?, + completion: ((Bool) -> Void)?) + + var duration: TimeInterval { + switch self { + case .none: return 0 + case .fade(let duration): return duration + + case .flipFromLeft(let duration): return duration + case .flipFromRight(let duration): return duration + case .flipFromTop(let duration): return duration + case .flipFromBottom(let duration): return duration + + case .custom(let duration, _, _, _): return duration + } + } + + var animationOptions: UIViewAnimationOptions { + switch self { + case .none: return [] + case .fade(_): return .transitionCrossDissolve + + case .flipFromLeft(_): return .transitionFlipFromLeft + case .flipFromRight(_): return .transitionFlipFromRight + case .flipFromTop(_): return .transitionFlipFromTop + case .flipFromBottom(_): return .transitionFlipFromBottom + + case .custom(_, let options, _, _): return options + } + } + + var animations: ((UIImageView, UIImage) -> Void)? { + switch self { + case .custom(_, _, let animations, _): return animations + default: return { $0.image = $1 } + } + } + + var completion: ((Bool) -> Void)? { + switch self { + case .custom(_, _, _, let completion): return completion + default: return nil + } + } +} +#endif diff --git a/Pods/Kingfisher/Sources/ImageView+Kingfisher.swift b/Pods/Kingfisher/Sources/ImageView+Kingfisher.swift new file mode 100755 index 0000000..9471506 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageView+Kingfisher.swift @@ -0,0 +1,288 @@ +// +// ImageView+Kingfisher.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +// MARK: - Extension methods. +/** + * Set image to use from web. + */ +extension Kingfisher where Base: ImageView { + /** + Set an image with a resource, a placeholder image, options, progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + public func setImage(with resource: Resource?, + placeholder: Image? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + guard let resource = resource else { + base.image = placeholder + completionHandler?(nil, nil, .none, nil) + return .empty + } + + var options = options ?? KingfisherEmptyOptionsInfo + + if !options.keepCurrentImageWhileLoading { + base.image = placeholder + } + + let maybeIndicator = indicator + maybeIndicator?.startAnimatingView() + + setWebURL(resource.downloadURL) + + if base.shouldPreloadAllGIF() { + options.append(.preloadAllGIFData) + } + + let task = KingfisherManager.shared.retrieveImage( + with: resource, + options: options, + progressBlock: { receivedSize, totalSize in + if let progressBlock = progressBlock { + progressBlock(receivedSize, totalSize) + } + }, + completionHandler: {[weak base] image, error, cacheType, imageURL in + DispatchQueue.main.safeAsync { + guard let strongBase = base, imageURL == self.webURL else { + return + } + self.setImageTask(nil) + guard let image = image else { + maybeIndicator?.stopAnimatingView() + completionHandler?(nil, error, cacheType, imageURL) + return + } + + guard let transitionItem = options.firstMatchIgnoringAssociatedValue(.transition(.none)), + case .transition(let transition) = transitionItem, ( options.forceTransition || cacheType == .none) else + { + maybeIndicator?.stopAnimatingView() + strongBase.image = image + completionHandler?(image, error, cacheType, imageURL) + return + } + + #if !os(macOS) + UIView.transition(with: strongBase, duration: 0.0, options: [], + animations: { maybeIndicator?.stopAnimatingView() }, + completion: { _ in + UIView.transition(with: strongBase, duration: transition.duration, + options: [transition.animationOptions, .allowUserInteraction], + animations: { + // Set image property in the animation. + transition.animations?(strongBase, image) + }, + completion: { finished in + transition.completion?(finished) + completionHandler?(image, error, cacheType, imageURL) + }) + }) + #endif + } + }) + + setImageTask(task) + + return task + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + public func cancelDownloadTask() { + imageTask?.cancel() + } +} + +// MARK: - Associated Object +private var lastURLKey: Void? +private var indicatorKey: Void? +private var indicatorTypeKey: Void? +private var imageTaskKey: Void? + +extension Kingfisher where Base: ImageView { + /// Get the image URL binded to this image view. + public var webURL: URL? { + return objc_getAssociatedObject(base, &lastURLKey) as? URL + } + + fileprivate func setWebURL(_ url: URL) { + objc_setAssociatedObject(base, &lastURLKey, url, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + /// Holds which indicator type is going to be used. + /// Default is .none, means no indicator will be shown. + public var indicatorType: IndicatorType { + get { + let indicator = (objc_getAssociatedObject(base, &indicatorTypeKey) as? Box)?.value + return indicator ?? .none + } + + set { + switch newValue { + case .none: + indicator = nil + case .activity: + indicator = ActivityIndicator() + case .image(let data): + indicator = ImageIndicator(imageData: data) + case .custom(let anIndicator): + indicator = anIndicator + } + + objc_setAssociatedObject(base, &indicatorTypeKey, Box(value: newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + /// Holds any type that conforms to the protocol `Indicator`. + /// The protocol `Indicator` has a `view` property that will be shown when loading an image. + /// It will be `nil` if `indicatorType` is `.none`. + public fileprivate(set) var indicator: Indicator? { + get { + return (objc_getAssociatedObject(base, &indicatorKey) as? Box)?.value + } + + set { + // Remove previous + if let previousIndicator = indicator { + previousIndicator.view.removeFromSuperview() + } + + // Add new + if var newIndicator = newValue { + newIndicator.view.frame = base.frame + newIndicator.viewCenter = CGPoint(x: base.bounds.midX, y: base.bounds.midY) + newIndicator.view.isHidden = true + base.addSubview(newIndicator.view) + } + + // Save in associated object + objc_setAssociatedObject(base, &indicatorKey, Box(value: newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + fileprivate var imageTask: RetrieveImageTask? { + return objc_getAssociatedObject(base, &imageTaskKey) as? RetrieveImageTask + } + + fileprivate func setImageTask(_ task: RetrieveImageTask?) { + objc_setAssociatedObject(base, &imageTaskKey, task, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } +} + + +// MARK: - Deprecated. Only for back compatibility. +/** +* Set image to use from web. Deprecated. Use `kf` namespacing instead. +*/ +extension ImageView { + /** + Set an image with a resource, a placeholder image, options, progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.setImage` instead.", renamed: "kf.setImage") + @discardableResult + public func kf_setImage(with resource: Resource?, + placeholder: Image? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + return kf.setImage(with: resource, placeholder: placeholder, options: options, progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.cancelDownloadTask` instead.", renamed: "kf.cancelDownloadTask") + public func kf_cancelDownloadTask() { kf.cancelDownloadTask() } + + /// Get the image URL binded to this image view. + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.webURL` instead.", renamed: "kf.webURL") + public var kf_webURL: URL? { return kf.webURL } + + /// Holds which indicator type is going to be used. + /// Default is .none, means no indicator will be shown. + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.indicatorType` instead.", renamed: "kf.indicatorType") + public var kf_indicatorType: IndicatorType { + get { return kf.indicatorType } + set { kf.indicatorType = newValue } + } + + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.indicator` instead.", renamed: "kf.indicator") + /// Holds any type that conforms to the protocol `Indicator`. + /// The protocol `Indicator` has a `view` property that will be shown when loading an image. + /// It will be `nil` if `kf_indicatorType` is `.none`. + public private(set) var kf_indicator: Indicator? { + get { return kf.indicator } + set { kf.indicator = newValue } + } + + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.imageTask") + fileprivate var kf_imageTask: RetrieveImageTask? { return kf.imageTask } + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.setImageTask") + fileprivate func kf_setImageTask(_ task: RetrieveImageTask?) { kf.setImageTask(task) } + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.setWebURL") + fileprivate func kf_setWebURL(_ url: URL) { kf.setWebURL(url) } +} + +extension ImageView { + func shouldPreloadAllGIF() -> Bool { return true } +} diff --git a/Pods/Kingfisher/Sources/Indicator.swift b/Pods/Kingfisher/Sources/Indicator.swift new file mode 100644 index 0000000..d1f55f0 --- /dev/null +++ b/Pods/Kingfisher/Sources/Indicator.swift @@ -0,0 +1,191 @@ +// +// Indicator.swift +// Kingfisher +// +// Created by João D. Moreira on 30/08/16. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(macOS) + import AppKit +#else + import UIKit +#endif + +#if os(macOS) + public typealias IndicatorView = NSView +#else + public typealias IndicatorView = UIView +#endif + +public enum IndicatorType { + /// No indicator. + case none + /// Use system activity indicator. + case activity + /// Use an image as indicator. GIF is supported. + case image(imageData: Data) + /// Use a custom indicator, which conforms to the `Indicator` protocol. + case custom(indicator: Indicator) +} + +// MARK: - Indicator Protocol +public protocol Indicator { + func startAnimatingView() + func stopAnimatingView() + + var viewCenter: CGPoint { get set } + var view: IndicatorView { get } +} + +extension Indicator { + #if os(macOS) + public var viewCenter: CGPoint { + get { + let frame = view.frame + return CGPoint(x: frame.origin.x + frame.size.width / 2.0, y: frame.origin.y + frame.size.height / 2.0 ) + } + set { + let frame = view.frame + let newFrame = CGRect(x: newValue.x - frame.size.width / 2.0, + y: newValue.y - frame.size.height / 2.0, + width: frame.size.width, + height: frame.size.height) + view.frame = newFrame + } + } + #else + public var viewCenter: CGPoint { + get { + return view.center + } + set { + view.center = newValue + } + } + #endif +} + +// MARK: - ActivityIndicator +// Displays a NSProgressIndicator / UIActivityIndicatorView +struct ActivityIndicator: Indicator { + + #if os(macOS) + private let activityIndicatorView: NSProgressIndicator + #else + private let activityIndicatorView: UIActivityIndicatorView + #endif + + var view: IndicatorView { + return activityIndicatorView + } + + func startAnimatingView() { + #if os(macOS) + activityIndicatorView.startAnimation(nil) + #else + activityIndicatorView.startAnimating() + #endif + activityIndicatorView.isHidden = false + } + + func stopAnimatingView() { + #if os(macOS) + activityIndicatorView.stopAnimation(nil) + #else + activityIndicatorView.stopAnimating() + #endif + activityIndicatorView.isHidden = true + } + + init() { + #if os(macOS) + activityIndicatorView = NSProgressIndicator(frame: CGRect(x: 0, y: 0, width: 16, height: 16)) + activityIndicatorView.controlSize = .small + activityIndicatorView.style = .spinningStyle + #else + #if os(tvOS) + let indicatorStyle = UIActivityIndicatorViewStyle.white + #else + let indicatorStyle = UIActivityIndicatorViewStyle.gray + #endif + activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle:indicatorStyle) + activityIndicatorView.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin, .flexibleTopMargin] + #endif + } +} + +// MARK: - ImageIndicator +// Displays an ImageView. Supports gif +struct ImageIndicator: Indicator { + private let animatedImageIndicatorView: ImageView + + var view: IndicatorView { + return animatedImageIndicatorView + } + + init?(imageData data: Data, processor: ImageProcessor = DefaultImageProcessor.default, options: KingfisherOptionsInfo = KingfisherEmptyOptionsInfo) { + + var options = options + // Use normal image view to show gif, so we need to preload all gif data. + if !options.preloadAllGIFData { + options.append(.preloadAllGIFData) + } + + guard let image = processor.process(item: .data(data), options: options) else { + return nil + } + + animatedImageIndicatorView = ImageView() + animatedImageIndicatorView.image = image + + #if os(macOS) + // Need for gif to animate on macOS + self.animatedImageIndicatorView.imageScaling = .scaleNone + self.animatedImageIndicatorView.canDrawSubviewsIntoLayer = true + #else + animatedImageIndicatorView.contentMode = .center + + animatedImageIndicatorView.autoresizingMask = [.flexibleLeftMargin, + .flexibleRightMargin, + .flexibleBottomMargin, + .flexibleTopMargin] + #endif + } + + func startAnimatingView() { + #if os(macOS) + animatedImageIndicatorView.animates = true + #else + animatedImageIndicatorView.startAnimating() + #endif + animatedImageIndicatorView.isHidden = false + } + + func stopAnimatingView() { + #if os(macOS) + animatedImageIndicatorView.animates = false + #else + animatedImageIndicatorView.stopAnimating() + #endif + animatedImageIndicatorView.isHidden = true + } +} diff --git a/Pods/Kingfisher/Sources/Kingfisher.h b/Pods/Kingfisher/Sources/Kingfisher.h new file mode 100644 index 0000000..aed591d --- /dev/null +++ b/Pods/Kingfisher/Sources/Kingfisher.h @@ -0,0 +1,37 @@ +// +// Kingfisher.h +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +//! Project version number for Kingfisher. +FOUNDATION_EXPORT double KingfisherVersionNumber; + +//! Project version string for Kingfisher. +FOUNDATION_EXPORT const unsigned char KingfisherVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/Pods/Kingfisher/Sources/Kingfisher.swift b/Pods/Kingfisher/Sources/Kingfisher.swift new file mode 100644 index 0000000..6e2d409 --- /dev/null +++ b/Pods/Kingfisher/Sources/Kingfisher.swift @@ -0,0 +1,71 @@ +// +// Kingfisher.swift +// Kingfisher +// +// Created by Wei Wang on 16/9/14. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import ImageIO + +#if os(macOS) + import AppKit + public typealias Image = NSImage + public typealias Color = NSColor + public typealias ImageView = NSImageView + typealias Button = NSButton +#else + import UIKit + public typealias Image = UIImage + public typealias Color = UIColor + #if !os(watchOS) + public typealias ImageView = UIImageView + typealias Button = UIButton + #endif +#endif + +public final class Kingfisher { + public let base: Base + public init(_ base: Base) { + self.base = base + } +} + +/** + A type that has Kingfisher extensions. + */ +public protocol KingfisherCompatible { + associatedtype CompatibleType + var kf: CompatibleType { get } +} + +public extension KingfisherCompatible { + public var kf: Kingfisher { + get { return Kingfisher(self) } + } +} + +extension Image: KingfisherCompatible { } +#if !os(watchOS) +extension ImageView: KingfisherCompatible { } +extension Button: KingfisherCompatible { } +#endif diff --git a/Pods/Kingfisher/Sources/KingfisherManager.swift b/Pods/Kingfisher/Sources/KingfisherManager.swift new file mode 100755 index 0000000..eb29f3d --- /dev/null +++ b/Pods/Kingfisher/Sources/KingfisherManager.swift @@ -0,0 +1,205 @@ +// +// KingfisherManager.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +public typealias DownloadProgressBlock = ((_ receivedSize: Int64, _ totalSize: Int64) -> ()) +public typealias CompletionHandler = ((_ image: Image?, _ error: NSError?, _ cacheType: CacheType, _ imageURL: URL?) -> ()) + +/// RetrieveImageTask represents a task of image retrieving process. +/// It contains an async task of getting image from disk and from network. +public class RetrieveImageTask { + + public static let empty = RetrieveImageTask() + + // If task is canceled before the download task started (which means the `downloadTask` is nil), + // the download task should not begin. + var cancelledBeforeDownloadStarting: Bool = false + + /// The disk retrieve task in this image task. Kingfisher will try to look up in cache first. This task represent the cache search task. + @available(*, deprecated, + message: "diskRetrieveTask is not in use anymore. You cannot cancel a disk retrieve task anymore once it started.") + public var diskRetrieveTask: RetrieveImageDiskTask? + + /// The network retrieve task in this image task. + public var downloadTask: RetrieveImageDownloadTask? + + /** + Cancel current task. If this task is already done, do nothing. + */ + public func cancel() { + if let downloadTask = downloadTask { + downloadTask.cancel() + } else { + cancelledBeforeDownloadStarting = true + } + } +} + +/// Error domain of Kingfisher +public let KingfisherErrorDomain = "com.onevcat.Kingfisher.Error" + +/// Main manager class of Kingfisher. It connects Kingfisher downloader and cache. +/// You can use this class to retrieve an image via a specified URL from web or cache. +public class KingfisherManager { + + /// Shared manager used by the extensions across Kingfisher. + public static let shared = KingfisherManager() + + /// Cache used by this manager + public var cache: ImageCache + + /// Downloader used by this manager + public var downloader: ImageDownloader + + convenience init() { + self.init(downloader: .default, cache: .default) + } + + init(downloader: ImageDownloader, cache: ImageCache) { + self.downloader = downloader + self.cache = cache + } + + /** + Get an image with resource. + If KingfisherOptions.None is used as `options`, Kingfisher will seek the image in memory and disk first. + If not found, it will download the image at `resource.downloadURL` and cache it with `resource.cacheKey`. + These default behaviors could be adjusted by passing different options. See `KingfisherOptions` for more. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called every time downloaded data changed. This could be used as a progress UI. + - parameter completionHandler: Called when the whole retrieving process finished. + + - returns: A `RetrieveImageTask` task object. You can use this object to cancel the task. + */ + @discardableResult + public func retrieveImage(with resource: Resource, + options: KingfisherOptionsInfo?, + progressBlock: DownloadProgressBlock?, + completionHandler: CompletionHandler?) -> RetrieveImageTask + { + let task = RetrieveImageTask() + + if let options = options, options.forceRefresh { + _ = downloadAndCacheImage( + with: resource.downloadURL, + forKey: resource.cacheKey, + retrieveImageTask: task, + progressBlock: progressBlock, + completionHandler: completionHandler, + options: options) + } else { + tryToRetrieveImageFromCache( + forKey: resource.cacheKey, + with: resource.downloadURL, + retrieveImageTask: task, + progressBlock: progressBlock, + completionHandler: completionHandler, + options: options) + } + + return task + } + + @discardableResult + func downloadAndCacheImage(with url: URL, + forKey key: String, + retrieveImageTask: RetrieveImageTask, + progressBlock: DownloadProgressBlock?, + completionHandler: CompletionHandler?, + options: KingfisherOptionsInfo?) -> RetrieveImageDownloadTask? + { + let options = options ?? KingfisherEmptyOptionsInfo + let downloader = options.downloader + return downloader.downloadImage(with: url, retrieveImageTask: retrieveImageTask, options: options, + progressBlock: { receivedSize, totalSize in + progressBlock?(receivedSize, totalSize) + }, + completionHandler: { image, error, imageURL, originalData in + + let targetCache = options.targetCache + if let error = error, error.code == KingfisherError.notModified.rawValue { + // Not modified. Try to find the image from cache. + // (The image should be in cache. It should be guaranteed by the framework users.) + targetCache.retrieveImage(forKey: key, options: options, completionHandler: { (cacheImage, cacheType) -> () in + completionHandler?(cacheImage, nil, cacheType, url) + }) + return + } + + if let image = image, let originalData = originalData { + targetCache.store(image, + original: originalData, + forKey: key, + processorIdentifier:options.processor.identifier, + cacheSerializer: options.cacheSerializer, + toDisk: !options.cacheMemoryOnly, + completionHandler: nil) + } + + completionHandler?(image, error, .none, url) + + }) + } + + func tryToRetrieveImageFromCache(forKey key: String, + with url: URL, + retrieveImageTask: RetrieveImageTask, + progressBlock: DownloadProgressBlock?, + completionHandler: CompletionHandler?, + options: KingfisherOptionsInfo?) + { + let diskTaskCompletionHandler: CompletionHandler = { (image, error, cacheType, imageURL) -> () in + completionHandler?(image, error, cacheType, imageURL) + } + + let targetCache = options?.targetCache ?? cache + targetCache.retrieveImage(forKey: key, options: options, + completionHandler: { image, cacheType in + if image != nil { + diskTaskCompletionHandler(image, nil, cacheType, url) + } else if let options = options, options.onlyFromCache { + let error = NSError(domain: KingfisherErrorDomain, code: KingfisherError.notCached.rawValue, userInfo: nil) + diskTaskCompletionHandler(nil, error, .none, url) + } else { + self.downloadAndCacheImage( + with: url, + forKey: key, + retrieveImageTask: retrieveImageTask, + progressBlock: progressBlock, + completionHandler: diskTaskCompletionHandler, + options: options) + } + } + ) + } +} diff --git a/Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift b/Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift new file mode 100755 index 0000000..1af6ce1 --- /dev/null +++ b/Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift @@ -0,0 +1,285 @@ +// +// KingfisherOptionsInfo.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/23. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + + +/** +* KingfisherOptionsInfo is a typealias for [KingfisherOptionsInfoItem]. You can use the enum of option item with value to control some behaviors of Kingfisher. +*/ +public typealias KingfisherOptionsInfo = [KingfisherOptionsInfoItem] +let KingfisherEmptyOptionsInfo = [KingfisherOptionsInfoItem]() + +/** +Items could be added into KingfisherOptionsInfo. +*/ +public enum KingfisherOptionsInfoItem { + /// The associated value of this member should be an ImageCache object. Kingfisher will use the specified + /// cache object when handling related operations, including trying to retrieve the cached images and store + /// the downloaded image to it. + case targetCache(ImageCache) + + /// The associated value of this member should be an ImageDownloader object. Kingfisher will use this + /// downloader to download the images. + case downloader(ImageDownloader) + + /// Member for animation transition when using UIImageView. Kingfisher will use the `ImageTransition` of + /// this enum to animate the image in if it is downloaded from web. The transition will not happen when the + /// image is retrieved from either memory or disk cache by default. If you need to do the transition even when + /// the image being retrieved from cache, set `ForceTransition` as well. + case transition(ImageTransition) + + /// Associated `Float` value will be set as the priority of image download task. The value for it should be + /// between 0.0~1.0. If this option not set, the default value (`NSURLSessionTaskPriorityDefault`) will be used. + case downloadPriority(Float) + + /// If set, `Kingfisher` will ignore the cache and try to fire a download task for the resource. + case forceRefresh + + /// If set, setting the image to an image view will happen with transition even when retrieved from cache. + /// See `Transition` option for more. + case forceTransition + + /// If set, `Kingfisher` will only cache the value in memory but not in disk. + case cacheMemoryOnly + + /// If set, `Kingfisher` will only try to retrieve the image from cache not from network. + case onlyFromCache + + /// Decode the image in background thread before using. + case backgroundDecode + + /// The associated value of this member will be used as the target queue of dispatch callbacks when + /// retrieving images from cache. If not set, `Kingfisher` will use main quese for callbacks. + case callbackDispatchQueue(DispatchQueue?) + + /// The associated value of this member will be used as the scale factor when converting retrieved data to an image. + /// It is the image scale, instead of your screen scale. You may need to specify the correct scale when you dealing + /// with 2x or 3x retina images. + case scaleFactor(CGFloat) + + /// Whether all the GIF data should be preloaded. Default it false, which means following frames will be + /// loaded on need. If true, all the GIF data will be loaded and decoded into memory. This option is mainly + /// used for back compatibility internally. You should not set it directly. `AnimatedImageView` will not preload + /// all data, while a normal image view (`UIImageView` or `NSImageView`) will load all data. Choose to use + /// corresponding image view type instead of setting this option. + case preloadAllGIFData + + /// The `ImageDownloadRequestModifier` contained will be used to change the request before it being sent. + /// This is the last chance you can modify the request. You can modify the request for some customizing purpose, + /// such as adding auth token to the header, do basic HTTP auth or something like url mapping. The original request + /// will be sent without any modification by default. + case requestModifier(ImageDownloadRequestModifier) + + /// Processor for processing when the downloading finishes, a processor will convert the downloaded data to an image + /// and/or apply some filter on it. If a cache is connected to the downloader (it happenes when you are using + /// KingfisherManager or the image extension methods), the converted image will also be sent to cache as well as the + /// image view. `DefaultImageProcessor.default` will be used by default. + case processor(ImageProcessor) + + /// Supply an `CacheSerializer` to convert some data to an image object for + /// retrieving from disk cache or vice versa for storing to disk cache. + /// `DefaultCacheSerializer.default` will be used by default. + case cacheSerializer(CacheSerializer) + + /// Keep the existing image while setting another image to an image view. + /// By setting this option, the placeholder image parameter of imageview extension method + /// will be ignored and the current image will be kept while loading or downloading the new image. + case keepCurrentImageWhileLoading +} + +precedencegroup ItemComparisonPrecedence { + associativity: none + higherThan: LogicalConjunctionPrecedence +} + +infix operator <== : ItemComparisonPrecedence + +// This operator returns true if two `KingfisherOptionsInfoItem` enum is the same, without considering the associated values. +func <== (lhs: KingfisherOptionsInfoItem, rhs: KingfisherOptionsInfoItem) -> Bool { + switch (lhs, rhs) { + case (.targetCache(_), .targetCache(_)): return true + case (.downloader(_), .downloader(_)): return true + case (.transition(_), .transition(_)): return true + case (.downloadPriority(_), .downloadPriority(_)): return true + case (.forceRefresh, .forceRefresh): return true + case (.forceTransition, .forceTransition): return true + case (.cacheMemoryOnly, .cacheMemoryOnly): return true + case (.onlyFromCache, .onlyFromCache): return true + case (.backgroundDecode, .backgroundDecode): return true + case (.callbackDispatchQueue(_), .callbackDispatchQueue(_)): return true + case (.scaleFactor(_), .scaleFactor(_)): return true + case (.preloadAllGIFData, .preloadAllGIFData): return true + case (.requestModifier(_), .requestModifier(_)): return true + case (.processor(_), .processor(_)): return true + case (.cacheSerializer(_), .cacheSerializer(_)): return true + case (.keepCurrentImageWhileLoading, .keepCurrentImageWhileLoading): return true + default: return false + } +} + +extension Collection where Iterator.Element == KingfisherOptionsInfoItem { + func firstMatchIgnoringAssociatedValue(_ target: Iterator.Element) -> Iterator.Element? { + return index { $0 <== target }.flatMap { self[$0] } + } + + func removeAllMatchesIgnoringAssociatedValue(_ target: Iterator.Element) -> [Iterator.Element] { + return self.filter { !($0 <== target) } + } +} + +public extension Collection where Iterator.Element == KingfisherOptionsInfoItem { + /// The target `ImageCache` which is used. + public var targetCache: ImageCache { + if let item = firstMatchIgnoringAssociatedValue(.targetCache(.default)), + case .targetCache(let cache) = item + { + return cache + } + return ImageCache.default + } + + /// The `ImageDownloader` which is specified. + public var downloader: ImageDownloader { + if let item = firstMatchIgnoringAssociatedValue(.downloader(.default)), + case .downloader(let downloader) = item + { + return downloader + } + return ImageDownloader.default + } + + /// Member for animation transition when using UIImageView. + public var transition: ImageTransition { + if let item = firstMatchIgnoringAssociatedValue(.transition(.none)), + case .transition(let transition) = item + { + return transition + } + return ImageTransition.none + } + + /// A `Float` value set as the priority of image download task. The value for it should be + /// between 0.0~1.0. + public var downloadPriority: Float { + if let item = firstMatchIgnoringAssociatedValue(.downloadPriority(0)), + case .downloadPriority(let priority) = item + { + return priority + } + return URLSessionTask.defaultPriority + } + + /// Whether an image will be always downloaded again or not. + public var forceRefresh: Bool { + return contains{ $0 <== .forceRefresh } + } + + /// Whether the transition should always happen or not. + public var forceTransition: Bool { + return contains{ $0 <== .forceTransition } + } + + /// Whether cache the image only in memory or not. + public var cacheMemoryOnly: Bool { + return contains{ $0 <== .cacheMemoryOnly } + } + + /// Whether only load the images from cache or not. + public var onlyFromCache: Bool { + return contains{ $0 <== .onlyFromCache } + } + + /// Whether the image should be decoded in background or not. + public var backgroundDecode: Bool { + return contains{ $0 <== .backgroundDecode } + } + + /// Whether the image data should be all loaded at once if it is a GIF. + public var preloadAllGIFData: Bool { + return contains { $0 <== .preloadAllGIFData } + } + + /// The queue of callbacks should happen from Kingfisher. + public var callbackDispatchQueue: DispatchQueue { + if let item = firstMatchIgnoringAssociatedValue(.callbackDispatchQueue(nil)), + case .callbackDispatchQueue(let queue) = item + { + return queue ?? DispatchQueue.main + } + return DispatchQueue.main + } + + /// The scale factor which should be used for the image. + public var scaleFactor: CGFloat { + if let item = firstMatchIgnoringAssociatedValue(.scaleFactor(0)), + case .scaleFactor(let scale) = item + { + return scale + } + return 1.0 + } + + /// The `ImageDownloadRequestModifier` will be used before sending a download request. + public var modifier: ImageDownloadRequestModifier { + if let item = firstMatchIgnoringAssociatedValue(.requestModifier(NoModifier.default)), + case .requestModifier(let modifier) = item + { + return modifier + } + return NoModifier.default + } + + /// `ImageProcessor` for processing when the downloading finishes. + public var processor: ImageProcessor { + if let item = firstMatchIgnoringAssociatedValue(.processor(DefaultImageProcessor.default)), + case .processor(let processor) = item + { + return processor + } + return DefaultImageProcessor.default + } + + /// `CacheSerializer` to convert image to data for storing in cache. + public var cacheSerializer: CacheSerializer { + if let item = firstMatchIgnoringAssociatedValue(.cacheSerializer(DefaultCacheSerializer.default)), + case .cacheSerializer(let cacheSerializer) = item + { + return cacheSerializer + } + return DefaultCacheSerializer.default + } + + /// Keep the existing image while setting another image to an image view. + /// Or the placeholder will be used while downloading. + public var keepCurrentImageWhileLoading: Bool { + return contains { $0 <== .keepCurrentImageWhileLoading } + } +} diff --git a/Pods/Kingfisher/Sources/RequestModifier.swift b/Pods/Kingfisher/Sources/RequestModifier.swift new file mode 100644 index 0000000..13d655a --- /dev/null +++ b/Pods/Kingfisher/Sources/RequestModifier.swift @@ -0,0 +1,53 @@ +// +// RequestModifier.swift +// Kingfisher +// +// Created by Wei Wang on 2016/09/05. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/// Request modifier of image downloader. +public protocol ImageDownloadRequestModifier { + func modified(for request: URLRequest) -> URLRequest? +} + +struct NoModifier: ImageDownloadRequestModifier { + static let `default` = NoModifier() + private init() {} + func modified(for request: URLRequest) -> URLRequest? { + return request + } +} + +public struct AnyModifier: ImageDownloadRequestModifier { + + let block: (URLRequest) -> URLRequest? + + public func modified(for request: URLRequest) -> URLRequest? { + return block(request) + } + + public init(modify: @escaping (URLRequest) -> URLRequest? ) { + block = modify + } +} diff --git a/Pods/Kingfisher/Sources/Resource.swift b/Pods/Kingfisher/Sources/Resource.swift new file mode 100755 index 0000000..c95691a --- /dev/null +++ b/Pods/Kingfisher/Sources/Resource.swift @@ -0,0 +1,74 @@ +// +// Resource.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + + +/// `Resource` protocol defines how to download and cache a resource from network. +public protocol Resource { + /// The key used in cache. + var cacheKey: String { get } + + /// The target image URL. + var downloadURL: URL { get } +} + +/** + ImageResource is a simple combination of `downloadURL` and `cacheKey`. + + When passed to image view set methods, Kingfisher will try to download the target + image from the `downloadURL`, and then store it with the `cacheKey` as the key in cache. + */ +public struct ImageResource: Resource { + /// The key used in cache. + public let cacheKey: String + + /// The target image URL. + public let downloadURL: URL + + /** + Create a resource. + + - parameter downloadURL: The target image URL. + - parameter cacheKey: The cache key. If `nil`, Kingfisher will use the `absoluteString` of `downloadURL` as the key. + + - returns: A resource. + */ + public init(downloadURL: URL, cacheKey: String? = nil) { + self.downloadURL = downloadURL + self.cacheKey = cacheKey ?? downloadURL.absoluteString + } +} + +/** + URL conforms to `Resource` in Kingfisher. + The `absoluteString` of this URL is used as `cacheKey`. And the URL itself will be used as `downloadURL`. + If you need customize the url and/or cache key, use `ImageResource` instead. + */ +extension URL: Resource { + public var cacheKey: String { return absoluteString } + public var downloadURL: URL { return self } +} diff --git a/Pods/Kingfisher/Sources/String+MD5.swift b/Pods/Kingfisher/Sources/String+MD5.swift new file mode 100755 index 0000000..05cf18d --- /dev/null +++ b/Pods/Kingfisher/Sources/String+MD5.swift @@ -0,0 +1,292 @@ +// +// String+MD5.swift +// Kingfisher +// +// To date, adding CommonCrypto to a Swift framework is problematic. See: +// http://stackoverflow.com/questions/25248598/importing-commoncrypto-in-a-swift-framework +// We're using a subset and modified version of CryptoSwift as an alternative. +// The following is an altered source version that only includes MD5. The original software can be found at: +// https://github.com/krzyzanowskim/CryptoSwift +// This is the original copyright notice: + +/* +Copyright (C) 2014 Marcin Krzyżanowski +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: +- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required. +- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +- This notice may not be removed or altered from any source or binary distribution. +*/ + +import Foundation + +public struct StringProxy { + fileprivate let base: String + init(proxy: String) { + base = proxy + } +} + +extension String: KingfisherCompatible { + public typealias CompatibleType = StringProxy + public var kf: CompatibleType { + return StringProxy(proxy: self) + } +} + +extension StringProxy { + var md5: String { + if let data = base.data(using: .utf8, allowLossyConversion: true) { + + let message = data.withUnsafeBytes { bytes -> [UInt8] in + return Array(UnsafeBufferPointer(start: bytes, count: data.count)) + } + + let MD5Calculator = MD5(message) + let MD5Data = MD5Calculator.calculate() + + let MD5String = NSMutableString() + for c in MD5Data { + MD5String.appendFormat("%02x", c) + } + return MD5String as String + + } else { + return base + } + } +} + + +/** array of bytes, little-endian representation */ +func arrayOfBytes(_ value: T, length: Int? = nil) -> [UInt8] { + let totalBytes = length ?? (MemoryLayout.size * 8) + + let valuePointer = UnsafeMutablePointer.allocate(capacity: 1) + valuePointer.pointee = value + + let bytes = valuePointer.withMemoryRebound(to: UInt8.self, capacity: totalBytes) { (bytesPointer) -> [UInt8] in + var bytes = [UInt8](repeating: 0, count: totalBytes) + for j in 0...size, totalBytes) { + bytes[totalBytes - 1 - j] = (bytesPointer + j).pointee + } + return bytes + } + + valuePointer.deinitialize() + valuePointer.deallocate(capacity: 1) + + return bytes +} + +extension Int { + /** Array of bytes with optional padding (little-endian) */ + func bytes(_ totalBytes: Int = MemoryLayout.size) -> [UInt8] { + return arrayOfBytes(self, length: totalBytes) + } + +} + +extension NSMutableData { + + /** Convenient way to append bytes */ + func appendBytes(_ arrayOfBytes: [UInt8]) { + append(arrayOfBytes, length: arrayOfBytes.count) + } + +} + +protocol HashProtocol { + var message: Array { get } + + /** Common part for hash calculation. Prepare header data. */ + func prepare(_ len: Int) -> Array +} + +extension HashProtocol { + + func prepare(_ len: Int) -> Array { + var tmpMessage = message + + // Step 1. Append Padding Bits + tmpMessage.append(0x80) // append one bit (UInt8 with one bit) to message + + // append "0" bit until message length in bits ≡ 448 (mod 512) + var msgLength = tmpMessage.count + var counter = 0 + + while msgLength % len != (len - 8) { + counter += 1 + msgLength += 1 + } + + tmpMessage += Array(repeating: 0, count: counter) + return tmpMessage + } +} + +func toUInt32Array(_ slice: ArraySlice) -> Array { + var result = Array() + result.reserveCapacity(16) + + for idx in stride(from: slice.startIndex, to: slice.endIndex, by: MemoryLayout.size) { + let d0 = UInt32(slice[idx.advanced(by: 3)]) << 24 + let d1 = UInt32(slice[idx.advanced(by: 2)]) << 16 + let d2 = UInt32(slice[idx.advanced(by: 1)]) << 8 + let d3 = UInt32(slice[idx]) + let val: UInt32 = d0 | d1 | d2 | d3 + + result.append(val) + } + return result +} + +struct BytesIterator: IteratorProtocol { + + let chunkSize: Int + let data: [UInt8] + + init(chunkSize: Int, data: [UInt8]) { + self.chunkSize = chunkSize + self.data = data + } + + var offset = 0 + + mutating func next() -> ArraySlice? { + let end = min(chunkSize, data.count - offset) + let result = data[offset.. 0 ? result : nil + } +} + +struct BytesSequence: Sequence { + let chunkSize: Int + let data: [UInt8] + + func makeIterator() -> BytesIterator { + return BytesIterator(chunkSize: chunkSize, data: data) + } +} + +func rotateLeft(_ value: UInt32, bits: UInt32) -> UInt32 { + return ((value << bits) & 0xFFFFFFFF) | (value >> (32 - bits)) +} + +class MD5: HashProtocol { + + static let size = 16 // 128 / 8 + let message: [UInt8] + + init (_ message: [UInt8]) { + self.message = message + } + + /** specifies the per-round shift amounts */ + private let shifts: [UInt32] = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, + 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, + 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, + 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21] + + /** binary integer part of the sines of integers (Radians) */ + private let sines: [UInt32] = [0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, + 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391] + + private let hashes: [UInt32] = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476] + + func calculate() -> [UInt8] { + var tmpMessage = prepare(64) + tmpMessage.reserveCapacity(tmpMessage.count + 4) + + // hash values + var hh = hashes + + // Step 2. Append Length a 64-bit representation of lengthInBits + let lengthInBits = (message.count * 8) + let lengthBytes = lengthInBits.bytes(64 / 8) + tmpMessage += lengthBytes.reversed() + + // Process the message in successive 512-bit chunks: + let chunkSizeBytes = 512 / 8 // 64 + + for chunk in BytesSequence(chunkSize: chunkSizeBytes, data: tmpMessage) { + // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15 + var M = toUInt32Array(chunk) + assert(M.count == 16, "Invalid array") + + // Initialize hash value for this chunk: + var A: UInt32 = hh[0] + var B: UInt32 = hh[1] + var C: UInt32 = hh[2] + var D: UInt32 = hh[3] + + var dTemp: UInt32 = 0 + + // Main loop + for j in 0 ..< sines.count { + var g = 0 + var F: UInt32 = 0 + + switch j { + case 0...15: + F = (B & C) | ((~B) & D) + g = j + break + case 16...31: + F = (D & B) | (~D & C) + g = (5 * j + 1) % 16 + break + case 32...47: + F = B ^ C ^ D + g = (3 * j + 5) % 16 + break + case 48...63: + F = C ^ (B | (~D)) + g = (7 * j) % 16 + break + default: + break + } + dTemp = D + D = C + C = B + B = B &+ rotateLeft((A &+ F &+ sines[j] &+ M[g]), bits: shifts[j]) + A = dTemp + } + + hh[0] = hh[0] &+ A + hh[1] = hh[1] &+ B + hh[2] = hh[2] &+ C + hh[3] = hh[3] &+ D + } + + var result = [UInt8]() + result.reserveCapacity(hh.count / 4) + + hh.forEach { + let itemLE = $0.littleEndian + let r1 = UInt8(itemLE & 0xff) + let r2 = UInt8((itemLE >> 8) & 0xff) + let r3 = UInt8((itemLE >> 16) & 0xff) + let r4 = UInt8((itemLE >> 24) & 0xff) + result += [r1, r2, r3, r4] + } + return result + } +} diff --git a/Pods/Kingfisher/Sources/ThreadHelper.swift b/Pods/Kingfisher/Sources/ThreadHelper.swift new file mode 100755 index 0000000..f0742cd --- /dev/null +++ b/Pods/Kingfisher/Sources/ThreadHelper.swift @@ -0,0 +1,40 @@ +// +// ThreadHelper.swift +// Kingfisher +// +// Created by Wei Wang on 15/10/9. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +extension DispatchQueue { + // This method will dispatch the `block` to self. + // If `self` is the main queue, and current thread is main thread, the block + // will be invoked immediately instead of being dispatched. + func safeAsync(_ block: @escaping ()->()) { + if self === DispatchQueue.main && Thread.isMainThread { + block() + } else { + async { block() } + } + } +} diff --git a/Pods/Kingfisher/Sources/UIButton+Kingfisher.swift b/Pods/Kingfisher/Sources/UIButton+Kingfisher.swift new file mode 100755 index 0000000..29933cb --- /dev/null +++ b/Pods/Kingfisher/Sources/UIButton+Kingfisher.swift @@ -0,0 +1,407 @@ +// +// UIButton+Kingfisher.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/13. +// +// Copyright (c) 2017 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import UIKit + +// MARK: - Set Images +/** + * Set image to use in button from web for a specified state. + */ +extension Kingfisher where Base: UIButton { + /** + Set an image to use for a specified state with a resource, a placeholder image, options, progress handler and + completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + public func setImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + guard let resource = resource else { + base.setImage(placeholder, for: state) + completionHandler?(nil, nil, .none, nil) + return .empty + } + + let options = options ?? KingfisherEmptyOptionsInfo + if !options.keepCurrentImageWhileLoading { + base.setImage(placeholder, for: state) + } + + setWebURL(resource.downloadURL, for: state) + let task = KingfisherManager.shared.retrieveImage( + with: resource, + options: options, + progressBlock: { receivedSize, totalSize in + if let progressBlock = progressBlock { + progressBlock(receivedSize, totalSize) + } + }, + completionHandler: {[weak base] image, error, cacheType, imageURL in + DispatchQueue.main.safeAsync { + guard let strongBase = base, imageURL == self.webURL(for: state) else { + return + } + self.setImageTask(nil) + + if image != nil { + strongBase.setImage(image, for: state) + } + + completionHandler?(image, error, cacheType, imageURL) + } + }) + + setImageTask(task) + return task + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + public func cancelImageDownloadTask() { + imageTask?.downloadTask?.cancel() + } + + /** + Set the background image to use for a specified state with a resource, + a placeholder image, options progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + public func setBackgroundImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + guard let resource = resource else { + base.setBackgroundImage(placeholder, for: state) + completionHandler?(nil, nil, .none, nil) + return .empty + } + + let options = options ?? KingfisherEmptyOptionsInfo + if !options.keepCurrentImageWhileLoading { + base.setBackgroundImage(placeholder, for: state) + } + + setBackgroundWebURL(resource.downloadURL, for: state) + let task = KingfisherManager.shared.retrieveImage( + with: resource, + options: options, + progressBlock: { receivedSize, totalSize in + if let progressBlock = progressBlock { + progressBlock(receivedSize, totalSize) + } + }, + completionHandler: { [weak base] image, error, cacheType, imageURL in + DispatchQueue.main.safeAsync { + guard let strongBase = base, imageURL == self.backgroundWebURL(for: state) else { + return + } + self.setBackgroundImageTask(nil) + if image != nil { + strongBase.setBackgroundImage(image, for: state) + } + completionHandler?(image, error, cacheType, imageURL) + } + }) + + setBackgroundImageTask(task) + return task + } + + /** + Cancel the background image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + public func cancelBackgroundImageDownloadTask() { + backgroundImageTask?.downloadTask?.cancel() + } + +} + +// MARK: - Associated Object +private var lastURLKey: Void? +private var imageTaskKey: Void? + +extension Kingfisher where Base: UIButton { + /** + Get the image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified image. + + - returns: Current URL for image. + */ + public func webURL(for state: UIControlState) -> URL? { + return webURLs[NSNumber(value:state.rawValue)] as? URL + } + + fileprivate func setWebURL(_ url: URL, for state: UIControlState) { + webURLs[NSNumber(value:state.rawValue)] = url + } + + fileprivate var webURLs: NSMutableDictionary { + var dictionary = objc_getAssociatedObject(base, &lastURLKey) as? NSMutableDictionary + if dictionary == nil { + dictionary = NSMutableDictionary() + setWebURLs(dictionary!) + } + return dictionary! + } + + fileprivate func setWebURLs(_ URLs: NSMutableDictionary) { + objc_setAssociatedObject(base, &lastURLKey, URLs, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + fileprivate var imageTask: RetrieveImageTask? { + return objc_getAssociatedObject(base, &imageTaskKey) as? RetrieveImageTask + } + + fileprivate func setImageTask(_ task: RetrieveImageTask?) { + objc_setAssociatedObject(base, &imageTaskKey, task, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } +} + + +private var lastBackgroundURLKey: Void? +private var backgroundImageTaskKey: Void? + + +extension Kingfisher where Base: UIButton { + /** + Get the background image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified background image. + + - returns: Current URL for background image. + */ + public func backgroundWebURL(for state: UIControlState) -> URL? { + return backgroundWebURLs[NSNumber(value:state.rawValue)] as? URL + } + + fileprivate func setBackgroundWebURL(_ url: URL, for state: UIControlState) { + backgroundWebURLs[NSNumber(value:state.rawValue)] = url + } + + fileprivate var backgroundWebURLs: NSMutableDictionary { + var dictionary = objc_getAssociatedObject(base, &lastBackgroundURLKey) as? NSMutableDictionary + if dictionary == nil { + dictionary = NSMutableDictionary() + setBackgroundWebURLs(dictionary!) + } + return dictionary! + } + + fileprivate func setBackgroundWebURLs(_ URLs: NSMutableDictionary) { + objc_setAssociatedObject(base, &lastBackgroundURLKey, URLs, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + fileprivate var backgroundImageTask: RetrieveImageTask? { + return objc_getAssociatedObject(base, &backgroundImageTaskKey) as? RetrieveImageTask + } + + fileprivate func setBackgroundImageTask(_ task: RetrieveImageTask?) { + objc_setAssociatedObject(base, &backgroundImageTaskKey, task, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } +} + +// MARK: - Deprecated. Only for back compatibility. +/** +* Set image to use from web for a specified state. Deprecated. Use `kf` namespacing instead. +*/ +extension UIButton { + /** + Set an image to use for a specified state with a resource, a placeholder image, options, progress handler and + completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.setImage` instead.", + renamed: "kf.setImage") + public func kf_setImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + return kf.setImage(with: resource, for: state, placeholder: placeholder, options: options, + progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.cancelImageDownloadTask` instead.", + renamed: "kf.cancelImageDownloadTask") + public func kf_cancelImageDownloadTask() { kf.cancelImageDownloadTask() } + + /** + Set the background image to use for a specified state with a resource, + a placeholder image, options progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.setBackgroundImage` instead.", + renamed: "kf.setBackgroundImage") + public func kf_setBackgroundImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + return kf.setBackgroundImage(with: resource, for: state, placeholder: placeholder, options: options, + progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Cancel the background image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.cancelBackgroundImageDownloadTask` instead.", + renamed: "kf.cancelBackgroundImageDownloadTask") + public func kf_cancelBackgroundImageDownloadTask() { kf.cancelBackgroundImageDownloadTask() } + + /** + Get the image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified image. + + - returns: Current URL for image. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.webURL` instead.", + renamed: "kf.webURL") + public func kf_webURL(for state: UIControlState) -> URL? { return kf.webURL(for: state) } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setWebURL") + fileprivate func kf_setWebURL(_ url: URL, for state: UIControlState) { kf.setWebURL(url, for: state) } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.webURLs") + fileprivate var kf_webURLs: NSMutableDictionary { return kf.webURLs } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setWebURLs") + fileprivate func kf_setWebURLs(_ URLs: NSMutableDictionary) { kf.setWebURLs(URLs) } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.imageTask") + fileprivate var kf_imageTask: RetrieveImageTask? { return kf.imageTask } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setImageTask") + fileprivate func kf_setImageTask(_ task: RetrieveImageTask?) { kf.setImageTask(task) } + + /** + Get the background image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified background image. + + - returns: Current URL for background image. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.backgroundWebURL` instead.", + renamed: "kf.backgroundWebURL") + public func kf_backgroundWebURL(for state: UIControlState) -> URL? { return kf.backgroundWebURL(for: state) } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setBackgroundWebURL") + fileprivate func kf_setBackgroundWebURL(_ url: URL, for state: UIControlState) { + kf.setBackgroundWebURL(url, for: state) + } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.backgroundWebURLs") + fileprivate var kf_backgroundWebURLs: NSMutableDictionary { return kf.backgroundWebURLs } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setBackgroundWebURLs") + fileprivate func kf_setBackgroundWebURLs(_ URLs: NSMutableDictionary) { kf.setBackgroundWebURLs(URLs) } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.backgroundImageTask") + fileprivate var kf_backgroundImageTask: RetrieveImageTask? { return kf.backgroundImageTask } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setBackgroundImageTask") + fileprivate func kf_setBackgroundImageTask(_ task: RetrieveImageTask?) { return kf.setBackgroundImageTask(task) } + +} diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock new file mode 100644 index 0000000..fc68e22 --- /dev/null +++ b/Pods/Manifest.lock @@ -0,0 +1,27 @@ +PODS: + - Alamofire (4.3.0) + - FDFullscreenPopGesture (1.1) + - Kingfisher (3.3.4) + - SnapKit (3.1.2) + - SVProgressHUD (2.1.2) + - SwiftyJSON (3.1.4) + +DEPENDENCIES: + - Alamofire (~> 4.3.0) + - FDFullscreenPopGesture (~> 1.1) + - Kingfisher (~> 3.3.4) + - SnapKit (~> 3.1.2) + - SVProgressHUD + - SwiftyJSON (~> 3.1.4) + +SPEC CHECKSUMS: + Alamofire: 856a113053a7bc9cbe5d6367a555d773fc5cfef7 + FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0 + Kingfisher: 35f289f015d26e81ea6c85048718c6205f3933c6 + SnapKit: 12b24f569cb7c143acc9c22b9d91b23e7b1c84a2 + SVProgressHUD: c404a55d78acbeb7ebb78b76d3faf986475a6994 + SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220 + +PODFILE CHECKSUM: 05f5431693d14c3f23850e24699be1c097e7ac3d + +COCOAPODS: 1.2.0 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b344ae7 --- /dev/null +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1708 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0584D96881FCB3DABFE446FF964012B5 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9F312FBBF05A55BA8BA2BD05A23E099 /* Constraint.swift */; }; + 06585D0F1D0C90183BAB4134C4DE606B /* ConstraintConstantTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = A91275FB130C52DF9364A09327078B2A /* ConstraintConstantTarget.swift */; }; + 082A7A3CE3208EB81B2B209257DBBCCD /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 2EB6E339D221106C6AC7E02AFC169449 /* SVProgressHUD.bundle */; }; + 0E9CC28AC8E34FE8E1C87E933E04BC7A /* ImageProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560B8325EDFC8107F17F5861D9B4372E /* ImageProcessor.swift */; }; + 10D6B0714802CAE40B3787C84C28FF0E /* ConstraintViewDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B474283C2047FA43CF51B96E6162F58 /* ConstraintViewDSL.swift */; }; + 10EB23E9ECC4B33E16933BB1EA560B6A /* Timeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88C13D03E8C157B9C33F9C849C34DD6E /* Timeline.swift */; }; + 131BEC71EB4BB80431F1F29AC2C34BDF /* ConstraintOffsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 154080BAB97096424B47AA41A81DC0FD /* ConstraintOffsetTarget.swift */; }; + 179523942E7D1E3EB210EF05E2C7AE79 /* Kingfisher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F89F0BCD74EB85F7F184583290B3107 /* Kingfisher.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1B9EDEDC964E6B08F78920B4F4B9DB84 /* Alamofire-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = C90D92B79421BF3169BCBD41867D32A2 /* Alamofire-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1C142A579DC48E167391E9DDC2207AB3 /* LayoutConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C99C6ECB9E0D4C89324DD3AA1B6D0D6 /* LayoutConstraintItem.swift */; }; + 1C4F35092211F226DC56EFD272A292BC /* UINavigationController+FDFullscreenPopGesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 74240140E3778F92905534FADF105EC8 /* UINavigationController+FDFullscreenPopGesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1C7A1C3C2FA17521B034AA554517D770 /* ConstraintLayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0D4DD55A4F69420059427E1739BC50D /* ConstraintLayoutSupportDSL.swift */; }; + 1E7D96022F2B49F8C89C9D347F7CFAF5 /* SwiftyJSON-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 693E43BA382DDB2E5BC34870EAD295A4 /* SwiftyJSON-dummy.m */; }; + 23129B1576B7204111A2F052D680DFBE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + 246A1B90DFA180A60EC6CF4897F21D25 /* ConstraintInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDECB2D828915FFAE41D94A55408C5A9 /* ConstraintInsets.swift */; }; + 265B3B75D221ABBF94B13AE8AB4E21E0 /* ConstraintMultiplierTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B60E78753D1BF3F3E5B35DF215C58EDD /* ConstraintMultiplierTarget.swift */; }; + 26EA90A6045FD5F230E0AC7170A38905 /* ConstraintMakerFinalizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACB45EA02ADDCA75EA50039136E5641B /* ConstraintMakerFinalizable.swift */; }; + 2E5E570FFC49EF98550401421A243C0F /* CacheSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F50862674A605EC7791B905E6CA18E8 /* CacheSerializer.swift */; }; + 33395912F2FFA355C4C36B7EDEAA3DA7 /* ImageView+Kingfisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A07C8A6335CF467D1F785E316B54CEA /* ImageView+Kingfisher.swift */; }; + 33A14E817C0FA585D5DA3A55E453299D /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D26B8C01EF4A837D107A4A5EA08E2D8 /* Image.swift */; }; + 3414E1D9CB15149A296E16C45967B021 /* ImagePrefetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B6C99CEEA71E2685A6C949A5992B129 /* ImagePrefetcher.swift */; }; + 342AE33215135AD56B73580012DC22AB /* AnimatedImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C6272A243F5D0440BACBF9E78BB1B9E /* AnimatedImageView.swift */; }; + 3626B94094672CB1C9DEA32B9F9502E1 /* TaskDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59C5D56545C67ED5B9F028807C886759 /* TaskDelegate.swift */; }; + 378B44CAA91C2106076668FDE72E1E02 /* KingfisherOptionsInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E2F84AE7B2C85D4D03A4945EEB80CE /* KingfisherOptionsInfo.swift */; }; + 4089E39F76F86466B8DDD39A1C1ABB6B /* Filter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3EAADC781291F9D6F8549B0F4ADC32D /* Filter.swift */; }; + 45E379B47EBBA540C7F3DA8604D762BB /* ConstraintConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BC087DE76A5EC0825F32DF45E843DAF /* ConstraintConfig.swift */; }; + 46C07510340F8BB3DC9E21688C4C26F7 /* SVProgressHUD-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 1410CF1E763B2421E4888AE276A444D2 /* SVProgressHUD-dummy.m */; }; + 4C8C61A41A070DD0AFE50D42573A39A1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + 504FBF2C8537ACD462F6E3FE8C4D5E4B /* ConstraintMakerPriortizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69BE98893EC9F8EA974C8ED30CF2DD0C /* ConstraintMakerPriortizable.swift */; }; + 52A280AB4852FDE92DF09B5E79D5C2AA /* Indicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D92320867D57966A88D8CAD233E961F /* Indicator.swift */; }; + 5387216E723A3C68E851CA15573CDD71 /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B125F57DDAB78E2E0AA3057FBB3DF58 /* Request.swift */; }; + 5F135EE83AC5546F549972B504E7A895 /* SVProgressAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = FEFECB6C5F070C2E5E0FC7276A5E0540 /* SVProgressAnimatedView.m */; }; + 61200D01A1855D7920CEF835C8BE00B0 /* DispatchQueue+Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC5C1330E632778009C28B09601D7855 /* DispatchQueue+Alamofire.swift */; }; + 612902259114F3A36B86E4B9E28BE947 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD02DD25A12E333226B2EDF88461EB7 /* UILayoutSupport+Extensions.swift */; }; + 62F65AD8DC4F0F9610F4B8B4738EC094 /* ServerTrustPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54FA41DF2D4D57EB9A595A080F614E36 /* ServerTrustPolicy.swift */; }; + 64766CCE6465D353D72325EB345178DD /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5ECD791190961624E3848428B53AF07 /* ConstraintMaker.swift */; }; + 6A375593407BC7937234B2B6A0811760 /* Kingfisher-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B0412712D24FA1982A73BD8E6C65684 /* Kingfisher-dummy.m */; }; + 6B184AED0EEF671B206D4790BFE770A7 /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 00C6CEB98892A4E5813EAF25695E0B41 /* SVProgressHUD.m */; }; + 6B658CD8A5A218455BB8B4CB9F0E38B1 /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7A0DF8308D70F21F627DBC96826D8A4 /* Debugging.swift */; }; + 6CD63E1564618B6213B98E0ABBC3127C /* ThreadHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191C2085C95030F629C2AFB63CA6C5FE /* ThreadHelper.swift */; }; + 6DA770087D354CDCD3889CDAE7C4C698 /* Box.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F70FDE340011FC86D0B724FD1DA3A8 /* Box.swift */; }; + 6EC01F79E723393A002BFB33E346973E /* ConstraintRelatableTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C5B3F63F16A4D40E0BC867AE7201176 /* ConstraintRelatableTarget.swift */; }; + 710D7A91D14C2E84D291AEDB334219EB /* SnapKit-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B6C8999F0BBE343D7F4504BF7E25B5 /* SnapKit-dummy.m */; }; + 71EFBE4144072FDC7A8C990C9224CABE /* ConstraintMakerEditable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322EC43A80C50DDCF13520B9BAE70EBB /* ConstraintMakerEditable.swift */; }; + 7636F846675C9F4ED96E00C6C19A4890 /* KingfisherManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950F24C35EA4DDB9AF163755F9D47F14 /* KingfisherManager.swift */; }; + 776702E8743007AC3AFC1E7F76299616 /* FDFullscreenPopGesture-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 88AE25ED96DB43BB7A08F929198E4237 /* FDFullscreenPopGesture-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7B5FE28C7EA4122B0598738E54DBEBD8 /* SessionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 863FEDEDD513FCEE3EBD3FB46F2AFC93 /* SessionDelegate.swift */; }; + 7D8CC01E8C9EFFF9F4D65406CDE0AB66 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9624080D81E3D097E175ED156DE6530 /* Result.swift */; }; + 86B7DA678C8705523C300947117C0706 /* ImageTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46B217DAA70469CA3931FBEB8BC15DA7 /* ImageTransition.swift */; }; + 8964444C2D53CCBD8F963D2510521D8B /* ConstraintLayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91A01C43394D72B3CB9F00289705657F /* ConstraintLayoutSupport.swift */; }; + 8AC17754F9B2A545F7327F6BB5716B6F /* SVRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F2D3922ADF8A27B13832972DA8A3E6E /* SVRadialGradientLayer.m */; }; + 8CB4E4500C18056535690A487D58AC96 /* ConstraintInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02027FAD496A49105A7454730A33DE75 /* ConstraintInsetTarget.swift */; }; + 8DA7E6883118CB3C8132B64D3D43AE0B /* Resource.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEFA4DC6364A2FA6EF025C72CB758AB1 /* Resource.swift */; }; + 8DD16E2DF74B562CA6612655C0160C3E /* ConstraintMakerExtendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93571BFEDF86AF8C9C2CB9748A309DE2 /* ConstraintMakerExtendable.swift */; }; + 92136C6584624998D5005F46C70A628B /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44B4C5EF04AF72A50CBFAFA7C8CB92B5 /* CFNetwork.framework */; }; + 93A3581B6C58CDD1506F30666ADCE33D /* SVProgressAnimatedView.h in Headers */ = {isa = PBXBuildFile; fileRef = A78EBE39B1B1E3C9902898F45D2BC742 /* SVProgressAnimatedView.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 951A388A8C60C5ED84CD7655B0B87211 /* Pods-DanTangSwift-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F2452CF0982004D32116C01B9B7334 /* Pods-DanTangSwift-dummy.m */; }; + 961BD6787599C46B71C9CD3A20FC8E01 /* SVProgressHUD.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C487BF541A275472CBC7BC436B9A6CC /* SVProgressHUD.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9739017C4AB797ADF0BC2709A76E4F57 /* LayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 576D4403A3387F7405EB919EF89DAAA5 /* LayoutConstraint.swift */; }; + 9C49ADF2375C77DF7A8EDB7018984DF1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + 9C99E45B90BD95712D9878994BFC8B88 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + 9ED2BB2981896E0A39EFA365503F58CE /* AFError.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF734D6BF90D0C7EA4D9D4EACDA7BE9F /* AFError.swift */; }; + 9F826F893E86EB86591B637A1CE4B13A /* String+MD5.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B143DA25A7C26E19B5AE5CB66079859 /* String+MD5.swift */; }; + A04BFC558D69E7DBB68023C80A9CFE4E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + A19E3B34FADA5DBE2D9E3E2F58767655 /* ConstraintLayoutGuide+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 415682BC6912131296EB845AE3DF33D0 /* ConstraintLayoutGuide+Extensions.swift */; }; + A2A6F71B727312BD45CC7A4AAD7B0AB7 /* NetworkReachabilityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4A8B722FC0F0813AC0440087C6A5C6 /* NetworkReachabilityManager.swift */; }; + A2D68527945CBD957D804CD46BD73782 /* SwiftyJSON-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 938A2A47869DE69641CFD21AE642FEB2 /* SwiftyJSON-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A8F35D1EBAEF99D38F02A0B8CA5D8FBE /* Kingfisher-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8463EFB5BE5707C4C0FF08A86B0367 /* Kingfisher-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9EEEA7477981DEEBC72432DE9990A4B /* Alamofire-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = BC7FE270F8D2DB248B5298AA0155378B /* Alamofire-dummy.m */; }; + AE1EF48399533730D0066E04B22CA2D6 /* SessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81F4688BE1BC212B6C0354776ABE6EE8 /* SessionManager.swift */; }; + B65FCF589DA398C3EFE0128064E510EC /* MultipartFormData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07C10090D296E2C385D11965F2E51AA4 /* MultipartFormData.swift */; }; + B674C44E1B7ACF20D25984174339009A /* ConstraintMakerRelatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C993F382EB412A5BFBCAF72A0EFB19 /* ConstraintMakerRelatable.swift */; }; + B84F960E74AE7F8A67099072C643F17F /* UINavigationController+FDFullscreenPopGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 9681D6D418AF9801F773EF7562D83F35 /* UINavigationController+FDFullscreenPopGesture.m */; }; + B9BCD9CD995DDBC709C0ECBD472B5B3F /* ConstraintPriorityTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA0ED10601FA6048950560302CE696A /* ConstraintPriorityTarget.swift */; }; + B9DDF5D72B26AEE9E1D71A2845B67227 /* SVRadialGradientLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = D4943AB1A090A8BABB0D4DAACE802A52 /* SVRadialGradientLayer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BBEFE2F9CEB73DC7BD97FFA66A0D9D4F /* Validation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD2E474F6F25A28D602170A72FDEA9E /* Validation.swift */; }; + BE5C67A07E289FE1F9BE27335B159997 /* ParameterEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6EA8C0B938E60B624946DC0AC159E37 /* ParameterEncoding.swift */; }; + C0993C7BC2AE50A495FF9582AFA38EA0 /* Pods-DanTangSwift-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = D6444891F353D851C5CBEBE87DFDCD5F /* Pods-DanTangSwift-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C0F87F5BBA059DED5F906203DDC75011 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + C2E2FF4387A2A736F49D68E524A327D8 /* ConstraintRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B9F0A1F20F7E97DBB98FA042D1689C1 /* ConstraintRelation.swift */; }; + C7A468CC827A1D5E782B3E1CC44B11C5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */; }; + C7E2BDC0EC4017A0F15F9A80B74BA152 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B29E773093D44B778DB74AC5663DA9EC /* QuartzCore.framework */; }; + C9CC5ED97D29C6C3DE22B78A9AA2AD91 /* Kingfisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83BD437503304DDEF21ABF937E6DD2FF /* Kingfisher.swift */; }; + CB6D60925223897FFA2662667DF83E8A /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016B16F844BEBD26CEC0D58C3561E323 /* Response.swift */; }; + CE05ECA6192C12D3BD85F15D4B8DA8C9 /* SVProgressHUD-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 47653EE02F61952FDD8BEB013ED3D0E2 /* SVProgressHUD-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE15ED57FCC8C8850E356F8730067F4B /* SVIndefiniteAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA9FA785C6A92287EA96A7C97B3E453 /* SVIndefiniteAnimatedView.m */; }; + D5CE2D591E361887F6721FCE16BBD0E3 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18CC0532264C74E9D9E0A7B8D749564 /* ConstraintDSL.swift */; }; + D625CAA07273E3F3BA219EC009C45EC7 /* ConstraintLayoutGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF8F0389C5B464D432EA707DA95E7C58 /* ConstraintLayoutGuide.swift */; }; + D76B88F4F539E3574CA0F0DDB0C8E6F5 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC2655D9243C94D9A9304A51C48975E8 /* ConstraintLayoutGuideDSL.swift */; }; + DC5B3D609FC11AC7E347F2157AEAECA7 /* SVIndefiniteAnimatedView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B4296862B61E46CB94328AF6C34629E /* SVIndefiniteAnimatedView.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DC6080C64C269628C3F5107BE87055E2 /* ImageDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = E35B9C35BEAD5BE999A3637E3AE4FA86 /* ImageDownloader.swift */; }; + DC81F1702E0AB345FE3F0E071DE72956 /* ConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B4C839296EB7B858AA80CF3D865C85A /* ConstraintItem.swift */; }; + E0590E9D162B134D859B567BD10C29A3 /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B7CB108109D173DC79D82413336041 /* SwiftyJSON.swift */; }; + E113782D04172DFAD1E0DC02C720DE33 /* ConstraintView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADB34A85C8F7951AB80B9697CDDA6572 /* ConstraintView.swift */; }; + E5D9851A41395BD8AA5E356D3E7B174E /* FDFullscreenPopGesture-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = B3F2D6432A5E08D2406C396E99FD2E53 /* FDFullscreenPopGesture-dummy.m */; }; + E78FA328043C0503325A7A80A584EFD4 /* ConstraintView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A75BF50C37EE3B6B21E0D3E8CEDFEEA /* ConstraintView+Extensions.swift */; }; + EA816A580C3858934ED6FE92040C26DD /* RequestModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EE2D8F22A386E73E57A406A9A80D689 /* RequestModifier.swift */; }; + EE89512E8D36E67CDC525DB9D5BBF5A7 /* UIButton+Kingfisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = B828E6FD105AE16D8DECC7422AA07194 /* UIButton+Kingfisher.swift */; }; + EEC0B4DBBFAFB36B41A1599E0A45A7E7 /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91B186968E08DDAECC4273A20C6D91B9 /* ConstraintDescription.swift */; }; + EFD264FC408EBF3BA2528E70B08DDD94 /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6E3BFD6D8249E916A48228C58FA2701 /* Notifications.swift */; }; + F38BDF594D1C1EAFCC5EE542C6BDB825 /* ConstraintAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FA89638DDA12AD4B1F3680548BD8943 /* ConstraintAttributes.swift */; }; + F6BECD98B97CBFEBE2C96F0E9E72A6C0 /* ResponseSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCDDBAB345E0E534BF73DC1AB1DF64E4 /* ResponseSerialization.swift */; }; + F8B3D3092ED0417E8CDF32033F6122F5 /* Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = C384CDD5587ED8C890EA8D290BFAE815 /* Alamofire.swift */; }; + F8E957950566622A3E4B61AACE8F0B4A /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E87C1A0368BEE298BDF45C2301B4F9B /* ImageCache.swift */; }; + FAAC8AF2A4126B8B8E57DFC71F537744 /* SnapKit-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 4198F2C06E0B18B94D16E53D9B79DC4A /* SnapKit-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2862929A8689C3A3C780DA1FA3119A5E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60B0AF289DE8AC7FC0376BE9539069F1; + remoteInfo = SwiftyJSON; + }; + 2909B4B1CB463DF5986B540A32F901F9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = C4944FEC314D1A66588651D006273ADE; + remoteInfo = Kingfisher; + }; + 59CC744BB6A3673EA4321922DFD6B602 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7C93740F8DAECC871D081AA4C909D0AD; + remoteInfo = SVProgressHUD; + }; + 5CF2CD9DCAD332281FF4C8E511AB728A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8A83C725DBFF5900754DFD3958596E0D; + remoteInfo = SnapKit; + }; + DEF6DFEFE5453D0C89432A8C3491DF44 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0F71FC248875B67F53494C44B17B40EB; + remoteInfo = FDFullscreenPopGesture; + }; + FE059D03C484005936564996EB5B2072 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 88E9EC28B8B46C3631E6B242B50F4442; + remoteInfo = Alamofire; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 00C6CEB98892A4E5813EAF25695E0B41 /* SVProgressHUD.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SVProgressHUD.m; path = SVProgressHUD/SVProgressHUD.m; sourceTree = ""; }; + 016B16F844BEBD26CEC0D58C3561E323 /* Response.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Response.swift; path = Source/Response.swift; sourceTree = ""; }; + 02027FAD496A49105A7454730A33DE75 /* ConstraintInsetTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintInsetTarget.swift; path = Source/ConstraintInsetTarget.swift; sourceTree = ""; }; + 07C10090D296E2C385D11965F2E51AA4 /* MultipartFormData.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MultipartFormData.swift; path = Source/MultipartFormData.swift; sourceTree = ""; }; + 09A148AC6A3FEF0ECDDB046DC2525094 /* FDFullscreenPopGesture.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = FDFullscreenPopGesture.modulemap; sourceTree = ""; }; + 0A07C8A6335CF467D1F785E316B54CEA /* ImageView+Kingfisher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "ImageView+Kingfisher.swift"; path = "Sources/ImageView+Kingfisher.swift"; sourceTree = ""; }; + 0D26B8C01EF4A837D107A4A5EA08E2D8 /* Image.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Image.swift; path = Sources/Image.swift; sourceTree = ""; }; + 103F475CC6BB5A40AEDD24251D32DFF9 /* SnapKit.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SnapKit.xcconfig; sourceTree = ""; }; + 1410CF1E763B2421E4888AE276A444D2 /* SVProgressHUD-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SVProgressHUD-dummy.m"; sourceTree = ""; }; + 154080BAB97096424B47AA41A81DC0FD /* ConstraintOffsetTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintOffsetTarget.swift; path = Source/ConstraintOffsetTarget.swift; sourceTree = ""; }; + 18E2F84AE7B2C85D4D03A4945EEB80CE /* KingfisherOptionsInfo.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = KingfisherOptionsInfo.swift; path = Sources/KingfisherOptionsInfo.swift; sourceTree = ""; }; + 191C2085C95030F629C2AFB63CA6C5FE /* ThreadHelper.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ThreadHelper.swift; path = Sources/ThreadHelper.swift; sourceTree = ""; }; + 1A8463EFB5BE5707C4C0FF08A86B0367 /* Kingfisher-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Kingfisher-umbrella.h"; sourceTree = ""; }; + 1AD4D4F2E186FCAC0C7833970787D5E0 /* Alamofire-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Alamofire-prefix.pch"; sourceTree = ""; }; + 1C6272A243F5D0440BACBF9E78BB1B9E /* AnimatedImageView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnimatedImageView.swift; path = Sources/AnimatedImageView.swift; sourceTree = ""; }; + 1F50862674A605EC7791B905E6CA18E8 /* CacheSerializer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CacheSerializer.swift; path = Sources/CacheSerializer.swift; sourceTree = ""; }; + 1F89F0BCD74EB85F7F184583290B3107 /* Kingfisher.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Kingfisher.h; path = Sources/Kingfisher.h; sourceTree = ""; }; + 215CEFCC193213346AFD76EA8491B220 /* Kingfisher.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Kingfisher.xcconfig; sourceTree = ""; }; + 2695B23FB23877A85491F0978296FE6B /* SVProgressHUD.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SVProgressHUD.framework; path = SVProgressHUD.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 277D87618B4E3B70263ECAE3B7196CF6 /* Alamofire.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = Alamofire.modulemap; sourceTree = ""; }; + 27F2452CF0982004D32116C01B9B7334 /* Pods-DanTangSwift-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-DanTangSwift-dummy.m"; sourceTree = ""; }; + 2B04F310D3A3F8B573B72525EAB92C98 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2B4C839296EB7B858AA80CF3D865C85A /* ConstraintItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintItem.swift; path = Source/ConstraintItem.swift; sourceTree = ""; }; + 2BEF12BC5EBC1C66335039264788BF02 /* SVProgressHUD-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SVProgressHUD-prefix.pch"; sourceTree = ""; }; + 2D92320867D57966A88D8CAD233E961F /* Indicator.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Indicator.swift; path = Sources/Indicator.swift; sourceTree = ""; }; + 2EB6E339D221106C6AC7E02AFC169449 /* SVProgressHUD.bundle */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "wrapper.plug-in"; name = SVProgressHUD.bundle; path = SVProgressHUD/SVProgressHUD.bundle; sourceTree = ""; }; + 322EC43A80C50DDCF13520B9BAE70EBB /* ConstraintMakerEditable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerEditable.swift; path = Source/ConstraintMakerEditable.swift; sourceTree = ""; }; + 355B54120687A0A98FB3F6D28198B04A /* SwiftyJSON.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = SwiftyJSON.modulemap; sourceTree = ""; }; + 3A75BF50C37EE3B6B21E0D3E8CEDFEEA /* ConstraintView+Extensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "ConstraintView+Extensions.swift"; path = "Source/ConstraintView+Extensions.swift"; sourceTree = ""; }; + 3B0412712D24FA1982A73BD8E6C65684 /* Kingfisher-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Kingfisher-dummy.m"; sourceTree = ""; }; + 3E87C1A0368BEE298BDF45C2301B4F9B /* ImageCache.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImageCache.swift; path = Sources/ImageCache.swift; sourceTree = ""; }; + 3F810C3AF0200B9C5D5B8C48325BFC7D /* SwiftyJSON.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SwiftyJSON.xcconfig; sourceTree = ""; }; + 3FA89638DDA12AD4B1F3680548BD8943 /* ConstraintAttributes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintAttributes.swift; path = Source/ConstraintAttributes.swift; sourceTree = ""; }; + 415682BC6912131296EB845AE3DF33D0 /* ConstraintLayoutGuide+Extensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "ConstraintLayoutGuide+Extensions.swift"; path = "Source/ConstraintLayoutGuide+Extensions.swift"; sourceTree = ""; }; + 4198F2C06E0B18B94D16E53D9B79DC4A /* SnapKit-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SnapKit-umbrella.h"; sourceTree = ""; }; + 44B4C5EF04AF72A50CBFAFA7C8CB92B5 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; }; + 46B217DAA70469CA3931FBEB8BC15DA7 /* ImageTransition.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImageTransition.swift; path = Sources/ImageTransition.swift; sourceTree = ""; }; + 47653EE02F61952FDD8BEB013ED3D0E2 /* SVProgressHUD-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SVProgressHUD-umbrella.h"; sourceTree = ""; }; + 495C17FEF7CDDB7E198431639C849565 /* Pods-DanTangSwift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = "Pods-DanTangSwift.modulemap"; sourceTree = ""; }; + 4B6C99CEEA71E2685A6C949A5992B129 /* ImagePrefetcher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImagePrefetcher.swift; path = Sources/ImagePrefetcher.swift; sourceTree = ""; }; + 4C487BF541A275472CBC7BC436B9A6CC /* SVProgressHUD.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SVProgressHUD.h; path = SVProgressHUD/SVProgressHUD.h; sourceTree = ""; }; + 4C99C6ECB9E0D4C89324DD3AA1B6D0D6 /* LayoutConstraintItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LayoutConstraintItem.swift; path = Source/LayoutConstraintItem.swift; sourceTree = ""; }; + 4F5C350037CF955788FB6B42E8609473 /* SwiftyJSON.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SwiftyJSON.framework; path = SwiftyJSON.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 54FA41DF2D4D57EB9A595A080F614E36 /* ServerTrustPolicy.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ServerTrustPolicy.swift; path = Source/ServerTrustPolicy.swift; sourceTree = ""; }; + 560B8325EDFC8107F17F5861D9B4372E /* ImageProcessor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImageProcessor.swift; path = Sources/ImageProcessor.swift; sourceTree = ""; }; + 576D4403A3387F7405EB919EF89DAAA5 /* LayoutConstraint.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LayoutConstraint.swift; path = Source/LayoutConstraint.swift; sourceTree = ""; }; + 58EA0480CB393BC46B23A49F60B12A28 /* Alamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Alamofire.framework; path = Alamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 59C5D56545C67ED5B9F028807C886759 /* TaskDelegate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TaskDelegate.swift; path = Source/TaskDelegate.swift; sourceTree = ""; }; + 5C5B3F63F16A4D40E0BC867AE7201176 /* ConstraintRelatableTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintRelatableTarget.swift; path = Source/ConstraintRelatableTarget.swift; sourceTree = ""; }; + 5D388F8FD7606E7D74A5B332A1B0167D /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SnapKit.framework; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 693E43BA382DDB2E5BC34870EAD295A4 /* SwiftyJSON-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SwiftyJSON-dummy.m"; sourceTree = ""; }; + 69BE98893EC9F8EA974C8ED30CF2DD0C /* ConstraintMakerPriortizable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerPriortizable.swift; path = Source/ConstraintMakerPriortizable.swift; sourceTree = ""; }; + 6B4296862B61E46CB94328AF6C34629E /* SVIndefiniteAnimatedView.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SVIndefiniteAnimatedView.h; path = SVProgressHUD/SVIndefiniteAnimatedView.h; sourceTree = ""; }; + 6B474283C2047FA43CF51B96E6162F58 /* ConstraintViewDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintViewDSL.swift; path = Source/ConstraintViewDSL.swift; sourceTree = ""; }; + 6BC087DE76A5EC0825F32DF45E843DAF /* ConstraintConfig.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintConfig.swift; path = Source/ConstraintConfig.swift; sourceTree = ""; }; + 6D4A8B722FC0F0813AC0440087C6A5C6 /* NetworkReachabilityManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NetworkReachabilityManager.swift; path = Source/NetworkReachabilityManager.swift; sourceTree = ""; }; + 6F2D3922ADF8A27B13832972DA8A3E6E /* SVRadialGradientLayer.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SVRadialGradientLayer.m; path = SVProgressHUD/SVRadialGradientLayer.m; sourceTree = ""; }; + 74240140E3778F92905534FADF105EC8 /* UINavigationController+FDFullscreenPopGesture.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UINavigationController+FDFullscreenPopGesture.h"; path = "FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h"; sourceTree = ""; }; + 75406655D849F4ECF802A4FFD62E8FEA /* Pods_DanTangSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_DanTangSwift.framework; path = "Pods-DanTangSwift.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 764CC11BCBEB9DC70190940EED0CB404 /* Kingfisher-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Kingfisher-prefix.pch"; sourceTree = ""; }; + 769F73EC81F6F88C175A7B9DECC4F0A6 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 77B01D924C25A0D4AC129971B308C100 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + 7AD2E474F6F25A28D602170A72FDEA9E /* Validation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Validation.swift; path = Source/Validation.swift; sourceTree = ""; }; + 7B9F0A1F20F7E97DBB98FA042D1689C1 /* ConstraintRelation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintRelation.swift; path = Source/ConstraintRelation.swift; sourceTree = ""; }; + 7BA0ED10601FA6048950560302CE696A /* ConstraintPriorityTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintPriorityTarget.swift; path = Source/ConstraintPriorityTarget.swift; sourceTree = ""; }; + 7E487C9D04A8A345447D8FAB3B00087A /* Kingfisher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Kingfisher.framework; path = Kingfisher.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7EE2D8F22A386E73E57A406A9A80D689 /* RequestModifier.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RequestModifier.swift; path = Sources/RequestModifier.swift; sourceTree = ""; }; + 81F4688BE1BC212B6C0354776ABE6EE8 /* SessionManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SessionManager.swift; path = Source/SessionManager.swift; sourceTree = ""; }; + 83B6C8999F0BBE343D7F4504BF7E25B5 /* SnapKit-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SnapKit-dummy.m"; sourceTree = ""; }; + 83BD437503304DDEF21ABF937E6DD2FF /* Kingfisher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Kingfisher.swift; path = Sources/Kingfisher.swift; sourceTree = ""; }; + 863FEDEDD513FCEE3EBD3FB46F2AFC93 /* SessionDelegate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SessionDelegate.swift; path = Source/SessionDelegate.swift; sourceTree = ""; }; + 88AE25ED96DB43BB7A08F929198E4237 /* FDFullscreenPopGesture-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "FDFullscreenPopGesture-umbrella.h"; sourceTree = ""; }; + 88C13D03E8C157B9C33F9C849C34DD6E /* Timeline.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Timeline.swift; path = Source/Timeline.swift; sourceTree = ""; }; + 8A89D9430A50475DF745F9F138946591 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 91A01C43394D72B3CB9F00289705657F /* ConstraintLayoutSupport.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutSupport.swift; path = Source/ConstraintLayoutSupport.swift; sourceTree = ""; }; + 91B186968E08DDAECC4273A20C6D91B9 /* ConstraintDescription.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintDescription.swift; path = Source/ConstraintDescription.swift; sourceTree = ""; }; + 93571BFEDF86AF8C9C2CB9748A309DE2 /* ConstraintMakerExtendable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerExtendable.swift; path = Source/ConstraintMakerExtendable.swift; sourceTree = ""; }; + 938A2A47869DE69641CFD21AE642FEB2 /* SwiftyJSON-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftyJSON-umbrella.h"; sourceTree = ""; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 950F24C35EA4DDB9AF163755F9D47F14 /* KingfisherManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = KingfisherManager.swift; path = Sources/KingfisherManager.swift; sourceTree = ""; }; + 95B7CB108109D173DC79D82413336041 /* SwiftyJSON.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SwiftyJSON.swift; path = Source/SwiftyJSON.swift; sourceTree = ""; }; + 9681D6D418AF9801F773EF7562D83F35 /* UINavigationController+FDFullscreenPopGesture.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UINavigationController+FDFullscreenPopGesture.m"; path = "FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m"; sourceTree = ""; }; + 979D31C072119791E918A369E32561CE /* Pods-DanTangSwift-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-DanTangSwift-frameworks.sh"; sourceTree = ""; }; + 9B125F57DDAB78E2E0AA3057FBB3DF58 /* Request.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Request.swift; path = Source/Request.swift; sourceTree = ""; }; + 9B143DA25A7C26E19B5AE5CB66079859 /* String+MD5.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "String+MD5.swift"; path = "Sources/String+MD5.swift"; sourceTree = ""; }; + 9BA9FA785C6A92287EA96A7C97B3E453 /* SVIndefiniteAnimatedView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SVIndefiniteAnimatedView.m; path = SVProgressHUD/SVIndefiniteAnimatedView.m; sourceTree = ""; }; + 9DD02DD25A12E333226B2EDF88461EB7 /* UILayoutSupport+Extensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "UILayoutSupport+Extensions.swift"; path = "Source/UILayoutSupport+Extensions.swift"; sourceTree = ""; }; + A0D4DD55A4F69420059427E1739BC50D /* ConstraintLayoutSupportDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutSupportDSL.swift; path = Source/ConstraintLayoutSupportDSL.swift; sourceTree = ""; }; + A155AAAAFFBFA547CC5FFB39F43D42B9 /* FDFullscreenPopGesture.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = FDFullscreenPopGesture.framework; path = FDFullscreenPopGesture.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A6E3BFD6D8249E916A48228C58FA2701 /* Notifications.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Notifications.swift; path = Source/Notifications.swift; sourceTree = ""; }; + A78EBE39B1B1E3C9902898F45D2BC742 /* SVProgressAnimatedView.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SVProgressAnimatedView.h; path = SVProgressHUD/SVProgressAnimatedView.h; sourceTree = ""; }; + A91275FB130C52DF9364A09327078B2A /* ConstraintConstantTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintConstantTarget.swift; path = Source/ConstraintConstantTarget.swift; sourceTree = ""; }; + AC2655D9243C94D9A9304A51C48975E8 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutGuideDSL.swift; path = Source/ConstraintLayoutGuideDSL.swift; sourceTree = ""; }; + AC4C969DB352C7F4A545BEFC690B6504 /* FDFullscreenPopGesture-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "FDFullscreenPopGesture-prefix.pch"; sourceTree = ""; }; + ACB45EA02ADDCA75EA50039136E5641B /* ConstraintMakerFinalizable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerFinalizable.swift; path = Source/ConstraintMakerFinalizable.swift; sourceTree = ""; }; + ADB34A85C8F7951AB80B9697CDDA6572 /* ConstraintView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintView.swift; path = Source/ConstraintView.swift; sourceTree = ""; }; + AEFA4DC6364A2FA6EF025C72CB758AB1 /* Resource.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Resource.swift; path = Sources/Resource.swift; sourceTree = ""; }; + AF734D6BF90D0C7EA4D9D4EACDA7BE9F /* AFError.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AFError.swift; path = Source/AFError.swift; sourceTree = ""; }; + B1E92370C95FFA4392FC05E878A535DF /* Alamofire.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Alamofire.xcconfig; sourceTree = ""; }; + B207B0B82B8408D6BD6195ED5FCA0958 /* Kingfisher.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = Kingfisher.modulemap; sourceTree = ""; }; + B29E773093D44B778DB74AC5663DA9EC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; + B3F2D6432A5E08D2406C396E99FD2E53 /* FDFullscreenPopGesture-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "FDFullscreenPopGesture-dummy.m"; sourceTree = ""; }; + B60E78753D1BF3F3E5B35DF215C58EDD /* ConstraintMultiplierTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMultiplierTarget.swift; path = Source/ConstraintMultiplierTarget.swift; sourceTree = ""; }; + B7A0DF8308D70F21F627DBC96826D8A4 /* Debugging.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Debugging.swift; path = Source/Debugging.swift; sourceTree = ""; }; + B828E6FD105AE16D8DECC7422AA07194 /* UIButton+Kingfisher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "UIButton+Kingfisher.swift"; path = "Sources/UIButton+Kingfisher.swift"; sourceTree = ""; }; + B9A24230584E7352842ACCC5A3197D8D /* Pods-DanTangSwift-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-DanTangSwift-resources.sh"; sourceTree = ""; }; + BC7FE270F8D2DB248B5298AA0155378B /* Alamofire-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Alamofire-dummy.m"; sourceTree = ""; }; + C1D563838B0C85F8B4F51DD37631F926 /* SwiftyJSON-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftyJSON-prefix.pch"; sourceTree = ""; }; + C384CDD5587ED8C890EA8D290BFAE815 /* Alamofire.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Alamofire.swift; path = Source/Alamofire.swift; sourceTree = ""; }; + C90D92B79421BF3169BCBD41867D32A2 /* Alamofire-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Alamofire-umbrella.h"; sourceTree = ""; }; + CAF00D2B05549006C10300B90FF29DF7 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CB2AAFE8B09E92E128E9155247DC449C /* SnapKit.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = SnapKit.modulemap; sourceTree = ""; }; + CF8F0389C5B464D432EA707DA95E7C58 /* ConstraintLayoutGuide.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutGuide.swift; path = Source/ConstraintLayoutGuide.swift; sourceTree = ""; }; + D0BBFB60D97A7F22B28A7B6E63C89801 /* SnapKit-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SnapKit-prefix.pch"; sourceTree = ""; }; + D3EAADC781291F9D6F8549B0F4ADC32D /* Filter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Filter.swift; path = Sources/Filter.swift; sourceTree = ""; }; + D4943AB1A090A8BABB0D4DAACE802A52 /* SVRadialGradientLayer.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SVRadialGradientLayer.h; path = SVProgressHUD/SVRadialGradientLayer.h; sourceTree = ""; }; + D5F70FDE340011FC86D0B724FD1DA3A8 /* Box.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Box.swift; path = Sources/Box.swift; sourceTree = ""; }; + D6444891F353D851C5CBEBE87DFDCD5F /* Pods-DanTangSwift-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-DanTangSwift-umbrella.h"; sourceTree = ""; }; + D6C993F382EB412A5BFBCAF72A0EFB19 /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerRelatable.swift; path = Source/ConstraintMakerRelatable.swift; sourceTree = ""; }; + D6EA8C0B938E60B624946DC0AC159E37 /* ParameterEncoding.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ParameterEncoding.swift; path = Source/ParameterEncoding.swift; sourceTree = ""; }; + DA9353E49A40C8DD6480DAADBE08EA19 /* FDFullscreenPopGesture.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = FDFullscreenPopGesture.xcconfig; sourceTree = ""; }; + E0CA7CBDB9F454817CB4B26E3F2EE969 /* Pods-DanTangSwift-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-DanTangSwift-acknowledgements.markdown"; sourceTree = ""; }; + E18CC0532264C74E9D9E0A7B8D749564 /* ConstraintDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintDSL.swift; path = Source/ConstraintDSL.swift; sourceTree = ""; }; + E35B9C35BEAD5BE999A3637E3AE4FA86 /* ImageDownloader.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImageDownloader.swift; path = Sources/ImageDownloader.swift; sourceTree = ""; }; + E44790910F40671D4BE434CE7A6555BB /* Pods-DanTangSwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-DanTangSwift.release.xcconfig"; sourceTree = ""; }; + E5ECD791190961624E3848428B53AF07 /* ConstraintMaker.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMaker.swift; path = Source/ConstraintMaker.swift; sourceTree = ""; }; + E84D54ADC519C007B0A5D0B9FDEE78CE /* SVProgressHUD.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SVProgressHUD.xcconfig; sourceTree = ""; }; + E9624080D81E3D097E175ED156DE6530 /* Result.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Result.swift; path = Source/Result.swift; sourceTree = ""; }; + ED0697745341D0EED3A5CB5E0FE84BF3 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + EDECB2D828915FFAE41D94A55408C5A9 /* ConstraintInsets.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintInsets.swift; path = Source/ConstraintInsets.swift; sourceTree = ""; }; + F9F312FBBF05A55BA8BA2BD05A23E099 /* Constraint.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Constraint.swift; path = Source/Constraint.swift; sourceTree = ""; }; + F9F576E977EE16C1821CD21A3BA0AEA0 /* Pods-DanTangSwift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-DanTangSwift.debug.xcconfig"; sourceTree = ""; }; + FBF81EEA5994CE3C75CE8BE96550C372 /* Pods-DanTangSwift-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-DanTangSwift-acknowledgements.plist"; sourceTree = ""; }; + FC5C1330E632778009C28B09601D7855 /* DispatchQueue+Alamofire.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "DispatchQueue+Alamofire.swift"; path = "Source/DispatchQueue+Alamofire.swift"; sourceTree = ""; }; + FCDDBAB345E0E534BF73DC1AB1DF64E4 /* ResponseSerialization.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ResponseSerialization.swift; path = Source/ResponseSerialization.swift; sourceTree = ""; }; + FD3F46AD85D1DE80F25673A7977C077D /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + FEFECB6C5F070C2E5E0FC7276A5E0540 /* SVProgressAnimatedView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SVProgressAnimatedView.m; path = SVProgressHUD/SVProgressAnimatedView.m; sourceTree = ""; }; + FFF3FA461630AF4A14DD7BC655EC7169 /* SVProgressHUD.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = SVProgressHUD.modulemap; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 26E13F296AC6E5AC0B52B42B35296AC9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9C49ADF2375C77DF7A8EDB7018984DF1 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 6E251F764469A7BA73DE373D7F56FC71 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8C61A41A070DD0AFE50D42573A39A1 /* Foundation.framework in Frameworks */, + C7E2BDC0EC4017A0F15F9A80B74BA152 /* QuartzCore.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 779C6576521FA5E5F43480B5949B5ADD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C7A468CC827A1D5E782B3E1CC44B11C5 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 99195E4207764744AEC07ECCBCD550EB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A04BFC558D69E7DBB68023C80A9CFE4E /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CB32E23EE04C467DC2DACF4E522F893B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23129B1576B7204111A2F052D680DFBE /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DCDB90035DE40F4A4AF65DF3F2124DF6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C0F87F5BBA059DED5F906203DDC75011 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ED03E5917B811BACFE75189AE0C2A469 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 92136C6584624998D5005F46C70A628B /* CFNetwork.framework in Frameworks */, + 9C99E45B90BD95712D9878994BFC8B88 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 122DA2E5084A4393C29BE363C764795C /* Frameworks */ = { + isa = PBXGroup; + children = ( + F50E85800E889287FEC5A6920DBA9546 /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 192F98DEEA56BE2162136BF20105D2FA /* Alamofire */ = { + isa = PBXGroup; + children = ( + AF734D6BF90D0C7EA4D9D4EACDA7BE9F /* AFError.swift */, + C384CDD5587ED8C890EA8D290BFAE815 /* Alamofire.swift */, + FC5C1330E632778009C28B09601D7855 /* DispatchQueue+Alamofire.swift */, + 07C10090D296E2C385D11965F2E51AA4 /* MultipartFormData.swift */, + 6D4A8B722FC0F0813AC0440087C6A5C6 /* NetworkReachabilityManager.swift */, + A6E3BFD6D8249E916A48228C58FA2701 /* Notifications.swift */, + D6EA8C0B938E60B624946DC0AC159E37 /* ParameterEncoding.swift */, + 9B125F57DDAB78E2E0AA3057FBB3DF58 /* Request.swift */, + 016B16F844BEBD26CEC0D58C3561E323 /* Response.swift */, + FCDDBAB345E0E534BF73DC1AB1DF64E4 /* ResponseSerialization.swift */, + E9624080D81E3D097E175ED156DE6530 /* Result.swift */, + 54FA41DF2D4D57EB9A595A080F614E36 /* ServerTrustPolicy.swift */, + 863FEDEDD513FCEE3EBD3FB46F2AFC93 /* SessionDelegate.swift */, + 81F4688BE1BC212B6C0354776ABE6EE8 /* SessionManager.swift */, + 59C5D56545C67ED5B9F028807C886759 /* TaskDelegate.swift */, + 88C13D03E8C157B9C33F9C849C34DD6E /* Timeline.swift */, + 7AD2E474F6F25A28D602170A72FDEA9E /* Validation.swift */, + 5E30134BCF251DF1348C5CF782586D30 /* Support Files */, + ); + name = Alamofire; + path = Alamofire; + sourceTree = ""; + }; + 317C45B78A1776625B2FF8EF0FD9818D /* Support Files */ = { + isa = PBXGroup; + children = ( + 8A89D9430A50475DF745F9F138946591 /* Info.plist */, + CB2AAFE8B09E92E128E9155247DC449C /* SnapKit.modulemap */, + 103F475CC6BB5A40AEDD24251D32DFF9 /* SnapKit.xcconfig */, + 83B6C8999F0BBE343D7F4504BF7E25B5 /* SnapKit-dummy.m */, + D0BBFB60D97A7F22B28A7B6E63C89801 /* SnapKit-prefix.pch */, + 4198F2C06E0B18B94D16E53D9B79DC4A /* SnapKit-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/SnapKit"; + sourceTree = ""; + }; + 3CF91A386D1A1755B333C2BC63710C2F /* SVProgressHUD */ = { + isa = PBXGroup; + children = ( + 6B4296862B61E46CB94328AF6C34629E /* SVIndefiniteAnimatedView.h */, + 9BA9FA785C6A92287EA96A7C97B3E453 /* SVIndefiniteAnimatedView.m */, + A78EBE39B1B1E3C9902898F45D2BC742 /* SVProgressAnimatedView.h */, + FEFECB6C5F070C2E5E0FC7276A5E0540 /* SVProgressAnimatedView.m */, + 4C487BF541A275472CBC7BC436B9A6CC /* SVProgressHUD.h */, + 00C6CEB98892A4E5813EAF25695E0B41 /* SVProgressHUD.m */, + D4943AB1A090A8BABB0D4DAACE802A52 /* SVRadialGradientLayer.h */, + 6F2D3922ADF8A27B13832972DA8A3E6E /* SVRadialGradientLayer.m */, + D99000995DD51D7A236CD3D05FB322B7 /* Resources */, + CF03C29C53F543C0BC71AD779D25FDED /* Support Files */, + ); + name = SVProgressHUD; + path = SVProgressHUD; + sourceTree = ""; + }; + 4985250691FB029D68CC1A0E9BC29661 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + 79E6780757F71524936F4F516EE58CB4 /* Pods-DanTangSwift */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + 5702F9196F354A3104E1FF59CB66FEAB /* Kingfisher */ = { + isa = PBXGroup; + children = ( + 1C6272A243F5D0440BACBF9E78BB1B9E /* AnimatedImageView.swift */, + D5F70FDE340011FC86D0B724FD1DA3A8 /* Box.swift */, + 1F50862674A605EC7791B905E6CA18E8 /* CacheSerializer.swift */, + D3EAADC781291F9D6F8549B0F4ADC32D /* Filter.swift */, + 0D26B8C01EF4A837D107A4A5EA08E2D8 /* Image.swift */, + 3E87C1A0368BEE298BDF45C2301B4F9B /* ImageCache.swift */, + E35B9C35BEAD5BE999A3637E3AE4FA86 /* ImageDownloader.swift */, + 4B6C99CEEA71E2685A6C949A5992B129 /* ImagePrefetcher.swift */, + 560B8325EDFC8107F17F5861D9B4372E /* ImageProcessor.swift */, + 46B217DAA70469CA3931FBEB8BC15DA7 /* ImageTransition.swift */, + 0A07C8A6335CF467D1F785E316B54CEA /* ImageView+Kingfisher.swift */, + 2D92320867D57966A88D8CAD233E961F /* Indicator.swift */, + 1F89F0BCD74EB85F7F184583290B3107 /* Kingfisher.h */, + 83BD437503304DDEF21ABF937E6DD2FF /* Kingfisher.swift */, + 950F24C35EA4DDB9AF163755F9D47F14 /* KingfisherManager.swift */, + 18E2F84AE7B2C85D4D03A4945EEB80CE /* KingfisherOptionsInfo.swift */, + 7EE2D8F22A386E73E57A406A9A80D689 /* RequestModifier.swift */, + AEFA4DC6364A2FA6EF025C72CB758AB1 /* Resource.swift */, + 9B143DA25A7C26E19B5AE5CB66079859 /* String+MD5.swift */, + 191C2085C95030F629C2AFB63CA6C5FE /* ThreadHelper.swift */, + B828E6FD105AE16D8DECC7422AA07194 /* UIButton+Kingfisher.swift */, + DC5299ECE44C627218D767BEE433345D /* Support Files */, + ); + name = Kingfisher; + path = Kingfisher; + sourceTree = ""; + }; + 5E30134BCF251DF1348C5CF782586D30 /* Support Files */ = { + isa = PBXGroup; + children = ( + 277D87618B4E3B70263ECAE3B7196CF6 /* Alamofire.modulemap */, + B1E92370C95FFA4392FC05E878A535DF /* Alamofire.xcconfig */, + BC7FE270F8D2DB248B5298AA0155378B /* Alamofire-dummy.m */, + 1AD4D4F2E186FCAC0C7833970787D5E0 /* Alamofire-prefix.pch */, + C90D92B79421BF3169BCBD41867D32A2 /* Alamofire-umbrella.h */, + 77B01D924C25A0D4AC129971B308C100 /* Info.plist */, + ); + name = "Support Files"; + path = "../Target Support Files/Alamofire"; + sourceTree = ""; + }; + 6A44AE238D20E593E1CBBE19B821226E /* Products */ = { + isa = PBXGroup; + children = ( + 58EA0480CB393BC46B23A49F60B12A28 /* Alamofire.framework */, + A155AAAAFFBFA547CC5FFB39F43D42B9 /* FDFullscreenPopGesture.framework */, + 7E487C9D04A8A345447D8FAB3B00087A /* Kingfisher.framework */, + 75406655D849F4ECF802A4FFD62E8FEA /* Pods_DanTangSwift.framework */, + 5D388F8FD7606E7D74A5B332A1B0167D /* SnapKit.framework */, + 2695B23FB23877A85491F0978296FE6B /* SVProgressHUD.framework */, + 4F5C350037CF955788FB6B42E8609473 /* SwiftyJSON.framework */, + ); + name = Products; + sourceTree = ""; + }; + 79E6780757F71524936F4F516EE58CB4 /* Pods-DanTangSwift */ = { + isa = PBXGroup; + children = ( + 2B04F310D3A3F8B573B72525EAB92C98 /* Info.plist */, + 495C17FEF7CDDB7E198431639C849565 /* Pods-DanTangSwift.modulemap */, + E0CA7CBDB9F454817CB4B26E3F2EE969 /* Pods-DanTangSwift-acknowledgements.markdown */, + FBF81EEA5994CE3C75CE8BE96550C372 /* Pods-DanTangSwift-acknowledgements.plist */, + 27F2452CF0982004D32116C01B9B7334 /* Pods-DanTangSwift-dummy.m */, + 979D31C072119791E918A369E32561CE /* Pods-DanTangSwift-frameworks.sh */, + B9A24230584E7352842ACCC5A3197D8D /* Pods-DanTangSwift-resources.sh */, + D6444891F353D851C5CBEBE87DFDCD5F /* Pods-DanTangSwift-umbrella.h */, + F9F576E977EE16C1821CD21A3BA0AEA0 /* Pods-DanTangSwift.debug.xcconfig */, + E44790910F40671D4BE434CE7A6555BB /* Pods-DanTangSwift.release.xcconfig */, + ); + name = "Pods-DanTangSwift"; + path = "Target Support Files/Pods-DanTangSwift"; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, + 122DA2E5084A4393C29BE363C764795C /* Frameworks */, + A3216A87F320807E58834683FEC069A1 /* Pods */, + 6A44AE238D20E593E1CBBE19B821226E /* Products */, + 4985250691FB029D68CC1A0E9BC29661 /* Targets Support Files */, + ); + sourceTree = ""; + }; + A3216A87F320807E58834683FEC069A1 /* Pods */ = { + isa = PBXGroup; + children = ( + 192F98DEEA56BE2162136BF20105D2FA /* Alamofire */, + E55EF49BC6003FF9045A6C3AF21764AB /* FDFullscreenPopGesture */, + 5702F9196F354A3104E1FF59CB66FEAB /* Kingfisher */, + CFAB72236086A88080113F6317BDD678 /* SnapKit */, + 3CF91A386D1A1755B333C2BC63710C2F /* SVProgressHUD */, + A69C87AFE7A06B7934637571AB94417D /* SwiftyJSON */, + ); + name = Pods; + sourceTree = ""; + }; + A69C87AFE7A06B7934637571AB94417D /* SwiftyJSON */ = { + isa = PBXGroup; + children = ( + 95B7CB108109D173DC79D82413336041 /* SwiftyJSON.swift */, + B876AC928922D3085568D9D44B97FBBB /* Support Files */, + ); + name = SwiftyJSON; + path = SwiftyJSON; + sourceTree = ""; + }; + AFA04D8697C7E0D41CE29CA30BCABE14 /* Support Files */ = { + isa = PBXGroup; + children = ( + 09A148AC6A3FEF0ECDDB046DC2525094 /* FDFullscreenPopGesture.modulemap */, + DA9353E49A40C8DD6480DAADBE08EA19 /* FDFullscreenPopGesture.xcconfig */, + B3F2D6432A5E08D2406C396E99FD2E53 /* FDFullscreenPopGesture-dummy.m */, + AC4C969DB352C7F4A545BEFC690B6504 /* FDFullscreenPopGesture-prefix.pch */, + 88AE25ED96DB43BB7A08F929198E4237 /* FDFullscreenPopGesture-umbrella.h */, + ED0697745341D0EED3A5CB5E0FE84BF3 /* Info.plist */, + ); + name = "Support Files"; + path = "../Target Support Files/FDFullscreenPopGesture"; + sourceTree = ""; + }; + B876AC928922D3085568D9D44B97FBBB /* Support Files */ = { + isa = PBXGroup; + children = ( + 769F73EC81F6F88C175A7B9DECC4F0A6 /* Info.plist */, + 355B54120687A0A98FB3F6D28198B04A /* SwiftyJSON.modulemap */, + 3F810C3AF0200B9C5D5B8C48325BFC7D /* SwiftyJSON.xcconfig */, + 693E43BA382DDB2E5BC34870EAD295A4 /* SwiftyJSON-dummy.m */, + C1D563838B0C85F8B4F51DD37631F926 /* SwiftyJSON-prefix.pch */, + 938A2A47869DE69641CFD21AE642FEB2 /* SwiftyJSON-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/SwiftyJSON"; + sourceTree = ""; + }; + CF03C29C53F543C0BC71AD779D25FDED /* Support Files */ = { + isa = PBXGroup; + children = ( + FD3F46AD85D1DE80F25673A7977C077D /* Info.plist */, + FFF3FA461630AF4A14DD7BC655EC7169 /* SVProgressHUD.modulemap */, + E84D54ADC519C007B0A5D0B9FDEE78CE /* SVProgressHUD.xcconfig */, + 1410CF1E763B2421E4888AE276A444D2 /* SVProgressHUD-dummy.m */, + 2BEF12BC5EBC1C66335039264788BF02 /* SVProgressHUD-prefix.pch */, + 47653EE02F61952FDD8BEB013ED3D0E2 /* SVProgressHUD-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/SVProgressHUD"; + sourceTree = ""; + }; + CFAB72236086A88080113F6317BDD678 /* SnapKit */ = { + isa = PBXGroup; + children = ( + F9F312FBBF05A55BA8BA2BD05A23E099 /* Constraint.swift */, + 3FA89638DDA12AD4B1F3680548BD8943 /* ConstraintAttributes.swift */, + 6BC087DE76A5EC0825F32DF45E843DAF /* ConstraintConfig.swift */, + A91275FB130C52DF9364A09327078B2A /* ConstraintConstantTarget.swift */, + 91B186968E08DDAECC4273A20C6D91B9 /* ConstraintDescription.swift */, + E18CC0532264C74E9D9E0A7B8D749564 /* ConstraintDSL.swift */, + EDECB2D828915FFAE41D94A55408C5A9 /* ConstraintInsets.swift */, + 02027FAD496A49105A7454730A33DE75 /* ConstraintInsetTarget.swift */, + 2B4C839296EB7B858AA80CF3D865C85A /* ConstraintItem.swift */, + CF8F0389C5B464D432EA707DA95E7C58 /* ConstraintLayoutGuide.swift */, + 415682BC6912131296EB845AE3DF33D0 /* ConstraintLayoutGuide+Extensions.swift */, + AC2655D9243C94D9A9304A51C48975E8 /* ConstraintLayoutGuideDSL.swift */, + 91A01C43394D72B3CB9F00289705657F /* ConstraintLayoutSupport.swift */, + A0D4DD55A4F69420059427E1739BC50D /* ConstraintLayoutSupportDSL.swift */, + E5ECD791190961624E3848428B53AF07 /* ConstraintMaker.swift */, + 322EC43A80C50DDCF13520B9BAE70EBB /* ConstraintMakerEditable.swift */, + 93571BFEDF86AF8C9C2CB9748A309DE2 /* ConstraintMakerExtendable.swift */, + ACB45EA02ADDCA75EA50039136E5641B /* ConstraintMakerFinalizable.swift */, + 69BE98893EC9F8EA974C8ED30CF2DD0C /* ConstraintMakerPriortizable.swift */, + D6C993F382EB412A5BFBCAF72A0EFB19 /* ConstraintMakerRelatable.swift */, + B60E78753D1BF3F3E5B35DF215C58EDD /* ConstraintMultiplierTarget.swift */, + 154080BAB97096424B47AA41A81DC0FD /* ConstraintOffsetTarget.swift */, + 7BA0ED10601FA6048950560302CE696A /* ConstraintPriorityTarget.swift */, + 5C5B3F63F16A4D40E0BC867AE7201176 /* ConstraintRelatableTarget.swift */, + 7B9F0A1F20F7E97DBB98FA042D1689C1 /* ConstraintRelation.swift */, + ADB34A85C8F7951AB80B9697CDDA6572 /* ConstraintView.swift */, + 3A75BF50C37EE3B6B21E0D3E8CEDFEEA /* ConstraintView+Extensions.swift */, + 6B474283C2047FA43CF51B96E6162F58 /* ConstraintViewDSL.swift */, + B7A0DF8308D70F21F627DBC96826D8A4 /* Debugging.swift */, + 576D4403A3387F7405EB919EF89DAAA5 /* LayoutConstraint.swift */, + 4C99C6ECB9E0D4C89324DD3AA1B6D0D6 /* LayoutConstraintItem.swift */, + 9DD02DD25A12E333226B2EDF88461EB7 /* UILayoutSupport+Extensions.swift */, + 317C45B78A1776625B2FF8EF0FD9818D /* Support Files */, + ); + name = SnapKit; + path = SnapKit; + sourceTree = ""; + }; + D99000995DD51D7A236CD3D05FB322B7 /* Resources */ = { + isa = PBXGroup; + children = ( + 2EB6E339D221106C6AC7E02AFC169449 /* SVProgressHUD.bundle */, + ); + name = Resources; + sourceTree = ""; + }; + DC5299ECE44C627218D767BEE433345D /* Support Files */ = { + isa = PBXGroup; + children = ( + CAF00D2B05549006C10300B90FF29DF7 /* Info.plist */, + B207B0B82B8408D6BD6195ED5FCA0958 /* Kingfisher.modulemap */, + 215CEFCC193213346AFD76EA8491B220 /* Kingfisher.xcconfig */, + 3B0412712D24FA1982A73BD8E6C65684 /* Kingfisher-dummy.m */, + 764CC11BCBEB9DC70190940EED0CB404 /* Kingfisher-prefix.pch */, + 1A8463EFB5BE5707C4C0FF08A86B0367 /* Kingfisher-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/Kingfisher"; + sourceTree = ""; + }; + E55EF49BC6003FF9045A6C3AF21764AB /* FDFullscreenPopGesture */ = { + isa = PBXGroup; + children = ( + 74240140E3778F92905534FADF105EC8 /* UINavigationController+FDFullscreenPopGesture.h */, + 9681D6D418AF9801F773EF7562D83F35 /* UINavigationController+FDFullscreenPopGesture.m */, + AFA04D8697C7E0D41CE29CA30BCABE14 /* Support Files */, + ); + name = FDFullscreenPopGesture; + path = FDFullscreenPopGesture; + sourceTree = ""; + }; + F50E85800E889287FEC5A6920DBA9546 /* iOS */ = { + isa = PBXGroup; + children = ( + 44B4C5EF04AF72A50CBFAFA7C8CB92B5 /* CFNetwork.framework */, + 789FEE98D8DA8D167A6AC10F788F32A3 /* Foundation.framework */, + B29E773093D44B778DB74AC5663DA9EC /* QuartzCore.framework */, + ); + name = iOS; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 0F94B6BFE5A6242FBBB0BE3D27F7CEE9 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + A8F35D1EBAEF99D38F02A0B8CA5D8FBE /* Kingfisher-umbrella.h in Headers */, + 179523942E7D1E3EB210EF05E2C7AE79 /* Kingfisher.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1AEDF980BC5399B33C9620D5078BA0D3 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 776702E8743007AC3AFC1E7F76299616 /* FDFullscreenPopGesture-umbrella.h in Headers */, + 1C4F35092211F226DC56EFD272A292BC /* UINavigationController+FDFullscreenPopGesture.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 777A557B1257CC58B7750134B26C037C /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + A2D68527945CBD957D804CD46BD73782 /* SwiftyJSON-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A7F93BD8DE79F038B3AF2138A840F89A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + DC5B3D609FC11AC7E347F2157AEAECA7 /* SVIndefiniteAnimatedView.h in Headers */, + 93A3581B6C58CDD1506F30666ADCE33D /* SVProgressAnimatedView.h in Headers */, + CE05ECA6192C12D3BD85F15D4B8DA8C9 /* SVProgressHUD-umbrella.h in Headers */, + 961BD6787599C46B71C9CD3A20FC8E01 /* SVProgressHUD.h in Headers */, + B9DDF5D72B26AEE9E1D71A2845B67227 /* SVRadialGradientLayer.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B4002B6E97835FDCCAA5963EFE09A3E0 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1B9EDEDC964E6B08F78920B4F4B9DB84 /* Alamofire-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BF3E66B4D8082CD724721815808BB584 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + C0993C7BC2AE50A495FF9582AFA38EA0 /* Pods-DanTangSwift-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F9255457F777CFC04B364DEFBDC5F57F /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + FAAC8AF2A4126B8B8E57DFC71F537744 /* SnapKit-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 0F71FC248875B67F53494C44B17B40EB /* FDFullscreenPopGesture */ = { + isa = PBXNativeTarget; + buildConfigurationList = 404F7EB5C0136CDDE3194542723E2E7C /* Build configuration list for PBXNativeTarget "FDFullscreenPopGesture" */; + buildPhases = ( + CDFEDD02529F13E67D2EDAED8E5DB4EB /* Sources */, + DCDB90035DE40F4A4AF65DF3F2124DF6 /* Frameworks */, + 1AEDF980BC5399B33C9620D5078BA0D3 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = FDFullscreenPopGesture; + productName = FDFullscreenPopGesture; + productReference = A155AAAAFFBFA547CC5FFB39F43D42B9 /* FDFullscreenPopGesture.framework */; + productType = "com.apple.product-type.framework"; + }; + 407B0D854F5D22F49E4B8182E4170661 /* Pods-DanTangSwift */ = { + isa = PBXNativeTarget; + buildConfigurationList = AC2006EB52C10CA89FA21F536F5769FC /* Build configuration list for PBXNativeTarget "Pods-DanTangSwift" */; + buildPhases = ( + EE30A0DF223F8FD2642EDA3D9F5B69AF /* Sources */, + 26E13F296AC6E5AC0B52B42B35296AC9 /* Frameworks */, + BF3E66B4D8082CD724721815808BB584 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + C3FADFBCBC16F5AE20E4E6700C0C07A5 /* PBXTargetDependency */, + 2E094B31706E10B44FCC33184F75DD74 /* PBXTargetDependency */, + C51562B87B878143A0A54D703AE5266A /* PBXTargetDependency */, + 89C6DEEEC0231CDA2625A4BC32588915 /* PBXTargetDependency */, + C4F8BE303F57C975CDB0482B8D56D41F /* PBXTargetDependency */, + 8FB067A4F305FCE32FDF09928E0F28AA /* PBXTargetDependency */, + ); + name = "Pods-DanTangSwift"; + productName = "Pods-DanTangSwift"; + productReference = 75406655D849F4ECF802A4FFD62E8FEA /* Pods_DanTangSwift.framework */; + productType = "com.apple.product-type.framework"; + }; + 60B0AF289DE8AC7FC0376BE9539069F1 /* SwiftyJSON */ = { + isa = PBXNativeTarget; + buildConfigurationList = ED7676258A4FE56AD60939B76BD24B51 /* Build configuration list for PBXNativeTarget "SwiftyJSON" */; + buildPhases = ( + 29EF12D527B1730345AC1D4093C257FB /* Sources */, + CB32E23EE04C467DC2DACF4E522F893B /* Frameworks */, + 777A557B1257CC58B7750134B26C037C /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftyJSON; + productName = SwiftyJSON; + productReference = 4F5C350037CF955788FB6B42E8609473 /* SwiftyJSON.framework */; + productType = "com.apple.product-type.framework"; + }; + 7C93740F8DAECC871D081AA4C909D0AD /* SVProgressHUD */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3449AF3BA4F197A249CAB24B453CB784 /* Build configuration list for PBXNativeTarget "SVProgressHUD" */; + buildPhases = ( + 85D5B86B5FDE65E6E6D6123974E93A5E /* Sources */, + 6E251F764469A7BA73DE373D7F56FC71 /* Frameworks */, + A7F93BD8DE79F038B3AF2138A840F89A /* Headers */, + ED5FD0C15D2D2ED3709157AAD31530FA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SVProgressHUD; + productName = SVProgressHUD; + productReference = 2695B23FB23877A85491F0978296FE6B /* SVProgressHUD.framework */; + productType = "com.apple.product-type.framework"; + }; + 88E9EC28B8B46C3631E6B242B50F4442 /* Alamofire */ = { + isa = PBXNativeTarget; + buildConfigurationList = 419E5D95491847CD79841B971A8A3277 /* Build configuration list for PBXNativeTarget "Alamofire" */; + buildPhases = ( + 32B9974868188C4803318E36329C87FE /* Sources */, + 99195E4207764744AEC07ECCBCD550EB /* Frameworks */, + B4002B6E97835FDCCAA5963EFE09A3E0 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Alamofire; + productName = Alamofire; + productReference = 58EA0480CB393BC46B23A49F60B12A28 /* Alamofire.framework */; + productType = "com.apple.product-type.framework"; + }; + 8A83C725DBFF5900754DFD3958596E0D /* SnapKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1164C08154738C62F53EDEFCEDA40073 /* Build configuration list for PBXNativeTarget "SnapKit" */; + buildPhases = ( + 9B6537E8BBCA1918B543351619C972F3 /* Sources */, + 779C6576521FA5E5F43480B5949B5ADD /* Frameworks */, + F9255457F777CFC04B364DEFBDC5F57F /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SnapKit; + productName = SnapKit; + productReference = 5D388F8FD7606E7D74A5B332A1B0167D /* SnapKit.framework */; + productType = "com.apple.product-type.framework"; + }; + C4944FEC314D1A66588651D006273ADE /* Kingfisher */ = { + isa = PBXNativeTarget; + buildConfigurationList = 76E7EFBCEA1340954A03AA68051C2306 /* Build configuration list for PBXNativeTarget "Kingfisher" */; + buildPhases = ( + EAC7EA95310C5E1E724C632852F7D186 /* Sources */, + ED03E5917B811BACFE75189AE0C2A469 /* Frameworks */, + 0F94B6BFE5A6242FBBB0BE3D27F7CEE9 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Kingfisher; + productName = Kingfisher; + productReference = 7E487C9D04A8A345447D8FAB3B00087A /* Kingfisher.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = 6A44AE238D20E593E1CBBE19B821226E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 88E9EC28B8B46C3631E6B242B50F4442 /* Alamofire */, + 0F71FC248875B67F53494C44B17B40EB /* FDFullscreenPopGesture */, + C4944FEC314D1A66588651D006273ADE /* Kingfisher */, + 407B0D854F5D22F49E4B8182E4170661 /* Pods-DanTangSwift */, + 8A83C725DBFF5900754DFD3958596E0D /* SnapKit */, + 7C93740F8DAECC871D081AA4C909D0AD /* SVProgressHUD */, + 60B0AF289DE8AC7FC0376BE9539069F1 /* SwiftyJSON */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + ED5FD0C15D2D2ED3709157AAD31530FA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 082A7A3CE3208EB81B2B209257DBBCCD /* SVProgressHUD.bundle in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 29EF12D527B1730345AC1D4093C257FB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1E7D96022F2B49F8C89C9D347F7CFAF5 /* SwiftyJSON-dummy.m in Sources */, + E0590E9D162B134D859B567BD10C29A3 /* SwiftyJSON.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 32B9974868188C4803318E36329C87FE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9ED2BB2981896E0A39EFA365503F58CE /* AFError.swift in Sources */, + A9EEEA7477981DEEBC72432DE9990A4B /* Alamofire-dummy.m in Sources */, + F8B3D3092ED0417E8CDF32033F6122F5 /* Alamofire.swift in Sources */, + 61200D01A1855D7920CEF835C8BE00B0 /* DispatchQueue+Alamofire.swift in Sources */, + B65FCF589DA398C3EFE0128064E510EC /* MultipartFormData.swift in Sources */, + A2A6F71B727312BD45CC7A4AAD7B0AB7 /* NetworkReachabilityManager.swift in Sources */, + EFD264FC408EBF3BA2528E70B08DDD94 /* Notifications.swift in Sources */, + BE5C67A07E289FE1F9BE27335B159997 /* ParameterEncoding.swift in Sources */, + 5387216E723A3C68E851CA15573CDD71 /* Request.swift in Sources */, + CB6D60925223897FFA2662667DF83E8A /* Response.swift in Sources */, + F6BECD98B97CBFEBE2C96F0E9E72A6C0 /* ResponseSerialization.swift in Sources */, + 7D8CC01E8C9EFFF9F4D65406CDE0AB66 /* Result.swift in Sources */, + 62F65AD8DC4F0F9610F4B8B4738EC094 /* ServerTrustPolicy.swift in Sources */, + 7B5FE28C7EA4122B0598738E54DBEBD8 /* SessionDelegate.swift in Sources */, + AE1EF48399533730D0066E04B22CA2D6 /* SessionManager.swift in Sources */, + 3626B94094672CB1C9DEA32B9F9502E1 /* TaskDelegate.swift in Sources */, + 10EB23E9ECC4B33E16933BB1EA560B6A /* Timeline.swift in Sources */, + BBEFE2F9CEB73DC7BD97FFA66A0D9D4F /* Validation.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 85D5B86B5FDE65E6E6D6123974E93A5E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CE15ED57FCC8C8850E356F8730067F4B /* SVIndefiniteAnimatedView.m in Sources */, + 5F135EE83AC5546F549972B504E7A895 /* SVProgressAnimatedView.m in Sources */, + 46C07510340F8BB3DC9E21688C4C26F7 /* SVProgressHUD-dummy.m in Sources */, + 6B184AED0EEF671B206D4790BFE770A7 /* SVProgressHUD.m in Sources */, + 8AC17754F9B2A545F7327F6BB5716B6F /* SVRadialGradientLayer.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B6537E8BBCA1918B543351619C972F3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0584D96881FCB3DABFE446FF964012B5 /* Constraint.swift in Sources */, + F38BDF594D1C1EAFCC5EE542C6BDB825 /* ConstraintAttributes.swift in Sources */, + 45E379B47EBBA540C7F3DA8604D762BB /* ConstraintConfig.swift in Sources */, + 06585D0F1D0C90183BAB4134C4DE606B /* ConstraintConstantTarget.swift in Sources */, + EEC0B4DBBFAFB36B41A1599E0A45A7E7 /* ConstraintDescription.swift in Sources */, + D5CE2D591E361887F6721FCE16BBD0E3 /* ConstraintDSL.swift in Sources */, + 246A1B90DFA180A60EC6CF4897F21D25 /* ConstraintInsets.swift in Sources */, + 8CB4E4500C18056535690A487D58AC96 /* ConstraintInsetTarget.swift in Sources */, + DC81F1702E0AB345FE3F0E071DE72956 /* ConstraintItem.swift in Sources */, + A19E3B34FADA5DBE2D9E3E2F58767655 /* ConstraintLayoutGuide+Extensions.swift in Sources */, + D625CAA07273E3F3BA219EC009C45EC7 /* ConstraintLayoutGuide.swift in Sources */, + D76B88F4F539E3574CA0F0DDB0C8E6F5 /* ConstraintLayoutGuideDSL.swift in Sources */, + 8964444C2D53CCBD8F963D2510521D8B /* ConstraintLayoutSupport.swift in Sources */, + 1C7A1C3C2FA17521B034AA554517D770 /* ConstraintLayoutSupportDSL.swift in Sources */, + 64766CCE6465D353D72325EB345178DD /* ConstraintMaker.swift in Sources */, + 71EFBE4144072FDC7A8C990C9224CABE /* ConstraintMakerEditable.swift in Sources */, + 8DD16E2DF74B562CA6612655C0160C3E /* ConstraintMakerExtendable.swift in Sources */, + 26EA90A6045FD5F230E0AC7170A38905 /* ConstraintMakerFinalizable.swift in Sources */, + 504FBF2C8537ACD462F6E3FE8C4D5E4B /* ConstraintMakerPriortizable.swift in Sources */, + B674C44E1B7ACF20D25984174339009A /* ConstraintMakerRelatable.swift in Sources */, + 265B3B75D221ABBF94B13AE8AB4E21E0 /* ConstraintMultiplierTarget.swift in Sources */, + 131BEC71EB4BB80431F1F29AC2C34BDF /* ConstraintOffsetTarget.swift in Sources */, + B9BCD9CD995DDBC709C0ECBD472B5B3F /* ConstraintPriorityTarget.swift in Sources */, + 6EC01F79E723393A002BFB33E346973E /* ConstraintRelatableTarget.swift in Sources */, + C2E2FF4387A2A736F49D68E524A327D8 /* ConstraintRelation.swift in Sources */, + E78FA328043C0503325A7A80A584EFD4 /* ConstraintView+Extensions.swift in Sources */, + E113782D04172DFAD1E0DC02C720DE33 /* ConstraintView.swift in Sources */, + 10D6B0714802CAE40B3787C84C28FF0E /* ConstraintViewDSL.swift in Sources */, + 6B658CD8A5A218455BB8B4CB9F0E38B1 /* Debugging.swift in Sources */, + 9739017C4AB797ADF0BC2709A76E4F57 /* LayoutConstraint.swift in Sources */, + 1C142A579DC48E167391E9DDC2207AB3 /* LayoutConstraintItem.swift in Sources */, + 710D7A91D14C2E84D291AEDB334219EB /* SnapKit-dummy.m in Sources */, + 612902259114F3A36B86E4B9E28BE947 /* UILayoutSupport+Extensions.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CDFEDD02529F13E67D2EDAED8E5DB4EB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E5D9851A41395BD8AA5E356D3E7B174E /* FDFullscreenPopGesture-dummy.m in Sources */, + B84F960E74AE7F8A67099072C643F17F /* UINavigationController+FDFullscreenPopGesture.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EAC7EA95310C5E1E724C632852F7D186 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 342AE33215135AD56B73580012DC22AB /* AnimatedImageView.swift in Sources */, + 6DA770087D354CDCD3889CDAE7C4C698 /* Box.swift in Sources */, + 2E5E570FFC49EF98550401421A243C0F /* CacheSerializer.swift in Sources */, + 4089E39F76F86466B8DDD39A1C1ABB6B /* Filter.swift in Sources */, + 33A14E817C0FA585D5DA3A55E453299D /* Image.swift in Sources */, + F8E957950566622A3E4B61AACE8F0B4A /* ImageCache.swift in Sources */, + DC6080C64C269628C3F5107BE87055E2 /* ImageDownloader.swift in Sources */, + 3414E1D9CB15149A296E16C45967B021 /* ImagePrefetcher.swift in Sources */, + 0E9CC28AC8E34FE8E1C87E933E04BC7A /* ImageProcessor.swift in Sources */, + 86B7DA678C8705523C300947117C0706 /* ImageTransition.swift in Sources */, + 33395912F2FFA355C4C36B7EDEAA3DA7 /* ImageView+Kingfisher.swift in Sources */, + 52A280AB4852FDE92DF09B5E79D5C2AA /* Indicator.swift in Sources */, + 6A375593407BC7937234B2B6A0811760 /* Kingfisher-dummy.m in Sources */, + C9CC5ED97D29C6C3DE22B78A9AA2AD91 /* Kingfisher.swift in Sources */, + 7636F846675C9F4ED96E00C6C19A4890 /* KingfisherManager.swift in Sources */, + 378B44CAA91C2106076668FDE72E1E02 /* KingfisherOptionsInfo.swift in Sources */, + EA816A580C3858934ED6FE92040C26DD /* RequestModifier.swift in Sources */, + 8DA7E6883118CB3C8132B64D3D43AE0B /* Resource.swift in Sources */, + 9F826F893E86EB86591B637A1CE4B13A /* String+MD5.swift in Sources */, + 6CD63E1564618B6213B98E0ABBC3127C /* ThreadHelper.swift in Sources */, + EE89512E8D36E67CDC525DB9D5BBF5A7 /* UIButton+Kingfisher.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EE30A0DF223F8FD2642EDA3D9F5B69AF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 951A388A8C60C5ED84CD7655B0B87211 /* Pods-DanTangSwift-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 2E094B31706E10B44FCC33184F75DD74 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = FDFullscreenPopGesture; + target = 0F71FC248875B67F53494C44B17B40EB /* FDFullscreenPopGesture */; + targetProxy = DEF6DFEFE5453D0C89432A8C3491DF44 /* PBXContainerItemProxy */; + }; + 89C6DEEEC0231CDA2625A4BC32588915 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SVProgressHUD; + target = 7C93740F8DAECC871D081AA4C909D0AD /* SVProgressHUD */; + targetProxy = 59CC744BB6A3673EA4321922DFD6B602 /* PBXContainerItemProxy */; + }; + 8FB067A4F305FCE32FDF09928E0F28AA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SwiftyJSON; + target = 60B0AF289DE8AC7FC0376BE9539069F1 /* SwiftyJSON */; + targetProxy = 2862929A8689C3A3C780DA1FA3119A5E /* PBXContainerItemProxy */; + }; + C3FADFBCBC16F5AE20E4E6700C0C07A5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Alamofire; + target = 88E9EC28B8B46C3631E6B242B50F4442 /* Alamofire */; + targetProxy = FE059D03C484005936564996EB5B2072 /* PBXContainerItemProxy */; + }; + C4F8BE303F57C975CDB0482B8D56D41F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SnapKit; + target = 8A83C725DBFF5900754DFD3958596E0D /* SnapKit */; + targetProxy = 5CF2CD9DCAD332281FF4C8E511AB728A /* PBXContainerItemProxy */; + }; + C51562B87B878143A0A54D703AE5266A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Kingfisher; + target = C4944FEC314D1A66588651D006273ADE /* Kingfisher */; + targetProxy = 2909B4B1CB463DF5986B540A32F901F9 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 015A368F878AC3E2CEAE21DDE8026304 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + ONLY_ACTIVE_ARCH = YES; + PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 088694703F459CD9F0E7F7C9F05580D4 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DA9353E49A40C8DD6480DAADBE08EA19 /* FDFullscreenPopGesture.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/FDFullscreenPopGesture/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = FDFullscreenPopGesture; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 0A29B6F510198AF64EFD762EF6FA97A5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B1E92370C95FFA4392FC05E878A535DF /* Alamofire.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Alamofire/Alamofire-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Alamofire/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Alamofire/Alamofire.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = Alamofire; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 2E09837D92A5BE4E172CE06F6B06E66C /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E84D54ADC519C007B0A5D0B9FDEE78CE /* SVProgressHUD.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SVProgressHUD/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SVProgressHUD/SVProgressHUD.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = SVProgressHUD; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 380C30050278E488BE23DB926933212E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 215CEFCC193213346AFD76EA8491B220 /* Kingfisher.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Kingfisher/Kingfisher-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Kingfisher/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Kingfisher/Kingfisher.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = Kingfisher; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 44CDBB6D11DE06DB64D6268622BDC47E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6E53245BBAAAB71AD4E0EE52CA99FD28 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 215CEFCC193213346AFD76EA8491B220 /* Kingfisher.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Kingfisher/Kingfisher-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Kingfisher/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Kingfisher/Kingfisher.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = Kingfisher; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 7EEA9C2D80E95D91A831A55B589F7542 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 103F475CC6BB5A40AEDD24251D32DFF9 /* SnapKit.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/SnapKit/SnapKit-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SnapKit/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SnapKit/SnapKit.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = SnapKit; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 8128090B5EB4FF873FEE5418196ED24E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 103F475CC6BB5A40AEDD24251D32DFF9 /* SnapKit.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/SnapKit/SnapKit-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SnapKit/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SnapKit/SnapKit.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = SnapKit; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 8A80D4A2771FAB9F6F4FCEC87D742C6A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F9F576E977EE16C1821CD21A3BA0AEA0 /* Pods-DanTangSwift.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-DanTangSwift/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_DanTangSwift; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + AEDF27C759D986D2D55907A9472E64DC /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3F810C3AF0200B9C5D5B8C48325BFC7D /* SwiftyJSON.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SwiftyJSON/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SwiftyJSON/SwiftyJSON.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = SwiftyJSON; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + C680A2E106D96BBE2560D18E05914D7A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DA9353E49A40C8DD6480DAADBE08EA19 /* FDFullscreenPopGesture.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/FDFullscreenPopGesture/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = FDFullscreenPopGesture; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + D02CEA183DB49F444FD0CB7C34F9FB66 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3F810C3AF0200B9C5D5B8C48325BFC7D /* SwiftyJSON.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SwiftyJSON/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SwiftyJSON/SwiftyJSON.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = SwiftyJSON; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + D7ACC6A4FF9873B166B6104C3D409B3E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E84D54ADC519C007B0A5D0B9FDEE78CE /* SVProgressHUD.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SVProgressHUD/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SVProgressHUD/SVProgressHUD.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = SVProgressHUD; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + E69902A0FBB63FA394FD9E4CF87263DF /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E44790910F40671D4BE434CE7A6555BB /* Pods-DanTangSwift.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-DanTangSwift/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_DanTangSwift; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + F383079BFBF927813EA3613CFB679FDE /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B1E92370C95FFA4392FC05E878A535DF /* Alamofire.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Alamofire/Alamofire-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Alamofire/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Alamofire/Alamofire.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = Alamofire; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1164C08154738C62F53EDEFCEDA40073 /* Build configuration list for PBXNativeTarget "SnapKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8128090B5EB4FF873FEE5418196ED24E /* Debug */, + 7EEA9C2D80E95D91A831A55B589F7542 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 015A368F878AC3E2CEAE21DDE8026304 /* Debug */, + 44CDBB6D11DE06DB64D6268622BDC47E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3449AF3BA4F197A249CAB24B453CB784 /* Build configuration list for PBXNativeTarget "SVProgressHUD" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D7ACC6A4FF9873B166B6104C3D409B3E /* Debug */, + 2E09837D92A5BE4E172CE06F6B06E66C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 404F7EB5C0136CDDE3194542723E2E7C /* Build configuration list for PBXNativeTarget "FDFullscreenPopGesture" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C680A2E106D96BBE2560D18E05914D7A /* Debug */, + 088694703F459CD9F0E7F7C9F05580D4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 419E5D95491847CD79841B971A8A3277 /* Build configuration list for PBXNativeTarget "Alamofire" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F383079BFBF927813EA3613CFB679FDE /* Debug */, + 0A29B6F510198AF64EFD762EF6FA97A5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 76E7EFBCEA1340954A03AA68051C2306 /* Build configuration list for PBXNativeTarget "Kingfisher" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6E53245BBAAAB71AD4E0EE52CA99FD28 /* Debug */, + 380C30050278E488BE23DB926933212E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + AC2006EB52C10CA89FA21F536F5769FC /* Build configuration list for PBXNativeTarget "Pods-DanTangSwift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8A80D4A2771FAB9F6F4FCEC87D742C6A /* Debug */, + E69902A0FBB63FA394FD9E4CF87263DF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ED7676258A4FE56AD60939B76BD24B51 /* Build configuration list for PBXNativeTarget "SwiftyJSON" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D02CEA183DB49F444FD0CB7C34F9FB66 /* Debug */, + AEDF27C759D986D2D55907A9472E64DC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Alamofire.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Alamofire.xcscheme new file mode 100644 index 0000000..44dc41e --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Alamofire.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/FDFullscreenPopGesture.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/FDFullscreenPopGesture.xcscheme new file mode 100644 index 0000000..0a9a960 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/FDFullscreenPopGesture.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Kingfisher.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Kingfisher.xcscheme new file mode 100644 index 0000000..76c33f4 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Kingfisher.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Pods-DanTangSwift.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Pods-DanTangSwift.xcscheme new file mode 100644 index 0000000..9fb6482 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/Pods-DanTangSwift.xcscheme @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SVProgressHUD.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SVProgressHUD.xcscheme new file mode 100644 index 0000000..f537be1 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SVProgressHUD.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SnapKit.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SnapKit.xcscheme new file mode 100644 index 0000000..cd10baf --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SnapKit.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SwiftyJSON.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SwiftyJSON.xcscheme new file mode 100644 index 0000000..1bf4875 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/SwiftyJSON.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..4b0990d --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/ZTX.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,82 @@ + + + + + SchemeUserState + + Alamofire.xcscheme + + isShown + + + FDFullscreenPopGesture.xcscheme + + isShown + + + Kingfisher.xcscheme + + isShown + + + Pods-DanTangSwift.xcscheme + + isShown + + + SVProgressHUD.xcscheme + + isShown + + + SnapKit.xcscheme + + isShown + + + SwiftyJSON.xcscheme + + isShown + + + + SuppressBuildableAutocreation + + 0F71FC248875B67F53494C44B17B40EB + + primary + + + 407B0D854F5D22F49E4B8182E4170661 + + primary + + + 60B0AF289DE8AC7FC0376BE9539069F1 + + primary + + + 7C93740F8DAECC871D081AA4C909D0AD + + primary + + + 88E9EC28B8B46C3631E6B242B50F4442 + + primary + + + 8A83C725DBFF5900754DFD3958596E0D + + primary + + + C4944FEC314D1A66588651D006273ADE + + primary + + + + + diff --git a/Pods/SVProgressHUD/LICENSE.txt b/Pods/SVProgressHUD/LICENSE.txt new file mode 100644 index 0000000..7c5f87f --- /dev/null +++ b/Pods/SVProgressHUD/LICENSE.txt @@ -0,0 +1,26 @@ +Copyright (c) 2011-2016 Sam Vermette, Tobias Tiemerding and contributors. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +A different license may apply to other resources included in this package, +including Freepik Icons. Please consult their +respective headers for the terms of their individual licenses. diff --git a/Pods/SVProgressHUD/README.md b/Pods/SVProgressHUD/README.md new file mode 100644 index 0000000..ae5587c --- /dev/null +++ b/Pods/SVProgressHUD/README.md @@ -0,0 +1,200 @@ +# SVProgressHUD + +![Pod Version](https://img.shields.io/cocoapods/v/SVProgressHUD.svg?style=flat) +![Pod Platform](https://img.shields.io/cocoapods/p/SVProgressHUD.svg?style=flat) +![Pod License](https://img.shields.io/cocoapods/l/SVProgressHUD.svg?style=flat) +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + +`SVProgressHUD` is a clean and easy-to-use HUD meant to display the progress of an ongoing task on iOS and tvOS. + +![SVProgressHUD](http://f.cl.ly/items/2G1F1Z0M0k0h2U3V1p39/SVProgressHUD.gif) + +## Demo + +Try `SVProgressHUD` on [Appetize.io](https://appetize.io/app/p8r2cvy8kq74x7q7tjqf5gyatr). + +## Installation + +### From CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like `SVProgressHUD` in your projects. First, add the following line to your [Podfile](http://guides.cocoapods.org/using/using-cocoapods.html): + +```ruby +pod 'SVProgressHUD' +``` + +If you want to use the latest features of `SVProgressHUD` use normal external source dependencies. + +```ruby +pod 'SVProgressHUD', :git => 'https://github.com/SVProgressHUD/SVProgressHUD.git' +``` + +This pulls from the `master` branch directly. + +Second, install `SVProgressHUD` into your project: + +```ruby +pod install +``` + +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate `SVProgressHUD` into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "SVProgressHUD/SVProgressHUD" +``` + +Run `carthage update` to build the framework and drag the built `SVProgressHUD.framework` (in Carthage/Build/iOS folder) into your Xcode project (Linked Frameworks and Libraries in `Targets`). + + +### Manually + +* Drag the `SVProgressHUD/SVProgressHUD` folder into your project. +* Take care that `SVProgressHUD.bundle` is added to `Targets->Build Phases->Copy Bundle Resources`. +* Add the **QuartzCore** framework to your project. + +## Swift + +Even though `SVProgressHUD` is written in Objective-C, it can be used in Swift with no hassle. If you use [CocoaPods](http://cocoapods.org) add the following line to your [Podfile](http://guides.cocoapods.org/using/using-cocoapods.html): + +```ruby +use_frameworks! +``` + +If you added `SVProgressHUD` manually, just add a [bridging header](https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) file to your project with the `SVProgressHUD` header included. + +## Usage + +(see sample Xcode project in `/Demo`) + +`SVProgressHUD` is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call `[SVProgressHUD method]`). + +**Use `SVProgressHUD` wisely! Only use it if you absolutely need to perform a task before taking the user forward. Bad use case examples: pull to refresh, infinite scrolling, sending message.** + +Using `SVProgressHUD` in your app will usually look as simple as this (using Grand Central Dispatch): + +```objective-c +[SVProgressHUD show]; +dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // time-consuming task + dispatch_async(dispatch_get_main_queue(), ^{ + [SVProgressHUD dismiss]; + }); +}); +``` + +### Showing the HUD + +You can show the status of indeterminate tasks using one of the following: + +```objective-c ++ (void)show; ++ (void)showWithStatus:(NSString*)string; +``` + +If you'd like the HUD to reflect the progress of a task, use one of these: + +```objective-c ++ (void)showProgress:(CGFloat)progress; ++ (void)showProgress:(CGFloat)progress status:(NSString*)status; +``` + +### Dismissing the HUD + +The HUD can be dismissed using: + +```objective-c ++ (void)dismiss; ++ (void)dismissWithDelay:(NSTimeInterval)delay; +``` + +If you'd like to stack HUDs, you can balance out every show call using: + +```objective-c ++ (void)popActivity; +``` + +The HUD will get dismissed once the `popActivity` calls will match the number of show calls. + +Or show a confirmation glyph before before getting dismissed a little bit later. The display time depends on `minimumDismissTimeInterval` and the length of the given string. + +```objective-c ++ (void)showInfoWithStatus:(NSString*)string; ++ (void)showSuccessWithStatus:(NSString*)string; ++ (void)showErrorWithStatus:(NSString*)string; ++ (void)showImage:(UIImage*)image status:(NSString*)string; +``` + +## Customization + +`SVProgressHUD` can be customized via the following methods: + +```objective-c ++ (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight ++ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone ++ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat ++ (void)setContainerView:(UIView*)containerView; // default is window level ++ (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing ++ (void)setRingThickness:(CGFloat)width; // default is 2 pt ++ (void)setRingRadius:(CGFloat)radius; // default is 18 pt ++ (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt ++ (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt ++ (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline] ++ (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom ++ (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom ++ (void)setBackgroundLayerColor:(UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.4], only used for SVProgressHUDMaskTypeCustom ++ (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik ++ (void)setSuccessImage:(UIImage*)image; // default is bundled success image from Freepik ++ (void)setErrorImage:(UIImage*)image; // default is bundled error image from Freepik ++ (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set ++ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds ++ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval; // default is infinite ++ (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds ++ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds ++ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel; // default is UIWindowLevelNormal +``` + +Additionally `SVProgressHUD` supports the `UIAppearance` protocol for most of the above methods. + +### Hint + +As standard `SVProgressHUD` offers two preconfigured styles: + +* `SVProgressHUDStyleLight`: White background with black spinner and text +* `SVProgressHUDStyleDark`: Black background with white spinner and text + +If you want to use custom colors use `setForegroundColor` and `setBackgroundColor:`. These implicity set the HUD's style to `SVProgressHUDStyleCustom`. + +## Notifications + +`SVProgressHUD` posts four notifications via `NSNotificationCenter` in response to being shown/dismissed: +* `SVProgressHUDWillAppearNotification` when the show animation starts +* `SVProgressHUDDidAppearNotification` when the show animation completes +* `SVProgressHUDWillDisappearNotification` when the dismiss animation starts +* `SVProgressHUDDidDisappearNotification` when the dismiss animation completes + +Each notification passes a `userInfo` dictionary holding the HUD's status string (if any), retrievable via `SVProgressHUDStatusUserInfoKey`. + +`SVProgressHUD` also posts `SVProgressHUDDidReceiveTouchEventNotification` when users touch on the overall screen or `SVProgressHUDDidTouchDownInsideNotification` when a user touches on the HUD directly. For this notifications `userInfo` is not passed but the object parameter contains the `UIEvent` that related to the touch. + +## App Extensions + +When using `SVProgressHUD` in an App Extension, `#define SV_APP_EXTENSIONS` to avoid using unavailable APIs. Additionally call `setViewForExtension:` from your extensions view controller with `self.view`. + +## Contributing to this project + +If you have feature requests or bug reports, feel free to help out by sending pull requests or by [creating new issues](https://github.com/SVProgressHUD/SVProgressHUD/issues/new). Please take a moment to +review the guidelines written by [Nicolas Gallagher](https://github.com/necolas): + +* [Bug reports](https://github.com/necolas/issue-guidelines/blob/master/CONTRIBUTING.md#bugs) +* [Feature requests](https://github.com/necolas/issue-guidelines/blob/master/CONTRIBUTING.md#features) +* [Pull requests](https://github.com/necolas/issue-guidelines/blob/master/CONTRIBUTING.md#pull-requests) + +## License + +`SVProgressHUD` is distributed under the terms and conditions of the [MIT license](https://github.com/SVProgressHUD/SVProgressHUD/blob/master/LICENSE.txt). The success, error and info icons are made by [Freepik](http://www.freepik.com) from [Flaticon](http://www.flaticon.com) and are licensed under [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/). + +## Credits + +`SVProgressHUD` is brought to you by [Sam Vermette](http://samvermette.com), [Tobias Tiemerding](http://tiemerding.com) and [contributors to the project](https://github.com/SVProgressHUD/SVProgressHUD/contributors). If you're using `SVProgressHUD` in your project, attribution would be very appreciated. diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVIndefiniteAnimatedView.h b/Pods/SVProgressHUD/SVProgressHUD/SVIndefiniteAnimatedView.h new file mode 100644 index 0000000..d6f1eaf --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVIndefiniteAnimatedView.h @@ -0,0 +1,17 @@ +// +// SVIndefiniteAnimatedView.h +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2014-2016 Guillaume Campagna. All rights reserved. +// + +#import + +@interface SVIndefiniteAnimatedView : UIView + +@property (nonatomic, assign) CGFloat strokeThickness; +@property (nonatomic, assign) CGFloat radius; +@property (nonatomic, strong) UIColor *strokeColor; + +@end + diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVIndefiniteAnimatedView.m b/Pods/SVProgressHUD/SVProgressHUD/SVIndefiniteAnimatedView.m new file mode 100644 index 0000000..235a0f9 --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVIndefiniteAnimatedView.m @@ -0,0 +1,137 @@ +// +// SVIndefiniteAnimatedView.m +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2014-2016 Guillaume Campagna. All rights reserved. +// + +#import "SVIndefiniteAnimatedView.h" +#import "SVProgressHUD.h" + +@interface SVIndefiniteAnimatedView () + +@property (nonatomic, strong) CAShapeLayer *indefiniteAnimatedLayer; + +@end + +@implementation SVIndefiniteAnimatedView + +- (void)willMoveToSuperview:(UIView*)newSuperview { + if (newSuperview) { + [self layoutAnimatedLayer]; + } else { + [_indefiniteAnimatedLayer removeFromSuperlayer]; + _indefiniteAnimatedLayer = nil; + } +} + +- (void)layoutAnimatedLayer { + CALayer *layer = self.indefiniteAnimatedLayer; + [self.layer addSublayer:layer]; + + CGFloat widthDiff = CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds); + CGFloat heightDiff = CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds); + layer.position = CGPointMake(CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds) / 2 - widthDiff / 2, CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds) / 2 - heightDiff / 2); +} + +- (CAShapeLayer*)indefiniteAnimatedLayer { + if(!_indefiniteAnimatedLayer) { + CGPoint arcCenter = CGPointMake(self.radius+self.strokeThickness/2+5, self.radius+self.strokeThickness/2+5); + UIBezierPath* smoothedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:self.radius startAngle:(CGFloat) (M_PI*3/2) endAngle:(CGFloat) (M_PI/2+M_PI*5) clockwise:YES]; + + _indefiniteAnimatedLayer = [CAShapeLayer layer]; + _indefiniteAnimatedLayer.contentsScale = [[UIScreen mainScreen] scale]; + _indefiniteAnimatedLayer.frame = CGRectMake(0.0f, 0.0f, arcCenter.x*2, arcCenter.y*2); + _indefiniteAnimatedLayer.fillColor = [UIColor clearColor].CGColor; + _indefiniteAnimatedLayer.strokeColor = self.strokeColor.CGColor; + _indefiniteAnimatedLayer.lineWidth = self.strokeThickness; + _indefiniteAnimatedLayer.lineCap = kCALineCapRound; + _indefiniteAnimatedLayer.lineJoin = kCALineJoinBevel; + _indefiniteAnimatedLayer.path = smoothedPath.CGPath; + + CALayer *maskLayer = [CALayer layer]; + + NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]]; + NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"]; + NSBundle *imageBundle = [NSBundle bundleWithURL:url]; + + NSString *path = [imageBundle pathForResource:@"angle-mask" ofType:@"png"]; + + maskLayer.contents = (__bridge id)[[UIImage imageWithContentsOfFile:path] CGImage]; + maskLayer.frame = _indefiniteAnimatedLayer.bounds; + _indefiniteAnimatedLayer.mask = maskLayer; + + NSTimeInterval animationDuration = 1; + CAMediaTimingFunction *linearCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; + + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; + animation.fromValue = (id) 0; + animation.toValue = @(M_PI*2); + animation.duration = animationDuration; + animation.timingFunction = linearCurve; + animation.removedOnCompletion = NO; + animation.repeatCount = INFINITY; + animation.fillMode = kCAFillModeForwards; + animation.autoreverses = NO; + [_indefiniteAnimatedLayer.mask addAnimation:animation forKey:@"rotate"]; + + CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; + animationGroup.duration = animationDuration; + animationGroup.repeatCount = INFINITY; + animationGroup.removedOnCompletion = NO; + animationGroup.timingFunction = linearCurve; + + CABasicAnimation *strokeStartAnimation = [CABasicAnimation animationWithKeyPath:@"strokeStart"]; + strokeStartAnimation.fromValue = @0.015; + strokeStartAnimation.toValue = @0.515; + + CABasicAnimation *strokeEndAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; + strokeEndAnimation.fromValue = @0.485; + strokeEndAnimation.toValue = @0.985; + + animationGroup.animations = @[strokeStartAnimation, strokeEndAnimation]; + [_indefiniteAnimatedLayer addAnimation:animationGroup forKey:@"progress"]; + + } + return _indefiniteAnimatedLayer; +} + +- (void)setFrame:(CGRect)frame { + if(!CGRectEqualToRect(frame, super.frame)) { + [super setFrame:frame]; + + if(self.superview) { + [self layoutAnimatedLayer]; + } + } + +} + +- (void)setRadius:(CGFloat)radius { + if(radius != _radius) { + _radius = radius; + + [_indefiniteAnimatedLayer removeFromSuperlayer]; + _indefiniteAnimatedLayer = nil; + + if(self.superview) { + [self layoutAnimatedLayer]; + } + } +} + +- (void)setStrokeColor:(UIColor*)strokeColor { + _strokeColor = strokeColor; + _indefiniteAnimatedLayer.strokeColor = strokeColor.CGColor; +} + +- (void)setStrokeThickness:(CGFloat)strokeThickness { + _strokeThickness = strokeThickness; + _indefiniteAnimatedLayer.lineWidth = _strokeThickness; +} + +- (CGSize)sizeThatFits:(CGSize)size { + return CGSizeMake((self.radius+self.strokeThickness/2+5)*2, (self.radius+self.strokeThickness/2+5)*2); +} + +@end diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressAnimatedView.h b/Pods/SVProgressHUD/SVProgressHUD/SVProgressAnimatedView.h new file mode 100644 index 0000000..6b4d54a --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVProgressAnimatedView.h @@ -0,0 +1,17 @@ +// +// SVProgressAnimatedView.h +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2016 Tobias Tiemerding. All rights reserved. +// + +#import + +@interface SVProgressAnimatedView : UIView + +@property (nonatomic, assign) CGFloat radius; +@property (nonatomic, assign) CGFloat strokeThickness; +@property (nonatomic, strong) UIColor *strokeColor; +@property (nonatomic, assign) CGFloat strokeEnd; + +@end diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressAnimatedView.m b/Pods/SVProgressHUD/SVProgressHUD/SVProgressAnimatedView.m new file mode 100644 index 0000000..156de23 --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVProgressAnimatedView.m @@ -0,0 +1,96 @@ +// +// SVProgressAnimatedView.m +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2016 Tobias Tiemerding. All rights reserved. +// + +#import "SVProgressAnimatedView.h" + +@interface SVProgressAnimatedView () + +@property (nonatomic, strong) CAShapeLayer *ringAnimatedLayer; + +@end + +@implementation SVProgressAnimatedView + +- (void)willMoveToSuperview:(UIView*)newSuperview { + if (newSuperview) { + [self layoutAnimatedLayer]; + } else { + [_ringAnimatedLayer removeFromSuperlayer]; + _ringAnimatedLayer = nil; + } +} + +- (void)layoutAnimatedLayer { + CALayer *layer = self.ringAnimatedLayer; + [self.layer addSublayer:layer]; + + CGFloat widthDiff = CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds); + CGFloat heightDiff = CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds); + layer.position = CGPointMake(CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds) / 2 - widthDiff / 2, CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds) / 2 - heightDiff / 2); +} + +- (CAShapeLayer*)ringAnimatedLayer { + if(!_ringAnimatedLayer) { + CGPoint arcCenter = CGPointMake(self.radius+self.strokeThickness/2+5, self.radius+self.strokeThickness/2+5); + UIBezierPath* smoothedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:self.radius startAngle:(CGFloat)-M_PI_2 endAngle:(CGFloat) (M_PI + M_PI_2) clockwise:YES]; + + _ringAnimatedLayer = [CAShapeLayer layer]; + _ringAnimatedLayer.contentsScale = [[UIScreen mainScreen] scale]; + _ringAnimatedLayer.frame = CGRectMake(0.0f, 0.0f, arcCenter.x*2, arcCenter.y*2); + _ringAnimatedLayer.fillColor = [UIColor clearColor].CGColor; + _ringAnimatedLayer.strokeColor = self.strokeColor.CGColor; + _ringAnimatedLayer.lineWidth = self.strokeThickness; + _ringAnimatedLayer.lineCap = kCALineCapRound; + _ringAnimatedLayer.lineJoin = kCALineJoinBevel; + _ringAnimatedLayer.path = smoothedPath.CGPath; + } + return _ringAnimatedLayer; +} + +- (void)setFrame:(CGRect)frame { + if(!CGRectEqualToRect(frame, super.frame)) { + [super setFrame:frame]; + + if(self.superview) { + [self layoutAnimatedLayer]; + } + } +} + +- (void)setRadius:(CGFloat)radius { + if(radius != _radius) { + _radius = radius; + + [_ringAnimatedLayer removeFromSuperlayer]; + _ringAnimatedLayer = nil; + + if(self.superview) { + [self layoutAnimatedLayer]; + } + } +} + +- (void)setStrokeColor:(UIColor*)strokeColor { + _strokeColor = strokeColor; + _ringAnimatedLayer.strokeColor = strokeColor.CGColor; +} + +- (void)setStrokeThickness:(CGFloat)strokeThickness { + _strokeThickness = strokeThickness; + _ringAnimatedLayer.lineWidth = _strokeThickness; +} + +- (void)setStrokeEnd:(CGFloat)strokeEnd { + _strokeEnd = strokeEnd; + _ringAnimatedLayer.strokeEnd = _strokeEnd; +} + +- (CGSize)sizeThatFits:(CGSize)size { + return CGSizeMake((self.radius+self.strokeThickness/2+5)*2, (self.radius+self.strokeThickness/2+5)*2); +} + +@end diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask.png new file mode 100644 index 0000000..0150a03 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask@2x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask@2x.png new file mode 100644 index 0000000..9a302b6 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask@2x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask@3x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask@3x.png new file mode 100644 index 0000000..d07f3ce Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/angle-mask@3x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error.png new file mode 100644 index 0000000..a57c8e4 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error@2x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error@2x.png new file mode 100644 index 0000000..aaf6798 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error@2x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error@3x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error@3x.png new file mode 100644 index 0000000..c92518f Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/error@3x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info.png new file mode 100644 index 0000000..a3a1f75 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info@2x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info@2x.png new file mode 100644 index 0000000..1b333e7 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info@2x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info@3x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info@3x.png new file mode 100644 index 0000000..d56aa0c Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/info@3x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success.png new file mode 100644 index 0000000..44769d0 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success@2x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success@2x.png new file mode 100644 index 0000000..a9d1653 Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success@2x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success@3x.png b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success@3x.png new file mode 100644 index 0000000..42bad9b Binary files /dev/null and b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle/success@3x.png differ diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.h b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.h new file mode 100644 index 0000000..efb13f6 --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.h @@ -0,0 +1,142 @@ +// +// SVProgressHUD.h +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2011-2016 Sam Vermette and contributors. All rights reserved. +// + +#import +#import + +#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000 + +#define UI_APPEARANCE_SELECTOR + +#endif + +extern NSString * const SVProgressHUDDidReceiveTouchEventNotification; +extern NSString * const SVProgressHUDDidTouchDownInsideNotification; +extern NSString * const SVProgressHUDWillDisappearNotification; +extern NSString * const SVProgressHUDDidDisappearNotification; +extern NSString * const SVProgressHUDWillAppearNotification; +extern NSString * const SVProgressHUDDidAppearNotification; + +extern NSString * const SVProgressHUDStatusUserInfoKey; + +typedef NS_ENUM(NSInteger, SVProgressHUDStyle) { + SVProgressHUDStyleLight, // default style, white HUD with black text, HUD background will be blurred on iOS 8 and above + SVProgressHUDStyleDark, // black HUD and white text, HUD background will be blurred on iOS 8 and above + SVProgressHUDStyleCustom // uses the fore- and background color properties +}; + +typedef NS_ENUM(NSUInteger, SVProgressHUDMaskType) { + SVProgressHUDMaskTypeNone = 1, // default mask type, allow user interactions while HUD is displayed + SVProgressHUDMaskTypeClear, // don't allow user interactions + SVProgressHUDMaskTypeBlack, // don't allow user interactions and dim the UI in the back of the HUD, as on iOS 7 and above + SVProgressHUDMaskTypeGradient, // don't allow user interactions and dim the UI with a a-la UIAlertView background gradient, as on iOS 6 + SVProgressHUDMaskTypeCustom // don't allow user interactions and dim the UI in the back of the HUD with a custom color +}; + +typedef NS_ENUM(NSUInteger, SVProgressHUDAnimationType) { + SVProgressHUDAnimationTypeFlat, // default animation type, custom flat animation (indefinite animated ring) + SVProgressHUDAnimationTypeNative // iOS native UIActivityIndicatorView +}; + +typedef void (^SVProgressHUDShowCompletion)(void); +typedef void (^SVProgressHUDDismissCompletion)(void); + +@interface SVProgressHUD : UIView + +#pragma mark - Customization + +@property (assign, nonatomic) SVProgressHUDStyle defaultStyle UI_APPEARANCE_SELECTOR; // default is SVProgressHUDStyleLight +@property (assign, nonatomic) SVProgressHUDMaskType defaultMaskType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDMaskTypeNone +@property (assign, nonatomic) SVProgressHUDAnimationType defaultAnimationType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDAnimationTypeFlat +@property (strong, nonatomic) UIView *containerView; // if nil then use default window level +@property (assign, nonatomic) CGSize minimumSize UI_APPEARANCE_SELECTOR; // default is CGSizeZero, can be used to avoid resizing for a larger message +@property (assign, nonatomic) CGFloat ringThickness UI_APPEARANCE_SELECTOR; // default is 2 pt +@property (assign, nonatomic) CGFloat ringRadius UI_APPEARANCE_SELECTOR; // default is 18 pt +@property (assign, nonatomic) CGFloat ringNoTextRadius UI_APPEARANCE_SELECTOR; // default is 24 pt +@property (assign, nonatomic) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; // default is 14 pt +@property (strong, nonatomic) UIFont *font UI_APPEARANCE_SELECTOR; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline] +@property (strong, nonatomic) UIColor *backgroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor whiteColor] +@property (strong, nonatomic) UIColor *foregroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor blackColor] +@property (strong, nonatomic) UIColor *backgroundLayerColor UI_APPEARANCE_SELECTOR; // default is [UIColor colorWithWhite:0 alpha:0.4] +@property (strong, nonatomic) UIImage *infoImage UI_APPEARANCE_SELECTOR; // default is the bundled info image provided by Freepik +@property (strong, nonatomic) UIImage *successImage UI_APPEARANCE_SELECTOR; // default is the bundled success image provided by Freepik +@property (strong, nonatomic) UIImage *errorImage UI_APPEARANCE_SELECTOR; // default is the bundled error image provided by Freepik +@property (strong, nonatomic) UIView *viewForExtension UI_APPEARANCE_SELECTOR; // default is nil, only used if #define SV_APP_EXTENSIONS is set +@property (assign, nonatomic) NSTimeInterval minimumDismissTimeInterval; // default is 5.0 seconds +@property (assign, nonatomic) NSTimeInterval maximumDismissTimeInterval; // default is infinite + +@property (assign, nonatomic) UIOffset offsetFromCenter UI_APPEARANCE_SELECTOR; // default is 0, 0 + +@property (assign, nonatomic) NSTimeInterval fadeInAnimationDuration UI_APPEARANCE_SELECTOR; // default is 0.15 +@property (assign, nonatomic) NSTimeInterval fadeOutAnimationDuration UI_APPEARANCE_SELECTOR; // default is 0.15 + +@property (assign, nonatomic) UIWindowLevel maxSupportedWindowLevel; // default is UIWindowLevelNormal + ++ (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight ++ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone ++ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat ++ (void)setContainerView:(UIView*)containerView; // default is window level ++ (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing for a larger message ++ (void)setRingThickness:(CGFloat)ringThickness; // default is 2 pt ++ (void)setRingRadius:(CGFloat)radius; // default is 18 pt ++ (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt ++ (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt ++ (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline] ++ (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom ++ (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom ++ (void)setBackgroundLayerColor:(UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.5], only used for SVProgressHUDMaskTypeBlack ++ (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik ++ (void)setSuccessImage:(UIImage*)image; // default is the bundled success image provided by Freepik ++ (void)setErrorImage:(UIImage*)image; // default is the bundled error image provided by Freepik ++ (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set ++ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds ++ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval; // default is infinite ++ (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds ++ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds ++ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel; // default is UIWindowLevelNormal + +#pragma mark - Show Methods + ++ (void)show; ++ (void)showWithMaskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use show and setDefaultMaskType: instead."))); ++ (void)showWithStatus:(NSString*)status; ++ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showWithStatus: and setDefaultMaskType: instead."))); + ++ (void)showProgress:(float)progress; ++ (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress: and setDefaultMaskType: instead."))); ++ (void)showProgress:(float)progress status:(NSString*)status; ++ (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress:status: and setDefaultMaskType: instead."))); + ++ (void)setStatus:(NSString*)status; // change the HUD loading status while it's showing + +// stops the activity indicator, shows a glyph + status, and dismisses the HUD a little bit later ++ (void)showInfoWithStatus:(NSString*)status; ++ (void)showInfoWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showInfoWithStatus: and setDefaultMaskType: instead."))); ++ (void)showSuccessWithStatus:(NSString*)status; ++ (void)showSuccessWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showSuccessWithStatus: and setDefaultMaskType: instead."))); ++ (void)showErrorWithStatus:(NSString*)status; ++ (void)showErrorWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showErrorWithStatus: and setDefaultMaskType: instead."))); + +// shows a image + status, use 28x28 white PNGs ++ (void)showImage:(UIImage*)image status:(NSString*)status; ++ (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showImage:status: and setDefaultMaskType: instead."))); + ++ (void)setOffsetFromCenter:(UIOffset)offset; ++ (void)resetOffsetFromCenter; + ++ (void)popActivity; // decrease activity count, if activity count == 0 the HUD is dismissed ++ (void)dismiss; ++ (void)dismissWithCompletion:(SVProgressHUDDismissCompletion)completion; ++ (void)dismissWithDelay:(NSTimeInterval)delay; ++ (void)dismissWithDelay:(NSTimeInterval)delay completion:(SVProgressHUDDismissCompletion)completion; + ++ (BOOL)isVisible; + ++ (NSTimeInterval)displayDurationForString:(NSString*)string; + +@end + diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m new file mode 100644 index 0000000..3ed6937 --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.m @@ -0,0 +1,1459 @@ +// +// SVProgressHUD.h +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2011-2016 Sam Vermette and contributors. All rights reserved. +// + +#if !__has_feature(objc_arc) +#error SVProgressHUD is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#endif + +#import "SVProgressHUD.h" +#import "SVIndefiniteAnimatedView.h" +#import "SVProgressAnimatedView.h" +#import "SVRadialGradientLayer.h" + +NSString * const SVProgressHUDDidReceiveTouchEventNotification = @"SVProgressHUDDidReceiveTouchEventNotification"; +NSString * const SVProgressHUDDidTouchDownInsideNotification = @"SVProgressHUDDidTouchDownInsideNotification"; +NSString * const SVProgressHUDWillDisappearNotification = @"SVProgressHUDWillDisappearNotification"; +NSString * const SVProgressHUDDidDisappearNotification = @"SVProgressHUDDidDisappearNotification"; +NSString * const SVProgressHUDWillAppearNotification = @"SVProgressHUDWillAppearNotification"; +NSString * const SVProgressHUDDidAppearNotification = @"SVProgressHUDDidAppearNotification"; + +NSString * const SVProgressHUDStatusUserInfoKey = @"SVProgressHUDStatusUserInfoKey"; + +static const CGFloat SVProgressHUDParallaxDepthPoints = 10.0f; +static const CGFloat SVProgressHUDUndefinedProgress = -1; +static const CGFloat SVProgressHUDDefaultAnimationDuration = 0.15f; +static const CGFloat SVProgressHUDVerticalSpacing = 12.0f; +static const CGFloat SVProgressHUDHorizontalSpacing = 12.0f; +static const CGFloat SVProgressHUDLabelSpacing = 8.0f; + + +@interface SVProgressHUD () + +@property (nonatomic, strong) NSTimer *fadeOutTimer; + +@property (nonatomic, strong) UIControl *controlView; +@property (nonatomic, strong) UIView *backgroundView; +@property (nonatomic, strong) SVRadialGradientLayer *backgroundRadialGradientLayer; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 +@property (nonatomic, strong) UIVisualEffectView *hudView; +@property (nonatomic, strong) UIVisualEffectView *hudVibrancyView; +#else +@property (nonatomic, strong) UIView *hudView; +#endif +@property (nonatomic, strong) UILabel *statusLabel; +@property (nonatomic, strong) UIImageView *imageView; + +@property (nonatomic, strong) UIView *indefiniteAnimatedView; +@property (nonatomic, strong) SVProgressAnimatedView *ringView; +@property (nonatomic, strong) SVProgressAnimatedView *backgroundRingView; + +@property (nonatomic, readwrite) CGFloat progress; +@property (nonatomic, readwrite) NSUInteger activityCount; + +@property (nonatomic, readonly) CGFloat visibleKeyboardHeight; +@property (nonatomic, readonly) UIWindow *frontWindow; + +- (void)updateHUDFrame; + +#if TARGET_OS_IOS +- (void)updateMotionEffectForOrientation:(UIInterfaceOrientation)orientation; +#endif +- (void)updateMotionEffectForXMotionEffectType:(UIInterpolatingMotionEffectType)xMotionEffectType yMotionEffectType:(UIInterpolatingMotionEffectType)yMotionEffectType; +- (void)updateViewHierarchy; + +- (void)setStatus:(NSString*)status; +- (void)setFadeOutTimer:(NSTimer*)timer; + +- (void)registerNotifications; +- (NSDictionary*)notificationUserInfo; + +- (void)positionHUD:(NSNotification*)notification; +- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle; + +- (void)controlViewDidReceiveTouchEvent:(id)sender forEvent:(UIEvent*)event; + +- (void)showProgress:(float)progress status:(NSString*)status; +- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration; +- (void)showStatus:(NSString*)status; + +- (void)dismiss; +- (void)dismissWithDelay:(NSTimeInterval)delay completion:(SVProgressHUDDismissCompletion)completion; + +- (void)cancelRingLayerAnimation; +- (void)cancelIndefiniteAnimatedViewAnimation; + +- (UIColor*)foregroundColorForStyle; +- (UIColor*)backgroundColorForStyle; + +@end + +@implementation SVProgressHUD { + BOOL _isInitializing; +} + ++ (SVProgressHUD*)sharedView { + static dispatch_once_t once; + + static SVProgressHUD *sharedView; +#if !defined(SV_APP_EXTENSIONS) + dispatch_once(&once, ^{ sharedView = [[self alloc] initWithFrame:[[[UIApplication sharedApplication] delegate] window].bounds]; }); +#else + dispatch_once(&once, ^{ sharedView = [[self alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; }); +#endif + return sharedView; +} + + +#pragma mark - Setters + ++ (void)setStatus:(NSString*)status { + [[self sharedView] setStatus:status]; +} + ++ (void)setDefaultStyle:(SVProgressHUDStyle)style { + [self sharedView].defaultStyle = style; + [self sharedView].hudView.alpha = style != SVProgressHUDStyleCustom ? 1.0f : 0.0f; +} + ++ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType { + [self sharedView].defaultMaskType = maskType; +} + ++ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type { + [self sharedView].defaultAnimationType = type; +} + ++ (void)setContainerView:(UIView *)containerView { + [self sharedView].containerView = containerView; +} + ++ (void)setMinimumSize:(CGSize)minimumSize { + [self sharedView].minimumSize = minimumSize; +} + ++ (void)setRingThickness:(CGFloat)ringThickness { + [self sharedView].ringThickness = ringThickness; +} + ++ (void)setRingRadius:(CGFloat)radius { + [self sharedView].ringRadius = radius; +} + ++ (void)setRingNoTextRadius:(CGFloat)radius { + [self sharedView].ringNoTextRadius = radius; +} + ++ (void)setCornerRadius:(CGFloat)cornerRadius { + [self sharedView].cornerRadius = cornerRadius; +} + ++ (void)setFont:(UIFont*)font { + [self sharedView].font = font; +} + ++ (void)setForegroundColor:(UIColor*)color { + [self sharedView].foregroundColor = color; + [self setDefaultStyle:SVProgressHUDStyleCustom]; +} + ++ (void)setBackgroundColor:(UIColor*)color { + [self sharedView].backgroundColor = color; + [self setDefaultStyle:SVProgressHUDStyleCustom]; +} + ++ (void)setBackgroundLayerColor:(UIColor*)color { + [self sharedView].backgroundLayerColor = color; +} + ++ (void)setInfoImage:(UIImage*)image { + [self sharedView].infoImage = image; +} + ++ (void)setSuccessImage:(UIImage*)image { + [self sharedView].successImage = image; +} + ++ (void)setErrorImage:(UIImage*)image { + [self sharedView].errorImage = image; +} + ++ (void)setViewForExtension:(UIView*)view { + [self sharedView].viewForExtension = view; +} + ++ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval { + [self sharedView].minimumDismissTimeInterval = interval; +} + ++ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval { + [self sharedView].maximumDismissTimeInterval = interval; +} + ++ (void)setFadeInAnimationDuration:(NSTimeInterval)duration { + [self sharedView].fadeInAnimationDuration = duration; +} + ++ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration { + [self sharedView].fadeOutAnimationDuration = duration; +} + ++ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel { + [self sharedView].maxSupportedWindowLevel = windowLevel; +} + + +#pragma mark - Show Methods + ++ (void)show { + [self showWithStatus:nil]; +} + ++ (void)showWithMaskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self show]; + [self setDefaultMaskType:existingMaskType]; +} + ++ (void)showWithStatus:(NSString*)status { + [self showProgress:SVProgressHUDUndefinedProgress status:status]; +} + ++ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showWithStatus:status]; + [self setDefaultMaskType:existingMaskType]; +} + ++ (void)showProgress:(float)progress { + [self showProgress:progress status:nil]; +} + ++ (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showProgress:progress]; + [self setDefaultMaskType:existingMaskType]; +} + ++ (void)showProgress:(float)progress status:(NSString*)status { + [[self sharedView] showProgress:progress status:status]; +} + ++ (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showProgress:progress status:status]; + [self setDefaultMaskType:existingMaskType]; +} + + +#pragma mark - Show, then automatically dismiss methods + ++ (void)showInfoWithStatus:(NSString*)status { + [self showImage:[self sharedView].infoImage status:status]; +} + ++ (void)showInfoWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showInfoWithStatus:status]; + [self setDefaultMaskType:existingMaskType]; +} + ++ (void)showSuccessWithStatus:(NSString*)status { + [self showImage:[self sharedView].successImage status:status]; +} + ++ (void)showSuccessWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showSuccessWithStatus:status]; + [self setDefaultMaskType:existingMaskType]; +} + ++ (void)showErrorWithStatus:(NSString*)status { + [self showImage:[self sharedView].errorImage status:status]; +} + ++ (void)showErrorWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showErrorWithStatus:status]; + [self setDefaultMaskType:existingMaskType]; +} + ++ (void)showImage:(UIImage*)image status:(NSString*)status { + NSTimeInterval displayInterval = [self displayDurationForString:status]; + [[self sharedView] showImage:image status:status duration:displayInterval]; +} + ++ (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType { + SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType; + [self setDefaultMaskType:maskType]; + [self showImage:image status:status]; + [self setDefaultMaskType:existingMaskType]; +} + + +#pragma mark - Dismiss Methods + ++ (void)popActivity { + if([self sharedView].activityCount > 0) { + [self sharedView].activityCount--; + } + if([self sharedView].activityCount == 0) { + [[self sharedView] dismiss]; + } +} + ++ (void)dismiss { + [self dismissWithDelay:0.0 completion:nil]; +} + ++ (void)dismissWithCompletion:(SVProgressHUDDismissCompletion)completion { + [self dismissWithDelay:0.0 completion:completion]; +} + ++ (void)dismissWithDelay:(NSTimeInterval)delay { + [self dismissWithDelay:delay completion:nil]; +} + ++ (void)dismissWithDelay:(NSTimeInterval)delay completion:(SVProgressHUDDismissCompletion)completion { + [[self sharedView] dismissWithDelay:delay completion:completion]; +} + + +#pragma mark - Offset + ++ (void)setOffsetFromCenter:(UIOffset)offset { + [self sharedView].offsetFromCenter = offset; +} + ++ (void)resetOffsetFromCenter { + [self setOffsetFromCenter:UIOffsetZero]; +} + + +#pragma mark - Instance Methods + +- (instancetype)initWithFrame:(CGRect)frame { + if((self = [super initWithFrame:frame])) { + _isInitializing = YES; + + self.userInteractionEnabled = NO; + self.activityCount = 0; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + self.hudView.contentView.alpha = 0.0f; +#else + self.hudView.alpha = 0.0f; +#endif + self.backgroundView.alpha = 0.0f; + + _backgroundColor = [UIColor clearColor]; + _foregroundColor = [UIColor blackColor]; + _backgroundLayerColor = [UIColor colorWithWhite:0 alpha:0.4]; + + // Set default values + _defaultMaskType = SVProgressHUDMaskTypeNone; + _defaultStyle = SVProgressHUDStyleLight; + _defaultAnimationType = SVProgressHUDAnimationTypeFlat; + _minimumSize = CGSizeZero; + _font = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]; + + NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]]; + NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"]; + NSBundle *imageBundle = [NSBundle bundleWithURL:url]; + + UIImage* infoImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"info" ofType:@"png"]]; + UIImage* successImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"success" ofType:@"png"]]; + UIImage* errorImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"error" ofType:@"png"]]; + + _infoImage = [infoImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + _successImage = [successImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + _errorImage = [errorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + + _ringThickness = 2.0f; + _ringRadius = 18.0f; + _ringNoTextRadius = 24.0f; + + _cornerRadius = 14.0f; + + _minimumDismissTimeInterval = 5.0; + _maximumDismissTimeInterval = CGFLOAT_MAX; + + _fadeInAnimationDuration = SVProgressHUDDefaultAnimationDuration; + _fadeOutAnimationDuration = SVProgressHUDDefaultAnimationDuration; + + _maxSupportedWindowLevel = UIWindowLevelNormal; + + // Accessibility support + self.accessibilityIdentifier = @"SVProgressHUD"; + self.accessibilityLabel = @"SVProgressHUD"; + self.isAccessibilityElement = YES; + + _isInitializing = NO; + } + return self; +} + +- (void)updateHUDFrame { + // Check if an image or progress ring is displayed + BOOL imageUsed = (self.imageView.image) && !(self.imageView.hidden); + BOOL progressUsed = self.imageView.hidden; + + // Calculate size of string + CGRect labelRect = CGRectZero; + CGFloat labelHeight = 0.0f; + CGFloat labelWidth = 0.0f; + + if(self.statusLabel.text) { + CGSize constraintSize = CGSizeMake(200.0f, 300.0f); + labelRect = [self.statusLabel.text boundingRectWithSize:constraintSize + options:(NSStringDrawingOptions)(NSStringDrawingUsesFontLeading | NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin) + attributes:@{NSFontAttributeName: self.statusLabel.font} + context:NULL]; + labelHeight = ceilf(CGRectGetHeight(labelRect)); + labelWidth = ceilf(CGRectGetWidth(labelRect)); + } + + // Calculate hud size based on content + // For the beginning use default values, these + // might get update if string is too large etc. + CGFloat hudWidth; + CGFloat hudHeight; + + CGFloat contentWidth = 0.0f; + CGFloat contentHeight = 0.0f; + + if(imageUsed || progressUsed) { + contentWidth = CGRectGetWidth(imageUsed ? self.imageView.frame : self.indefiniteAnimatedView.frame); + contentHeight = CGRectGetHeight(imageUsed ? self.imageView.frame : self.indefiniteAnimatedView.frame); + } + + // |-spacing-content-spacing-| + hudWidth = SVProgressHUDHorizontalSpacing + MAX(labelWidth, contentWidth) + SVProgressHUDHorizontalSpacing; + + // |-spacing-content-(labelSpacing-label-)spacing-| + hudHeight = SVProgressHUDVerticalSpacing + labelHeight + contentHeight + SVProgressHUDVerticalSpacing; + if(self.statusLabel.text && (imageUsed || progressUsed)){ + // Add spacing if both content and label are used + hudHeight += SVProgressHUDLabelSpacing; + } + + // Update values on subviews + self.hudView.bounds = CGRectMake(0.0f, 0.0f, MAX(self.minimumSize.width, hudWidth), MAX(self.minimumSize.height, hudHeight)); +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + self.hudVibrancyView.bounds = self.hudView.bounds; +#endif + + // Animate value update + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + + // Spinner and image view + CGFloat centerY; + if(self.statusLabel.text) { + CGFloat yOffset = MAX(SVProgressHUDVerticalSpacing, (self.minimumSize.height - contentHeight - SVProgressHUDLabelSpacing - labelHeight) / 2.0f); + centerY = yOffset + contentHeight / 2.0f; + } else { + centerY = CGRectGetMidY(self.hudView.bounds); + } + self.indefiniteAnimatedView.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY); + if(self.progress != SVProgressHUDUndefinedProgress) { + self.backgroundRingView.center = self.ringView.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY); + } + self.imageView.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY); + + // Label + if(imageUsed || progressUsed) { + centerY = CGRectGetMaxY(imageUsed ? self.imageView.frame : self.indefiniteAnimatedView.frame) + SVProgressHUDLabelSpacing + labelHeight / 2.0f; + } else { + centerY = CGRectGetMidY(self.hudView.bounds); + } + self.statusLabel.frame = labelRect; + self.statusLabel.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY); + self.statusLabel.hidden = !self.statusLabel.text; + + [CATransaction commit]; +} + +#if TARGET_OS_IOS +- (void)updateMotionEffectForOrientation:(UIInterfaceOrientation)orientation { + UIInterpolatingMotionEffectType xMotionEffectType = UIInterfaceOrientationIsPortrait(orientation) ? UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis : UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis; + UIInterpolatingMotionEffectType yMotionEffectType = UIInterfaceOrientationIsPortrait(orientation) ? UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis : UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis; + [self updateMotionEffectForXMotionEffectType:xMotionEffectType yMotionEffectType:yMotionEffectType]; +} +#endif + +- (void)updateMotionEffectForXMotionEffectType:(UIInterpolatingMotionEffectType)xMotionEffectType yMotionEffectType:(UIInterpolatingMotionEffectType)yMotionEffectType { + UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:xMotionEffectType]; + effectX.minimumRelativeValue = @(-SVProgressHUDParallaxDepthPoints); + effectX.maximumRelativeValue = @(SVProgressHUDParallaxDepthPoints); + + UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:yMotionEffectType]; + effectY.minimumRelativeValue = @(-SVProgressHUDParallaxDepthPoints); + effectY.maximumRelativeValue = @(SVProgressHUDParallaxDepthPoints); + + UIMotionEffectGroup *effectGroup = [UIMotionEffectGroup new]; + effectGroup.motionEffects = @[effectX, effectY]; + + // Clear old motion effect, then add new motion effects + self.hudView.motionEffects = @[]; + [self.hudView addMotionEffect:effectGroup]; +} + +- (void)updateViewHierarchy { + // Add the overlay to the application window if necessary + if(!self.controlView.superview) { + if(self.containerView){ + [self.containerView addSubview:self.controlView]; + } else { +#if !defined(SV_APP_EXTENSIONS) + [self.frontWindow addSubview:self.controlView]; +#else + // If SVProgressHUD ist used inside an app extension add it to the given view + if(self.viewForExtension) { + [self.viewForExtension addSubview:self.controlView]; + } +#endif + } + } else { + // The HUD is already on screen, but maybot not in front. Therefore + // ensure that overlay will be on top of rootViewController (which may + // be changed during runtime). + [self.controlView.superview bringSubviewToFront:self.controlView]; + } + + // Add self to the overlay view + if(!self.superview) { + [self.controlView addSubview:self]; + } +} + +- (void)setStatus:(NSString*)status { + self.statusLabel.text = status; + [self updateHUDFrame]; +} + +- (void)setFadeOutTimer:(NSTimer*)timer { + if(_fadeOutTimer) { + [_fadeOutTimer invalidate]; + _fadeOutTimer = nil; + } + if(timer) { + _fadeOutTimer = timer; + } +} + + +#pragma mark - Notifications and their handling + +- (void)registerNotifications { +#if TARGET_OS_IOS + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(positionHUD:) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(positionHUD:) + name:UIKeyboardWillHideNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(positionHUD:) + name:UIKeyboardDidHideNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(positionHUD:) + name:UIKeyboardWillShowNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(positionHUD:) + name:UIKeyboardDidShowNotification + object:nil]; +#endif + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(positionHUD:) + name:UIApplicationDidBecomeActiveNotification + object:nil]; +} + +- (NSDictionary*)notificationUserInfo { + return (self.statusLabel.text ? @{SVProgressHUDStatusUserInfoKey : self.statusLabel.text} : nil); +} + +- (void)positionHUD:(NSNotification*)notification { + CGFloat keyboardHeight = 0.0f; + double animationDuration = 0.0; + +#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS + self.frame = [[[UIApplication sharedApplication] delegate] window].bounds; + UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation; +#elif !defined(SV_APP_EXTENSIONS) && !TARGET_OS_IOS + self.frame= [UIApplication sharedApplication].keyWindow.bounds; +#else + if (self.viewForExtension) { + self.frame = self.viewForExtension.frame; + } else { + self.frame = UIScreen.mainScreen.bounds; + } +#if TARGET_OS_IOS + UIInterfaceOrientation orientation = CGRectGetWidth(self.frame) > CGRectGetHeight(self.frame) ? UIInterfaceOrientationLandscapeLeft : UIInterfaceOrientationPortrait; +#endif +#endif + + // no transforms applied to window in iOS 8, but only if compiled with iOS 8 sdk as base sdk, otherwise system supports old rotation logic. + BOOL ignoreOrientation = NO; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { + ignoreOrientation = YES; + } +#endif + +#if TARGET_OS_IOS + // Get keyboardHeight in regards to current state + if(notification) { + NSDictionary* keyboardInfo = [notification userInfo]; + CGRect keyboardFrame = [keyboardInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue]; + animationDuration = [keyboardInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; + + if(notification.name == UIKeyboardWillShowNotification || notification.name == UIKeyboardDidShowNotification) { + keyboardHeight = CGRectGetWidth(keyboardFrame); + + if(ignoreOrientation || UIInterfaceOrientationIsPortrait(orientation)) { + keyboardHeight = CGRectGetHeight(keyboardFrame); + } + } + } else { + keyboardHeight = self.visibleKeyboardHeight; + } +#endif + + // Get the currently active frame of the display (depends on orientation) + CGRect orientationFrame = self.bounds; + +#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS + CGRect statusBarFrame = UIApplication.sharedApplication.statusBarFrame; +#else + CGRect statusBarFrame = CGRectZero; +#endif + +#if TARGET_OS_IOS + if(!ignoreOrientation && UIInterfaceOrientationIsLandscape(orientation)) { + float temp = CGRectGetWidth(orientationFrame); + orientationFrame.size.width = CGRectGetHeight(orientationFrame); + orientationFrame.size.height = temp; + + temp = CGRectGetWidth(statusBarFrame); + statusBarFrame.size.width = CGRectGetHeight(statusBarFrame); + statusBarFrame.size.height = temp; + } + + // Update the motion effects in regards to orientation + [self updateMotionEffectForOrientation:orientation]; +#else + [self updateMotionEffectForXMotionEffectType:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis yMotionEffectType:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; +#endif + + // Calculate available height for display + CGFloat activeHeight = CGRectGetHeight(orientationFrame); + if(keyboardHeight > 0) { + activeHeight += CGRectGetHeight(statusBarFrame) * 2; + } + activeHeight -= keyboardHeight; + + CGFloat posX = CGRectGetMidX(orientationFrame); + CGFloat posY = floorf(activeHeight*0.45f); + + CGFloat rotateAngle = 0.0; + CGPoint newCenter = CGPointMake(posX, posY); + + if(notification) { + // Animate update if notification was present + [UIView animateWithDuration:animationDuration + delay:0 + options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState) + animations:^{ + [self moveToPoint:newCenter rotateAngle:rotateAngle]; + [self.hudView setNeedsDisplay]; + } completion:nil]; + } else { + [self moveToPoint:newCenter rotateAngle:rotateAngle]; + } +} + +- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle { + self.hudView.transform = CGAffineTransformMakeRotation(angle); + if (self.containerView) { + self.hudView.center = self.containerView.center; + } else { + self.hudView.center = CGPointMake(newCenter.x + self.offsetFromCenter.horizontal, newCenter.y + self.offsetFromCenter.vertical); + } +} + + +#pragma mark - Event handling + +- (void)controlViewDidReceiveTouchEvent:(id)sender forEvent:(UIEvent*)event { + [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidReceiveTouchEventNotification + object:self + userInfo:[self notificationUserInfo]]; + + UITouch *touch = event.allTouches.anyObject; + CGPoint touchLocation = [touch locationInView:self]; + + if(CGRectContainsPoint(self.hudView.frame, touchLocation)) { + [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidTouchDownInsideNotification + object:self + userInfo:[self notificationUserInfo]]; + } +} + + +#pragma mark - Master show/dismiss methods + +- (void)showProgress:(float)progress status:(NSString*)status { + __weak SVProgressHUD *weakSelf = self; + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + __strong SVProgressHUD *strongSelf = weakSelf; + if(strongSelf){ + // Update / Check view hierarchy to ensure the HUD is visible + [strongSelf updateViewHierarchy]; + + // Reset imageView and fadeout timer if an image is currently displayed + strongSelf.imageView.hidden = YES; + strongSelf.imageView.image = nil; + + if(strongSelf.fadeOutTimer) { + strongSelf.activityCount = 0; + } + strongSelf.fadeOutTimer = nil; + + // Update text and set progress to the given value + strongSelf.statusLabel.text = status; + strongSelf.progress = progress; + + // Choose the "right" indicator depending on the progress + if(progress >= 0) { + // Cancel the indefiniteAnimatedView, then show the ringLayer + [strongSelf cancelIndefiniteAnimatedViewAnimation]; + + // Add ring to HUD + if(!strongSelf.ringView.superview){ +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + [strongSelf.hudVibrancyView.contentView addSubview:strongSelf.ringView]; +#else + [strongSelf.hudView addSubview:strongSelf.ringView]; +#endif + } + if(!strongSelf.backgroundRingView.superview){ +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + [strongSelf.hudVibrancyView.contentView addSubview:strongSelf.backgroundRingView]; +#else + [strongSelf.hudView addSubview:strongSelf.backgroundRingView]; +#endif + } + + // Set progress animated + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + strongSelf.ringView.strokeEnd = progress; + [CATransaction commit]; + + // Update the activity count + if(progress == 0) { + strongSelf.activityCount++; + } + } else { + // Cancel the ringLayer animation, then show the indefiniteAnimatedView + [strongSelf cancelRingLayerAnimation]; + + // Add indefiniteAnimatedView to HUD +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + [strongSelf.hudVibrancyView.contentView addSubview:strongSelf.indefiniteAnimatedView]; +#else + [strongSelf.hudView addSubview:strongSelf.indefiniteAnimatedView]; +#endif + if([strongSelf.indefiniteAnimatedView respondsToSelector:@selector(startAnimating)]) { + [(id)strongSelf.indefiniteAnimatedView startAnimating]; + } + + // Update the activity count + strongSelf.activityCount++; + } + + // Show + [strongSelf showStatus:status]; + } + }]; +} + +- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration { + __weak SVProgressHUD *weakSelf = self; + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + __strong SVProgressHUD *strongSelf = weakSelf; + if(strongSelf){ + // Update / Check view hierarchy to ensure the HUD is visible + [strongSelf updateViewHierarchy]; + + // Reset progress and cancel any running animation + strongSelf.progress = SVProgressHUDUndefinedProgress; + [strongSelf cancelRingLayerAnimation]; + [strongSelf cancelIndefiniteAnimatedViewAnimation]; + + // Update imageView + UIColor *tintColor = strongSelf.foregroundColorForStyle; + UIImage *tintedImage = image; + if (image.renderingMode != UIImageRenderingModeAlwaysTemplate) { + tintedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + } + strongSelf.imageView.tintColor = tintColor; + strongSelf.imageView.image = tintedImage; + strongSelf.imageView.hidden = NO; + + // Update text + strongSelf.statusLabel.text = status; + + // Show + [strongSelf showStatus:status]; + + // An image will dismissed automatically. Therefore we start a timer + // which then will call dismiss after the predefined duration + strongSelf.fadeOutTimer = [NSTimer timerWithTimeInterval:duration target:strongSelf selector:@selector(dismiss) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:strongSelf.fadeOutTimer forMode:NSRunLoopCommonModes]; + } + }]; +} + +- (void)showStatus:(NSString*)status { + // Update the HUDs frame to the new content and position HUD + [self updateHUDFrame]; + [self positionHUD:nil]; + + // Update accessibility as well as user interaction + if(self.defaultMaskType != SVProgressHUDMaskTypeNone) { + self.controlView.userInteractionEnabled = YES; + self.accessibilityLabel = status; + self.isAccessibilityElement = YES; + } else { + self.controlView.userInteractionEnabled = NO; + self.hudView.accessibilityLabel = status; + self.hudView.isAccessibilityElement = YES; + } + + // Show if not already visible + // Checking one alpha value is sufficient as they are all the same +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if(self.hudView.contentView.alpha != 1.0f){ +#else + if(self.hudView.alpha != 1.0f){ +#endif + // Post notification to inform user + [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillAppearNotification + object:self + userInfo:[self notificationUserInfo]]; + + // Zoom HUD a little to make a nice appear / pop up animation + self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 1.3, 1.3); + + // Define blocks + __block void (^animationsBlock)(void) = ^{ + // Shrink HUD to finish pop up animation + self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 1/1.3f, 1/1.3f); + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if(self.defaultStyle != SVProgressHUDStyleCustom){ + // Fade in effect + UIBlurEffectStyle blurEffectStyle = self.defaultStyle == SVProgressHUDStyleDark ? UIBlurEffectStyleDark : UIBlurEffectStyleExtraLight; + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:blurEffectStyle]; + + self.hudView.effect = blurEffect; + self.hudVibrancyView.effect = [UIVibrancyEffect effectForBlurEffect:blurEffect]; + } else { + self.hudView.alpha = 1.0f; + } + + // Update alpha + self.hudView.contentView.alpha = 1.0f; +#else + self.hudView.alpha = 1.0f; +#endif + self.backgroundView.alpha = 1.0f; + }; + + __block void (^completionBlock)(void) = ^{ + // Check if we really achieved to show the HUD (<=> alpha values are applied) + // and the change of these values has not been cancelled in between e.g. due to a dismissal + // Checking one alpha value is sufficient as they are all the same +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if(self.hudView.contentView.alpha == 1.0f){ +#else + if(self.hudView.alpha == 1.0f){ +#endif + // Register observer <=> we now have to handle orientation changes etc. + [self registerNotifications]; + + // Post notification to inform user + [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidAppearNotification + object:self + userInfo:[self notificationUserInfo]]; + } + + // Update accessibility + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil); + UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, status); + }; + + if (self.fadeInAnimationDuration > 0) { + // Animate appearance + [UIView animateWithDuration:self.fadeInAnimationDuration + delay:0 + options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState) + animations:^{ + animationsBlock(); + } completion:^(BOOL finished) { + completionBlock(); + }]; + } else { + animationsBlock(); + completionBlock(); + } + + // Inform iOS to redraw the view hierarchy + [self setNeedsDisplay]; + } +} + +- (void)dismiss { + [self dismissWithDelay:0.0 completion:nil]; +} + +- (void)dismissWithDelay:(NSTimeInterval)delay completion:(SVProgressHUDDismissCompletion)completion { + __weak SVProgressHUD *weakSelf = self; + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + __strong SVProgressHUD *strongSelf = weakSelf; + if(strongSelf){ + // Post notification to inform user + [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillDisappearNotification + object:nil + userInfo:[strongSelf notificationUserInfo]]; + + // Reset activity count + strongSelf.activityCount = 0; + + // Define blocks + __block void (^animationsBlock)(void) = ^{ + // Shrink HUD a little to make a nice disappear animation + strongSelf.hudView.transform = CGAffineTransformScale(strongSelf.hudView.transform, 1/1.3f, 1/1.3f); + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if(self.defaultStyle != SVProgressHUDStyleCustom){ + // Fade out effect == remove, and update alpha + strongSelf.hudView.effect = nil; + strongSelf.hudVibrancyView.effect = nil; + } else { + strongSelf.hudView.alpha = 0.0f; + } + + strongSelf.hudView.contentView.alpha = 0.0f; +#else + strongSelf.hudView.alpha = 0.0f; +#endif + strongSelf.backgroundView.alpha = 0.0f; + }; + + __block void (^completionBlock)(void) = ^{ + // Check if we really achieved to dismiss the HUD (<=> alpha values are applied) + // and the change of these values has not been cancelled in between e.g. due to a new show + // Checking one alpha value is sufficient as they are all the same +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + if(strongSelf.hudView.contentView.alpha == 0.0f){ +#else + if(strongSelf.hudView.alpha == 0.0f){ +#endif + // Clean up view hierarchy (overlays) + [strongSelf.controlView removeFromSuperview]; + [strongSelf.backgroundView removeFromSuperview]; + [strongSelf.hudView removeFromSuperview]; + [strongSelf removeFromSuperview]; + + // Reset progress and cancel any running animation + strongSelf.progress = SVProgressHUDUndefinedProgress; + [strongSelf cancelRingLayerAnimation]; + [strongSelf cancelIndefiniteAnimatedViewAnimation]; + + // Remove observer <=> we do not have to handle orientation changes etc. + [[NSNotificationCenter defaultCenter] removeObserver:strongSelf]; + + // Post notification to inform user + [[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidDisappearNotification + object:strongSelf + userInfo:[strongSelf notificationUserInfo]]; + + // Tell the rootViewController to update the StatusBar appearance +#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS + UIViewController *rootController = [[UIApplication sharedApplication] keyWindow].rootViewController; + [rootController setNeedsStatusBarAppearanceUpdate]; +#endif + // Update accessibility + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil); + + // Run an (optional) completionHandler + if (completion) { + completion(); + } + } + }; + + // UIViewAnimationOptionBeginFromCurrentState AND a delay doesn't always work as expected + // When UIViewAnimationOptionBeginFromCurrentState ist set, animateWithDuration: evaluates the current + // values to check if an animation is necessary. The evaluation happens at function call time and not + // after the delay => the animation is sometimes skipped. Therefore we delay using dispatch_after. + + dispatch_time_t dipatchTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)); + dispatch_after(dipatchTime, dispatch_get_main_queue(), ^{ + if (strongSelf.fadeOutAnimationDuration > 0) { + // Animate appearance + [UIView animateWithDuration:strongSelf.fadeOutAnimationDuration + delay:0 + options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState) + animations:^{ + animationsBlock(); + } completion:^(BOOL finished) { + completionBlock(); + }]; + } else { + animationsBlock(); + completionBlock(); + } + }); + + // Inform iOS to redraw the view hierarchy + [strongSelf setNeedsDisplay]; + } else if (completion) { + // Run an (optional) completionHandler + completion(); + } + }]; +} + + +#pragma mark - Ring progress animation + +- (UIView*)indefiniteAnimatedView { + // Get the correct spinner for defaultAnimationType + if(self.defaultAnimationType == SVProgressHUDAnimationTypeFlat){ + // Check if spinner exists and is an object of different class + if(_indefiniteAnimatedView && ![_indefiniteAnimatedView isKindOfClass:[SVIndefiniteAnimatedView class]]){ + [_indefiniteAnimatedView removeFromSuperview]; + _indefiniteAnimatedView = nil; + } + + if(!_indefiniteAnimatedView){ + _indefiniteAnimatedView = [[SVIndefiniteAnimatedView alloc] initWithFrame:CGRectZero]; + } + + // Update styling + SVIndefiniteAnimatedView *indefiniteAnimatedView = (SVIndefiniteAnimatedView*)_indefiniteAnimatedView; + indefiniteAnimatedView.strokeColor = self.foregroundColorForStyle; + indefiniteAnimatedView.strokeThickness = self.ringThickness; + indefiniteAnimatedView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius; + } else { + // Check if spinner exists and is an object of different class + if(_indefiniteAnimatedView && ![_indefiniteAnimatedView isKindOfClass:[UIActivityIndicatorView class]]){ + [_indefiniteAnimatedView removeFromSuperview]; + _indefiniteAnimatedView = nil; + } + + if(!_indefiniteAnimatedView){ + _indefiniteAnimatedView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + } + + // Update styling + UIActivityIndicatorView *activityIndicatorView = (UIActivityIndicatorView*)_indefiniteAnimatedView; + activityIndicatorView.color = self.foregroundColorForStyle; + } + [_indefiniteAnimatedView sizeToFit]; + + return _indefiniteAnimatedView; +} + +- (SVProgressAnimatedView*)ringView { + if(!_ringView) { + _ringView = [[SVProgressAnimatedView alloc] initWithFrame:CGRectZero]; + } + + // Update styling + _ringView.strokeColor = self.foregroundColorForStyle; + _ringView.strokeThickness = self.ringThickness; + _ringView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius; + + return _ringView; +} + +- (SVProgressAnimatedView*)backgroundRingView { + if(!_backgroundRingView) { + _backgroundRingView = [[SVProgressAnimatedView alloc] initWithFrame:CGRectZero]; + _backgroundRingView.strokeEnd = 1.0f; + } + + // Update styling + _backgroundRingView.strokeColor = [self.foregroundColorForStyle colorWithAlphaComponent:0.1f]; + _backgroundRingView.strokeThickness = self.ringThickness; + _backgroundRingView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius; + + return _backgroundRingView; +} + +- (void)cancelRingLayerAnimation { + // Animate value update, stop animation + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + + [self.hudView.layer removeAllAnimations]; + self.ringView.strokeEnd = 0.0f; + + [CATransaction commit]; + + // Remove from view + [self.ringView removeFromSuperview]; + [self.backgroundRingView removeFromSuperview]; +} + +- (void)cancelIndefiniteAnimatedViewAnimation { + // Stop animation + if([self.indefiniteAnimatedView respondsToSelector:@selector(stopAnimating)]) { + [(id)self.indefiniteAnimatedView stopAnimating]; + } + // Remove from view + [self.indefiniteAnimatedView removeFromSuperview]; +} + + +#pragma mark - Utilities + ++ (BOOL)isVisible { + // Checking one alpha value is sufficient as they are all the same + return ([self sharedView].hudView.contentView.alpha > 0.0f); +} + + +#pragma mark - Getters + ++ (NSTimeInterval)displayDurationForString:(NSString*)string { + CGFloat minimum = MAX((CGFloat)string.length * 0.06 + 0.5, [self sharedView].minimumDismissTimeInterval); + return MIN(minimum, [self sharedView].maximumDismissTimeInterval); +} + +- (UIColor*)foregroundColorForStyle { + if(self.defaultStyle == SVProgressHUDStyleLight) { + return [UIColor blackColor]; + } else if(self.defaultStyle == SVProgressHUDStyleDark) { + return [UIColor whiteColor]; + } else { + return self.foregroundColor; + } +} + +- (UIColor*)backgroundColorForStyle { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + // On iOS 8 and SVProgressHUDStyleLight / SVProgressHUDStyleDark the + // the background color is set via a UIVisualEffectsView + return self.defaultStyle == SVProgressHUDStyleCustom ? self.backgroundColor : [UIColor clearColor]; +#else + if(self.defaultStyle == SVProgressHUDStyleLight) { + return [UIColor whiteColor]; + } else if(self.defaultStyle == SVProgressHUDStyleDark) { + return [UIColor blackColor]; + } else { + return self.backgroundColor; + } +#endif +} + +- (UIControl*)controlView { + if(!_controlView) { + _controlView = [UIControl new]; + _controlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _controlView.backgroundColor = [UIColor clearColor]; + [_controlView addTarget:self action:@selector(controlViewDidReceiveTouchEvent:forEvent:) forControlEvents:UIControlEventTouchDown]; + } + + // Update frames +#if !defined(SV_APP_EXTENSIONS) + CGRect windowBounds = [[[UIApplication sharedApplication] delegate] window].bounds; + _controlView.frame = windowBounds; +#else + _controlView.frame = [UIScreen mainScreen].bounds; +#endif + + return _controlView; +} + +-(UIView *)backgroundView { + if(!_backgroundView){ + _backgroundView = [UIView new]; + } + if(!_backgroundView.superview){ + [self insertSubview:_backgroundView belowSubview:self.hudView]; + } + + // Update styling + switch (self.defaultMaskType) { + case SVProgressHUDMaskTypeCustom: + case SVProgressHUDMaskTypeBlack:{ + if(_backgroundRadialGradientLayer && _backgroundRadialGradientLayer.superlayer){ + [_backgroundRadialGradientLayer removeFromSuperlayer]; + } + _backgroundView.backgroundColor = self.defaultMaskType == SVProgressHUDMaskTypeCustom ? self.backgroundLayerColor : [UIColor colorWithWhite:0 alpha:0.4]; + break; + } + case SVProgressHUDMaskTypeGradient:{ + if(!_backgroundRadialGradientLayer){ + _backgroundRadialGradientLayer = [SVRadialGradientLayer layer]; + } + if(!_backgroundRadialGradientLayer.superlayer){ + [_backgroundView.layer insertSublayer:_backgroundRadialGradientLayer atIndex:0]; + } + } + default: + break; + } + + // Update frame + if(_backgroundView){ + _backgroundView.frame = self.bounds; + } + if(_backgroundRadialGradientLayer){ + _backgroundRadialGradientLayer.frame = self.bounds; + + // Calculate the new center of the gradient, it may change if keyboard is visible + CGPoint gradientCenter = self.center; + gradientCenter.y = (self.bounds.size.height - self.visibleKeyboardHeight)/2; + _backgroundRadialGradientLayer.gradientCenter = gradientCenter; + } + + return _backgroundView; +} +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 +- (UIVisualEffectView*)hudView { +#else +- (UIView*)hudView { +#endif + if(!_hudView) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + _hudView = [UIVisualEffectView new]; +#else + _hudView = [UIView new]; +#endif + _hudView.layer.masksToBounds = YES; + _hudView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; + } + if(!_hudView.superview) { + [self addSubview:_hudView]; + } + + // Update styling + _hudView.layer.cornerRadius = self.cornerRadius; + _hudView.backgroundColor = self.backgroundColorForStyle; + + return _hudView; +} + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 +- (UIVisualEffectView*)hudVibrancyView { + if(!_hudVibrancyView){ + _hudVibrancyView = [UIVisualEffectView new]; + + _hudView.layer.masksToBounds = YES; + _hudVibrancyView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; + } + if(!_hudVibrancyView.superview){ + [self.hudView.contentView addSubview:_hudVibrancyView]; + } + + return _hudVibrancyView; +} +#endif + +- (UILabel*)statusLabel { + if(!_statusLabel) { + _statusLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + _statusLabel.backgroundColor = [UIColor clearColor]; + _statusLabel.adjustsFontSizeToFitWidth = YES; + _statusLabel.textAlignment = NSTextAlignmentCenter; + _statusLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; + _statusLabel.numberOfLines = 0; + } + if(!_statusLabel.superview) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + [self.hudVibrancyView.contentView addSubview:_statusLabel]; +#else + [self.hudView addSubview:_statusLabel]; +#endif + } + + // Update styling + _statusLabel.textColor = self.foregroundColorForStyle; + _statusLabel.font = self.font; + + return _statusLabel; +} + +- (UIImageView*)imageView { + if(!_imageView) { + _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 28.0f, 28.0f)]; + } + if(!_imageView.superview) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + [self.hudVibrancyView.contentView addSubview:_imageView]; +#else + [self.hudView addSubview:_imageView]; +#endif + } + + return _imageView; +} + +- (CGFloat)visibleKeyboardHeight { +#if !defined(SV_APP_EXTENSIONS) + UIWindow *keyboardWindow = nil; + for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { + if(![[testWindow class] isEqual:[UIWindow class]]) { + keyboardWindow = testWindow; + break; + } + } + + for (__strong UIView *possibleKeyboard in [keyboardWindow subviews]) { + if([possibleKeyboard isKindOfClass:NSClassFromString(@"UIPeripheralHostView")] || [possibleKeyboard isKindOfClass:NSClassFromString(@"UIKeyboard")]) { + return CGRectGetHeight(possibleKeyboard.bounds); + } else if([possibleKeyboard isKindOfClass:NSClassFromString(@"UIInputSetContainerView")]) { + for (__strong UIView *possibleKeyboardSubview in [possibleKeyboard subviews]) { + if([possibleKeyboardSubview isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) { + return CGRectGetHeight(possibleKeyboardSubview.bounds); + } + } + } + } +#endif + return 0; +} + +- (UIWindow *)frontWindow { +#if !defined(SV_APP_EXTENSIONS) + NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator]; + for (UIWindow *window in frontToBackWindows) { + BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen; + BOOL windowIsVisible = !window.hidden && window.alpha > 0; + BOOL windowLevelSupported = (window.windowLevel >= UIWindowLevelNormal && window.windowLevel <= self.maxSupportedWindowLevel); + + if(windowOnMainScreen && windowIsVisible && windowLevelSupported) { + return window; + } + } +#endif + return nil; +} + +#pragma mark - UIAppearance Setters + +- (void)setDefaultStyle:(SVProgressHUDStyle)style { + if (!_isInitializing) _defaultStyle = style; +} + +- (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType { + if (!_isInitializing) _defaultMaskType = maskType; +} + +- (void)setDefaultAnimationType:(SVProgressHUDAnimationType)animationType { + if (!_isInitializing) _defaultAnimationType = animationType; +} + +- (void)setContainerView:(UIView *)containerView { + if (!_isInitializing) _containerView = containerView; +} + +- (void)setMinimumSize:(CGSize)minimumSize { + if (!_isInitializing) _minimumSize = minimumSize; +} + +- (void)setRingThickness:(CGFloat)ringThickness { + if (!_isInitializing) _ringThickness = ringThickness; +} + +- (void)setRingRadius:(CGFloat)ringRadius { + if (!_isInitializing) _ringRadius = ringRadius; +} + +- (void)setRingNoTextRadius:(CGFloat)ringNoTextRadius { + if (!_isInitializing) _ringNoTextRadius = ringNoTextRadius; +} + +- (void)setCornerRadius:(CGFloat)cornerRadius { + if (!_isInitializing) _cornerRadius = cornerRadius; +} + +- (void)setFont:(UIFont*)font { + if (!_isInitializing) _font = font; +} + +- (void)setForegroundColor:(UIColor*)color { + if (!_isInitializing) _foregroundColor = color; +} + +- (void)setBackgroundColor:(UIColor*)color { + if (!_isInitializing) _backgroundColor = color; +} + +- (void)setBackgroundLayerColor:(UIColor*)color { + if (!_isInitializing) _backgroundLayerColor = color; +} + +- (void)setInfoImage:(UIImage*)image { + if (!_isInitializing) _infoImage = image; +} + +- (void)setSuccessImage:(UIImage*)image { + if (!_isInitializing) _successImage = image; +} + +- (void)setErrorImage:(UIImage*)image { + if (!_isInitializing) _errorImage = image; +} + +- (void)setViewForExtension:(UIView*)view { + if (!_isInitializing) _viewForExtension = view; +} + +- (void)setOffsetFromCenter:(UIOffset)offset { + if (!_isInitializing) _offsetFromCenter = offset; +} + +- (void)setMinimumDismissTimeInterval:(NSTimeInterval)minimumDismissTimeInterval { + if (!_isInitializing) _minimumDismissTimeInterval = minimumDismissTimeInterval; +} + +- (void)setFadeInAnimationDuration:(NSTimeInterval)duration { + if (!_isInitializing) _fadeInAnimationDuration = duration; +} + +- (void)setFadeOutAnimationDuration:(NSTimeInterval)duration { + if (!_isInitializing) _fadeOutAnimationDuration = duration; +} + +- (void)setMaxSupportedWindowLevel:(UIWindowLevel)maxSupportedWindowLevel { + if (!_isInitializing) _maxSupportedWindowLevel = maxSupportedWindowLevel; +} + +@end diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVRadialGradientLayer.h b/Pods/SVProgressHUD/SVProgressHUD/SVRadialGradientLayer.h new file mode 100644 index 0000000..634449e --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVRadialGradientLayer.h @@ -0,0 +1,14 @@ +// +// SVRadialGradientLayer.h +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2014-2016 Tobias Tiemerding. All rights reserved. +// + +#import + +@interface SVRadialGradientLayer : CALayer + +@property (nonatomic) CGPoint gradientCenter; + +@end diff --git a/Pods/SVProgressHUD/SVProgressHUD/SVRadialGradientLayer.m b/Pods/SVProgressHUD/SVProgressHUD/SVRadialGradientLayer.m new file mode 100644 index 0000000..a1d0356 --- /dev/null +++ b/Pods/SVProgressHUD/SVProgressHUD/SVRadialGradientLayer.m @@ -0,0 +1,25 @@ +// +// SVRadialGradientLayer.m +// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD +// +// Copyright (c) 2014-2016 Tobias Tiemerding. All rights reserved. +// + +#import "SVRadialGradientLayer.h" + +@implementation SVRadialGradientLayer + +- (void)drawInContext:(CGContextRef)context { + size_t locationsCount = 2; + CGFloat locations[2] = {0.0f, 1.0f}; + CGFloat colors[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.75f}; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, locationsCount); + CGColorSpaceRelease(colorSpace); + + float radius = MIN(self.bounds.size.width , self.bounds.size.height); + CGContextDrawRadialGradient (context, gradient, self.gradientCenter, 0, self.gradientCenter, radius, kCGGradientDrawsAfterEndLocation); + CGGradientRelease(gradient); +} + +@end diff --git a/Pods/SnapKit/LICENSE b/Pods/SnapKit/LICENSE new file mode 100644 index 0000000..a18ccfb --- /dev/null +++ b/Pods/SnapKit/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Pods/SnapKit/README.md b/Pods/SnapKit/README.md new file mode 100644 index 0000000..a6da596 --- /dev/null +++ b/Pods/SnapKit/README.md @@ -0,0 +1,133 @@ + + +SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. + +[![Build Status](https://travis-ci.org/SnapKit/SnapKit.svg)](https://travis-ci.org/SnapKit/SnapKit) +[![Platform](https://img.shields.io/cocoapods/p/SnapKit.svg?style=flat)](https://github.com/SnapKit/SnapKit) +[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SnapKit.svg)](https://cocoapods.org/pods/SnapKit) +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + +#### ⚠️ **To use with Swift 2.x please ensure you are using == 0.22.0** ⚠️ +#### ⚠️ **To use with Swift 3.x please ensure you are using >= 3.0.0** ⚠️ + +## Contents + +- [Requirements](#requirements) +- [Migration Guides](#migration-guides) +- [Communication](#communication) +- [Installation](#installation) +- [Usage](#usage) +- [Credits](#credits) +- [License](#license) + +## Requirements + +- iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+ +- Xcode 8.0+ +- Swift 3.0+ + +## Migration Guides + +- [SnapKit 3.0 Migration Guide](https://github.com/SnapKit/SnapKit/blob/master/Documentation/SnapKit%203.0%20Migration%20Guide.md) + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/snapkit). (Tag 'snapkit') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/snapkit). +- If you **found a bug**, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + + +## Installation + +### CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +> CocoaPods 1.1.0+ is required to build SnapKit 3.0.0+. + +To integrate SnapKit into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '10.0' +use_frameworks! + +target '' do + pod 'SnapKit', '~> 3.1.2' +end +``` + +Then, run the following command: + +```bash +$ pod install +``` + +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "SnapKit/SnapKit" ~> 3.0.2 +``` + +Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project. + +### Manually + +If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually. + +--- + +## Usage + +### Quick Start + +```swift +import SnapKit + +class MyViewController: UIViewController { + + lazy var box = UIView() + + override func viewDidLoad() { + super.viewDidLoad() + + self.view.addSubview(box) + box.snp.makeConstraints { (make) -> Void in + make.width.height.equalTo(50) + make.center.equalTo(self.view) + } + } + +} +``` + +### Resources + +- [Documentation](http://snapkit.io/docs/) +- [F.A.Q.](http://snapkit.io/faq/) + +## Credits + +- Robert Payne ([@robertjpayne](https://twitter.com/robertjpayne)) +- Many other contributors + +## License + +SnapKit is released under the MIT license. See LICENSE for details. diff --git a/Pods/SnapKit/Source/Constraint.swift b/Pods/SnapKit/Source/Constraint.swift new file mode 100644 index 0000000..5c8c483 --- /dev/null +++ b/Pods/SnapKit/Source/Constraint.swift @@ -0,0 +1,286 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public final class Constraint { + + internal let sourceLocation: (String, UInt) + internal let label: String? + + private let from: ConstraintItem + private let to: ConstraintItem + private let relation: ConstraintRelation + private let multiplier: ConstraintMultiplierTarget + private var constant: ConstraintConstantTarget { + didSet { + self.updateConstantAndPriorityIfNeeded() + } + } + private var priority: ConstraintPriorityTarget { + didSet { + self.updateConstantAndPriorityIfNeeded() + } + } + private var layoutConstraints: [LayoutConstraint] + + // MARK: Initialization + + internal init(from: ConstraintItem, + to: ConstraintItem, + relation: ConstraintRelation, + sourceLocation: (String, UInt), + label: String?, + multiplier: ConstraintMultiplierTarget, + constant: ConstraintConstantTarget, + priority: ConstraintPriorityTarget) { + self.from = from + self.to = to + self.relation = relation + self.sourceLocation = sourceLocation + self.label = label + self.multiplier = multiplier + self.constant = constant + self.priority = priority + self.layoutConstraints = [] + + // get attributes + let layoutFromAttributes = self.from.attributes.layoutAttributes + let layoutToAttributes = self.to.attributes.layoutAttributes + + // get layout from + let layoutFrom = self.from.layoutConstraintItem! + + // get relation + let layoutRelation = self.relation.layoutRelation + + for layoutFromAttribute in layoutFromAttributes { + // get layout to attribute + let layoutToAttribute: NSLayoutAttribute + #if os(iOS) || os(tvOS) + if layoutToAttributes.count > 0 { + if self.from.attributes == .edges && self.to.attributes == .margins { + switch layoutFromAttribute { + case .left: + layoutToAttribute = .leftMargin + case .right: + layoutToAttribute = .rightMargin + case .top: + layoutToAttribute = .topMargin + case .bottom: + layoutToAttribute = .bottomMargin + default: + fatalError() + } + } else if self.from.attributes == .margins && self.to.attributes == .edges { + switch layoutFromAttribute { + case .leftMargin: + layoutToAttribute = .left + case .rightMargin: + layoutToAttribute = .right + case .topMargin: + layoutToAttribute = .top + case .bottomMargin: + layoutToAttribute = .bottom + default: + fatalError() + } + } else if self.from.attributes == self.to.attributes { + layoutToAttribute = layoutFromAttribute + } else { + layoutToAttribute = layoutToAttributes[0] + } + } else { + if self.to.target == nil && (layoutFromAttribute == .centerX || layoutFromAttribute == .centerY) { + layoutToAttribute = layoutFromAttribute == .centerX ? .left : .top + } else { + layoutToAttribute = layoutFromAttribute + } + } + #else + if self.from.attributes == self.to.attributes { + layoutToAttribute = layoutFromAttribute + } else if layoutToAttributes.count > 0 { + layoutToAttribute = layoutToAttributes[0] + } else { + layoutToAttribute = layoutFromAttribute + } + #endif + + // get layout constant + let layoutConstant: CGFloat = self.constant.constraintConstantTargetValueFor(layoutAttribute: layoutToAttribute) + + // get layout to + var layoutTo: AnyObject? = self.to.target + + // use superview if possible + if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height { + layoutTo = layoutFrom.superview + } + + // create layout constraint + let layoutConstraint = LayoutConstraint( + item: layoutFrom, + attribute: layoutFromAttribute, + relatedBy: layoutRelation, + toItem: layoutTo, + attribute: layoutToAttribute, + multiplier: self.multiplier.constraintMultiplierTargetValue, + constant: layoutConstant + ) + + // set label + layoutConstraint.label = self.label + + // set priority + layoutConstraint.priority = self.priority.constraintPriorityTargetValue + + // set constraint + layoutConstraint.constraint = self + + // append + self.layoutConstraints.append(layoutConstraint) + } + } + + // MARK: Public + + @available(*, deprecated:3.0, message:"Use activate().") + public func install() { + self.activate() + } + + @available(*, deprecated:3.0, message:"Use deactivate().") + public func uninstall() { + self.deactivate() + } + + public func activate() { + self.activateIfNeeded() + } + + public func deactivate() { + self.deactivateIfNeeded() + } + + @discardableResult + public func update(offset: ConstraintOffsetTarget) -> Constraint { + self.constant = offset.constraintOffsetTargetValue + return self + } + + @discardableResult + public func update(inset: ConstraintInsetTarget) -> Constraint { + self.constant = inset.constraintInsetTargetValue + return self + } + + @discardableResult + public func update(priority: ConstraintPriorityTarget) -> Constraint { + self.priority = priority.constraintPriorityTargetValue + return self + } + + @available(*, deprecated:3.0, message:"Use update(offset: ConstraintOffsetTarget) instead.") + public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) } + + @available(*, deprecated:3.0, message:"Use update(inset: ConstraintInsetTarget) instead.") + public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) } + + @available(*, deprecated:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) } + + @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityRequired() -> Void {} + + @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") } + + @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") } + + @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") } + + // MARK: Internal + + internal func updateConstantAndPriorityIfNeeded() { + for layoutConstraint in self.layoutConstraints { + let attribute = (layoutConstraint.secondAttribute == .notAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute + layoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: attribute) + + #if os(iOS) || os(tvOS) + let requiredPriority: UILayoutPriority = UILayoutPriorityRequired + #else + let requiredPriority: Float = 1000.0 + #endif + + + if (layoutConstraint.priority < requiredPriority), (self.priority.constraintPriorityTargetValue != requiredPriority) { + layoutConstraint.priority = self.priority.constraintPriorityTargetValue + } + } + } + + internal func activateIfNeeded(updatingExisting: Bool = false) { + guard let item = self.from.layoutConstraintItem else { + print("WARNING: SnapKit failed to get from item from constraint. Activate will be a no-op.") + return + } + let layoutConstraints = self.layoutConstraints + + if updatingExisting { + var existingLayoutConstraints: [LayoutConstraint] = [] + for constraint in item.constraints { + existingLayoutConstraints += constraint.layoutConstraints + } + + for layoutConstraint in layoutConstraints { + let existingLayoutConstraint = existingLayoutConstraints.first { $0 == layoutConstraint } + guard let updateLayoutConstraint = existingLayoutConstraint else { + fatalError("Updated constraint could not find existing matching constraint to update: \(layoutConstraint)") + } + + let updateLayoutAttribute = (updateLayoutConstraint.secondAttribute == .notAnAttribute) ? updateLayoutConstraint.firstAttribute : updateLayoutConstraint.secondAttribute + updateLayoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: updateLayoutAttribute) + } + } else { + NSLayoutConstraint.activate(layoutConstraints) + item.add(constraints: [self]) + } + } + + internal func deactivateIfNeeded() { + guard let item = self.from.layoutConstraintItem else { + print("WARNING: SnapKit failed to get from item from constraint. Deactivate will be a no-op.") + return + } + let layoutConstraints = self.layoutConstraints + NSLayoutConstraint.deactivate(layoutConstraints) + item.remove(constraints: [self]) + } +} diff --git a/Pods/SnapKit/Source/ConstraintAttributes.swift b/Pods/SnapKit/Source/ConstraintAttributes.swift new file mode 100644 index 0000000..4083235 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintAttributes.swift @@ -0,0 +1,190 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +internal struct ConstraintAttributes : OptionSet { + + internal init(rawValue: UInt) { + self.rawValue = rawValue + } + internal init(_ rawValue: UInt) { + self.init(rawValue: rawValue) + } + internal init(nilLiteral: ()) { + self.rawValue = 0 + } + + internal private(set) var rawValue: UInt + internal static var allZeros: ConstraintAttributes { return self.init(0) } + internal static func convertFromNilLiteral() -> ConstraintAttributes { return self.init(0) } + internal var boolValue: Bool { return self.rawValue != 0 } + + internal func toRaw() -> UInt { return self.rawValue } + internal static func fromRaw(_ raw: UInt) -> ConstraintAttributes? { return self.init(raw) } + internal static func fromMask(_ raw: UInt) -> ConstraintAttributes { return self.init(raw) } + + // normal + + internal static var none: ConstraintAttributes { return self.init(0) } + internal static var left: ConstraintAttributes { return self.init(1) } + internal static var top: ConstraintAttributes { return self.init(2) } + internal static var right: ConstraintAttributes { return self.init(4) } + internal static var bottom: ConstraintAttributes { return self.init(8) } + internal static var leading: ConstraintAttributes { return self.init(16) } + internal static var trailing: ConstraintAttributes { return self.init(32) } + internal static var width: ConstraintAttributes { return self.init(64) } + internal static var height: ConstraintAttributes { return self.init(128) } + internal static var centerX: ConstraintAttributes { return self.init(256) } + internal static var centerY: ConstraintAttributes { return self.init(512) } + internal static var lastBaseline: ConstraintAttributes { return self.init(1024) } + + @available(iOS 8.0, OSX 10.11, *) + internal static var firstBaseline: ConstraintAttributes { return self.init(2048) } + + @available(iOS 8.0, *) + internal static var leftMargin: ConstraintAttributes { return self.init(4096) } + + @available(iOS 8.0, *) + internal static var rightMargin: ConstraintAttributes { return self.init(8192) } + + @available(iOS 8.0, *) + internal static var topMargin: ConstraintAttributes { return self.init(16384) } + + @available(iOS 8.0, *) + internal static var bottomMargin: ConstraintAttributes { return self.init(32768) } + + @available(iOS 8.0, *) + internal static var leadingMargin: ConstraintAttributes { return self.init(65536) } + + @available(iOS 8.0, *) + internal static var trailingMargin: ConstraintAttributes { return self.init(131072) } + + @available(iOS 8.0, *) + internal static var centerXWithinMargins: ConstraintAttributes { return self.init(262144) } + + @available(iOS 8.0, *) + internal static var centerYWithinMargins: ConstraintAttributes { return self.init(524288) } + + // aggregates + + internal static var edges: ConstraintAttributes { return self.init(15) } + internal static var size: ConstraintAttributes { return self.init(192) } + internal static var center: ConstraintAttributes { return self.init(768) } + + @available(iOS 8.0, *) + internal static var margins: ConstraintAttributes { return self.init(61440) } + + @available(iOS 8.0, *) + internal static var centerWithinMargins: ConstraintAttributes { return self.init(786432) } + + internal var layoutAttributes:[NSLayoutAttribute] { + var attrs = [NSLayoutAttribute]() + if (self.contains(ConstraintAttributes.left)) { + attrs.append(.left) + } + if (self.contains(ConstraintAttributes.top)) { + attrs.append(.top) + } + if (self.contains(ConstraintAttributes.right)) { + attrs.append(.right) + } + if (self.contains(ConstraintAttributes.bottom)) { + attrs.append(.bottom) + } + if (self.contains(ConstraintAttributes.leading)) { + attrs.append(.leading) + } + if (self.contains(ConstraintAttributes.trailing)) { + attrs.append(.trailing) + } + if (self.contains(ConstraintAttributes.width)) { + attrs.append(.width) + } + if (self.contains(ConstraintAttributes.height)) { + attrs.append(.height) + } + if (self.contains(ConstraintAttributes.centerX)) { + attrs.append(.centerX) + } + if (self.contains(ConstraintAttributes.centerY)) { + attrs.append(.centerY) + } + if (self.contains(ConstraintAttributes.lastBaseline)) { + attrs.append(.lastBaseline) + } + + #if os(iOS) || os(tvOS) + if (self.contains(ConstraintAttributes.firstBaseline)) { + attrs.append(.firstBaseline) + } + if (self.contains(ConstraintAttributes.leftMargin)) { + attrs.append(.leftMargin) + } + if (self.contains(ConstraintAttributes.rightMargin)) { + attrs.append(.rightMargin) + } + if (self.contains(ConstraintAttributes.topMargin)) { + attrs.append(.topMargin) + } + if (self.contains(ConstraintAttributes.bottomMargin)) { + attrs.append(.bottomMargin) + } + if (self.contains(ConstraintAttributes.leadingMargin)) { + attrs.append(.leadingMargin) + } + if (self.contains(ConstraintAttributes.trailingMargin)) { + attrs.append(.trailingMargin) + } + if (self.contains(ConstraintAttributes.centerXWithinMargins)) { + attrs.append(.centerXWithinMargins) + } + if (self.contains(ConstraintAttributes.centerYWithinMargins)) { + attrs.append(.centerYWithinMargins) + } + #endif + + return attrs + } +} + +internal func + (left: ConstraintAttributes, right: ConstraintAttributes) -> ConstraintAttributes { + return left.union(right) +} + +internal func +=(left: inout ConstraintAttributes, right: ConstraintAttributes) { + left.formUnion(right) +} + +internal func -=(left: inout ConstraintAttributes, right: ConstraintAttributes) { + left.subtract(right) +} + +internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool { + return left.rawValue == right.rawValue +} diff --git a/Pods/SnapKit/Source/ConstraintConfig.swift b/Pods/SnapKit/Source/ConstraintConfig.swift new file mode 100644 index 0000000..2746b7d --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintConfig.swift @@ -0,0 +1,37 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit + public typealias ConstraintInterfaceLayoutDirection = UIUserInterfaceLayoutDirection +#else + import AppKit + public typealias ConstraintInterfaceLayoutDirection = NSUserInterfaceLayoutDirection +#endif + + +public struct ConstraintConfig { + + public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .leftToRight + +} diff --git a/Pods/SnapKit/Source/ConstraintConstantTarget.swift b/Pods/SnapKit/Source/ConstraintConstantTarget.swift new file mode 100644 index 0000000..801bb79 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintConstantTarget.swift @@ -0,0 +1,147 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintConstantTarget { +} + +extension CGPoint: ConstraintConstantTarget { +} + +extension CGSize: ConstraintConstantTarget { +} + +extension ConstraintInsets: ConstraintConstantTarget { +} + +extension ConstraintConstantTarget { + + internal func constraintConstantTargetValueFor(layoutAttribute: NSLayoutAttribute) -> CGFloat { + if let value = self as? CGFloat { + return value + } + + if let value = self as? Float { + return CGFloat(value) + } + + if let value = self as? Double { + return CGFloat(value) + } + + if let value = self as? Int { + return CGFloat(value) + } + + if let value = self as? UInt { + return CGFloat(value) + } + + if let value = self as? CGSize { + if layoutAttribute == .width { + return value.width + } else if layoutAttribute == .height { + return value.height + } else { + return 0.0 + } + } + + if let value = self as? CGPoint { + #if os(iOS) || os(tvOS) + switch layoutAttribute { + case .left, .right, .leading, .trailing, .centerX, .leftMargin, .rightMargin, .leadingMargin, .trailingMargin, .centerXWithinMargins: + return value.x + case .top, .bottom, .centerY, .topMargin, .bottomMargin, .centerYWithinMargins, .lastBaseline, .firstBaseline: + return value.y + case .width, .height, .notAnAttribute: + return 0.0 + } + #else + switch layoutAttribute { + case .left, .right, .leading, .trailing, .centerX: + return value.x + case .top, .bottom, .centerY, .lastBaseline, .firstBaseline: + return value.y + case .width, .height, .notAnAttribute: + return 0.0 + } + #endif + } + + if let value = self as? ConstraintInsets { + #if os(iOS) || os(tvOS) + switch layoutAttribute { + case .left, .leftMargin, .centerX, .centerXWithinMargins: + return value.left + case .top, .topMargin, .centerY, .centerYWithinMargins, .lastBaseline, .firstBaseline: + return value.top + case .right, .rightMargin: + return -value.right + case .bottom, .bottomMargin: + return -value.bottom + case .leading, .leadingMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right + case .trailing, .trailingMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left + case .width: + return -(value.left + value.right) + case .height: + return -(value.top + value.bottom) + case .notAnAttribute: + return 0.0 + } + #else + switch layoutAttribute { + case .left, .centerX: + return value.left + case .top, .centerY, .lastBaseline, .firstBaseline: + return value.top + case .right: + return -value.right + case .bottom: + return -value.bottom + case .leading: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right + case .trailing: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left + case .width: + return -(value.left + value.right) + case .height: + return -(value.top + value.bottom) + case .notAnAttribute: + return 0.0 + } + #endif + } + + return 0.0 + } + +} diff --git a/Pods/SnapKit/Source/ConstraintDSL.swift b/Pods/SnapKit/Source/ConstraintDSL.swift new file mode 100644 index 0000000..ed7b7e5 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintDSL.swift @@ -0,0 +1,185 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintDSL { + + var target: AnyObject? { get } + + func setLabel(_ value: String?) + func label() -> String? + +} +extension ConstraintDSL { + + public func setLabel(_ value: String?) { + objc_setAssociatedObject(self.target, &labelKey, value, .OBJC_ASSOCIATION_COPY_NONATOMIC) + } + public func label() -> String? { + return objc_getAssociatedObject(self.target, &labelKey) as? String + } + +} +private var labelKey: UInt8 = 0 + + +public protocol ConstraintBasicAttributesDSL : ConstraintDSL { +} +extension ConstraintBasicAttributesDSL { + + // MARK: Basics + + public var left: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.left) + } + + public var top: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top) + } + + public var right: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.right) + } + + public var bottom: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom) + } + + public var leading: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leading) + } + + public var trailing: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.trailing) + } + + public var width: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.width) + } + + public var height: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height) + } + + public var centerX: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerX) + } + + public var centerY: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerY) + } + + public var edges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.edges) + } + + public var size: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size) + } + + public var center: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.center) + } + +} + +public protocol ConstraintAttributesDSL : ConstraintBasicAttributesDSL { +} +extension ConstraintAttributesDSL { + + // MARK: Baselines + + @available(*, deprecated:3.0, message:"Use .lastBaseline instead") + public var baseline: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) + } + + @available(iOS 8.0, OSX 10.11, *) + public var lastBaseline: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) + } + + @available(iOS 8.0, OSX 10.11, *) + public var firstBaseline: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.firstBaseline) + } + + // MARK: Margins + + @available(iOS 8.0, *) + public var leftMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leftMargin) + } + + @available(iOS 8.0, *) + public var topMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.topMargin) + } + + @available(iOS 8.0, *) + public var rightMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.rightMargin) + } + + @available(iOS 8.0, *) + public var bottomMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottomMargin) + } + + @available(iOS 8.0, *) + public var leadingMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leadingMargin) + } + + @available(iOS 8.0, *) + public var trailingMargin: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.trailingMargin) + } + + @available(iOS 8.0, *) + public var centerXWithinMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerXWithinMargins) + } + + @available(iOS 8.0, *) + public var centerYWithinMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerYWithinMargins) + } + + @available(iOS 8.0, *) + public var margins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.margins) + } + + @available(iOS 8.0, *) + public var centerWithinMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerWithinMargins) + } + +} diff --git a/Pods/SnapKit/Source/ConstraintDescription.swift b/Pods/SnapKit/Source/ConstraintDescription.swift new file mode 100644 index 0000000..3521f9f --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintDescription.swift @@ -0,0 +1,69 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintDescription { + + internal let item: LayoutConstraintItem + internal var attributes: ConstraintAttributes + internal var relation: ConstraintRelation? = nil + internal var sourceLocation: (String, UInt)? = nil + internal var label: String? = nil + internal var related: ConstraintItem? = nil + internal var multiplier: ConstraintMultiplierTarget = 1.0 + internal var constant: ConstraintConstantTarget = 0.0 + internal var priority: ConstraintPriorityTarget = 1000.0 + internal lazy var constraint: Constraint? = { + guard let relation = self.relation, + let related = self.related, + let sourceLocation = self.sourceLocation else { + return nil + } + let from = ConstraintItem(target: self.item, attributes: self.attributes) + + return Constraint( + from: from, + to: related, + relation: relation, + sourceLocation: sourceLocation, + label: self.label, + multiplier: self.multiplier, + constant: self.constant, + priority: self.priority + ) + }() + + // MARK: Initialization + + internal init(item: LayoutConstraintItem, attributes: ConstraintAttributes) { + self.item = item + self.attributes = attributes + } + +} diff --git a/Pods/SnapKit/Source/ConstraintInsetTarget.swift b/Pods/SnapKit/Source/ConstraintInsetTarget.swift new file mode 100644 index 0000000..ba8a0f3 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintInsetTarget.swift @@ -0,0 +1,72 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintInsetTarget: ConstraintConstantTarget { +} + +extension Int: ConstraintInsetTarget { +} + +extension UInt: ConstraintInsetTarget { +} + +extension Float: ConstraintInsetTarget { +} + +extension Double: ConstraintInsetTarget { +} + +extension CGFloat: ConstraintInsetTarget { +} + +extension ConstraintInsets: ConstraintInsetTarget { +} + +extension ConstraintInsetTarget { + + internal var constraintInsetTargetValue: ConstraintInsets { + if let amount = self as? ConstraintInsets { + return amount + } else if let amount = self as? Float { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else if let amount = self as? Double { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else if let amount = self as? CGFloat { + return ConstraintInsets(top: amount, left: amount, bottom: amount, right: amount) + } else if let amount = self as? Int { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else if let amount = self as? UInt { + return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) + } else { + return ConstraintInsets(top: 0, left: 0, bottom: 0, right: 0) + } + } + +} diff --git a/Pods/SnapKit/Source/ConstraintInsets.swift b/Pods/SnapKit/Source/ConstraintInsets.swift new file mode 100644 index 0000000..6ecac6b --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintInsets.swift @@ -0,0 +1,35 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + public typealias ConstraintInsets = UIEdgeInsets +#else + public typealias ConstraintInsets = EdgeInsets +#endif diff --git a/Pods/SnapKit/Source/ConstraintItem.swift b/Pods/SnapKit/Source/ConstraintItem.swift new file mode 100644 index 0000000..a342c1d --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintItem.swift @@ -0,0 +1,61 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public final class ConstraintItem { + + internal weak var target: AnyObject? + internal let attributes: ConstraintAttributes + + internal init(target: AnyObject?, attributes: ConstraintAttributes) { + self.target = target + self.attributes = attributes + } + + internal var layoutConstraintItem: LayoutConstraintItem? { + return self.target as? LayoutConstraintItem + } + +} + +public func ==(lhs: ConstraintItem, rhs: ConstraintItem) -> Bool { + // pointer equality + guard lhs !== rhs else { + return true + } + + // must both have valid targets and identical attributes + guard let target1 = lhs.target, + let target2 = rhs.target, + target1 === target2 && lhs.attributes == rhs.attributes else { + return false + } + + return true +} diff --git a/Pods/SnapKit/Source/ConstraintLayoutGuide+Extensions.swift b/Pods/SnapKit/Source/ConstraintLayoutGuide+Extensions.swift new file mode 100644 index 0000000..c2d9e9d --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintLayoutGuide+Extensions.swift @@ -0,0 +1,36 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#endif + + +@available(iOS 9.0, OSX 10.11, *) +public extension ConstraintLayoutGuide { + + public var snp: ConstraintLayoutGuideDSL { + return ConstraintLayoutGuideDSL(guide: self) + } + +} diff --git a/Pods/SnapKit/Source/ConstraintLayoutGuide.swift b/Pods/SnapKit/Source/ConstraintLayoutGuide.swift new file mode 100644 index 0000000..e3e50c8 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintLayoutGuide.swift @@ -0,0 +1,37 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + @available(iOS 9.0, *) + public typealias ConstraintLayoutGuide = UILayoutGuide +#else + @available(OSX 10.11, *) + public typealias ConstraintLayoutGuide = NSLayoutGuide +#endif diff --git a/Pods/SnapKit/Source/ConstraintLayoutGuideDSL.swift b/Pods/SnapKit/Source/ConstraintLayoutGuideDSL.swift new file mode 100644 index 0000000..0007819 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintLayoutGuideDSL.swift @@ -0,0 +1,66 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +@available(iOS 9.0, OSX 10.11, *) +public struct ConstraintLayoutGuideDSL: ConstraintAttributesDSL { + + @discardableResult + public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + return ConstraintMaker.prepareConstraints(item: self.guide, closure: closure) + } + + public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.makeConstraints(item: self.guide, closure: closure) + } + + public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.remakeConstraints(item: self.guide, closure: closure) + } + + public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.updateConstraints(item: self.guide, closure: closure) + } + + public func removeConstraints() { + ConstraintMaker.removeConstraints(item: self.guide) + } + + public var target: AnyObject? { + return self.guide + } + + internal let guide: ConstraintLayoutGuide + + internal init(guide: ConstraintLayoutGuide) { + self.guide = guide + + } + +} diff --git a/Pods/SnapKit/Source/ConstraintLayoutSupport.swift b/Pods/SnapKit/Source/ConstraintLayoutSupport.swift new file mode 100644 index 0000000..e92e9fb --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintLayoutSupport.swift @@ -0,0 +1,36 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + @available(iOS 8.0, *) + public typealias ConstraintLayoutSupport = UILayoutSupport +#else + public class ConstraintLayoutSupport {} +#endif diff --git a/Pods/SnapKit/Source/ConstraintLayoutSupportDSL.swift b/Pods/SnapKit/Source/ConstraintLayoutSupportDSL.swift new file mode 100644 index 0000000..5d6ae89 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintLayoutSupportDSL.swift @@ -0,0 +1,56 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +@available(iOS 8.0, *) +public struct ConstraintLayoutSupportDSL: ConstraintDSL { + + public var target: AnyObject? { + return self.support + } + + internal let support: ConstraintLayoutSupport + + internal init(support: ConstraintLayoutSupport) { + self.support = support + + } + + public var top: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top) + } + + public var bottom: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom) + } + + public var height: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height) + } +} diff --git a/Pods/SnapKit/Source/ConstraintMaker.swift b/Pods/SnapKit/Source/ConstraintMaker.swift new file mode 100644 index 0000000..b20cdb5 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMaker.swift @@ -0,0 +1,220 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public class ConstraintMaker { + + public var left: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.left) + } + + public var top: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.top) + } + + public var bottom: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.bottom) + } + + public var right: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.right) + } + + public var leading: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.leading) + } + + public var trailing: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.trailing) + } + + public var width: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.width) + } + + public var height: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.height) + } + + public var centerX: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerX) + } + + public var centerY: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerY) + } + + @available(*, deprecated:3.0, message:"Use lastBaseline instead") + public var baseline: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.lastBaseline) + } + + public var lastBaseline: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.lastBaseline) + } + + @available(iOS 8.0, OSX 10.11, *) + public var firstBaseline: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.firstBaseline) + } + + @available(iOS 8.0, *) + public var leftMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.leftMargin) + } + + @available(iOS 8.0, *) + public var rightMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.rightMargin) + } + + @available(iOS 8.0, *) + public var topMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.topMargin) + } + + @available(iOS 8.0, *) + public var bottomMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.bottomMargin) + } + + @available(iOS 8.0, *) + public var leadingMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.leadingMargin) + } + + @available(iOS 8.0, *) + public var trailingMargin: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.trailingMargin) + } + + @available(iOS 8.0, *) + public var centerXWithinMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerXWithinMargins) + } + + @available(iOS 8.0, *) + public var centerYWithinMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerYWithinMargins) + } + + public var edges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.edges) + } + public var size: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.size) + } + public var center: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.center) + } + + @available(iOS 8.0, *) + public var margins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.margins) + } + + @available(iOS 8.0, *) + public var centerWithinMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.centerWithinMargins) + } + + private let item: LayoutConstraintItem + private var descriptions = [ConstraintDescription]() + + internal init(item: LayoutConstraintItem) { + self.item = item + self.item.prepare() + } + + internal func makeExtendableWithAttributes(_ attributes: ConstraintAttributes) -> ConstraintMakerExtendable { + let description = ConstraintDescription(item: self.item, attributes: attributes) + self.descriptions.append(description) + return ConstraintMakerExtendable(description) + } + + internal static func prepareConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + let maker = ConstraintMaker(item: item) + closure(maker) + var constraints: [Constraint] = [] + for description in maker.descriptions { + guard let constraint = description.constraint else { + continue + } + constraints.append(constraint) + } + return constraints + } + + internal static func makeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { + let maker = ConstraintMaker(item: item) + closure(maker) + var constraints: [Constraint] = [] + for description in maker.descriptions { + guard let constraint = description.constraint else { + continue + } + constraints.append(constraint) + } + for constraint in constraints { + constraint.activateIfNeeded(updatingExisting: false) + } + } + + internal static func remakeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { + self.removeConstraints(item: item) + self.makeConstraints(item: item, closure: closure) + } + + internal static func updateConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { + guard item.constraints.count > 0 else { + self.makeConstraints(item: item, closure: closure) + return + } + + let maker = ConstraintMaker(item: item) + closure(maker) + var constraints: [Constraint] = [] + for description in maker.descriptions { + guard let constraint = description.constraint else { + continue + } + constraints.append(constraint) + } + for constraint in constraints { + constraint.activateIfNeeded(updatingExisting: true) + } + } + + internal static func removeConstraints(item: LayoutConstraintItem) { + let constraints = item.constraints + for constraint in constraints { + constraint.deactivateIfNeeded() + } + } + +} diff --git a/Pods/SnapKit/Source/ConstraintMakerEditable.swift b/Pods/SnapKit/Source/ConstraintMakerEditable.swift new file mode 100644 index 0000000..fb88c41 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMakerEditable.swift @@ -0,0 +1,56 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerEditable: ConstraintMakerPriortizable { + + @discardableResult + public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { + self.description.multiplier = amount + return self + } + + @discardableResult + public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { + return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue) + } + + @discardableResult + public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable { + self.description.constant = amount.constraintOffsetTargetValue + return self + } + + @discardableResult + public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable { + self.description.constant = amount.constraintInsetTargetValue + return self + } + +} diff --git a/Pods/SnapKit/Source/ConstraintMakerExtendable.swift b/Pods/SnapKit/Source/ConstraintMakerExtendable.swift new file mode 100644 index 0000000..658c833 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMakerExtendable.swift @@ -0,0 +1,163 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerExtendable: ConstraintMakerRelatable { + + public var left: ConstraintMakerExtendable { + self.description.attributes += .left + return self + } + + public var top: ConstraintMakerExtendable { + self.description.attributes += .top + return self + } + + public var bottom: ConstraintMakerExtendable { + self.description.attributes += .bottom + return self + } + + public var right: ConstraintMakerExtendable { + self.description.attributes += .right + return self + } + + public var leading: ConstraintMakerExtendable { + self.description.attributes += .leading + return self + } + + public var trailing: ConstraintMakerExtendable { + self.description.attributes += .trailing + return self + } + + public var width: ConstraintMakerExtendable { + self.description.attributes += .width + return self + } + + public var height: ConstraintMakerExtendable { + self.description.attributes += .height + return self + } + + public var centerX: ConstraintMakerExtendable { + self.description.attributes += .centerX + return self + } + + public var centerY: ConstraintMakerExtendable { + self.description.attributes += .centerY + return self + } + + @available(*, deprecated:3.0, message:"Use lastBaseline instead") + public var baseline: ConstraintMakerExtendable { + self.description.attributes += .lastBaseline + return self + } + + public var lastBaseline: ConstraintMakerExtendable { + self.description.attributes += .lastBaseline + return self + } + + @available(iOS 8.0, OSX 10.11, *) + public var firstBaseline: ConstraintMakerExtendable { + self.description.attributes += .firstBaseline + return self + } + + @available(iOS 8.0, *) + public var leftMargin: ConstraintMakerExtendable { + self.description.attributes += .leftMargin + return self + } + + @available(iOS 8.0, *) + public var rightMargin: ConstraintMakerExtendable { + self.description.attributes += .rightMargin + return self + } + + @available(iOS 8.0, *) + public var bottomMargin: ConstraintMakerExtendable { + self.description.attributes += .bottomMargin + return self + } + + @available(iOS 8.0, *) + public var leadingMargin: ConstraintMakerExtendable { + self.description.attributes += .leadingMargin + return self + } + + @available(iOS 8.0, *) + public var trailingMargin: ConstraintMakerExtendable { + self.description.attributes += .trailingMargin + return self + } + + @available(iOS 8.0, *) + public var centerXWithinMargins: ConstraintMakerExtendable { + self.description.attributes += .centerXWithinMargins + return self + } + + @available(iOS 8.0, *) + public var centerYWithinMargins: ConstraintMakerExtendable { + self.description.attributes += .centerYWithinMargins + return self + } + + public var edges: ConstraintMakerExtendable { + self.description.attributes += .edges + return self + } + public var size: ConstraintMakerExtendable { + self.description.attributes += .size + return self + } + + @available(iOS 8.0, *) + public var margins: ConstraintMakerExtendable { + self.description.attributes += .margins + return self + } + + @available(iOS 8.0, *) + public var centerWithinMargins: ConstraintMakerExtendable { + self.description.attributes += .centerWithinMargins + return self + } + +} diff --git a/Pods/SnapKit/Source/ConstraintMakerFinalizable.swift b/Pods/SnapKit/Source/ConstraintMakerFinalizable.swift new file mode 100644 index 0000000..4e1379e --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMakerFinalizable.swift @@ -0,0 +1,49 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerFinalizable { + + internal let description: ConstraintDescription + + internal init(_ description: ConstraintDescription) { + self.description = description + } + + @discardableResult + public func labeled(_ label: String) -> ConstraintMakerFinalizable { + self.description.label = label + return self + } + + public var constraint: Constraint { + return self.description.constraint! + } + +} diff --git a/Pods/SnapKit/Source/ConstraintMakerPriortizable.swift b/Pods/SnapKit/Source/ConstraintMakerPriortizable.swift new file mode 100644 index 0000000..82a6de6 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMakerPriortizable.swift @@ -0,0 +1,67 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { + + @discardableResult + public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable { + self.description.priority = amount + return self + } + + @available(*, deprecated:3.0, message:"Use priority(_ amount: ConstraintPriorityTarget) instead.") + @discardableResult + public func priorityRequired() -> ConstraintMakerFinalizable { + return self.priority(1000) + } + + @available(*, deprecated:3.0, message:"Use priority(_ amount: ConstraintPriorityTarget) instead.") + @discardableResult + public func priorityHigh() -> ConstraintMakerFinalizable { + return self.priority(750) + } + + @available(*, deprecated:3.0, message:"Use priority(_ amount: ConstraintPriorityTarget) instead.") + @discardableResult + public func priorityMedium() -> ConstraintMakerFinalizable { + #if os(iOS) || os(tvOS) + return self.priority(500) + #else + return self.priority(501) + #endif + } + + @available(*, deprecated:3.0, message:"Use priority(_ amount: ConstraintPriorityTarget) instead.") + @discardableResult + public func priorityLow() -> ConstraintMakerFinalizable { + return self.priority(250) + } + +} diff --git a/Pods/SnapKit/Source/ConstraintMakerRelatable.swift b/Pods/SnapKit/Source/ConstraintMakerRelatable.swift new file mode 100644 index 0000000..98c7158 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMakerRelatable.swift @@ -0,0 +1,113 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class ConstraintMakerRelatable { + + internal let description: ConstraintDescription + + internal init(_ description: ConstraintDescription) { + self.description = description + } + + internal func relatedTo(_ other: ConstraintRelatableTarget, relation: ConstraintRelation, file: String, line: UInt) -> ConstraintMakerEditable { + let related: ConstraintItem + let constant: ConstraintConstantTarget + + if let other = other as? ConstraintItem { + guard other.attributes == ConstraintAttributes.none || + other.attributes.layoutAttributes.count <= 1 || + other.attributes.layoutAttributes == self.description.attributes.layoutAttributes || + other.attributes == .edges && self.description.attributes == .margins || + other.attributes == .margins && self.description.attributes == .edges else { + fatalError("Cannot constraint to multiple non identical attributes. (\(file), \(line))"); + } + + related = other + constant = 0.0 + } else if let other = other as? ConstraintView { + related = ConstraintItem(target: other, attributes: ConstraintAttributes.none) + constant = 0.0 + } else if let other = other as? ConstraintConstantTarget { + related = ConstraintItem(target: nil, attributes: ConstraintAttributes.none) + constant = other + } else if #available(iOS 9.0, OSX 10.11, *), let other = other as? ConstraintLayoutGuide { + related = ConstraintItem(target: other, attributes: ConstraintAttributes.none) + constant = 0.0 + } else { + fatalError("Invalid constraint. (\(file), \(line))") + } + + let editable = ConstraintMakerEditable(self.description) + editable.description.sourceLocation = (file, line) + editable.description.relation = relation + editable.description.related = related + editable.description.constant = constant + return editable + } + + @discardableResult + public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + return self.relatedTo(other, relation: .equal, file: file, line: line) + } + + @discardableResult + public func equalToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.") + } + return self.relatedTo(other, relation: .equal, file: file, line: line) + } + + @discardableResult + public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line) + } + + @discardableResult + public func lessThanOrEqualToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.") + } + return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line) + } + + @discardableResult + public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line) + } + + @discardableResult + public func greaterThanOrEqualToSuperview(_ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.") + } + return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line) + } +} diff --git a/Pods/SnapKit/Source/ConstraintMultiplierTarget.swift b/Pods/SnapKit/Source/ConstraintMultiplierTarget.swift new file mode 100644 index 0000000..6fecd33 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintMultiplierTarget.swift @@ -0,0 +1,75 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintMultiplierTarget { + + var constraintMultiplierTargetValue: CGFloat { get } + +} + +extension Int: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension UInt: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension Float: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension Double: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return CGFloat(self) + } + +} + +extension CGFloat: ConstraintMultiplierTarget { + + public var constraintMultiplierTargetValue: CGFloat { + return self + } + +} diff --git a/Pods/SnapKit/Source/ConstraintOffsetTarget.swift b/Pods/SnapKit/Source/ConstraintOffsetTarget.swift new file mode 100644 index 0000000..bd9e0a1 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintOffsetTarget.swift @@ -0,0 +1,69 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintOffsetTarget: ConstraintConstantTarget { +} + +extension Int: ConstraintOffsetTarget { +} + +extension UInt: ConstraintOffsetTarget { +} + +extension Float: ConstraintOffsetTarget { +} + +extension Double: ConstraintOffsetTarget { +} + +extension CGFloat: ConstraintOffsetTarget { +} + +extension ConstraintOffsetTarget { + + internal var constraintOffsetTargetValue: CGFloat { + let offset: CGFloat + if let amount = self as? Float { + offset = CGFloat(amount) + } else if let amount = self as? Double { + offset = CGFloat(amount) + } else if let amount = self as? CGFloat { + offset = CGFloat(amount) + } else if let amount = self as? Int { + offset = CGFloat(amount) + } else if let amount = self as? UInt { + offset = CGFloat(amount) + } else { + offset = 0.0 + } + return offset + } + +} diff --git a/Pods/SnapKit/Source/ConstraintPriorityTarget.swift b/Pods/SnapKit/Source/ConstraintPriorityTarget.swift new file mode 100644 index 0000000..eb32f79 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintPriorityTarget.swift @@ -0,0 +1,75 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintPriorityTarget { + + var constraintPriorityTargetValue: Float { get } + +} + +extension Int: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +extension UInt: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +extension Float: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return self + } + +} + +extension Double: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} + +extension CGFloat: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return Float(self) + } + +} diff --git a/Pods/SnapKit/Source/ConstraintRelatableTarget.swift b/Pods/SnapKit/Source/ConstraintRelatableTarget.swift new file mode 100644 index 0000000..6976367 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintRelatableTarget.swift @@ -0,0 +1,66 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol ConstraintRelatableTarget { +} + +extension Int: ConstraintRelatableTarget { +} + +extension UInt: ConstraintRelatableTarget { +} + +extension Float: ConstraintRelatableTarget { +} + +extension Double: ConstraintRelatableTarget { +} + +extension CGFloat: ConstraintRelatableTarget { +} + +extension CGSize: ConstraintRelatableTarget { +} + +extension CGPoint: ConstraintRelatableTarget { +} + +extension ConstraintInsets: ConstraintRelatableTarget { +} + +extension ConstraintItem: ConstraintRelatableTarget { +} + +extension ConstraintView: ConstraintRelatableTarget { +} + +@available(iOS 9.0, OSX 10.11, *) +extension ConstraintLayoutGuide: ConstraintRelatableTarget { +} diff --git a/Pods/SnapKit/Source/ConstraintRelation.swift b/Pods/SnapKit/Source/ConstraintRelation.swift new file mode 100644 index 0000000..d53bb3b --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintRelation.swift @@ -0,0 +1,48 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +internal enum ConstraintRelation : Int { + case equal = 1 + case lessThanOrEqual + case greaterThanOrEqual + + internal var layoutRelation: NSLayoutRelation { + get { + switch(self) { + case .equal: + return .equal + case .lessThanOrEqual: + return .lessThanOrEqual + case .greaterThanOrEqual: + return .greaterThanOrEqual + } + } + } +} diff --git a/Pods/SnapKit/Source/ConstraintView+Extensions.swift b/Pods/SnapKit/Source/ConstraintView+Extensions.swift new file mode 100644 index 0000000..77afad9 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintView+Extensions.swift @@ -0,0 +1,152 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public extension ConstraintView { + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_left: ConstraintItem { return self.snp.left } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_top: ConstraintItem { return self.snp.top } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_right: ConstraintItem { return self.snp.right } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_bottom: ConstraintItem { return self.snp.bottom } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_leading: ConstraintItem { return self.snp.leading } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_trailing: ConstraintItem { return self.snp.trailing } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_width: ConstraintItem { return self.snp.width } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_height: ConstraintItem { return self.snp.height } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_centerX: ConstraintItem { return self.snp.centerX } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_centerY: ConstraintItem { return self.snp.centerY } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_baseline: ConstraintItem { return self.snp.baseline } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, OSX 10.11, *) + public var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, OSX 10.11, *) + public var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_leftMargin: ConstraintItem { return self.snp.leftMargin } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_topMargin: ConstraintItem { return self.snp.topMargin } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_rightMargin: ConstraintItem { return self.snp.rightMargin } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_edges: ConstraintItem { return self.snp.edges } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_size: ConstraintItem { return self.snp.size } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public var snp_center: ConstraintItem { return self.snp.center } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_margins: ConstraintItem { return self.snp.margins } + + @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS 8.0, *) + public var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + return self.snp.prepareConstraints(closure) + } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + self.snp.makeConstraints(closure) + } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + self.snp.remakeConstraints(closure) + } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + self.snp.updateConstraints(closure) + } + + @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + public func snp_removeConstraints() { + self.snp.removeConstraints() + } + + public var snp: ConstraintViewDSL { + return ConstraintViewDSL(view: self) + } + +} diff --git a/Pods/SnapKit/Source/ConstraintView.swift b/Pods/SnapKit/Source/ConstraintView.swift new file mode 100644 index 0000000..6ff8a76 --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintView.swift @@ -0,0 +1,35 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + public typealias ConstraintView = UIView +#else + public typealias ConstraintView = NSView +#endif diff --git a/Pods/SnapKit/Source/ConstraintViewDSL.swift b/Pods/SnapKit/Source/ConstraintViewDSL.swift new file mode 100644 index 0000000..0242c4a --- /dev/null +++ b/Pods/SnapKit/Source/ConstraintViewDSL.swift @@ -0,0 +1,101 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public struct ConstraintViewDSL: ConstraintAttributesDSL { + + @discardableResult + public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + return ConstraintMaker.prepareConstraints(item: self.view, closure: closure) + } + + public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.makeConstraints(item: self.view, closure: closure) + } + + public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.remakeConstraints(item: self.view, closure: closure) + } + + public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + ConstraintMaker.updateConstraints(item: self.view, closure: closure) + } + + public func removeConstraints() { + ConstraintMaker.removeConstraints(item: self.view) + } + + public var contentHuggingHorizontalPriority: Float { + get { + return self.view.contentHuggingPriority(for: .horizontal) + } + set { + self.view.setContentHuggingPriority(newValue, for: .horizontal) + } + } + + public var contentHuggingVerticalPriority: Float { + get { + return self.view.contentHuggingPriority(for: .vertical) + } + set { + self.view.setContentHuggingPriority(newValue, for: .vertical) + } + } + + public var contentCompressionResistanceHorizontalPriority: Float { + get { + return self.view.contentCompressionResistancePriority(for: .horizontal) + } + set { + self.view.setContentHuggingPriority(newValue, for: .horizontal) + } + } + + public var contentCompressionResistanceVerticalPriority: Float { + get { + return self.view.contentCompressionResistancePriority(for: .vertical) + } + set { + self.view.setContentCompressionResistancePriority(newValue, for: .vertical) + } + } + + public var target: AnyObject? { + return self.view + } + + internal let view: ConstraintView + + internal init(view: ConstraintView) { + self.view = view + + } + +} diff --git a/Pods/SnapKit/Source/Debugging.swift b/Pods/SnapKit/Source/Debugging.swift new file mode 100644 index 0000000..fdc505d --- /dev/null +++ b/Pods/SnapKit/Source/Debugging.swift @@ -0,0 +1,160 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +public extension LayoutConstraint { + + override public var description: String { + var description = "<" + + description += descriptionForObject(self) + + if let firstItem = conditionalOptional(from: self.firstItem) { + description += " \(descriptionForObject(firstItem))" + } + + if self.firstAttribute != .notAnAttribute { + description += ".\(descriptionForAttribute(self.firstAttribute))" + } + + description += " \(descriptionForRelation(self.relation))" + + if let secondItem = self.secondItem { + description += " \(descriptionForObject(secondItem))" + } + + if self.secondAttribute != .notAnAttribute { + description += ".\(descriptionForAttribute(self.secondAttribute))" + } + + if self.multiplier != 1.0 { + description += " * \(self.multiplier)" + } + + if self.secondAttribute == .notAnAttribute { + description += " \(self.constant)" + } else { + if self.constant > 0.0 { + description += " + \(self.constant)" + } else if self.constant < 0.0 { + description += " - \(abs(self.constant))" + } + } + + if self.priority != 1000.0 { + description += " ^\(self.priority)" + } + + description += ">" + + return description + } + +} + +private func descriptionForRelation(_ relation: NSLayoutRelation) -> String { + switch relation { + case .equal: return "==" + case .greaterThanOrEqual: return ">=" + case .lessThanOrEqual: return "<=" + } +} + +private func descriptionForAttribute(_ attribute: NSLayoutAttribute) -> String { + #if os(iOS) || os(tvOS) + switch attribute { + case .notAnAttribute: return "notAnAttribute" + case .top: return "top" + case .left: return "left" + case .bottom: return "bottom" + case .right: return "right" + case .leading: return "leading" + case .trailing: return "trailing" + case .width: return "width" + case .height: return "height" + case .centerX: return "centerX" + case .centerY: return "centerY" + case .lastBaseline: return "lastBaseline" + case .firstBaseline: return "firstBaseline" + case .topMargin: return "topMargin" + case .leftMargin: return "leftMargin" + case .bottomMargin: return "bottomMargin" + case .rightMargin: return "rightMargin" + case .leadingMargin: return "leadingMargin" + case .trailingMargin: return "trailingMargin" + case .centerXWithinMargins: return "centerXWithinMargins" + case .centerYWithinMargins: return "centerYWithinMargins" + } + #else + switch attribute { + case .notAnAttribute: return "notAnAttribute" + case .top: return "top" + case .left: return "left" + case .bottom: return "bottom" + case .right: return "right" + case .leading: return "leading" + case .trailing: return "trailing" + case .width: return "width" + case .height: return "height" + case .centerX: return "centerX" + case .centerY: return "centerY" + case .lastBaseline: return "lastBaseline" + case .firstBaseline: return "firstBaseline" + } + #endif +} + +private func conditionalOptional(from object: Optional) -> Optional { + return object +} + +private func conditionalOptional(from object: T) -> Optional { + return Optional.some(object) +} + +private func descriptionForObject(_ object: AnyObject) -> String { + let pointerDescription = String(format: "%p", UInt(bitPattern: ObjectIdentifier(object))) + var desc = "" + + desc += type(of: object).description() + + if let object = object as? ConstraintView { + desc += ":\(object.snp.label() ?? pointerDescription)" + } else if let object = object as? LayoutConstraint { + desc += ":\(object.label ?? pointerDescription)" + } else { + desc += ":\(pointerDescription)" + } + + if let object = object as? LayoutConstraint, let file = object.constraint?.sourceLocation.0, let line = object.constraint?.sourceLocation.1 { + desc += "@\((file as NSString).lastPathComponent)#\(line)" + } + + desc += "" + return desc +} diff --git a/Pods/SnapKit/Source/LayoutConstraint.swift b/Pods/SnapKit/Source/LayoutConstraint.swift new file mode 100644 index 0000000..8bb5ed2 --- /dev/null +++ b/Pods/SnapKit/Source/LayoutConstraint.swift @@ -0,0 +1,57 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public class LayoutConstraint : NSLayoutConstraint { + + public var label: String? { + get { + return self.identifier + } + set { + self.identifier = newValue + } + } + + internal weak var constraint: Constraint? = nil + +} + +internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { + guard lhs.firstItem === rhs.firstItem && + lhs.secondItem === rhs.secondItem && + lhs.firstAttribute == rhs.firstAttribute && + lhs.secondAttribute == rhs.secondAttribute && + lhs.relation == rhs.relation && + lhs.priority == rhs.priority && + lhs.multiplier == rhs.multiplier else { + return false + } + return true +} diff --git a/Pods/SnapKit/Source/LayoutConstraintItem.swift b/Pods/SnapKit/Source/LayoutConstraintItem.swift new file mode 100644 index 0000000..a59de6b --- /dev/null +++ b/Pods/SnapKit/Source/LayoutConstraintItem.swift @@ -0,0 +1,93 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +public protocol LayoutConstraintItem: class { +} + +@available(iOS 9.0, OSX 10.11, *) +extension ConstraintLayoutGuide : LayoutConstraintItem { +} + +extension ConstraintView : LayoutConstraintItem { +} + + +extension LayoutConstraintItem { + + internal func prepare() { + if let view = self as? ConstraintView { + view.translatesAutoresizingMaskIntoConstraints = false + } + } + + internal var superview: ConstraintView? { + if let view = self as? ConstraintView { + return view.superview + } + + if #available(iOS 9.0, OSX 10.11, *), let guide = self as? ConstraintLayoutGuide { + return guide.owningView + } + + return nil + } + internal var constraints: [Constraint] { + return self.constraintsSet.allObjects as! [Constraint] + } + + internal func add(constraints: [Constraint]) { + let constraintsSet = self.constraintsSet + for constraint in constraints { + constraintsSet.add(constraint) + } + } + + internal func remove(constraints: [Constraint]) { + let constraintsSet = self.constraintsSet + for constraint in constraints { + constraintsSet.remove(constraint) + } + } + + private var constraintsSet: NSMutableSet { + let constraintsSet: NSMutableSet + + if let existing = objc_getAssociatedObject(self, &constraintsKey) as? NSMutableSet { + constraintsSet = existing + } else { + constraintsSet = NSMutableSet() + objc_setAssociatedObject(self, &constraintsKey, constraintsSet, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + return constraintsSet + + } + +} +private var constraintsKey: UInt8 = 0 diff --git a/Pods/SnapKit/Source/UILayoutSupport+Extensions.swift b/Pods/SnapKit/Source/UILayoutSupport+Extensions.swift new file mode 100644 index 0000000..cfbce2e --- /dev/null +++ b/Pods/SnapKit/Source/UILayoutSupport+Extensions.swift @@ -0,0 +1,36 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#endif + + +@available(iOS 8.0, *) +public extension ConstraintLayoutSupport { + + public var snp: ConstraintLayoutSupportDSL { + return ConstraintLayoutSupportDSL(support: self) + } + +} diff --git a/Pods/SwiftyJSON/LICENSE b/Pods/SwiftyJSON/LICENSE new file mode 100644 index 0000000..916a0ac --- /dev/null +++ b/Pods/SwiftyJSON/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Ruoyu Fu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Pods/SwiftyJSON/README.md b/Pods/SwiftyJSON/README.md new file mode 100644 index 0000000..6256c84 --- /dev/null +++ b/Pods/SwiftyJSON/README.md @@ -0,0 +1,519 @@ +# SwiftyJSON + +[![Travis CI](https://travis-ci.org/SwiftyJSON/SwiftyJSON.svg?branch=master)](https://travis-ci.org/SwiftyJSON/SwiftyJSON) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![CocoaPods](https://img.shields.io/cocoapods/v/SwiftyJSON.svg) ![Platform](https://img.shields.io/badge/platforms-iOS%208.0+%20%7C%20macOS%2010.10+%20%7C%20tvOS%209.0+%20%7C%20watchOS%202.0+-333333.svg) + +SwiftyJSON makes it easy to deal with JSON data in Swift. + +1. [Why is the typical JSON handling in Swift NOT good](#why-is-the-typical-json-handling-in-swift-not-good) +2. [Requirements](#requirements) +3. [Integration](#integration) +4. [Usage](#usage) + - [Initialization](#initialization) + - [Subscript](#subscript) + - [Loop](#loop) + - [Error](#error) + - [Optional getter](#optional-getter) + - [Non-optional getter](#non-optional-getter) + - [Setter](#setter) + - [Raw object](#raw-object) + - [Literal convertibles](#literal-convertibles) + - [Merging](#merging) +5. [Work with Alamofire](#work-with-alamofire) + +> For Legacy Swift support, take a look at the [swift2 branch](https://github.com/SwiftyJSON/SwiftyJSON/tree/swift2) + +> [中文介绍](http://tangplin.github.io/swiftyjson/) + + +## Why is the typical JSON handling in Swift NOT good? + +Swift is very strict about types. But although explicit typing is good for saving us from mistakes, it becomes painful when dealing with JSON and other areas that are, by nature, implicit about types. + +Take the Twitter API for example. Say we want to retrieve a user's "name" value of some tweet in Swift (according to Twitter's API https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline). + +The code would look like this: + +```swift +if let statusesArray = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]], + let user = statusesArray[0]["user"] as? [String: Any], + let username = user["name"] as? String { + // Finally we got the username +} +``` + +It's not good. + +Even if we use optional chaining, it would be messy: + +```swift +if let JSONObject = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]], + let username = (JSONObject[0]["user"] as? [String: Any])?["name"] as? String { + // There's our username +} +``` + +An unreadable mess--for something that should really be simple! + +With SwiftyJSON all you have to do is: + +```swift +let json = JSON(data: dataFromNetworking) +if let userName = json[0]["user"]["name"].string { + //Now you got your value +} +``` + +And don't worry about the Optional Wrapping thing. It's done for you automatically. + +```swift +let json = JSON(data: dataFromNetworking) +if let userName = json[999999]["wrong_key"]["wrong_name"].string { + //Calm down, take it easy, the ".string" property still produces the correct Optional String type with safety +} else { + //Print the error + print(json[999999]["wrong_key"]["wrong_name"]) +} +``` + +## Requirements + +- iOS 8.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+ +- Xcode 8 + +## Integration + +#### CocoaPods (iOS 8+, OS X 10.9+) + +You can use [CocoaPods](http://cocoapods.org/) to install `SwiftyJSON`by adding it to your `Podfile`: + +```ruby +platform :ios, '8.0' +use_frameworks! + +target 'MyApp' do + pod 'SwiftyJSON' +end +``` + +Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 8.0: + + +#### Carthage (iOS 8+, OS X 10.9+) + +You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftyJSON` by adding it to your `Cartfile`: + +``` +github "SwiftyJSON/SwiftyJSON" +``` + +#### Swift Package Manager + +You can use [The Swift Package Manager](https://swift.org/package-manager) to install `SwiftyJSON` by adding the proper description to your `Package.swift` file: + +```swift +import PackageDescription + +let package = Package( + name: "YOUR_PROJECT_NAME", + targets: [], + dependencies: [ + .Package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", versions: Version(1,0,0).. = json["list"].arrayValue +``` + +```swift +//If not a Dictionary or nil, return [:] +let user: Dictionary = json["user"].dictionaryValue +``` + +#### Setter + +```swift +json["name"] = JSON("new-name") +json[0] = JSON(1) +``` + +```swift +json["id"].int = 1234567890 +json["coordinate"].double = 8766.766 +json["name"].string = "Jack" +json.arrayObject = [1,2,3,4] +json.dictionaryObject = ["name":"Jack", "age":25] +``` + +#### Raw object + +```swift +let jsonObject: Any = json.object +``` + +```swift +if let jsonObject: Any = json.rawValue +``` + +```swift +//convert the JSON to raw NSData +if let data = json.rawData() { + //Do something you want +} +``` + +```swift +//convert the JSON to a raw String +if let string = json.rawString() { + //Do something you want +} +``` + +#### Existence + +```swift +//shows you whether value specified in JSON or not +if json["name"].exists() +``` + +#### Literal convertibles + +For more info about literal convertibles: [Swift Literal Convertibles](http://nshipster.com/swift-literal-convertible/) + +```swift +//StringLiteralConvertible +let json: JSON = "I'm a json" +``` + +```swift +//IntegerLiteralConvertible +let json: JSON = 12345 +``` + +```swift +//BooleanLiteralConvertible +let json: JSON = true +``` + +```swift +//FloatLiteralConvertible +let json: JSON = 2.8765 +``` + +```swift +//DictionaryLiteralConvertible +let json: JSON = ["I":"am", "a":"json"] +``` + +```swift +//ArrayLiteralConvertible +let json: JSON = ["I", "am", "a", "json"] +``` + +```swift +//NilLiteralConvertible +let json: JSON = nil +``` + +```swift +//With subscript in array +var json: JSON = [1,2,3] +json[0] = 100 +json[1] = 200 +json[2] = 300 +json[999] = 300 //Don't worry, nothing will happen +``` + +```swift +//With subscript in dictionary +var json: JSON = ["name": "Jack", "age": 25] +json["name"] = "Mike" +json["age"] = "25" //It's OK to set String +json["address"] = "L.A." // Add the "address": "L.A." in json +``` + +```swift +//Array & Dictionary +var json: JSON = ["name": "Jack", "age": 25, "list": ["a", "b", "c", ["what": "this"]]] +json["list"][3]["what"] = "that" +json["list",3,"what"] = "that" +let path: [JSONSubscriptType] = ["list",3,"what"] +json[path] = "that" +``` + +```swift +//With other JSON objects +let user: JSON = ["username" : "Steve", "password": "supersecurepassword"] +let auth: JSON = [ + "user": user.object //use user.object instead of just user + "apikey": "supersecretapitoken" +] +``` + +#### Merging + +It is possible to merge one JSON into another JSON. Merging a JSON into another JSON adds all non existing values to the original JSON which are only present in the `other` JSON. + +If both JSONs contain a value for the same key, _mostly_ this value gets overwritten in the original JSON, but there are two cases where it provides some special treatment: + +- In case of both values being a `JSON.Type.array` the values form the array found in the `other` JSON getting appended to the original JSON's array value. +- In case of both values being a `JSON.Type.dictionary` both JSON-values are getting merged the same way the encapsulating JSON is merged. + +In case, where two fields in a JSON have a different types, the value will get always overwritten. + +There are two different fashions for merging: `merge` modifies the original JSON, whereas `merged` works non-destructively on a copy. + +```swift +let original: JSON = [ + "first_name": "John", + "age": 20, + "skills": ["Coding", "Reading"], + "address": [ + "street": "Front St", + "zip": "12345", + ] +] + +let update: JSON = [ + "last_name": "Doe", + "age": 21, + "skills": ["Writing"], + "address": [ + "zip": "12342", + "city": "New York City" + ] +] + +let updated = original.merge(with: update) +// [ +// "first_name": "John", +// "last_name": "Doe", +// "age": 21, +// "skills": ["Coding", "Reading", "Writing"], +// "address": [ +// "street": "Front St", +// "zip": "12342", +// "city": "New York City" +// ] +// ] +``` + +## String representation +There are two options available: +- use the default Swift one +- use a custom one that will handle optionals well and represent `nil` as `"null"`: +```swift +let dict = ["1":2, "2":"two", "3": nil] as [String: Any?] +let json = JSON(dict) +let representation = json.rawString(options: [.castNilToNSNull: true]) +// representation is "{\"1\":2,\"2\":\"two\",\"3\":null}", which represents {"1":2,"2":"two","3":null} +``` + +## Work with Alamofire + +SwiftyJSON nicely wraps the result of the Alamofire JSON response handler: + +```swift +Alamofire.request(url, method: .get).validate().responseJSON { response in + switch response.result { + case .success(let value): + let json = JSON(value) + print("JSON: \(json)") + case .failure(let error): + print(error) + } +} +``` diff --git a/Pods/SwiftyJSON/Source/SwiftyJSON.swift b/Pods/SwiftyJSON/Source/SwiftyJSON.swift new file mode 100644 index 0000000..e79c10d --- /dev/null +++ b/Pods/SwiftyJSON/Source/SwiftyJSON.swift @@ -0,0 +1,1485 @@ +// SwiftyJSON.swift +// +// Copyright (c) 2014 - 2017 Ruoyu Fu, Pinglin Tang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +// MARK: - Error + +///Error domain +public let ErrorDomain: String = "SwiftyJSONErrorDomain" + +///Error code +public let ErrorUnsupportedType: Int = 999 +public let ErrorIndexOutOfBounds: Int = 900 +public let ErrorWrongType: Int = 901 +public let ErrorNotExist: Int = 500 +public let ErrorInvalidJSON: Int = 490 + +// MARK: - JSON Type + +/** + JSON's type definitions. + + See http://www.json.org + */ +public enum Type :Int{ + + case number + case string + case bool + case array + case dictionary + case null + case unknown +} + +// MARK: - JSON Base +public struct JSON { + + /** + Creates a JSON using the data. + + - parameter data: The NSData used to convert to json.Top level object in data is an NSArray or NSDictionary + - parameter opt: The JSON serialization reading options. `.AllowFragments` by default. + - parameter error: The NSErrorPointer used to return the error. `nil` by default. + + - returns: The created JSON + */ + public init(data: Data, options opt: JSONSerialization.ReadingOptions = .allowFragments, error: NSErrorPointer = nil) { + do { + let object: Any = try JSONSerialization.jsonObject(with: data, options: opt) + self.init(jsonObject: object) + } catch let aError as NSError { + if error != nil { + error?.pointee = aError + } + self.init(jsonObject: NSNull()) + } + } + + /** + Creates a JSON object + - parameter object: the object + - note: this does not parse a `String` into JSON, instead use `init(parseJSON: String)` + - returns: the created JSON object + */ + public init(_ object: Any) { + switch object { + case let object as [JSON] where object.count > 0: + self.init(array: object) + case let object as [String: JSON] where object.count > 0: + self.init(dictionary: object) + case let object as Data: + self.init(data: object) + default: + self.init(jsonObject: object) + } + } + + /** + Parses the JSON string into a JSON object + - parameter json: the JSON string + - returns: the created JSON object + */ + public init(parseJSON jsonString: String) { + if let data = jsonString.data(using: .utf8) { + self.init(data) + } else { + self.init(NSNull()) + } + } + + /** + Creates a JSON from JSON string + - parameter string: Normal json string like '{"a":"b"}' + + - returns: The created JSON + */ + @available(*, deprecated: 3.2, message: "Use instead `init(parseJSON: )`") + public static func parse(_ json: String) -> JSON { + return json.data(using: String.Encoding.utf8) + .flatMap{ JSON(data: $0) } ?? JSON(NSNull()) + } + + /** + Creates a JSON using the object. + + - parameter object: The object must have the following properties: All objects are NSString/String, NSNumber/Int/Float/Double/Bool, NSArray/Array, NSDictionary/Dictionary, or NSNull; All dictionary keys are NSStrings/String; NSNumbers are not NaN or infinity. + + - returns: The created JSON + */ + fileprivate init(jsonObject: Any) { + self.object = jsonObject + } + + /** + Creates a JSON from a [JSON] + + - parameter jsonArray: A Swift array of JSON objects + + - returns: The created JSON + */ + fileprivate init(array: [JSON]) { + self.init(array.map { $0.object }) + } + + /** + Creates a JSON from a [String: JSON] + + - parameter jsonDictionary: A Swift dictionary of JSON objects + + - returns: The created JSON + */ + fileprivate init(dictionary: [String: JSON]) { + var newDictionary = [String: Any](minimumCapacity: dictionary.count) + for (key, json) in dictionary { + newDictionary[key] = json.object + } + + self.init(newDictionary) + } + + /** + Merges another JSON into this JSON, whereas primitive values which are not present in this JSON are getting added, + present values getting overwritten, array values getting appended and nested JSONs getting merged the same way. + + - parameter other: The JSON which gets merged into this JSON + - throws `ErrorWrongType` if the other JSONs differs in type on the top level. + */ + public mutating func merge(with other: JSON) throws { + try self.merge(with: other, typecheck: true) + } + + /** + Merges another JSON into this JSON and returns a new JSON, whereas primitive values which are not present in this JSON are getting added, + present values getting overwritten, array values getting appended and nested JSONS getting merged the same way. + + - parameter other: The JSON which gets merged into this JSON + - returns: New merged JSON + - throws `ErrorWrongType` if the other JSONs differs in type on the top level. + */ + public func merged(with other: JSON) throws -> JSON { + var merged = self + try merged.merge(with: other, typecheck: true) + return merged + } + + // Private woker function which does the actual merging + // Typecheck is set to true for the first recursion level to prevent total override of the source JSON + fileprivate mutating func merge(with other: JSON, typecheck: Bool) throws { + if self.type == other.type { + switch self.type { + case .dictionary: + for (key, _) in other { + try self[key].merge(with: other[key], typecheck: false) + } + case .array: + self = JSON(self.arrayValue + other.arrayValue) + default: + self = other + } + } else { + if typecheck { + throw NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Couldn't merge, because the JSONs differ in type on top level."]) + } else { + self = other + } + } + } + + /// Private object + fileprivate var rawArray: [Any] = [] + fileprivate var rawDictionary: [String : Any] = [:] + fileprivate var rawString: String = "" + fileprivate var rawNumber: NSNumber = 0 + fileprivate var rawNull: NSNull = NSNull() + fileprivate var rawBool: Bool = false + /// Private type + fileprivate var _type: Type = .null + /// prviate error + fileprivate var _error: NSError? = nil + + /// Object in JSON + public var object: Any { + get { + switch self.type { + case .array: + return self.rawArray + case .dictionary: + return self.rawDictionary + case .string: + return self.rawString + case .number: + return self.rawNumber + case .bool: + return self.rawBool + default: + return self.rawNull + } + } + set { + _error = nil + switch newValue { + case let number as NSNumber: + if number.isBool { + _type = .bool + self.rawBool = number.boolValue + } else { + _type = .number + self.rawNumber = number + } + case let string as String: + _type = .string + self.rawString = string + case _ as NSNull: + _type = .null + case _ as [JSON]: + _type = .array + case nil: + _type = .null + case let array as [Any]: + _type = .array + self.rawArray = array + case let dictionary as [String : Any]: + _type = .dictionary + self.rawDictionary = dictionary + default: + _type = .unknown + _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"]) + } + } + } + + /// JSON type + public var type: Type { get { return _type } } + + /// Error in JSON + public var error: NSError? { get { return self._error } } + + /// The static null JSON + @available(*, unavailable, renamed:"null") + public static var nullJSON: JSON { get { return null } } + public static var null: JSON { get { return JSON(NSNull()) } } +} + +public enum Index: Comparable +{ + case array(Int) + case dictionary(DictionaryIndex) + case null + + static public func ==(lhs: Index, rhs: Index) -> Bool { + switch (lhs, rhs) { + case (.array(let left), .array(let right)): + return left == right + case (.dictionary(let left), .dictionary(let right)): + return left == right + case (.null, .null): return true + default: + return false + } + } + + static public func <(lhs: Index, rhs: Index) -> Bool { + switch (lhs, rhs) { + case (.array(let left), .array(let right)): + return left < right + case (.dictionary(let left), .dictionary(let right)): + return left < right + default: + return false + } + } +} + +public typealias JSONIndex = Index +public typealias JSONRawIndex = Index + + +extension JSON: Collection +{ + + public typealias Index = JSONRawIndex + + public var startIndex: Index + { + switch type + { + case .array: + return .array(rawArray.startIndex) + case .dictionary: + return .dictionary(rawDictionary.startIndex) + default: + return .null + } + } + + public var endIndex: Index + { + switch type + { + case .array: + return .array(rawArray.endIndex) + case .dictionary: + return .dictionary(rawDictionary.endIndex) + default: + return .null + } + } + + public func index(after i: Index) -> Index + { + switch i + { + case .array(let idx): + return .array(rawArray.index(after: idx)) + case .dictionary(let idx): + return .dictionary(rawDictionary.index(after: idx)) + default: + return .null + } + + } + + public subscript (position: Index) -> (String, JSON) + { + switch position + { + case .array(let idx): + return (String(idx), JSON(self.rawArray[idx])) + case .dictionary(let idx): + let (key, value) = self.rawDictionary[idx] + return (key, JSON(value)) + default: + return ("", JSON.null) + } + } + + +} + +// MARK: - Subscript + +/** + * To mark both String and Int can be used in subscript. + */ +public enum JSONKey +{ + case index(Int) + case key(String) +} + +public protocol JSONSubscriptType { + var jsonKey:JSONKey { get } +} + +extension Int: JSONSubscriptType { + public var jsonKey:JSONKey { + return JSONKey.index(self) + } +} + +extension String: JSONSubscriptType { + public var jsonKey:JSONKey { + return JSONKey.key(self) + } +} + +extension JSON { + + /// If `type` is `.Array`, return json whose object is `array[index]`, otherwise return null json with error. + fileprivate subscript(index index: Int) -> JSON { + get { + if self.type != .array { + var r = JSON.null + r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"]) + return r + } else if index >= 0 && index < self.rawArray.count { + return JSON(self.rawArray[index]) + } else { + var r = JSON.null + r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"]) + return r + } + } + set { + if self.type == .array { + if self.rawArray.count > index && newValue.error == nil { + self.rawArray[index] = newValue.object + } + } + } + } + + /// If `type` is `.Dictionary`, return json whose object is `dictionary[key]` , otherwise return null json with error. + fileprivate subscript(key key: String) -> JSON { + get { + var r = JSON.null + if self.type == .dictionary { + if let o = self.rawDictionary[key] { + r = JSON(o) + } else { + r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"]) + } + } else { + r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"]) + } + return r + } + set { + if self.type == .dictionary && newValue.error == nil { + self.rawDictionary[key] = newValue.object + } + } + } + + /// If `sub` is `Int`, return `subscript(index:)`; If `sub` is `String`, return `subscript(key:)`. + fileprivate subscript(sub sub: JSONSubscriptType) -> JSON { + get { + switch sub.jsonKey { + case .index(let index): return self[index: index] + case .key(let key): return self[key: key] + } + } + set { + switch sub.jsonKey { + case .index(let index): self[index: index] = newValue + case .key(let key): self[key: key] = newValue + } + } + } + + /** + Find a json in the complex data structures by using array of Int and/or String as path. + + - parameter path: The target json's path. Example: + + let json = JSON[data] + let path = [9,"list","person","name"] + let name = json[path] + + The same as: let name = json[9]["list"]["person"]["name"] + + - returns: Return a json found by the path or a null json with error + */ + public subscript(path: [JSONSubscriptType]) -> JSON { + get { + return path.reduce(self) { $0[sub: $1] } + } + set { + switch path.count { + case 0: + return + case 1: + self[sub:path[0]].object = newValue.object + default: + var aPath = path; aPath.remove(at: 0) + var nextJSON = self[sub: path[0]] + nextJSON[aPath] = newValue + self[sub: path[0]] = nextJSON + } + } + } + + /** + Find a json in the complex data structures by using array of Int and/or String as path. + + - parameter path: The target json's path. Example: + + let name = json[9,"list","person","name"] + + The same as: let name = json[9]["list"]["person"]["name"] + + - returns: Return a json found by the path or a null json with error + */ + public subscript(path: JSONSubscriptType...) -> JSON { + get { + return self[path] + } + set { + self[path] = newValue + } + } +} + +// MARK: - LiteralConvertible + +extension JSON: Swift.ExpressibleByStringLiteral { + + public init(stringLiteral value: StringLiteralType) { + self.init(value as Any) + } + + public init(extendedGraphemeClusterLiteral value: StringLiteralType) { + self.init(value as Any) + } + + public init(unicodeScalarLiteral value: StringLiteralType) { + self.init(value as Any) + } +} + +extension JSON: Swift.ExpressibleByIntegerLiteral { + + public init(integerLiteral value: IntegerLiteralType) { + self.init(value as Any) + } +} + +extension JSON: Swift.ExpressibleByBooleanLiteral { + + public init(booleanLiteral value: BooleanLiteralType) { + self.init(value as Any) + } +} + +extension JSON: Swift.ExpressibleByFloatLiteral { + + public init(floatLiteral value: FloatLiteralType) { + self.init(value as Any) + } +} + +extension JSON: Swift.ExpressibleByDictionaryLiteral { + public init(dictionaryLiteral elements: (String, Any)...) { + let array = elements + self.init(dictionaryLiteral: array) + } + + public init(dictionaryLiteral elements: [(String, Any)]) { + let jsonFromDictionaryLiteral: ([String : Any]) -> JSON = { dictionary in + let initializeElement = Array(dictionary.keys).flatMap { key -> (String, Any)? in + if let value = dictionary[key] { + return (key, value) + } + return nil + } + return JSON(dictionaryLiteral: initializeElement) + } + + var dict = [String : Any](minimumCapacity: elements.count) + + for element in elements { + let elementToSet: Any + if let json = element.1 as? JSON { + elementToSet = json.object + } else if let jsonArray = element.1 as? [JSON] { + elementToSet = JSON(jsonArray).object + } else if let dictionary = element.1 as? [String : Any] { + elementToSet = jsonFromDictionaryLiteral(dictionary).object + } else if let dictArray = element.1 as? [[String : Any]] { + let jsonArray = dictArray.map { jsonFromDictionaryLiteral($0) } + elementToSet = JSON(jsonArray).object + } else { + elementToSet = element.1 + } + dict[element.0] = elementToSet + } + + self.init(dict) + } +} + +extension JSON: Swift.ExpressibleByArrayLiteral { + + public init(arrayLiteral elements: Any...) { + self.init(elements as Any) + } +} + +extension JSON: Swift.ExpressibleByNilLiteral { + + @available(*, deprecated, message: "use JSON.null instead. Will be removed in future versions") + public init(nilLiteral: ()) { + self.init(NSNull() as Any) + } +} + +// MARK: - Raw + +extension JSON: Swift.RawRepresentable { + + public init?(rawValue: Any) { + if JSON(rawValue).type == .unknown { + return nil + } else { + self.init(rawValue) + } + } + + public var rawValue: Any { + return self.object + } + + public func rawData(options opt: JSONSerialization.WritingOptions = JSONSerialization.WritingOptions(rawValue: 0)) throws -> Data { + guard JSONSerialization.isValidJSONObject(self.object) else { + throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"]) + } + + return try JSONSerialization.data(withJSONObject: self.object, options: opt) + } + + public func rawString(_ encoding: String.Encoding = .utf8, options opt: JSONSerialization.WritingOptions = .prettyPrinted) -> String? { + do { + return try _rawString(encoding, options: [.jsonSerialization: opt]) + } catch { + print("Could not serialize object to JSON because:", error.localizedDescription) + return nil + } + } + + public func rawString(_ options: [writtingOptionsKeys: Any]) -> String? { + let encoding = options[.encoding] as? String.Encoding ?? String.Encoding.utf8 + let maxObjectDepth = options[.maxObjextDepth] as? Int ?? 10 + do { + return try _rawString(encoding, options: options, maxObjectDepth: maxObjectDepth) + } catch { + print("Could not serialize object to JSON because:", error.localizedDescription) + return nil + } + } + + fileprivate func _rawString( + _ encoding: String.Encoding = .utf8, + options: [writtingOptionsKeys: Any], + maxObjectDepth: Int = 10 + ) throws -> String? { + if (maxObjectDepth < 0) { + throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Element too deep. Increase maxObjectDepth and make sure there is no reference loop"]) + } + switch self.type { + case .dictionary: + do { + if !(options[.castNilToNSNull] as? Bool ?? false) { + let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted + let data = try self.rawData(options: jsonOption) + return String(data: data, encoding: encoding) + } + + guard let dict = self.object as? [String: Any?] else { + return nil + } + let body = try dict.keys.map { key throws -> String in + guard let value = dict[key] else { + return "\"\(key)\": null" + } + guard let unwrappedValue = value else { + return "\"\(key)\": null" + } + + let nestedValue = JSON(unwrappedValue) + guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else { + throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Could not serialize nested JSON"]) + } + if nestedValue.type == .string { + return "\"\(key)\": \"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\"" + } else { + return "\"\(key)\": \(nestedString)" + } + } + + return "{\(body.joined(separator: ","))}" + } catch _ { + return nil + } + case .array: + do { + if !(options[.castNilToNSNull] as? Bool ?? false) { + let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted + let data = try self.rawData(options: jsonOption) + return String(data: data, encoding: encoding) + } + + guard let array = self.object as? [Any?] else { + return nil + } + let body = try array.map { value throws -> String in + guard let unwrappedValue = value else { + return "null" + } + + let nestedValue = JSON(unwrappedValue) + guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else { + throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Could not serialize nested JSON"]) + } + if nestedValue.type == .string { + return "\"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\"" + } else { + return nestedString + } + } + + return "[\(body.joined(separator: ","))]" + } catch _ { + return nil + } + case .string: + return self.rawString + case .number: + return self.rawNumber.stringValue + case .bool: + return self.rawBool.description + case .null: + return "null" + default: + return nil + } + } +} + +// MARK: - Printable, DebugPrintable + +extension JSON: Swift.CustomStringConvertible, Swift.CustomDebugStringConvertible { + + public var description: String { + if let string = self.rawString(options:.prettyPrinted) { + return string + } else { + return "unknown" + } + } + + public var debugDescription: String { + return description + } +} + +// MARK: - Array + +extension JSON { + + //Optional [JSON] + public var array: [JSON]? { + get { + if self.type == .array { + return self.rawArray.map{ JSON($0) } + } else { + return nil + } + } + } + + //Non-optional [JSON] + public var arrayValue: [JSON] { + get { + return self.array ?? [] + } + } + + //Optional [Any] + public var arrayObject: [Any]? { + get { + switch self.type { + case .array: + return self.rawArray + default: + return nil + } + } + set { + if let array = newValue { + self.object = array as Any + } else { + self.object = NSNull() + } + } + } +} + +// MARK: - Dictionary + +extension JSON { + + //Optional [String : JSON] + public var dictionary: [String : JSON]? { + if self.type == .dictionary { + var d = [String : JSON](minimumCapacity: rawDictionary.count) + for (key, value) in rawDictionary { + d[key] = JSON(value) + } + return d + } else { + return nil + } + } + + //Non-optional [String : JSON] + public var dictionaryValue: [String : JSON] { + return self.dictionary ?? [:] + } + + //Optional [String : Any] + + public var dictionaryObject: [String : Any]? { + get { + switch self.type { + case .dictionary: + return self.rawDictionary + default: + return nil + } + } + set { + if let v = newValue { + self.object = v as Any + } else { + self.object = NSNull() + } + } + } +} + +// MARK: - Bool + +extension JSON { // : Swift.Bool + + //Optional bool + public var bool: Bool? { + get { + switch self.type { + case .bool: + return self.rawBool + default: + return nil + } + } + set { + if let newValue = newValue { + self.object = newValue as Bool + } else { + self.object = NSNull() + } + } + } + + //Non-optional bool + public var boolValue: Bool { + get { + switch self.type { + case .bool: + return self.rawBool + case .number: + return self.rawNumber.boolValue + case .string: + return ["true", "y", "t"].contains() { (truthyString) in + return self.rawString.caseInsensitiveCompare(truthyString) == .orderedSame + } + default: + return false + } + } + set { + self.object = newValue + } + } +} + +// MARK: - String + +extension JSON { + + //Optional string + public var string: String? { + get { + switch self.type { + case .string: + return self.object as? String + default: + return nil + } + } + set { + if let newValue = newValue { + self.object = NSString(string:newValue) + } else { + self.object = NSNull() + } + } + } + + //Non-optional string + public var stringValue: String { + get { + switch self.type { + case .string: + return self.object as? String ?? "" + case .number: + return self.rawNumber.stringValue + case .bool: + return (self.object as? Bool).map { String($0) } ?? "" + default: + return "" + } + } + set { + self.object = NSString(string:newValue) + } + } +} + +// MARK: - Number +extension JSON { + + //Optional number + public var number: NSNumber? { + get { + switch self.type { + case .number: + return self.rawNumber + case .bool: + return NSNumber(value: self.rawBool ? 1 : 0) + default: + return nil + } + } + set { + self.object = newValue ?? NSNull() + } + } + + //Non-optional number + public var numberValue: NSNumber { + get { + switch self.type { + case .string: + let decimal = NSDecimalNumber(string: self.object as? String) + if decimal == NSDecimalNumber.notANumber { // indicates parse error + return NSDecimalNumber.zero + } + return decimal + case .number: + return self.object as? NSNumber ?? NSNumber(value: 0) + case .bool: + return NSNumber(value: self.rawBool ? 1 : 0) + default: + return NSNumber(value: 0.0) + } + } + set { + self.object = newValue + } + } +} + +//MARK: - Null +extension JSON { + + public var null: NSNull? { + get { + switch self.type { + case .null: + return self.rawNull + default: + return nil + } + } + set { + self.object = NSNull() + } + } + public func exists() -> Bool{ + if let errorValue = error, errorValue.code == ErrorNotExist || + errorValue.code == ErrorIndexOutOfBounds || + errorValue.code == ErrorWrongType { + return false + } + return true + } +} + +//MARK: - URL +extension JSON { + + //Optional URL + public var url: URL? { + get { + switch self.type { + case .string: + // Check for existing percent escapes first to prevent double-escaping of % character + if let _ = self.rawString.range(of: "%[0-9A-Fa-f]{2}", options: .regularExpression, range: nil, locale: nil) { + return Foundation.URL(string: self.rawString) + } else if let encodedString_ = self.rawString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) { + // We have to use `Foundation.URL` otherwise it conflicts with the variable name. + return Foundation.URL(string: encodedString_) + } else { + return nil + } + default: + return nil + } + } + set { + self.object = newValue?.absoluteString ?? NSNull() + } + } +} + +// MARK: - Int, Double, Float, Int8, Int16, Int32, Int64 + +extension JSON { + + public var double: Double? { + get { + return self.number?.doubleValue + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var doubleValue: Double { + get { + return self.numberValue.doubleValue + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var float: Float? { + get { + return self.number?.floatValue + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var floatValue: Float { + get { + return self.numberValue.floatValue + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var int: Int? + { + get + { + return self.number?.intValue + } + set + { + if let newValue = newValue + { + self.object = NSNumber(value: newValue) + } else + { + self.object = NSNull() + } + } + } + + public var intValue: Int { + get { + return self.numberValue.intValue + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var uInt: UInt? { + get { + return self.number?.uintValue + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var uIntValue: UInt { + get { + return self.numberValue.uintValue + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var int8: Int8? { + get { + return self.number?.int8Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: Int(newValue)) + } else { + self.object = NSNull() + } + } + } + + public var int8Value: Int8 { + get { + return self.numberValue.int8Value + } + set { + self.object = NSNumber(value: Int(newValue)) + } + } + + public var uInt8: UInt8? { + get { + return self.number?.uint8Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var uInt8Value: UInt8 { + get { + return self.numberValue.uint8Value + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var int16: Int16? { + get { + return self.number?.int16Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var int16Value: Int16 { + get { + return self.numberValue.int16Value + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var uInt16: UInt16? { + get { + return self.number?.uint16Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var uInt16Value: UInt16 { + get { + return self.numberValue.uint16Value + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var int32: Int32? { + get { + return self.number?.int32Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var int32Value: Int32 { + get { + return self.numberValue.int32Value + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var uInt32: UInt32? { + get { + return self.number?.uint32Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var uInt32Value: UInt32 { + get { + return self.numberValue.uint32Value + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var int64: Int64? { + get { + return self.number?.int64Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var int64Value: Int64 { + get { + return self.numberValue.int64Value + } + set { + self.object = NSNumber(value: newValue) + } + } + + public var uInt64: UInt64? { + get { + return self.number?.uint64Value + } + set { + if let newValue = newValue { + self.object = NSNumber(value: newValue) + } else { + self.object = NSNull() + } + } + } + + public var uInt64Value: UInt64 { + get { + return self.numberValue.uint64Value + } + set { + self.object = NSNumber(value: newValue) + } + } +} + +//MARK: - Comparable +extension JSON : Swift.Comparable {} + +public func ==(lhs: JSON, rhs: JSON) -> Bool { + + switch (lhs.type, rhs.type) { + case (.number, .number): + return lhs.rawNumber == rhs.rawNumber + case (.string, .string): + return lhs.rawString == rhs.rawString + case (.bool, .bool): + return lhs.rawBool == rhs.rawBool + case (.array, .array): + return lhs.rawArray as NSArray == rhs.rawArray as NSArray + case (.dictionary, .dictionary): + return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary + case (.null, .null): + return true + default: + return false + } +} + +public func <=(lhs: JSON, rhs: JSON) -> Bool { + + switch (lhs.type, rhs.type) { + case (.number, .number): + return lhs.rawNumber <= rhs.rawNumber + case (.string, .string): + return lhs.rawString <= rhs.rawString + case (.bool, .bool): + return lhs.rawBool == rhs.rawBool + case (.array, .array): + return lhs.rawArray as NSArray == rhs.rawArray as NSArray + case (.dictionary, .dictionary): + return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary + case (.null, .null): + return true + default: + return false + } +} + +public func >=(lhs: JSON, rhs: JSON) -> Bool { + + switch (lhs.type, rhs.type) { + case (.number, .number): + return lhs.rawNumber >= rhs.rawNumber + case (.string, .string): + return lhs.rawString >= rhs.rawString + case (.bool, .bool): + return lhs.rawBool == rhs.rawBool + case (.array, .array): + return lhs.rawArray as NSArray == rhs.rawArray as NSArray + case (.dictionary, .dictionary): + return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary + case (.null, .null): + return true + default: + return false + } +} + +public func >(lhs: JSON, rhs: JSON) -> Bool { + + switch (lhs.type, rhs.type) { + case (.number, .number): + return lhs.rawNumber > rhs.rawNumber + case (.string, .string): + return lhs.rawString > rhs.rawString + default: + return false + } +} + +public func <(lhs: JSON, rhs: JSON) -> Bool { + + switch (lhs.type, rhs.type) { + case (.number, .number): + return lhs.rawNumber < rhs.rawNumber + case (.string, .string): + return lhs.rawString < rhs.rawString + default: + return false + } +} + +private let trueNumber = NSNumber(value: true) +private let falseNumber = NSNumber(value: false) +private let trueObjCType = String(cString: trueNumber.objCType) +private let falseObjCType = String(cString: falseNumber.objCType) + +// MARK: - NSNumber: Comparable + +extension NSNumber { + var isBool:Bool { + get { + let objCType = String(cString: self.objCType) + if (self.compare(trueNumber) == .orderedSame && objCType == trueObjCType) || (self.compare(falseNumber) == .orderedSame && objCType == falseObjCType){ + return true + } else { + return false + } + } + } +} + +func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { + switch (lhs.isBool, rhs.isBool) { + case (false, true): + return false + case (true, false): + return false + default: + return lhs.compare(rhs) == .orderedSame + } +} + +func !=(lhs: NSNumber, rhs: NSNumber) -> Bool { + return !(lhs == rhs) +} + +func <(lhs: NSNumber, rhs: NSNumber) -> Bool { + + switch (lhs.isBool, rhs.isBool) { + case (false, true): + return false + case (true, false): + return false + default: + return lhs.compare(rhs) == .orderedAscending + } +} + +func >(lhs: NSNumber, rhs: NSNumber) -> Bool { + + switch (lhs.isBool, rhs.isBool) { + case (false, true): + return false + case (true, false): + return false + default: + return lhs.compare(rhs) == ComparisonResult.orderedDescending + } +} + +func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { + + switch (lhs.isBool, rhs.isBool) { + case (false, true): + return false + case (true, false): + return false + default: + return lhs.compare(rhs) != .orderedDescending + } +} + +func >=(lhs: NSNumber, rhs: NSNumber) -> Bool { + + switch (lhs.isBool, rhs.isBool) { + case (false, true): + return false + case (true, false): + return false + default: + return lhs.compare(rhs) != .orderedAscending + } +} + +public enum writtingOptionsKeys { + case jsonSerialization + case castNilToNSNull + case maxObjextDepth + case encoding +} diff --git a/Pods/Target Support Files/Alamofire/Alamofire-dummy.m b/Pods/Target Support Files/Alamofire/Alamofire-dummy.m new file mode 100644 index 0000000..a6c4594 --- /dev/null +++ b/Pods/Target Support Files/Alamofire/Alamofire-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Alamofire : NSObject +@end +@implementation PodsDummy_Alamofire +@end diff --git a/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch b/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h b/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h new file mode 100644 index 0000000..00014e3 --- /dev/null +++ b/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double AlamofireVersionNumber; +FOUNDATION_EXPORT const unsigned char AlamofireVersionString[]; + diff --git a/Pods/Target Support Files/Alamofire/Alamofire.modulemap b/Pods/Target Support Files/Alamofire/Alamofire.modulemap new file mode 100644 index 0000000..d1f125f --- /dev/null +++ b/Pods/Target Support Files/Alamofire/Alamofire.modulemap @@ -0,0 +1,6 @@ +framework module Alamofire { + umbrella header "Alamofire-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Alamofire/Alamofire.xcconfig b/Pods/Target Support Files/Alamofire/Alamofire.xcconfig new file mode 100644 index 0000000..619e5f4 --- /dev/null +++ b/Pods/Target Support Files/Alamofire/Alamofire.xcconfig @@ -0,0 +1,10 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Alamofire +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/Alamofire +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/Alamofire/Info.plist b/Pods/Target Support Files/Alamofire/Info.plist new file mode 100644 index 0000000..a83149a --- /dev/null +++ b/Pods/Target Support Files/Alamofire/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 4.3.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-dummy.m b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-dummy.m new file mode 100644 index 0000000..0f7d986 --- /dev/null +++ b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_FDFullscreenPopGesture : NSObject +@end +@implementation PodsDummy_FDFullscreenPopGesture +@end diff --git a/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-prefix.pch b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-umbrella.h b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-umbrella.h new file mode 100644 index 0000000..4cc0115 --- /dev/null +++ b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture-umbrella.h @@ -0,0 +1,17 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "UINavigationController+FDFullscreenPopGesture.h" + +FOUNDATION_EXPORT double FDFullscreenPopGestureVersionNumber; +FOUNDATION_EXPORT const unsigned char FDFullscreenPopGestureVersionString[]; + diff --git a/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.modulemap b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.modulemap new file mode 100644 index 0000000..7d1d3a2 --- /dev/null +++ b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.modulemap @@ -0,0 +1,6 @@ +framework module FDFullscreenPopGesture { + umbrella header "FDFullscreenPopGesture-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.xcconfig b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.xcconfig new file mode 100644 index 0000000..5b738e9 --- /dev/null +++ b/Pods/Target Support Files/FDFullscreenPopGesture/FDFullscreenPopGesture.xcconfig @@ -0,0 +1,9 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/FDFullscreenPopGesture +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/FDFullscreenPopGesture +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/FDFullscreenPopGesture/Info.plist b/Pods/Target Support Files/FDFullscreenPopGesture/Info.plist new file mode 100644 index 0000000..21a30b4 --- /dev/null +++ b/Pods/Target Support Files/FDFullscreenPopGesture/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.1.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Kingfisher/Info.plist b/Pods/Target Support Files/Kingfisher/Info.plist new file mode 100644 index 0000000..0d92414 --- /dev/null +++ b/Pods/Target Support Files/Kingfisher/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.3.4 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Kingfisher/Kingfisher-dummy.m b/Pods/Target Support Files/Kingfisher/Kingfisher-dummy.m new file mode 100644 index 0000000..1b89d0e --- /dev/null +++ b/Pods/Target Support Files/Kingfisher/Kingfisher-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Kingfisher : NSObject +@end +@implementation PodsDummy_Kingfisher +@end diff --git a/Pods/Target Support Files/Kingfisher/Kingfisher-prefix.pch b/Pods/Target Support Files/Kingfisher/Kingfisher-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/Kingfisher/Kingfisher-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/Kingfisher/Kingfisher-umbrella.h b/Pods/Target Support Files/Kingfisher/Kingfisher-umbrella.h new file mode 100644 index 0000000..89b88ac --- /dev/null +++ b/Pods/Target Support Files/Kingfisher/Kingfisher-umbrella.h @@ -0,0 +1,17 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "Kingfisher.h" + +FOUNDATION_EXPORT double KingfisherVersionNumber; +FOUNDATION_EXPORT const unsigned char KingfisherVersionString[]; + diff --git a/Pods/Target Support Files/Kingfisher/Kingfisher.modulemap b/Pods/Target Support Files/Kingfisher/Kingfisher.modulemap new file mode 100644 index 0000000..2a20d91 --- /dev/null +++ b/Pods/Target Support Files/Kingfisher/Kingfisher.modulemap @@ -0,0 +1,6 @@ +framework module Kingfisher { + umbrella header "Kingfisher-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Kingfisher/Kingfisher.xcconfig b/Pods/Target Support Files/Kingfisher/Kingfisher.xcconfig new file mode 100644 index 0000000..6e8fd9e --- /dev/null +++ b/Pods/Target Support Files/Kingfisher/Kingfisher.xcconfig @@ -0,0 +1,12 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Kingfisher +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "CFNetwork" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/Kingfisher +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES +SWIFT_VERSION = 3.0 diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Info.plist b/Pods/Target Support Files/Pods-DanTangSwift/Info.plist new file mode 100644 index 0000000..2243fe6 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-acknowledgements.markdown b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-acknowledgements.markdown new file mode 100644 index 0000000..808c769 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-acknowledgements.markdown @@ -0,0 +1,156 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## Alamofire + +Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +## FDFullscreenPopGesture + +The MIT License (MIT) + +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + +## Kingfisher + +The MIT License (MIT) + +Copyright (c) 2017 Wei Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + +## SVProgressHUD + +Copyright (c) 2011-2016 Sam Vermette, Tobias Tiemerding and contributors. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +A different license may apply to other resources included in this package, +including Freepik Icons. Please consult their +respective headers for the terms of their individual licenses. + + +## SnapKit + +Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +## SwiftyJSON + +The MIT License (MIT) + +Copyright (c) 2016 Ruoyu Fu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Generated by CocoaPods - https://cocoapods.org diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-acknowledgements.plist b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-acknowledgements.plist new file mode 100644 index 0000000..f72dbfb --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-acknowledgements.plist @@ -0,0 +1,218 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License + MIT + Title + Alamofire + Type + PSGroupSpecifier + + + FooterText + The MIT License (MIT) + +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + License + MIT + Title + FDFullscreenPopGesture + Type + PSGroupSpecifier + + + FooterText + The MIT License (MIT) + +Copyright (c) 2017 Wei Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + License + MIT + Title + Kingfisher + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011-2016 Sam Vermette, Tobias Tiemerding and contributors. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +A different license may apply to other resources included in this package, +including Freepik Icons. Please consult their +respective headers for the terms of their individual licenses. + + License + MIT + Title + SVProgressHUD + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License + MIT + Title + SnapKit + Type + PSGroupSpecifier + + + FooterText + The MIT License (MIT) + +Copyright (c) 2016 Ruoyu Fu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License + MIT + Title + SwiftyJSON + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-dummy.m b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-dummy.m new file mode 100644 index 0000000..bcefd0a --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_DanTangSwift : NSObject +@end +@implementation PodsDummy_Pods_DanTangSwift +@end diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-frameworks.sh b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-frameworks.sh new file mode 100755 index 0000000..6eb58e4 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-frameworks.sh @@ -0,0 +1,109 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/Alamofire/Alamofire.framework" + install_framework "$BUILT_PRODUCTS_DIR/FDFullscreenPopGesture/FDFullscreenPopGesture.framework" + install_framework "$BUILT_PRODUCTS_DIR/Kingfisher/Kingfisher.framework" + install_framework "$BUILT_PRODUCTS_DIR/SVProgressHUD/SVProgressHUD.framework" + install_framework "$BUILT_PRODUCTS_DIR/SnapKit/SnapKit.framework" + install_framework "$BUILT_PRODUCTS_DIR/SwiftyJSON/SwiftyJSON.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/Alamofire/Alamofire.framework" + install_framework "$BUILT_PRODUCTS_DIR/FDFullscreenPopGesture/FDFullscreenPopGesture.framework" + install_framework "$BUILT_PRODUCTS_DIR/Kingfisher/Kingfisher.framework" + install_framework "$BUILT_PRODUCTS_DIR/SVProgressHUD/SVProgressHUD.framework" + install_framework "$BUILT_PRODUCTS_DIR/SnapKit/SnapKit.framework" + install_framework "$BUILT_PRODUCTS_DIR/SwiftyJSON/SwiftyJSON.framework" +fi +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-resources.sh b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-resources.sh new file mode 100755 index 0000000..4602c68 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-resources.sh @@ -0,0 +1,99 @@ +#!/bin/sh +set -e + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + 3) + TARGET_DEVICE_ARGS="--target-device tv" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "${PODS_ROOT}*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-umbrella.h b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-umbrella.h new file mode 100644 index 0000000..64c3d83 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double Pods_DanTangSwiftVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_DanTangSwiftVersionString[]; + diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.debug.xcconfig b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.debug.xcconfig new file mode 100644 index 0000000..2c82805 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.debug.xcconfig @@ -0,0 +1,10 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Alamofire" "$PODS_CONFIGURATION_BUILD_DIR/FDFullscreenPopGesture" "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher" "$PODS_CONFIGURATION_BUILD_DIR/SVProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/SnapKit" "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Alamofire/Alamofire.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher/Kingfisher.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SVProgressHUD/SVProgressHUD.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SnapKit/SnapKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON/SwiftyJSON.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "FDFullscreenPopGesture" -framework "Kingfisher" -framework "SVProgressHUD" -framework "SnapKit" -framework "SwiftyJSON" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.modulemap b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.modulemap new file mode 100644 index 0000000..43027fa --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.modulemap @@ -0,0 +1,6 @@ +framework module Pods_DanTangSwift { + umbrella header "Pods-DanTangSwift-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.release.xcconfig b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.release.xcconfig new file mode 100644 index 0000000..2c82805 --- /dev/null +++ b/Pods/Target Support Files/Pods-DanTangSwift/Pods-DanTangSwift.release.xcconfig @@ -0,0 +1,10 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Alamofire" "$PODS_CONFIGURATION_BUILD_DIR/FDFullscreenPopGesture" "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher" "$PODS_CONFIGURATION_BUILD_DIR/SVProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/SnapKit" "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Alamofire/Alamofire.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher/Kingfisher.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SVProgressHUD/SVProgressHUD.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SnapKit/SnapKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON/SwiftyJSON.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "FDFullscreenPopGesture" -framework "Kingfisher" -framework "SVProgressHUD" -framework "SnapKit" -framework "SwiftyJSON" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/SVProgressHUD/Info.plist b/Pods/Target Support Files/SVProgressHUD/Info.plist new file mode 100644 index 0000000..9a86452 --- /dev/null +++ b/Pods/Target Support Files/SVProgressHUD/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 2.1.2 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-dummy.m b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-dummy.m new file mode 100644 index 0000000..696032a --- /dev/null +++ b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SVProgressHUD : NSObject +@end +@implementation PodsDummy_SVProgressHUD +@end diff --git a/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-umbrella.h b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-umbrella.h new file mode 100644 index 0000000..bff1d78 --- /dev/null +++ b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD-umbrella.h @@ -0,0 +1,20 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "SVIndefiniteAnimatedView.h" +#import "SVProgressAnimatedView.h" +#import "SVProgressHUD.h" +#import "SVRadialGradientLayer.h" + +FOUNDATION_EXPORT double SVProgressHUDVersionNumber; +FOUNDATION_EXPORT const unsigned char SVProgressHUDVersionString[]; + diff --git a/Pods/Target Support Files/SVProgressHUD/SVProgressHUD.modulemap b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD.modulemap new file mode 100644 index 0000000..2eaf140 --- /dev/null +++ b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD.modulemap @@ -0,0 +1,6 @@ +framework module SVProgressHUD { + umbrella header "SVProgressHUD-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/SVProgressHUD/SVProgressHUD.xcconfig b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD.xcconfig new file mode 100644 index 0000000..a769171 --- /dev/null +++ b/Pods/Target Support Files/SVProgressHUD/SVProgressHUD.xcconfig @@ -0,0 +1,10 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SVProgressHUD +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "QuartzCore" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/SVProgressHUD +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/SnapKit/Info.plist b/Pods/Target Support Files/SnapKit/Info.plist new file mode 100644 index 0000000..c11c2ee --- /dev/null +++ b/Pods/Target Support Files/SnapKit/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.1.2 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/SnapKit/SnapKit-dummy.m b/Pods/Target Support Files/SnapKit/SnapKit-dummy.m new file mode 100644 index 0000000..b44e8e5 --- /dev/null +++ b/Pods/Target Support Files/SnapKit/SnapKit-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SnapKit : NSObject +@end +@implementation PodsDummy_SnapKit +@end diff --git a/Pods/Target Support Files/SnapKit/SnapKit-prefix.pch b/Pods/Target Support Files/SnapKit/SnapKit-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/SnapKit/SnapKit-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/SnapKit/SnapKit-umbrella.h b/Pods/Target Support Files/SnapKit/SnapKit-umbrella.h new file mode 100644 index 0000000..1b1be64 --- /dev/null +++ b/Pods/Target Support Files/SnapKit/SnapKit-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double SnapKitVersionNumber; +FOUNDATION_EXPORT const unsigned char SnapKitVersionString[]; + diff --git a/Pods/Target Support Files/SnapKit/SnapKit.modulemap b/Pods/Target Support Files/SnapKit/SnapKit.modulemap new file mode 100644 index 0000000..4b3e47b --- /dev/null +++ b/Pods/Target Support Files/SnapKit/SnapKit.modulemap @@ -0,0 +1,6 @@ +framework module SnapKit { + umbrella header "SnapKit-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/SnapKit/SnapKit.xcconfig b/Pods/Target Support Files/SnapKit/SnapKit.xcconfig new file mode 100644 index 0000000..3fe6941 --- /dev/null +++ b/Pods/Target Support Files/SnapKit/SnapKit.xcconfig @@ -0,0 +1,10 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SnapKit +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/SnapKit +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/SwiftyJSON/Info.plist b/Pods/Target Support Files/SwiftyJSON/Info.plist new file mode 100644 index 0000000..36f2c7e --- /dev/null +++ b/Pods/Target Support Files/SwiftyJSON/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.1.4 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-dummy.m b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-dummy.m new file mode 100644 index 0000000..3159bec --- /dev/null +++ b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SwiftyJSON : NSObject +@end +@implementation PodsDummy_SwiftyJSON +@end diff --git a/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-umbrella.h b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-umbrella.h new file mode 100644 index 0000000..b627dec --- /dev/null +++ b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double SwiftyJSONVersionNumber; +FOUNDATION_EXPORT const unsigned char SwiftyJSONVersionString[]; + diff --git a/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.modulemap b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.modulemap new file mode 100644 index 0000000..6f41751 --- /dev/null +++ b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.modulemap @@ -0,0 +1,6 @@ +framework module SwiftyJSON { + umbrella header "SwiftyJSON-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.xcconfig b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.xcconfig new file mode 100644 index 0000000..07e3ce3 --- /dev/null +++ b/Pods/Target Support Files/SwiftyJSON/SwiftyJSON.xcconfig @@ -0,0 +1,11 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftyJSON +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES +SWIFT_VERSION = 3.0