├── .gitignore
├── .swift-version
├── .travis.yml
├── Example
├── JPCrop.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── JPCrop-Example.xcscheme
├── JPCrop.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── JPCrop
│ ├── AppDelegate.swift
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ ├── CropRatioBar.swift
│ ├── CropSlider.swift
│ ├── CropViewController.swift
│ ├── Extension.swift
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── 1024.png
│ │ │ ├── 20@2x.png
│ │ │ ├── 20@3x.png
│ │ │ ├── 29@2x.png
│ │ │ ├── 29@3x.png
│ │ │ ├── 40@2x.png
│ │ │ ├── 40@3x.png
│ │ │ ├── 60@2x.png
│ │ │ ├── 60@3x.png
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── Literal.Extension.swift
│ ├── NavigationController.swift
│ ├── ViewController.swift
│ ├── cover_ali.jpg
│ └── girl.jpg
├── Podfile
├── Podfile.lock
└── Pods
│ ├── Local Podspecs
│ └── JPCrop.podspec.json
│ ├── Manifest.lock
│ ├── Nimble
│ ├── Carthage
│ │ └── Checkouts
│ │ │ └── CwlPreconditionTesting
│ │ │ ├── Dependencies
│ │ │ └── CwlCatchException
│ │ │ │ └── Sources
│ │ │ │ ├── CwlCatchException
│ │ │ │ └── CwlCatchException.swift
│ │ │ │ └── CwlCatchExceptionSupport
│ │ │ │ ├── CwlCatchException.m
│ │ │ │ └── include
│ │ │ │ └── CwlCatchException.h
│ │ │ └── Sources
│ │ │ ├── CwlMachBadInstructionHandler
│ │ │ ├── CwlMachBadInstructionHandler.m
│ │ │ ├── include
│ │ │ │ └── CwlMachBadInstructionHandler.h
│ │ │ ├── mach_excServer.c
│ │ │ └── mach_excServer.h
│ │ │ └── CwlPreconditionTesting
│ │ │ ├── CwlBadInstructionException.swift
│ │ │ ├── CwlCatchBadInstruction.swift
│ │ │ ├── CwlCatchBadInstructionPosix.swift
│ │ │ ├── CwlDarwinDefinitions.swift
│ │ │ └── include
│ │ │ └── CwlPreconditionTesting.h
│ ├── LICENSE
│ ├── README.md
│ └── Sources
│ │ ├── Nimble
│ │ ├── Adapters
│ │ │ ├── AdapterProtocols.swift
│ │ │ ├── AssertionDispatcher.swift
│ │ │ ├── AssertionRecorder.swift
│ │ │ ├── NMBExpectation.swift
│ │ │ ├── NMBObjCMatcher.swift
│ │ │ ├── NimbleEnvironment.swift
│ │ │ └── NimbleXCTestHandler.swift
│ │ ├── DSL+Wait.swift
│ │ ├── DSL.swift
│ │ ├── Expectation.swift
│ │ ├── ExpectationMessage.swift
│ │ ├── Expression.swift
│ │ ├── FailureMessage.swift
│ │ ├── Matchers
│ │ │ ├── AllPass.swift
│ │ │ ├── Async.swift
│ │ │ ├── BeAKindOf.swift
│ │ │ ├── BeAnInstanceOf.swift
│ │ │ ├── BeCloseTo.swift
│ │ │ ├── BeEmpty.swift
│ │ │ ├── BeGreaterThan.swift
│ │ │ ├── BeGreaterThanOrEqualTo.swift
│ │ │ ├── BeIdenticalTo.swift
│ │ │ ├── BeLessThan.swift
│ │ │ ├── BeLessThanOrEqual.swift
│ │ │ ├── BeLogical.swift
│ │ │ ├── BeNil.swift
│ │ │ ├── BeVoid.swift
│ │ │ ├── BeginWith.swift
│ │ │ ├── Contain.swift
│ │ │ ├── ContainElementSatisfying.swift
│ │ │ ├── ElementsEqual.swift
│ │ │ ├── EndWith.swift
│ │ │ ├── Equal.swift
│ │ │ ├── HaveCount.swift
│ │ │ ├── Match.swift
│ │ │ ├── MatchError.swift
│ │ │ ├── MatcherFunc.swift
│ │ │ ├── MatcherProtocols.swift
│ │ │ ├── PostNotification.swift
│ │ │ ├── Predicate.swift
│ │ │ ├── RaisesException.swift
│ │ │ ├── SatisfyAllOf.swift
│ │ │ ├── SatisfyAnyOf.swift
│ │ │ ├── ThrowAssertion.swift
│ │ │ ├── ThrowError.swift
│ │ │ └── ToSucceed.swift
│ │ ├── Nimble.h
│ │ └── Utils
│ │ │ ├── Await.swift
│ │ │ ├── Errors.swift
│ │ │ ├── Functional.swift
│ │ │ ├── SourceLocation.swift
│ │ │ └── Stringers.swift
│ │ └── NimbleObjectiveC
│ │ ├── DSL.h
│ │ ├── DSL.m
│ │ ├── NMBExceptionCapture.h
│ │ ├── NMBExceptionCapture.m
│ │ ├── NMBStringify.h
│ │ ├── NMBStringify.m
│ │ └── XCTestObservationCenter+Register.m
│ ├── Pods.xcodeproj
│ └── project.pbxproj
│ ├── Target Support Files
│ ├── JPCrop
│ │ ├── JPCrop-Info.plist
│ │ ├── JPCrop-dummy.m
│ │ ├── JPCrop-prefix.pch
│ │ ├── JPCrop-umbrella.h
│ │ ├── JPCrop.debug.xcconfig
│ │ ├── JPCrop.modulemap
│ │ └── JPCrop.release.xcconfig
│ ├── Pods-JPCrop_Example
│ │ ├── Pods-JPCrop_Example-Info.plist
│ │ ├── Pods-JPCrop_Example-acknowledgements.markdown
│ │ ├── Pods-JPCrop_Example-acknowledgements.plist
│ │ ├── Pods-JPCrop_Example-dummy.m
│ │ ├── Pods-JPCrop_Example-frameworks.sh
│ │ ├── Pods-JPCrop_Example-umbrella.h
│ │ ├── Pods-JPCrop_Example.debug.xcconfig
│ │ ├── Pods-JPCrop_Example.modulemap
│ │ └── Pods-JPCrop_Example.release.xcconfig
│ └── pop
│ │ ├── pop-Info.plist
│ │ ├── pop-dummy.m
│ │ ├── pop-prefix.pch
│ │ ├── pop-umbrella.h
│ │ ├── pop.debug.xcconfig
│ │ ├── pop.modulemap
│ │ └── pop.release.xcconfig
│ └── pop
│ ├── LICENSE
│ ├── README.md
│ └── pop
│ ├── POP.h
│ ├── POPAction.h
│ ├── POPAnimatableProperty.h
│ ├── POPAnimatableProperty.mm
│ ├── POPAnimatablePropertyTypes.h
│ ├── POPAnimation.h
│ ├── POPAnimation.mm
│ ├── POPAnimationEvent.h
│ ├── POPAnimationEvent.mm
│ ├── POPAnimationEventInternal.h
│ ├── POPAnimationExtras.h
│ ├── POPAnimationExtras.mm
│ ├── POPAnimationInternal.h
│ ├── POPAnimationPrivate.h
│ ├── POPAnimationRuntime.h
│ ├── POPAnimationRuntime.mm
│ ├── POPAnimationTracer.h
│ ├── POPAnimationTracer.mm
│ ├── POPAnimationTracerInternal.h
│ ├── POPAnimator.h
│ ├── POPAnimator.mm
│ ├── POPAnimatorPrivate.h
│ ├── POPBasicAnimation.h
│ ├── POPBasicAnimation.mm
│ ├── POPBasicAnimationInternal.h
│ ├── POPCGUtils.h
│ ├── POPCGUtils.mm
│ ├── POPCustomAnimation.h
│ ├── POPCustomAnimation.mm
│ ├── POPDecayAnimation.h
│ ├── POPDecayAnimation.mm
│ ├── POPDecayAnimationInternal.h
│ ├── POPDefines.h
│ ├── POPGeometry.h
│ ├── POPGeometry.mm
│ ├── POPLayerExtras.h
│ ├── POPLayerExtras.mm
│ ├── POPMath.h
│ ├── POPMath.mm
│ ├── POPPropertyAnimation.h
│ ├── POPPropertyAnimation.mm
│ ├── POPPropertyAnimationInternal.h
│ ├── POPSpringAnimation.h
│ ├── POPSpringAnimation.mm
│ ├── POPSpringAnimationInternal.h
│ ├── POPSpringSolver.h
│ ├── POPVector.h
│ ├── POPVector.mm
│ └── WebCore
│ ├── FloatConversion.h
│ ├── TransformationMatrix.cpp
│ ├── TransformationMatrix.h
│ └── UnitBezier.h
├── JPCrop.podspec
├── JPCrop
├── Assets
│ └── .gitkeep
└── Classes
│ ├── .gitkeep
│ ├── Croper+API.swift
│ ├── Croper+Calculation.swift
│ ├── Croper+Crop.swift
│ ├── Croper+Func.swift
│ ├── Croper+Model.swift
│ ├── Croper+UI.swift
│ └── Croper.swift
├── LICENSE
├── README.md
└── _Pods.xcodeproj
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Xcode
5 | build/
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata/
15 | *.xccheckout
16 | profile
17 | *.moved-aside
18 | DerivedData
19 | *.hmap
20 | *.ipa
21 |
22 | # Bundler
23 | .bundle
24 |
25 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
26 | # Carthage/Checkouts
27 |
28 | Carthage/Build
29 |
30 | # We recommend against adding the Pods directory to your .gitignore. However
31 | # you should judge for yourself, the pros and cons are mentioned at:
32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
33 | #
34 | # Note: if you ignore the Pods directory, make sure to uncomment
35 | # `pod install` in .travis.yml
36 | #
37 | # Pods/
38 |
--------------------------------------------------------------------------------
/.swift-version:
--------------------------------------------------------------------------------
1 | 5.0
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # references:
2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/
3 | # * https://github.com/supermarin/xcpretty#usage
4 |
5 | osx_image: xcode7.3
6 | language: objective-c
7 | # cache: cocoapods
8 | # podfile: Example/Podfile
9 | # before_install:
10 | # - gem install cocoapods # Since Travis is not always on latest version
11 | # - pod install --project-directory=Example
12 | script:
13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/JPCrop.xcworkspace -scheme JPCrop-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
14 | - pod lib lint
15 |
--------------------------------------------------------------------------------
/Example/JPCrop.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/JPCrop.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Example/JPCrop.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/JPCrop/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // JPCrop
4 | //
5 | // Created by Rogue24 on 12/26/2020.
6 | // Copyright (c) 2020 Rogue24. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/1024.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/20@2x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/20@3x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/29@2x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/29@3x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/40@2x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/40@3x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/60@2x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/Images.xcassets/AppIcon.appiconset/60@3x.png
--------------------------------------------------------------------------------
/Example/JPCrop/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "20@2x.png",
5 | "idiom" : "iphone",
6 | "scale" : "2x",
7 | "size" : "20x20"
8 | },
9 | {
10 | "filename" : "20@3x.png",
11 | "idiom" : "iphone",
12 | "scale" : "3x",
13 | "size" : "20x20"
14 | },
15 | {
16 | "filename" : "29@2x.png",
17 | "idiom" : "iphone",
18 | "scale" : "2x",
19 | "size" : "29x29"
20 | },
21 | {
22 | "filename" : "29@3x.png",
23 | "idiom" : "iphone",
24 | "scale" : "3x",
25 | "size" : "29x29"
26 | },
27 | {
28 | "filename" : "40@2x.png",
29 | "idiom" : "iphone",
30 | "scale" : "2x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "filename" : "40@3x.png",
35 | "idiom" : "iphone",
36 | "scale" : "3x",
37 | "size" : "40x40"
38 | },
39 | {
40 | "filename" : "60@2x.png",
41 | "idiom" : "iphone",
42 | "scale" : "2x",
43 | "size" : "60x60"
44 | },
45 | {
46 | "filename" : "60@3x.png",
47 | "idiom" : "iphone",
48 | "scale" : "3x",
49 | "size" : "60x60"
50 | },
51 | {
52 | "filename" : "1024.png",
53 | "idiom" : "ios-marketing",
54 | "scale" : "1x",
55 | "size" : "1024x1024"
56 | }
57 | ],
58 | "info" : {
59 | "author" : "xcode",
60 | "version" : 1
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Example/JPCrop/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIViewControllerBasedStatusBarAppearance
6 |
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 |
39 | NSCameraUsageDescription
40 | 我想访问您的相机。
41 | NSPhotoLibraryUsageDescription
42 | 我想访问您的相册。
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Example/JPCrop/Literal.Extension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Literal.Extension.swift
3 | // Neves_Example
4 | //
5 | // Created by 周健平 on 2020/10/18.
6 | // Copyright © 2020 CocoaPods. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | extension Int: ExpressibleByBooleanLiteral, ExpressibleByStringLiteral {
12 | public init(booleanLiteral value: Bool) { self = value ? 1 : 0 }
13 | public init(stringLiteral value: String) { self = Int(Double(stringLiteral: value)) }
14 | public init(unicodeScalarLiteral value: String) { self = Int(Double(stringLiteral: value)) }
15 | public init(extendedGraphemeClusterLiteral value: String) { self = Int(Double(stringLiteral: value)) }
16 | }
17 |
18 | extension Float: ExpressibleByBooleanLiteral, ExpressibleByStringLiteral {
19 | public init(booleanLiteral value: Bool) { self = value ? 1 : 0 }
20 | public init(stringLiteral value: String) { self = Float(value) ?? 0 }
21 | public init(unicodeScalarLiteral value: String) { self = Float(value) ?? 0 }
22 | public init(extendedGraphemeClusterLiteral value: String) { self = Float(value) ?? 0 }
23 | }
24 |
25 | extension Double: ExpressibleByBooleanLiteral, ExpressibleByStringLiteral {
26 | public init(booleanLiteral value: Bool) { self = value ? 1 : 0 }
27 | public init(stringLiteral value: String) { self = Double(value) ?? 0 }
28 | public init(unicodeScalarLiteral value: String) { self = Double(value) ?? 0 }
29 | public init(extendedGraphemeClusterLiteral value: String) { self = Double(value) ?? 0 }
30 | }
31 |
32 | extension Bool: ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
33 | public init(integerLiteral value: Int) { self = value > 0 }
34 | public init(floatLiteral value: Double) { self = value > 0 }
35 | }
36 |
37 | extension CGPoint: ExpressibleByArrayLiteral {
38 | public init(arrayLiteral elements: CGFloat...) {
39 | if elements.count == 2 {
40 | self = .init(x: elements[0], y: elements[1])
41 | } else {
42 | self = .zero
43 | }
44 | }
45 | }
46 |
47 | extension CGPoint {
48 | public var exchange: CGPoint { CGPoint(x: y, y: x) }
49 | }
50 |
51 | extension CGSize: ExpressibleByArrayLiteral {
52 | public init(arrayLiteral elements: CGFloat...) {
53 | if elements.count == 2 {
54 | self = .init(width: elements[0], height: elements[1])
55 | } else {
56 | self = .zero
57 | }
58 | }
59 | }
60 |
61 | extension CGSize {
62 | public var exchange: CGSize { CGSize(width: height, height: width) }
63 | }
64 |
65 | extension CGRect: ExpressibleByArrayLiteral {
66 | public init(arrayLiteral elements: CGFloat...) {
67 | if elements.count == 4 {
68 | self = .init(x: elements[0], y: elements[1], width: elements[2], height: elements[3])
69 | } else {
70 | self = .zero
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Example/JPCrop/NavigationController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NavigationController.swift
3 | // JPCrop_Example
4 | //
5 | // Created by Rogue24 on 2022/9/10.
6 | // Copyright © 2022 CocoaPods. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class NavigationController: UINavigationController {
12 | override var childForStatusBarHidden: UIViewController? { topViewController }
13 | override var childForStatusBarStyle: UIViewController? { topViewController }
14 | }
15 |
--------------------------------------------------------------------------------
/Example/JPCrop/cover_ali.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/cover_ali.jpg
--------------------------------------------------------------------------------
/Example/JPCrop/girl.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/Example/JPCrop/girl.jpg
--------------------------------------------------------------------------------
/Example/Podfile:
--------------------------------------------------------------------------------
1 | use_frameworks!
2 |
3 | platform :ios, '11.0'
4 |
5 | target 'JPCrop_Example' do
6 | pod 'JPCrop', :path => '../'
7 | pod 'pop'
8 |
9 | post_install do |installer|
10 | installer.pods_project.targets.each do |target|
11 | target.build_configurations.each do |config|
12 | config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
13 | end
14 | end
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/Example/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - JPCrop (0.2.4)
3 | - pop (1.0.12)
4 |
5 | DEPENDENCIES:
6 | - JPCrop (from `../`)
7 | - pop
8 |
9 | SPEC REPOS:
10 | trunk:
11 | - pop
12 |
13 | EXTERNAL SOURCES:
14 | JPCrop:
15 | :path: "../"
16 |
17 | SPEC CHECKSUMS:
18 | JPCrop: 3a5b56acc7c0865312540c9738ae4253cee3fa2b
19 | pop: d582054913807fd11fd50bfe6a539d91c7e1a55a
20 |
21 | PODFILE CHECKSUM: 2370da9e45a5c7299c50a99d73814c8e01e456f7
22 |
23 | COCOAPODS: 1.12.1
24 |
--------------------------------------------------------------------------------
/Example/Pods/Local Podspecs/JPCrop.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "JPCrop",
3 | "version": "0.2.4",
4 | "summary": "A clipping tool that can fine tune the direction of rotation.",
5 | "description": "A clipping tool that can fine tune the direction of rotation.",
6 | "homepage": "https://github.com/Rogue24/JPCrop",
7 | "license": {
8 | "type": "MIT",
9 | "file": "LICENSE"
10 | },
11 | "authors": {
12 | "Rogue24": "zhoujianping24@hotmail.com"
13 | },
14 | "source": {
15 | "git": "https://github.com/Rogue24/JPCrop.git",
16 | "tag": "0.2.4"
17 | },
18 | "platforms": {
19 | "ios": "11.0"
20 | },
21 | "source_files": "JPCrop/Classes/**/*",
22 | "swift_versions": "5.0",
23 | "swift_version": "5.0"
24 | }
25 |
--------------------------------------------------------------------------------
/Example/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - JPCrop (0.2.4)
3 | - pop (1.0.12)
4 |
5 | DEPENDENCIES:
6 | - JPCrop (from `../`)
7 | - pop
8 |
9 | SPEC REPOS:
10 | trunk:
11 | - pop
12 |
13 | EXTERNAL SOURCES:
14 | JPCrop:
15 | :path: "../"
16 |
17 | SPEC CHECKSUMS:
18 | JPCrop: 3a5b56acc7c0865312540c9738ae4253cee3fa2b
19 | pop: d582054913807fd11fd50bfe6a539d91c7e1a55a
20 |
21 | PODFILE CHECKSUM: 2370da9e45a5c7299c50a99d73814c8e01e456f7
22 |
23 | COCOAPODS: 1.12.1
24 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CwlCatchException.swift
3 | // CwlAssertionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | import Foundation
22 |
23 | #if canImport(NimbleCwlCatchExceptionSupport)
24 | import NimbleCwlCatchExceptionSupport
25 | #endif
26 |
27 | private func catchReturnTypeConverter(_ type: T.Type, block: @escaping () -> Void) -> T? {
28 | return catchExceptionOfKind(type, block) as? T
29 | }
30 |
31 | extension NSException {
32 | public static func catchException(in block: @escaping () -> Void) -> Self? {
33 | return catchReturnTypeConverter(self, block: block)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m:
--------------------------------------------------------------------------------
1 | //
2 | // CwlCatchException.m
3 | // CwlAssertionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #import "CwlCatchException.h"
22 |
23 | NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void)) {
24 | @try {
25 | inBlock();
26 | } @catch (NSException *exception) {
27 | if ([exception isKindOfClass:type]) {
28 | return exception;
29 | } else {
30 | @throw;
31 | }
32 | }
33 | return nil;
34 | }
35 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h:
--------------------------------------------------------------------------------
1 | //
2 | // CwlCatchException.h
3 | // CwlCatchException
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #import
22 |
23 | //! Project version number for CwlCatchException.
24 | FOUNDATION_EXPORT double CwlCatchExceptionVersionNumber;
25 |
26 | //! Project version string for CwlCatchException.
27 | FOUNDATION_EXPORT const unsigned char CwlCatchExceptionVersionString[];
28 |
29 | NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void));
30 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m:
--------------------------------------------------------------------------------
1 | //
2 | // CwlMachBadExceptionHandler.m
3 | // CwlPreconditionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #ifdef __APPLE__
22 | #import "TargetConditionals.h"
23 | #if TARGET_OS_OSX || TARGET_OS_IOS
24 |
25 | #import "mach_excServer.h"
26 | #import "CwlMachBadInstructionHandler.h"
27 |
28 | @protocol BadInstructionReply
29 | +(NSNumber *)receiveReply:(NSValue *)value;
30 | @end
31 |
32 | /// A basic function that receives callbacks from mach_exc_server and relays them to the Swift implemented BadInstructionException.catch_mach_exception_raise_state.
33 | kern_return_t catch_mach_exception_raise_state(mach_port_t exception_port, exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) {
34 | bad_instruction_exception_reply_t reply = { exception_port, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt };
35 | Class badInstructionClass = NSClassFromString(@"BadInstructionException");
36 | NSValue *value = [NSValue valueWithBytes: &reply objCType: @encode(bad_instruction_exception_reply_t)];
37 | return [[badInstructionClass performSelector: @selector(receiveReply:) withObject: value] intValue];
38 | }
39 |
40 | // The mach port should be configured so that this function is never used.
41 | kern_return_t catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) {
42 | assert(false);
43 | return KERN_FAILURE;
44 | }
45 |
46 | // The mach port should be configured so that this function is never used.
47 | kern_return_t catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) {
48 | assert(false);
49 | return KERN_FAILURE;
50 | }
51 |
52 | #endif /* TARGET_OS_OSX || TARGET_OS_IOS */
53 | #endif /* __APPLE__ */
54 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h:
--------------------------------------------------------------------------------
1 | //
2 | // CwlMachBadInstructionHandler.h
3 | // CwlPreconditionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #import
22 |
23 | #if TARGET_OS_OSX || TARGET_OS_IOS
24 |
25 | #import
26 |
27 | extern bool _swift_disableExclusivityChecking;
28 | extern bool _swift_reportFatalErrorsToDebugger;
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | extern boolean_t mach_exc_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
33 |
34 | // The request_mach_exception_raise_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift.
35 | typedef struct
36 | {
37 | mach_msg_header_t Head;
38 | /* start of the kernel processed data */
39 | mach_msg_body_t msgh_body;
40 | mach_msg_port_descriptor_t thread;
41 | mach_msg_port_descriptor_t task;
42 | /* end of the kernel processed data */
43 | NDR_record_t NDR;
44 | exception_type_t exception;
45 | mach_msg_type_number_t codeCnt;
46 | int64_t code[2];
47 | int flavor;
48 | mach_msg_type_number_t old_stateCnt;
49 | natural_t old_state[224];
50 | } request_mach_exception_raise_t;
51 |
52 | // The reply_mach_exception_raise_state_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift.
53 | typedef struct
54 | {
55 | mach_msg_header_t Head;
56 | NDR_record_t NDR;
57 | kern_return_t RetCode;
58 | int flavor;
59 | mach_msg_type_number_t new_stateCnt;
60 | natural_t new_state[224];
61 | } reply_mach_exception_raise_state_t;
62 |
63 | typedef struct
64 | {
65 | mach_port_t exception_port;
66 | exception_type_t exception;
67 | mach_exception_data_type_t const * _Nullable code;
68 | mach_msg_type_number_t codeCnt;
69 | int32_t * _Nullable flavor;
70 | natural_t const * _Nullable old_state;
71 | mach_msg_type_number_t old_stateCnt;
72 | thread_state_t _Nullable new_state;
73 | mach_msg_type_number_t * _Nullable new_stateCnt;
74 | } bad_instruction_exception_reply_t;
75 |
76 | NS_ASSUME_NONNULL_END
77 |
78 | #endif
79 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CwlBadInstructionException.swift
3 | // CwlPreconditionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #if (os(macOS) || os(iOS)) && arch(x86_64)
22 |
23 | import Foundation
24 |
25 | #if canImport(NimbleCwlMachBadInstructionHandler)
26 | import NimbleCwlMachBadInstructionHandler
27 | #endif
28 |
29 | private func raiseBadInstructionException() {
30 | BadInstructionException().raise()
31 | }
32 |
33 | /// A simple NSException subclass. It's not required to subclass NSException (since the exception type is represented in the name) but this helps for identifying the exception through runtime type.
34 | @objc(BadInstructionException)
35 | public class BadInstructionException: NSException {
36 | static var name: String = "com.cocoawithlove.BadInstruction"
37 |
38 | init() {
39 | super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil)
40 | }
41 |
42 | required public init?(coder aDecoder: NSCoder) {
43 | super.init(coder: aDecoder)
44 | }
45 |
46 | /// An Objective-C callable function, invoked from the `mach_exc_server` callback function `catch_mach_exception_raise_state` to push the `raiseBadInstructionException` function onto the stack.
47 | @objc(receiveReply:)
48 | public class func receiveReply(_ value: NSValue) -> NSNumber {
49 | var reply = bad_instruction_exception_reply_t(exception_port: 0, exception: 0, code: nil, codeCnt: 0, flavor: nil, old_state: nil, old_stateCnt: 0, new_state: nil, new_stateCnt: nil)
50 | withUnsafeMutablePointer(to: &reply) { value.getValue(UnsafeMutableRawPointer($0)) }
51 |
52 | let old_state: UnsafePointer = reply.old_state!
53 | let old_stateCnt: mach_msg_type_number_t = reply.old_stateCnt
54 | let new_state: thread_state_t = reply.new_state!
55 | let new_stateCnt: UnsafeMutablePointer = reply.new_stateCnt!
56 |
57 | // Make sure we've been given enough memory
58 | if old_stateCnt != x86_THREAD_STATE64_COUNT || new_stateCnt.pointee < x86_THREAD_STATE64_COUNT {
59 | return NSNumber(value: KERN_INVALID_ARGUMENT)
60 | }
61 |
62 | // Read the old thread state
63 | var state = old_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { return $0.pointee }
64 |
65 | // 1. Decrement the stack pointer
66 | state.__rsp -= __uint64_t(MemoryLayout.size)
67 |
68 | // 2. Save the old Instruction Pointer to the stack.
69 | if let pointer = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(state.__rsp)) {
70 | pointer.pointee = state.__rip
71 | } else {
72 | return NSNumber(value: KERN_INVALID_ARGUMENT)
73 | }
74 |
75 | // 3. Set the Instruction Pointer to the new function's address
76 | var f: @convention(c) () -> Void = raiseBadInstructionException
77 | withUnsafePointer(to: &f) {
78 | state.__rip = $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { return $0.pointee }
79 | }
80 |
81 | // Write the new thread state
82 | new_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { $0.pointee = state }
83 | new_stateCnt.pointee = x86_THREAD_STATE64_COUNT
84 |
85 | return NSNumber(value: KERN_SUCCESS)
86 | }
87 | }
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CwlDarwinDefinitions.swift
3 | // CwlPreconditionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #if (os(macOS) || os(iOS)) && arch(x86_64)
22 |
23 | import Darwin
24 |
25 | // From /usr/include/mach/message.h
26 | // #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */
27 | // #define MACH_MSGH_BITS_REMOTE(bits) \
28 | // ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
29 | // #define MACH_MSGH_BITS(remote, local) /* legacy */ \
30 | // ((remote) | ((local) << 8))
31 | public let MACH_MSG_TYPE_MAKE_SEND: UInt32 = 20
32 | public func MACH_MSGH_BITS_REMOTE(_ bits: UInt32) -> UInt32 { return bits & UInt32(MACH_MSGH_BITS_REMOTE_MASK) }
33 | public func MACH_MSGH_BITS(_ remote: UInt32, _ local: UInt32) -> UInt32 { return ((remote) | ((local) << 8)) }
34 |
35 | // From /usr/include/mach/exception_types.h
36 | // #define EXC_BAD_INSTRUCTION 2 /* Instruction failed */
37 | // #define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION)
38 | public let EXC_BAD_INSTRUCTION: UInt32 = 2
39 | public let EXC_MASK_BAD_INSTRUCTION: UInt32 = 1 << EXC_BAD_INSTRUCTION
40 |
41 | // From /usr/include/mach/i386/thread_status.h
42 | // #define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \
43 | // ( sizeof (x86_thread_state64_t) / sizeof (int) ))
44 | public let x86_THREAD_STATE64_COUNT = UInt32(MemoryLayout.size / MemoryLayout.size)
45 |
46 | public let EXC_TYPES_COUNT = 14
47 | public struct execTypesCountTuple {
48 | // From /usr/include/mach/i386/exception.h
49 | // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */
50 | public var value: (T, T, T, T, T, T, T, T, T, T, T, T, T, T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
51 | public init() {
52 | }
53 | }
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/include/CwlPreconditionTesting.h:
--------------------------------------------------------------------------------
1 | //
2 | // CwlPreconditionTesting.h
3 | // CwlPreconditionTesting
4 | //
5 | // Created by Matt Gallagher on 2016/01/10.
6 | // Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved.
7 | //
8 | // Permission to use, copy, modify, and/or distribute this software for any
9 | // purpose with or without fee is hereby granted, provided that the above
10 | // copyright notice and this permission notice appear in all copies.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | //
20 |
21 | #import
22 |
23 | //! Project version number for CwlUtils.
24 | FOUNDATION_EXPORT double CwlPreconditionTestingVersionNumber;
25 |
26 | //! Project version string for CwlUtils.
27 | FOUNDATION_EXPORT const unsigned char CwlAssertingTestingVersionString[];
28 |
29 | #import "CwlMachBadInstructionHandler.h"
30 |
31 | #if TARGET_OS_OSX || TARGET_OS_IOS
32 | #import "CwlCatchException.h"
33 | #elif !TARGET_OS_TV
34 | #error Unsupported platform.
35 | #endif
36 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/AdapterProtocols.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// Protocol for the assertion handler that Nimble uses for all expectations.
4 | public protocol AssertionHandler {
5 | func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation)
6 | }
7 |
8 | /// Global backing interface for assertions that Nimble creates.
9 | /// Defaults to a private test handler that passes through to XCTest.
10 | ///
11 | /// If XCTest is not available, you must assign your own assertion handler
12 | /// before using any matchers, otherwise Nimble will abort the program.
13 | ///
14 | /// @see AssertionHandler
15 | public var NimbleAssertionHandler: AssertionHandler = { () -> AssertionHandler in
16 | // swiftlint:disable:previous identifier_name
17 | return isXCTestAvailable() ? NimbleXCTestHandler() : NimbleXCTestUnavailableHandler()
18 | }()
19 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift:
--------------------------------------------------------------------------------
1 | /// AssertionDispatcher allows multiple AssertionHandlers to receive
2 | /// assertion messages.
3 | ///
4 | /// @warning Does not fully dispatch if one of the handlers raises an exception.
5 | /// This is possible with XCTest-based assertion handlers.
6 | ///
7 | public class AssertionDispatcher: AssertionHandler {
8 | let handlers: [AssertionHandler]
9 |
10 | public init(handlers: [AssertionHandler]) {
11 | self.handlers = handlers
12 | }
13 |
14 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) {
15 | for handler in handlers {
16 | handler.assert(assertion, message: message, location: location)
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | #if canImport(Darwin)
4 |
5 | // swiftlint:disable line_length
6 | public typealias MatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage) throws -> Bool
7 | public typealias FullMatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage, _ shouldNotMatch: Bool) throws -> Bool
8 | // swiftlint:enable line_length
9 |
10 | public class NMBObjCMatcher: NSObject, NMBMatcher {
11 | // swiftlint:disable identifier_name
12 | let _match: MatcherBlock
13 | let _doesNotMatch: MatcherBlock
14 | // swiftlint:enable identifier_name
15 | let canMatchNil: Bool
16 |
17 | public init(canMatchNil: Bool, matcher: @escaping MatcherBlock, notMatcher: @escaping MatcherBlock) {
18 | self.canMatchNil = canMatchNil
19 | self._match = matcher
20 | self._doesNotMatch = notMatcher
21 | }
22 |
23 | public convenience init(matcher: @escaping MatcherBlock) {
24 | self.init(canMatchNil: true, matcher: matcher)
25 | }
26 |
27 | public convenience init(canMatchNil: Bool, matcher: @escaping MatcherBlock) {
28 | self.init(canMatchNil: canMatchNil, matcher: matcher, notMatcher: ({ actualExpression, failureMessage in
29 | return try !matcher(actualExpression, failureMessage)
30 | }))
31 | }
32 |
33 | public convenience init(matcher: @escaping FullMatcherBlock) {
34 | self.init(canMatchNil: true, matcher: matcher)
35 | }
36 |
37 | public convenience init(canMatchNil: Bool, matcher: @escaping FullMatcherBlock) {
38 | self.init(canMatchNil: canMatchNil, matcher: ({ actualExpression, failureMessage in
39 | return try matcher(actualExpression, failureMessage, false)
40 | }), notMatcher: ({ actualExpression, failureMessage in
41 | return try matcher(actualExpression, failureMessage, true)
42 | }))
43 | }
44 |
45 | private func canMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool {
46 | do {
47 | if !canMatchNil {
48 | if try actualExpression.evaluate() == nil {
49 | failureMessage.postfixActual = " (use beNil() to match nils)"
50 | return false
51 | }
52 | }
53 | } catch let error {
54 | failureMessage.actualValue = "an unexpected error thrown: \(error)"
55 | return false
56 | }
57 | return true
58 | }
59 |
60 | public func matches(_ actualBlock: @escaping () -> NSObject?, failureMessage: FailureMessage, location: SourceLocation) -> Bool {
61 | let expr = Expression(expression: actualBlock, location: location)
62 | let result: Bool
63 | do {
64 | result = try _match(expr, failureMessage)
65 | } catch let error {
66 | failureMessage.stringValue = "unexpected error thrown: <\(error)>"
67 | return false
68 | }
69 |
70 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) {
71 | return result
72 | } else {
73 | return false
74 | }
75 | }
76 |
77 | public func doesNotMatch(_ actualBlock: @escaping () -> NSObject?, failureMessage: FailureMessage, location: SourceLocation) -> Bool {
78 | let expr = Expression(expression: actualBlock, location: location)
79 | let result: Bool
80 | do {
81 | result = try _doesNotMatch(expr, failureMessage)
82 | } catch let error {
83 | failureMessage.stringValue = "unexpected error thrown: <\(error)>"
84 | return false
85 | }
86 |
87 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) {
88 | return result
89 | } else {
90 | return false
91 | }
92 | }
93 | }
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift:
--------------------------------------------------------------------------------
1 | import Dispatch
2 | import Foundation
3 |
4 | /// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this
5 | /// class' existence
6 | internal class NimbleEnvironment: NSObject {
7 | static var activeInstance: NimbleEnvironment {
8 | get {
9 | let env = Thread.current.threadDictionary["NimbleEnvironment"]
10 | if let env = env as? NimbleEnvironment {
11 | return env
12 | } else {
13 | let newEnv = NimbleEnvironment()
14 | self.activeInstance = newEnv
15 | return newEnv
16 | }
17 | }
18 | set {
19 | Thread.current.threadDictionary["NimbleEnvironment"] = newValue
20 | }
21 | }
22 |
23 | // swiftlint:disable:next todo
24 | // TODO: eventually migrate the global to this environment value
25 | var assertionHandler: AssertionHandler {
26 | get { return NimbleAssertionHandler }
27 | set { NimbleAssertionHandler = newValue }
28 | }
29 |
30 | var suppressTVOSAssertionWarning: Bool = false
31 | var awaiter: Awaiter
32 |
33 | override init() {
34 | let timeoutQueue = DispatchQueue.global(qos: .userInitiated)
35 | awaiter = Awaiter(
36 | waitLock: AssertionWaitLock(),
37 | asyncQueue: .main,
38 | timeoutQueue: timeoutQueue
39 | )
40 |
41 | super.init()
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import XCTest
3 |
4 | /// Default handler for Nimble. This assertion handler passes failures along to
5 | /// XCTest.
6 | public class NimbleXCTestHandler: AssertionHandler {
7 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) {
8 | if !assertion {
9 | recordFailure("\(message.stringValue)\n", location: location)
10 | }
11 | }
12 | }
13 |
14 | /// Alternative handler for Nimble. This assertion handler passes failures along
15 | /// to XCTest by attempting to reduce the failure message size.
16 | public class NimbleShortXCTestHandler: AssertionHandler {
17 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) {
18 | if !assertion {
19 | let msg: String
20 | if let actual = message.actualValue {
21 | msg = "got: \(actual) \(message.postfixActual)"
22 | } else {
23 | msg = "expected \(message.to) \(message.postfixMessage)"
24 | }
25 | recordFailure("\(msg)\n", location: location)
26 | }
27 | }
28 | }
29 |
30 | /// Fallback handler in case XCTest is unavailable. This assertion handler will abort
31 | /// the program if it is invoked.
32 | class NimbleXCTestUnavailableHandler: AssertionHandler {
33 | func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) {
34 | fatalError("XCTest is not available and no custom assertion handler was configured. Aborting.")
35 | }
36 | }
37 |
38 | #if !SWIFT_PACKAGE
39 | /// Helper class providing access to the currently executing XCTestCase instance, if any
40 | @objc final internal class CurrentTestCaseTracker: NSObject, XCTestObservation {
41 | @objc static let sharedInstance = CurrentTestCaseTracker()
42 |
43 | private(set) var currentTestCase: XCTestCase?
44 |
45 | private var stashed_swift_reportFatalErrorsToDebugger: Bool = false
46 |
47 | @objc func testCaseWillStart(_ testCase: XCTestCase) {
48 | #if swift(>=3.2) && !os(tvOS)
49 | stashed_swift_reportFatalErrorsToDebugger = _swift_reportFatalErrorsToDebugger
50 | _swift_reportFatalErrorsToDebugger = false
51 | #endif
52 |
53 | currentTestCase = testCase
54 | }
55 |
56 | @objc func testCaseDidFinish(_ testCase: XCTestCase) {
57 | currentTestCase = nil
58 |
59 | #if swift(>=3.2) && !os(tvOS)
60 | _swift_reportFatalErrorsToDebugger = stashed_swift_reportFatalErrorsToDebugger
61 | #endif
62 | }
63 | }
64 | #endif
65 |
66 | func isXCTestAvailable() -> Bool {
67 | #if canImport(Darwin)
68 | // XCTest is weakly linked and so may not be present
69 | return NSClassFromString("XCTestCase") != nil
70 | #else
71 | return true
72 | #endif
73 | }
74 |
75 | public func recordFailure(_ message: String, location: SourceLocation) {
76 | #if SWIFT_PACKAGE
77 | XCTFail("\(message)", file: location.file, line: location.line)
78 | #else
79 | if let testCase = CurrentTestCaseTracker.sharedInstance.currentTestCase {
80 | let line = Int(location.line)
81 | testCase.recordFailure(withDescription: message, inFile: location.file, atLine: line, expected: true)
82 | } else {
83 | let msg = """
84 | Attempted to report a test failure to XCTest while no test case was running. The failure was:
85 | \"\(message)\"
86 | It occurred at: \(location.file):\(location.line)
87 | """
88 | NSException(name: .internalInconsistencyException, reason: msg, userInfo: nil).raise()
89 | }
90 | #endif
91 | }
92 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/DSL.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// Make an expectation on a given actual value. The value given is lazily evaluated.
4 | public func expect(_ expression: @autoclosure @escaping () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation {
5 | return Expectation(
6 | expression: Expression(
7 | expression: expression,
8 | location: SourceLocation(file: file, line: line),
9 | isClosure: true))
10 | }
11 |
12 | /// Make an expectation on a given actual value. The closure is lazily invoked.
13 | public func expect(_ file: FileString = #file, line: UInt = #line, expression: @escaping () throws -> T?) -> Expectation {
14 | return Expectation(
15 | expression: Expression(
16 | expression: expression,
17 | location: SourceLocation(file: file, line: line),
18 | isClosure: true))
19 | }
20 |
21 | /// Always fails the test with a message and a specified location.
22 | public func fail(_ message: String, location: SourceLocation) {
23 | let handler = NimbleEnvironment.activeInstance.assertionHandler
24 | handler.assert(false, message: FailureMessage(stringValue: message), location: location)
25 | }
26 |
27 | /// Always fails the test with a message.
28 | public func fail(_ message: String, file: FileString = #file, line: UInt = #line) {
29 | fail(message, location: SourceLocation(file: file, line: line))
30 | }
31 |
32 | /// Always fails the test.
33 | public func fail(_ file: FileString = #file, line: UInt = #line) {
34 | fail("fail() always fails", file: file, line: line)
35 | }
36 |
37 | /// Like Swift's precondition(), but raises NSExceptions instead of sigaborts
38 | internal func nimblePrecondition(
39 | _ expr: @autoclosure() -> Bool,
40 | _ name: @autoclosure() -> String,
41 | _ message: @autoclosure() -> String,
42 | file: StaticString = #file,
43 | line: UInt = #line) {
44 | let result = expr()
45 | if !result {
46 | #if canImport(Darwin)
47 | let exception = NSException(
48 | name: NSExceptionName(name()),
49 | reason: message(),
50 | userInfo: nil
51 | )
52 | exception.raise()
53 | #else
54 | preconditionFailure("\(name()) - \(message())", file: file, line: line)
55 | #endif
56 | }
57 | }
58 |
59 | internal func internalError(_ msg: String, file: FileString = #file, line: UInt = #line) -> Never {
60 | // swiftlint:disable line_length
61 | fatalError(
62 | """
63 | Nimble Bug Found: \(msg) at \(file):\(line).
64 | Please file a bug to Nimble: https://github.com/Quick/Nimble/issues with the code snippet that caused this error.
65 | """
66 | )
67 | // swiftlint:enable line_length
68 | }
69 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/FailureMessage.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// Encapsulates the failure message that matchers can report to the end user.
4 | ///
5 | /// This is shared state between Nimble and matchers that mutate this value.
6 | public class FailureMessage: NSObject {
7 | public var expected: String = "expected"
8 | public var actualValue: String? = "" // empty string -> use default; nil -> exclude
9 | public var to: String = "to"
10 | public var postfixMessage: String = "match"
11 | public var postfixActual: String = ""
12 | /// An optional message that will be appended as a new line and provides additional details
13 | /// about the failure. This message will only be visible in the issue navigator / in logs but
14 | /// not directly in the source editor since only a single line is presented there.
15 | public var extendedMessage: String?
16 | public var userDescription: String?
17 |
18 | public var stringValue: String {
19 | get {
20 | if let value = _stringValueOverride {
21 | return value
22 | } else {
23 | return computeStringValue()
24 | }
25 | }
26 | set {
27 | _stringValueOverride = newValue
28 | }
29 | }
30 |
31 | // swiftlint:disable:next identifier_name
32 | internal var _stringValueOverride: String?
33 | internal var hasOverriddenStringValue: Bool {
34 | return _stringValueOverride != nil
35 | }
36 |
37 | public override init() {
38 | }
39 |
40 | public init(stringValue: String) {
41 | _stringValueOverride = stringValue
42 | }
43 |
44 | internal func stripNewlines(_ str: String) -> String {
45 | let whitespaces = CharacterSet.whitespacesAndNewlines
46 | return str
47 | .components(separatedBy: "\n")
48 | .map { line in line.trimmingCharacters(in: whitespaces) }
49 | .joined(separator: "")
50 | }
51 |
52 | internal func computeStringValue() -> String {
53 | var value = "\(expected) \(to) \(postfixMessage)"
54 | if let actualValue = actualValue {
55 | value = "\(expected) \(to) \(postfixMessage), got \(actualValue)\(postfixActual)"
56 | }
57 | value = stripNewlines(value)
58 |
59 | if let extendedMessage = extendedMessage {
60 | value += "\n\(stripNewlines(extendedMessage))"
61 | }
62 |
63 | if let userDescription = userDescription {
64 | return "\(userDescription)\n\(value)"
65 | }
66 |
67 | return value
68 | }
69 |
70 | internal func appendMessage(_ msg: String) {
71 | if hasOverriddenStringValue {
72 | stringValue += "\(msg)"
73 | } else if actualValue != nil {
74 | postfixActual += msg
75 | } else {
76 | postfixMessage += msg
77 | }
78 | }
79 |
80 | internal func appendDetails(_ msg: String) {
81 | if hasOverriddenStringValue {
82 | if let desc = userDescription {
83 | stringValue = "\(desc)\n\(stringValue)"
84 | }
85 | stringValue += "\n\(msg)"
86 | } else {
87 | if let desc = userDescription {
88 | userDescription = desc
89 | }
90 | extendedMessage = msg
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | private func matcherMessage(forType expectedType: T.Type) -> String {
4 | return "be a kind of \(String(describing: expectedType))"
5 | }
6 | private func matcherMessage(forClass expectedClass: AnyClass) -> String {
7 | return "be a kind of \(String(describing: expectedClass))"
8 | }
9 |
10 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class.
11 | public func beAKindOf(_ expectedType: T.Type) -> Predicate {
12 | return Predicate.define { actualExpression in
13 | let message: ExpectationMessage
14 |
15 | let instance = try actualExpression.evaluate()
16 | guard let validInstance = instance else {
17 | message = .expectedCustomValueTo(matcherMessage(forType: expectedType), "")
18 | return PredicateResult(status: .fail, message: message)
19 | }
20 | message = .expectedCustomValueTo(
21 | "be a kind of \(String(describing: expectedType))",
22 | "<\(String(describing: type(of: validInstance))) instance>"
23 | )
24 |
25 | return PredicateResult(
26 | bool: validInstance is T,
27 | message: message
28 | )
29 | }
30 | }
31 |
32 | #if canImport(Darwin)
33 |
34 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class.
35 | /// @see beAnInstanceOf if you want to match against the exact class
36 | public func beAKindOf(_ expectedClass: AnyClass) -> Predicate {
37 | return Predicate.define { actualExpression in
38 | let message: ExpectationMessage
39 | let status: PredicateStatus
40 |
41 | let instance = try actualExpression.evaluate()
42 | if let validInstance = instance {
43 | status = PredicateStatus(bool: instance != nil && instance!.isKind(of: expectedClass))
44 | message = .expectedCustomValueTo(
45 | matcherMessage(forClass: expectedClass),
46 | "<\(String(describing: type(of: validInstance))) instance>"
47 | )
48 | } else {
49 | status = .fail
50 | message = .expectedCustomValueTo(
51 | matcherMessage(forClass: expectedClass),
52 | ""
53 | )
54 | }
55 |
56 | return PredicateResult(status: status, message: message)
57 | }
58 | }
59 |
60 | extension NMBObjCMatcher {
61 | @objc public class func beAKindOfMatcher(_ expected: AnyClass) -> NMBMatcher {
62 | return NMBPredicate { actualExpression in
63 | return try beAKindOf(expected).satisfies(actualExpression).toObjectiveC()
64 | }
65 | }
66 | }
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is an _exact_ instance of the given class.
4 | public func beAnInstanceOf(_ expectedType: T.Type) -> Predicate {
5 | let errorMessage = "be an instance of \(String(describing: expectedType))"
6 | return Predicate.define { actualExpression in
7 | let instance = try actualExpression.evaluate()
8 | guard let validInstance = instance else {
9 | return PredicateResult(
10 | status: .doesNotMatch,
11 | message: .expectedActualValueTo(errorMessage)
12 | )
13 | }
14 |
15 | let actualString = "<\(String(describing: type(of: validInstance))) instance>"
16 |
17 | return PredicateResult(
18 | status: PredicateStatus(bool: type(of: validInstance) == expectedType),
19 | message: .expectedCustomValueTo(errorMessage, actualString)
20 | )
21 | }
22 | }
23 |
24 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class.
25 | /// @see beAKindOf if you want to match against subclasses
26 | public func beAnInstanceOf(_ expectedClass: AnyClass) -> Predicate {
27 | let errorMessage = "be an instance of \(String(describing: expectedClass))"
28 | return Predicate.define { actualExpression in
29 | let instance = try actualExpression.evaluate()
30 | let actualString: String
31 | if let validInstance = instance {
32 | actualString = "<\(String(describing: type(of: validInstance))) instance>"
33 | } else {
34 | actualString = ""
35 | }
36 | #if canImport(Darwin)
37 | let matches = instance != nil && instance!.isMember(of: expectedClass)
38 | #else
39 | let matches = instance != nil && type(of: instance!) == expectedClass
40 | #endif
41 | return PredicateResult(
42 | status: PredicateStatus(bool: matches),
43 | message: .expectedCustomValueTo(errorMessage, actualString)
44 | )
45 | }
46 | }
47 |
48 | #if canImport(Darwin)
49 | extension NMBObjCMatcher {
50 | @objc public class func beAnInstanceOfMatcher(_ expected: AnyClass) -> NMBMatcher {
51 | return NMBPredicate { actualExpression in
52 | return try beAnInstanceOf(expected).satisfies(actualExpression).toObjectiveC()
53 | }
54 | }
55 | }
56 | #endif
57 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value.
4 | public func beGreaterThan(_ expectedValue: T?) -> Predicate {
5 | let errorMessage = "be greater than <\(stringify(expectedValue))>"
6 | return Predicate.simple(errorMessage) { actualExpression in
7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue {
8 | return PredicateStatus(bool: actual > expected)
9 | }
10 | return .fail
11 | }
12 | }
13 |
14 | public func >(lhs: Expectation, rhs: T) {
15 | lhs.to(beGreaterThan(rhs))
16 | }
17 |
18 | #if canImport(Darwin) || !compiler(>=5.1)
19 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value.
20 | public func beGreaterThan(_ expectedValue: NMBComparable?) -> Predicate {
21 | let errorMessage = "be greater than <\(stringify(expectedValue))>"
22 | return Predicate.simple(errorMessage) { actualExpression in
23 | let actualValue = try actualExpression.evaluate()
24 | let matches = actualValue != nil
25 | && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedDescending
26 | return PredicateStatus(bool: matches)
27 | }
28 | }
29 |
30 | public func > (lhs: Expectation, rhs: NMBComparable?) {
31 | lhs.to(beGreaterThan(rhs))
32 | }
33 | #endif
34 |
35 | #if canImport(Darwin)
36 | extension NMBObjCMatcher {
37 | @objc public class func beGreaterThanMatcher(_ expected: NMBComparable?) -> NMBMatcher {
38 | return NMBPredicate { actualExpression in
39 | let expr = actualExpression.cast { $0 as? NMBComparable }
40 | return try beGreaterThan(expected).satisfies(expr).toObjectiveC()
41 | }
42 | }
43 | }
44 | #endif
45 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is greater than
4 | /// or equal to the expected value.
5 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> Predicate {
6 | let message = "be greater than or equal to <\(stringify(expectedValue))>"
7 | return Predicate.simple(message) { actualExpression in
8 | let actualValue = try actualExpression.evaluate()
9 | if let actual = actualValue, let expected = expectedValue {
10 | return PredicateStatus(bool: actual >= expected)
11 | }
12 | return .fail
13 | }
14 | }
15 |
16 | public func >=(lhs: Expectation, rhs: T) {
17 | lhs.to(beGreaterThanOrEqualTo(rhs))
18 | }
19 |
20 | #if canImport(Darwin) || !compiler(>=5.1)
21 | /// A Nimble matcher that succeeds when the actual value is greater than
22 | /// or equal to the expected value.
23 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> Predicate {
24 | let message = "be greater than or equal to <\(stringify(expectedValue))>"
25 | return Predicate.simple(message) { actualExpression in
26 | let actualValue = try actualExpression.evaluate()
27 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedAscending
28 | return PredicateStatus(bool: matches)
29 | }
30 | }
31 |
32 | public func >=(lhs: Expectation, rhs: T) {
33 | lhs.to(beGreaterThanOrEqualTo(rhs))
34 | }
35 | #endif
36 |
37 | #if canImport(Darwin)
38 | extension NMBObjCMatcher {
39 | @objc public class func beGreaterThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBMatcher {
40 | return NMBPredicate { actualExpression in
41 | let expr = actualExpression.cast { $0 as? NMBComparable }
42 | return try beGreaterThanOrEqualTo(expected).satisfies(expr).toObjectiveC()
43 | }
44 | }
45 | }
46 | #endif
47 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is the same instance
4 | /// as the expected instance.
5 | public func beIdenticalTo(_ expected: Any?) -> Predicate {
6 | return Predicate.define { actualExpression in
7 | let actual = try actualExpression.evaluate() as AnyObject?
8 |
9 | let bool = actual === (expected as AnyObject?) && actual !== nil
10 | return PredicateResult(
11 | bool: bool,
12 | message: .expectedCustomValueTo(
13 | "be identical to \(identityAsString(expected))",
14 | "\(identityAsString(actual))"
15 | )
16 | )
17 | }
18 | }
19 |
20 | public func === (lhs: Expectation, rhs: Any?) {
21 | lhs.to(beIdenticalTo(rhs))
22 | }
23 | public func !== (lhs: Expectation, rhs: Any?) {
24 | lhs.toNot(beIdenticalTo(rhs))
25 | }
26 |
27 | /// A Nimble matcher that succeeds when the actual value is the same instance
28 | /// as the expected instance.
29 | ///
30 | /// Alias for "beIdenticalTo".
31 | public func be(_ expected: Any?) -> Predicate {
32 | return beIdenticalTo(expected)
33 | }
34 |
35 | #if canImport(Darwin)
36 | extension NMBObjCMatcher {
37 | @objc public class func beIdenticalToMatcher(_ expected: NSObject?) -> NMBMatcher {
38 | return NMBPredicate { actualExpression in
39 | let aExpr = actualExpression.cast { $0 as Any? }
40 | return try beIdenticalTo(expected).satisfies(aExpr).toObjectiveC()
41 | }
42 | }
43 | }
44 | #endif
45 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeLessThan.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is less than the expected value.
4 | public func beLessThan(_ expectedValue: T?) -> Predicate {
5 | let message = "be less than <\(stringify(expectedValue))>"
6 | return Predicate.simple(message) { actualExpression in
7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue {
8 | return PredicateStatus(bool: actual < expected)
9 | }
10 | return .fail
11 | }
12 | }
13 |
14 | public func <(lhs: Expectation, rhs: T) {
15 | lhs.to(beLessThan(rhs))
16 | }
17 |
18 | #if canImport(Darwin) || !compiler(>=5.1)
19 | /// A Nimble matcher that succeeds when the actual value is less than the expected value.
20 | public func beLessThan(_ expectedValue: NMBComparable?) -> Predicate {
21 | let message = "be less than <\(stringify(expectedValue))>"
22 | return Predicate.simple(message) { actualExpression in
23 | let actualValue = try actualExpression.evaluate()
24 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedAscending
25 | return PredicateStatus(bool: matches)
26 | }
27 | }
28 |
29 | public func < (lhs: Expectation, rhs: NMBComparable?) {
30 | lhs.to(beLessThan(rhs))
31 | }
32 | #endif
33 |
34 | #if canImport(Darwin)
35 | extension NMBObjCMatcher {
36 | @objc public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBMatcher {
37 | return NMBPredicate { actualExpression in
38 | let expr = actualExpression.cast { $0 as? NMBComparable }
39 | return try beLessThan(expected).satisfies(expr).toObjectiveC()
40 | }
41 | }
42 | }
43 | #endif
44 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeLessThanOrEqual.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is less than
4 | /// or equal to the expected value.
5 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> Predicate {
6 | return Predicate.simple("be less than or equal to <\(stringify(expectedValue))>") { actualExpression in
7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue {
8 | return PredicateStatus(bool: actual <= expected)
9 | }
10 | return .fail
11 | }
12 | }
13 |
14 | public func <=(lhs: Expectation, rhs: T) {
15 | lhs.to(beLessThanOrEqualTo(rhs))
16 | }
17 |
18 | #if canImport(Darwin) || !compiler(>=5.1)
19 | /// A Nimble matcher that succeeds when the actual value is less than
20 | /// or equal to the expected value.
21 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> Predicate {
22 | return Predicate.simple("be less than or equal to <\(stringify(expectedValue))>") { actualExpression in
23 | let actualValue = try actualExpression.evaluate()
24 | let matches = actualValue.map { $0.NMB_compare(expectedValue) != .orderedDescending } ?? false
25 | return PredicateStatus(bool: matches)
26 | }
27 | }
28 |
29 | public func <=(lhs: Expectation, rhs: T) {
30 | lhs.to(beLessThanOrEqualTo(rhs))
31 | }
32 | #endif
33 |
34 | #if canImport(Darwin)
35 | extension NMBObjCMatcher {
36 | @objc public class func beLessThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBMatcher {
37 | return NMBPredicate { actualExpression in
38 | let expr = actualExpression.cast { $0 as? NMBComparable }
39 | return try beLessThanOrEqualTo(expected).satisfies(expr).toObjectiveC()
40 | }
41 | }
42 | }
43 | #endif
44 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeNil.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is nil.
4 | public func beNil() -> Predicate {
5 | return Predicate.simpleNilable("be nil") { actualExpression in
6 | let actualValue = try actualExpression.evaluate()
7 | return PredicateStatus(bool: actualValue == nil)
8 | }
9 | }
10 |
11 | #if canImport(Darwin)
12 | extension NMBObjCMatcher {
13 | @objc public class func beNilMatcher() -> NMBMatcher {
14 | return NMBPredicate { actualExpression in
15 | return try beNil().satisfies(actualExpression).toObjectiveC()
16 | }
17 | }
18 | }
19 | #endif
20 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeVoid.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is Void.
4 | public func beVoid() -> Predicate<()> {
5 | return Predicate.simpleNilable("be void") { actualExpression in
6 | let actualValue: ()? = try actualExpression.evaluate()
7 | return PredicateStatus(bool: actualValue != nil)
8 | }
9 | }
10 |
11 | extension Expectation where T == () {
12 | public static func == (lhs: Expectation<()>, rhs: ()) {
13 | lhs.to(beVoid())
14 | }
15 |
16 | public static func != (lhs: Expectation<()>, rhs: ()) {
17 | lhs.toNot(beVoid())
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeginWith.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual sequence's first element
4 | /// is equal to the expected value.
5 | public func beginWith(_ startingElement: T) -> Predicate
6 | where S.Iterator.Element == T {
7 | return Predicate.simple("begin with <\(startingElement)>") { actualExpression in
8 | if let actualValue = try actualExpression.evaluate() {
9 | var actualGenerator = actualValue.makeIterator()
10 | return PredicateStatus(bool: actualGenerator.next() == startingElement)
11 | }
12 | return .fail
13 | }
14 | }
15 |
16 | /// A Nimble matcher that succeeds when the actual collection's first element
17 | /// is equal to the expected object.
18 | public func beginWith(_ startingElement: Any) -> Predicate {
19 | return Predicate.simple("begin with <\(startingElement)>") { actualExpression in
20 | guard let collection = try actualExpression.evaluate() else { return .fail }
21 | guard collection.count > 0 else { return .doesNotMatch }
22 | #if os(Linux)
23 | guard let collectionValue = collection.object(at: 0) as? NSObject else {
24 | return .fail
25 | }
26 | #else
27 | let collectionValue = collection.object(at: 0) as AnyObject
28 | #endif
29 | return PredicateStatus(bool: collectionValue.isEqual(startingElement))
30 | }
31 | }
32 |
33 | /// A Nimble matcher that succeeds when the actual string contains expected substring
34 | /// where the expected substring's location is zero.
35 | public func beginWith(_ startingSubstring: String) -> Predicate {
36 | return Predicate.simple("begin with <\(startingSubstring)>") { actualExpression in
37 | if let actual = try actualExpression.evaluate() {
38 | return PredicateStatus(bool: actual.hasPrefix(startingSubstring))
39 | }
40 | return .fail
41 | }
42 | }
43 |
44 | #if canImport(Darwin)
45 | extension NMBObjCMatcher {
46 | @objc public class func beginWithMatcher(_ expected: Any) -> NMBMatcher {
47 | return NMBPredicate { actualExpression in
48 | let actual = try actualExpression.evaluate()
49 | if actual is String {
50 | let expr = actualExpression.cast { $0 as? String }
51 | // swiftlint:disable:next force_cast
52 | return try beginWith(expected as! String).satisfies(expr).toObjectiveC()
53 | } else {
54 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection }
55 | return try beginWith(expected).satisfies(expr).toObjectiveC()
56 | }
57 | }
58 | }
59 | }
60 | #endif
61 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | public func containElementSatisfying(_ predicate: @escaping ((T) -> Bool), _ predicateDescription: String = "") -> Predicate where S.Iterator.Element == T {
4 |
5 | return Predicate.define { actualExpression in
6 | let message: ExpectationMessage
7 | if predicateDescription == "" {
8 | message = .expectedTo("find object in collection that satisfies predicate")
9 | } else {
10 | message = .expectedTo("find object in collection \(predicateDescription)")
11 | }
12 |
13 | if let sequence = try actualExpression.evaluate() {
14 | for object in sequence {
15 | if predicate(object) {
16 | return PredicateResult(bool: true, message: message)
17 | }
18 | }
19 |
20 | return PredicateResult(bool: false, message: message)
21 | }
22 |
23 | return PredicateResult(status: .fail, message: message)
24 | }
25 | }
26 |
27 | #if canImport(Darwin)
28 | extension NMBObjCMatcher {
29 | @objc public class func containElementSatisfyingMatcher(_ predicate: @escaping ((NSObject) -> Bool)) -> NMBMatcher {
30 | return NMBPredicate { actualExpression in
31 | let value = try actualExpression.evaluate()
32 | guard let enumeration = value as? NSFastEnumeration else {
33 | let message = ExpectationMessage.fail(
34 | "containElementSatisfying must be provided an NSFastEnumeration object"
35 | )
36 | return NMBPredicateResult(status: .fail, message: message.toObjectiveC())
37 | }
38 |
39 | let message = ExpectationMessage
40 | .expectedTo("find object in collection that satisfies predicate")
41 | .toObjectiveC()
42 |
43 | var iterator = NSFastEnumerationIterator(enumeration)
44 | while let item = iterator.next() {
45 | guard let object = item as? NSObject else {
46 | continue
47 | }
48 |
49 | if predicate(object) {
50 | return NMBPredicateResult(status: .matches, message: message)
51 | }
52 | }
53 |
54 | return NMBPredicateResult(status: .doesNotMatch, message: message)
55 | }
56 | }
57 | }
58 | #endif
59 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ElementsEqual.swift:
--------------------------------------------------------------------------------
1 | /// A Nimble matcher that succeeds when the actual sequence contain the same elements in the same order to the exepected sequence.
2 | public func elementsEqual(_ expectedValue: S?) -> Predicate where S.Element: Equatable {
3 | // A matcher abstraction for https://developer.apple.com/documentation/swift/sequence/2949668-elementsequal
4 | return Predicate.define("elementsEqual <\(stringify(expectedValue))>") { (actualExpression, msg) in
5 | let actualValue = try actualExpression.evaluate()
6 | switch (expectedValue, actualValue) {
7 | case (nil, _?):
8 | return PredicateResult(status: .fail, message: msg.appendedBeNilHint())
9 | case (nil, nil), (_, nil):
10 | return PredicateResult(status: .fail, message: msg)
11 | case (let expected?, let actual?):
12 | let matches = expected.elementsEqual(actual)
13 | return PredicateResult(bool: matches, message: msg)
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/EndWith.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual sequence's last element
4 | /// is equal to the expected value.
5 | public func endWith(_ endingElement: T) -> Predicate
6 | where S.Iterator.Element == T {
7 | return Predicate.simple("end with <\(endingElement)>") { actualExpression in
8 | if let actualValue = try actualExpression.evaluate() {
9 | var actualGenerator = actualValue.makeIterator()
10 | var lastItem: T?
11 | var item: T?
12 | repeat {
13 | lastItem = item
14 | item = actualGenerator.next()
15 | } while(item != nil)
16 |
17 | return PredicateStatus(bool: lastItem == endingElement)
18 | }
19 | return .fail
20 | }
21 | }
22 |
23 | /// A Nimble matcher that succeeds when the actual collection's last element
24 | /// is equal to the expected object.
25 | public func endWith(_ endingElement: Any) -> Predicate {
26 | return Predicate.simple("end with <\(endingElement)>") { actualExpression in
27 | guard let collection = try actualExpression.evaluate() else { return .fail }
28 | guard collection.count > 0 else { return PredicateStatus(bool: false) }
29 | #if os(Linux)
30 | guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else {
31 | return .fail
32 | }
33 | #else
34 | let collectionValue = collection.object(at: collection.count - 1) as AnyObject
35 | #endif
36 |
37 | return PredicateStatus(bool: collectionValue.isEqual(endingElement))
38 | }
39 | }
40 |
41 | /// A Nimble matcher that succeeds when the actual string contains the expected substring
42 | /// where the expected substring's location is the actual string's length minus the
43 | /// expected substring's length.
44 | public func endWith(_ endingSubstring: String) -> Predicate {
45 | return Predicate.simple("end with <\(endingSubstring)>") { actualExpression in
46 | if let collection = try actualExpression.evaluate() {
47 | return PredicateStatus(bool: collection.hasSuffix(endingSubstring))
48 | }
49 | return .fail
50 | }
51 | }
52 |
53 | #if canImport(Darwin)
54 | extension NMBObjCMatcher {
55 | @objc public class func endWithMatcher(_ expected: Any) -> NMBMatcher {
56 | return NMBPredicate { actualExpression in
57 | let actual = try actualExpression.evaluate()
58 | if actual is String {
59 | let expr = actualExpression.cast { $0 as? String }
60 | // swiftlint:disable:next force_cast
61 | return try endWith(expected as! String).satisfies(expr).toObjectiveC()
62 | } else {
63 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection }
64 | return try endWith(expected).satisfies(expr).toObjectiveC()
65 | }
66 | }
67 | }
68 | }
69 | #endif
70 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/HaveCount.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // The `haveCount` matchers do not print the full string representation of the collection value,
4 | // instead they only print the type name and the expected count. This makes it easier to understand
5 | // the reason for failed expectations. See: https://github.com/Quick/Nimble/issues/308.
6 | // The representation of the collection content is provided in a new line as an `extendedMessage`.
7 |
8 | /// A Nimble matcher that succeeds when the actual Collection's count equals
9 | /// the expected value
10 | public func haveCount(_ expectedValue: Int) -> Predicate {
11 | return Predicate.define { actualExpression in
12 | if let actualValue = try actualExpression.evaluate() {
13 | let message = ExpectationMessage
14 | .expectedCustomValueTo(
15 | "have \(prettyCollectionType(actualValue)) with count \(stringify(expectedValue))",
16 | "\(actualValue.count)"
17 | )
18 | .appended(details: "Actual Value: \(stringify(actualValue))")
19 |
20 | let result = expectedValue == actualValue.count
21 | return PredicateResult(bool: result, message: message)
22 | } else {
23 | return PredicateResult(status: .fail, message: .fail(""))
24 | }
25 | }
26 | }
27 |
28 | /// A Nimble matcher that succeeds when the actual collection's count equals
29 | /// the expected value
30 | public func haveCount(_ expectedValue: Int) -> Predicate {
31 | return Predicate { actualExpression in
32 | if let actualValue = try actualExpression.evaluate() {
33 | let message = ExpectationMessage
34 | .expectedCustomValueTo(
35 | "have \(prettyCollectionType(actualValue)) with count \(stringify(expectedValue))",
36 | "\(actualValue.count)"
37 | )
38 | .appended(details: "Actual Value: \(stringify(actualValue))")
39 |
40 | let result = expectedValue == actualValue.count
41 | return PredicateResult(bool: result, message: message)
42 | } else {
43 | return PredicateResult(status: .fail, message: .fail(""))
44 | }
45 | }
46 | }
47 |
48 | #if canImport(Darwin)
49 | extension NMBObjCMatcher {
50 | @objc public class func haveCountMatcher(_ expected: NSNumber) -> NMBMatcher {
51 | return NMBPredicate { actualExpression in
52 | let location = actualExpression.location
53 | let actualValue = try actualExpression.evaluate()
54 | if let value = actualValue as? NMBCollection {
55 | let expr = Expression(expression: ({ value as NMBCollection}), location: location)
56 | return try haveCount(expected.intValue).satisfies(expr).toObjectiveC()
57 | }
58 |
59 | let message: ExpectationMessage
60 | if let actualValue = actualValue {
61 | message = ExpectationMessage.expectedCustomValueTo(
62 | "get type of NSArray, NSSet, NSDictionary, or NSHashTable",
63 | "\(String(describing: type(of: actualValue)))"
64 | )
65 | } else {
66 | message = ExpectationMessage
67 | .expectedActualValueTo("have a collection with count \(stringify(expected.intValue))")
68 | .appendedBeNilHint()
69 | }
70 | return NMBPredicateResult(status: .fail, message: message.toObjectiveC())
71 | }
72 | }
73 | }
74 | #endif
75 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/Match.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual string satisfies the regular expression
4 | /// described by the expected string.
5 | public func match(_ expectedValue: String?) -> Predicate {
6 | return Predicate.simple("match <\(stringify(expectedValue))>") { actualExpression in
7 | if let actual = try actualExpression.evaluate() {
8 | if let regexp = expectedValue {
9 | let bool = actual.range(of: regexp, options: .regularExpression) != nil
10 | return PredicateStatus(bool: bool)
11 | }
12 | }
13 |
14 | return .fail
15 | }
16 | }
17 |
18 | #if canImport(Darwin)
19 |
20 | extension NMBObjCMatcher {
21 | @objc public class func matchMatcher(_ expected: NSString) -> NMBMatcher {
22 | return NMBPredicate { actualExpression in
23 | let actual = actualExpression.cast { $0 as? String }
24 | return try match(expected.description).satisfies(actual).toObjectiveC()
25 | }
26 | }
27 | }
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/MatchError.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual expression evaluates to an
4 | /// error from the specified case.
5 | ///
6 | /// Errors are tried to be compared by their implementation of Equatable,
7 | /// otherwise they fallback to comparison by _domain and _code.
8 | public func matchError(_ error: T) -> Predicate {
9 | return Predicate.define { actualExpression in
10 | let actualError = try actualExpression.evaluate()
11 |
12 | let failureMessage = FailureMessage()
13 | setFailureMessageForError(
14 | failureMessage,
15 | postfixMessageVerb: "match",
16 | actualError: actualError,
17 | error: error
18 | )
19 |
20 | var matches = false
21 | if let actualError = actualError, errorMatchesExpectedError(actualError, expectedError: error) {
22 | matches = true
23 | }
24 |
25 | return PredicateResult(bool: matches, message: failureMessage.toExpectationMessage())
26 | }
27 | }
28 |
29 | /// A Nimble matcher that succeeds when the actual expression evaluates to an
30 | /// error from the specified case.
31 | ///
32 | /// Errors are tried to be compared by their implementation of Equatable,
33 | /// otherwise they fallback to comparision by _domain and _code.
34 | public func matchError(_ error: T) -> Predicate {
35 | return Predicate.define { actualExpression in
36 | let actualError = try actualExpression.evaluate()
37 |
38 | let failureMessage = FailureMessage()
39 | setFailureMessageForError(
40 | failureMessage,
41 | postfixMessageVerb: "match",
42 | actualError: actualError,
43 | error: error
44 | )
45 |
46 | var matches = false
47 | if let actualError = actualError as? T, error == actualError {
48 | matches = true
49 | }
50 |
51 | return PredicateResult(bool: matches, message: failureMessage.toExpectationMessage())
52 | }
53 | }
54 |
55 | /// A Nimble matcher that succeeds when the actual expression evaluates to an
56 | /// error of the specified type
57 | public func matchError(_ errorType: T.Type) -> Predicate {
58 | return Predicate.define { actualExpression in
59 | let actualError = try actualExpression.evaluate()
60 |
61 | let failureMessage = FailureMessage()
62 | setFailureMessageForError(
63 | failureMessage,
64 | postfixMessageVerb: "match",
65 | actualError: actualError,
66 | errorType: errorType
67 | )
68 |
69 | var matches = false
70 | if actualError as? T != nil {
71 | matches = true
72 | }
73 |
74 | return PredicateResult(bool: matches, message: failureMessage.toExpectationMessage())
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/MatcherFunc.swift:
--------------------------------------------------------------------------------
1 | /// DEPRECATED: A convenience API to build matchers that don't need special negation
2 | /// behavior. The toNot() behavior is the negation of to().
3 | ///
4 | /// @see NonNilMatcherFunc if you prefer to have this matcher fail when nil
5 | /// values are received in an expectation.
6 | ///
7 | /// You may use this when implementing your own custom matchers.
8 | ///
9 | /// Use the Matcher protocol instead of this type to accept custom matchers as
10 | /// input parameters.
11 | /// @see allPass for an example that uses accepts other matchers as input.
12 | @available(*, deprecated, message: "Use to Predicate instead")
13 | public struct MatcherFunc: Matcher {
14 | public let matcher: (Expression, FailureMessage) throws -> Bool
15 |
16 | public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) {
17 | self.matcher = matcher
18 | }
19 |
20 | public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool {
21 | return try matcher(actualExpression, failureMessage)
22 | }
23 |
24 | public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool {
25 | return try !matcher(actualExpression, failureMessage)
26 | }
27 |
28 | /// Compatibility layer to new Matcher API. Converts an old-style matcher to a new one.
29 | /// Note: You should definitely spend the time to convert to the new api as soon as possible
30 | /// since this struct type is deprecated.
31 | public var predicate: Predicate {
32 | return Predicate.fromDeprecatedMatcher(self)
33 | }
34 | }
35 |
36 | /// DEPRECATED: A convenience API to build matchers that don't need special negation
37 | /// behavior. The toNot() behavior is the negation of to().
38 | ///
39 | /// Unlike MatcherFunc, this will always fail if an expectation contains nil.
40 | /// This applies regardless of using to() or toNot().
41 | ///
42 | /// You may use this when implementing your own custom matchers.
43 | ///
44 | /// Use the Matcher protocol instead of this type to accept custom matchers as
45 | /// input parameters.
46 | /// @see allPass for an example that uses accepts other matchers as input.
47 | @available(*, deprecated, message: "Use to Predicate instead")
48 | public struct NonNilMatcherFunc: Matcher {
49 | public let matcher: (Expression, FailureMessage) throws -> Bool
50 |
51 | public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) {
52 | self.matcher = matcher
53 | }
54 |
55 | public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool {
56 | let pass = try matcher(actualExpression, failureMessage)
57 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) {
58 | return false
59 | }
60 | return pass
61 | }
62 |
63 | public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool {
64 | let pass = try !matcher(actualExpression, failureMessage)
65 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) {
66 | return false
67 | }
68 | return pass
69 | }
70 |
71 | internal func attachNilErrorIfNeeded(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool {
72 | if try actualExpression.evaluate() == nil {
73 | failureMessage.postfixActual = " (use beNil() to match nils)"
74 | return true
75 | }
76 | return false
77 | }
78 |
79 | /// Compatibility layer to new Matcher API. Converts an old-style matcher to a new one.
80 | /// Note: You should definitely spend the time to convert to the new api as soon as possible
81 | /// since this struct type is deprecated.
82 | public var predicate: Predicate {
83 | return Predicate.fromDeprecatedMatcher(self)
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/PostNotification.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | internal class NotificationCollector {
4 | private(set) var observedNotifications: [Notification]
5 | private let notificationCenter: NotificationCenter
6 | private var token: NSObjectProtocol?
7 |
8 | required init(notificationCenter: NotificationCenter) {
9 | self.notificationCenter = notificationCenter
10 | self.observedNotifications = []
11 | }
12 |
13 | func startObserving() {
14 | // swiftlint:disable:next line_length
15 | self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil) { [weak self] notification in
16 | // linux-swift gets confused by .append(n)
17 | self?.observedNotifications.append(notification)
18 | }
19 | }
20 |
21 | deinit {
22 | if let token = self.token {
23 | self.notificationCenter.removeObserver(token)
24 | }
25 | }
26 | }
27 |
28 | private let mainThread = pthread_self()
29 |
30 | public func postNotifications(
31 | _ predicate: Predicate<[Notification]>,
32 | fromNotificationCenter center: NotificationCenter = .default
33 | ) -> Predicate {
34 | _ = mainThread // Force lazy-loading of this value
35 | let collector = NotificationCollector(notificationCenter: center)
36 | collector.startObserving()
37 | var once: Bool = false
38 |
39 | return Predicate { actualExpression in
40 | let collectorNotificationsExpression = Expression(
41 | memoizedExpression: { _ in
42 | return collector.observedNotifications
43 | },
44 | location: actualExpression.location,
45 | withoutCaching: true
46 | )
47 |
48 | assert(pthread_equal(mainThread, pthread_self()) != 0, "Only expecting closure to be evaluated on main thread.")
49 | if !once {
50 | once = true
51 | _ = try actualExpression.evaluate()
52 | }
53 |
54 | let actualValue: String
55 | if collector.observedNotifications.isEmpty {
56 | actualValue = "no notifications"
57 | } else {
58 | actualValue = "<\(stringify(collector.observedNotifications))>"
59 | }
60 |
61 | var result = try predicate.satisfies(collectorNotificationsExpression)
62 | result.message = result.message.replacedExpectation { message in
63 | return .expectedCustomValueTo(message.expectedMessage, actualValue)
64 | }
65 | return result
66 | }
67 | }
68 |
69 | public func postNotifications(
70 | _ notificationsMatcher: T,
71 | fromNotificationCenter center: NotificationCenter = .default)
72 | -> Predicate
73 | where T: Matcher, T.ValueType == [Notification]
74 | {
75 | _ = mainThread // Force lazy-loading of this value
76 | let collector = NotificationCollector(notificationCenter: center)
77 | collector.startObserving()
78 | var once: Bool = false
79 |
80 | return Predicate { actualExpression in
81 | let collectorNotificationsExpression = Expression(memoizedExpression: { _ in
82 | return collector.observedNotifications
83 | }, location: actualExpression.location, withoutCaching: true)
84 |
85 | assert(pthread_equal(mainThread, pthread_self()) != 0, "Only expecting closure to be evaluated on main thread.")
86 | if !once {
87 | once = true
88 | _ = try actualExpression.evaluate()
89 | }
90 |
91 | let failureMessage = FailureMessage()
92 | let match = try notificationsMatcher.matches(collectorNotificationsExpression, failureMessage: failureMessage)
93 | if collector.observedNotifications.isEmpty {
94 | failureMessage.actualValue = "no notifications"
95 | } else {
96 | failureMessage.actualValue = "<\(stringify(collector.observedNotifications))>"
97 | }
98 | return PredicateResult(bool: match, message: failureMessage.toExpectationMessage())
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/SatisfyAllOf.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value matches with all of the matchers
4 | /// provided in the variable list of matchers.
5 | public func satisfyAllOf(_ predicates: Predicate...) -> Predicate {
6 | return satisfyAllOf(predicates)
7 | }
8 |
9 | /// A Nimble matcher that succeeds when the actual value matches with all of the matchers
10 | /// provided in the variable list of matchers.
11 | public func satisfyAllOf(_ matchers: U...) -> Predicate
12 | where U: Matcher, U.ValueType == T {
13 | return satisfyAllOf(matchers.map { $0.predicate })
14 | }
15 |
16 | internal func satisfyAllOf(_ predicates: [Predicate]) -> Predicate {
17 | return Predicate.define { actualExpression in
18 | var postfixMessages = [String]()
19 | var matches = true
20 | for predicate in predicates {
21 | let result = try predicate.satisfies(actualExpression)
22 | if result.toBoolean(expectation: .toNotMatch) {
23 | matches = false
24 | }
25 | postfixMessages.append("{\(result.message.expectedMessage)}")
26 | }
27 |
28 | var msg: ExpectationMessage
29 | if let actualValue = try actualExpression.evaluate() {
30 | msg = .expectedCustomValueTo(
31 | "match all of: " + postfixMessages.joined(separator: ", and "),
32 | "\(actualValue)"
33 | )
34 | } else {
35 | msg = .expectedActualValueTo(
36 | "match all of: " + postfixMessages.joined(separator: ", and ")
37 | )
38 | }
39 |
40 | return PredicateResult(bool: matches, message: msg)
41 | }
42 | }
43 |
44 | public func && (left: Predicate, right: Predicate) -> Predicate {
45 | return satisfyAllOf(left, right)
46 | }
47 |
48 | #if canImport(Darwin)
49 | extension NMBObjCMatcher {
50 | @objc public class func satisfyAllOfMatcher(_ matchers: [NMBMatcher]) -> NMBPredicate {
51 | return NMBPredicate { actualExpression in
52 | if matchers.isEmpty {
53 | return NMBPredicateResult(
54 | status: NMBPredicateStatus.fail,
55 | message: NMBExpectationMessage(
56 | fail: "satisfyAllOf must be called with at least one matcher"
57 | )
58 | )
59 | }
60 |
61 | var elementEvaluators = [Predicate]()
62 | for matcher in matchers {
63 | let elementEvaluator = Predicate { expression in
64 | if let predicate = matcher as? NMBPredicate {
65 | // swiftlint:disable:next line_length
66 | return predicate.satisfies({ try expression.evaluate() }, location: actualExpression.location).toSwift()
67 | } else {
68 | let failureMessage = FailureMessage()
69 | let success = matcher.matches(
70 | // swiftlint:disable:next force_try
71 | { try! expression.evaluate() },
72 | failureMessage: failureMessage,
73 | location: actualExpression.location
74 | )
75 | return PredicateResult(bool: success, message: failureMessage.toExpectationMessage())
76 | }
77 | }
78 |
79 | elementEvaluators.append(elementEvaluator)
80 | }
81 |
82 | return try satisfyAllOf(elementEvaluators).satisfies(actualExpression).toObjectiveC()
83 | }
84 | }
85 | }
86 | #endif
87 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value matches with any of the matchers
4 | /// provided in the variable list of matchers.
5 | public func satisfyAnyOf(_ predicates: Predicate...) -> Predicate {
6 | return satisfyAnyOf(predicates)
7 | }
8 |
9 | /// A Nimble matcher that succeeds when the actual value matches with any of the matchers
10 | /// provided in the variable list of matchers.
11 | public func satisfyAnyOf(_ matchers: U...) -> Predicate
12 | where U: Matcher, U.ValueType == T {
13 | return satisfyAnyOf(matchers.map { $0.predicate })
14 | }
15 |
16 | internal func satisfyAnyOf(_ predicates: [Predicate]) -> Predicate {
17 | return Predicate.define { actualExpression in
18 | var postfixMessages = [String]()
19 | var matches = false
20 | for predicate in predicates {
21 | let result = try predicate.satisfies(actualExpression)
22 | if result.toBoolean(expectation: .toMatch) {
23 | matches = true
24 | }
25 | postfixMessages.append("{\(result.message.expectedMessage)}")
26 | }
27 |
28 | var msg: ExpectationMessage
29 | if let actualValue = try actualExpression.evaluate() {
30 | msg = .expectedCustomValueTo(
31 | "match one of: " + postfixMessages.joined(separator: ", or "),
32 | "\(actualValue)"
33 | )
34 | } else {
35 | msg = .expectedActualValueTo(
36 | "match one of: " + postfixMessages.joined(separator: ", or ")
37 | )
38 | }
39 |
40 | return PredicateResult(bool: matches, message: msg)
41 | }
42 | }
43 |
44 | public func || (left: Predicate, right: Predicate) -> Predicate {
45 | return satisfyAnyOf(left, right)
46 | }
47 |
48 | public func || (left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> Predicate {
49 | return satisfyAnyOf(left, right)
50 | }
51 |
52 | public func || (left: MatcherFunc, right: MatcherFunc) -> Predicate {
53 | return satisfyAnyOf(left, right)
54 | }
55 |
56 | #if canImport(Darwin)
57 | extension NMBObjCMatcher {
58 | @objc public class func satisfyAnyOfMatcher(_ matchers: [NMBMatcher]) -> NMBPredicate {
59 | return NMBPredicate { actualExpression in
60 | if matchers.isEmpty {
61 | return NMBPredicateResult(
62 | status: NMBPredicateStatus.fail,
63 | message: NMBExpectationMessage(
64 | fail: "satisfyAnyOf must be called with at least one matcher"
65 | )
66 | )
67 | }
68 |
69 | var elementEvaluators = [Predicate]()
70 | for matcher in matchers {
71 | let elementEvaluator = Predicate { expression in
72 | if let predicate = matcher as? NMBPredicate {
73 | // swiftlint:disable:next line_length
74 | return predicate.satisfies({ try expression.evaluate() }, location: actualExpression.location).toSwift()
75 | } else {
76 | let failureMessage = FailureMessage()
77 | let success = matcher.matches(
78 | // swiftlint:disable:next force_try
79 | { try! expression.evaluate() },
80 | failureMessage: failureMessage,
81 | location: actualExpression.location
82 | )
83 | return PredicateResult(bool: success, message: failureMessage.toExpectationMessage())
84 | }
85 | }
86 |
87 | elementEvaluators.append(elementEvaluator)
88 | }
89 |
90 | return try satisfyAnyOf(elementEvaluators).satisfies(actualExpression).toObjectiveC()
91 | }
92 | }
93 | }
94 | #endif
95 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | #if canImport(NimbleCwlPreconditionTesting)
4 | import NimbleCwlPreconditionTesting
5 | #endif
6 |
7 | public func throwAssertion() -> Predicate {
8 | return Predicate { actualExpression in
9 | #if arch(x86_64) && canImport(Darwin)
10 | let message = ExpectationMessage.expectedTo("throw an assertion")
11 |
12 | var actualError: Error?
13 | let caughtException: BadInstructionException? = catchBadInstruction {
14 | #if os(tvOS)
15 | if !NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning {
16 | print()
17 | print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " +
18 | "fatal error while using throwAssertion(), please disable 'Debug Executable' " +
19 | "in your scheme. Go to 'Edit Scheme > Test > Info' and uncheck " +
20 | "'Debug Executable'. If you've already done that, suppress this warning " +
21 | "by setting `NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true`. " +
22 | "This is required because the standard methods of catching assertions " +
23 | "(mach APIs) are unavailable for tvOS. Instead, the same mechanism the " +
24 | "debugger uses is the fallback method for tvOS."
25 | )
26 | print()
27 | NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true
28 | }
29 | #endif
30 | do {
31 | try actualExpression.evaluate()
32 | } catch {
33 | actualError = error
34 | }
35 | }
36 |
37 | if let actualError = actualError {
38 | return PredicateResult(
39 | bool: false,
40 | message: message.appended(message: "; threw error instead <\(actualError)>")
41 | )
42 | } else {
43 | return PredicateResult(bool: caughtException != nil, message: message)
44 | }
45 | #else
46 | fatalError("The throwAssertion Nimble matcher can only run on x86_64 platforms with " +
47 | "Objective-C (e.g. macOS, iPhone 5s or later simulators). You can silence this error " +
48 | "by placing the test case inside an #if arch(x86_64) or canImport(Darwin) conditional statement")
49 | #endif
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ToSucceed.swift:
--------------------------------------------------------------------------------
1 | /**
2 | Used by the `toSucceed` matcher.
3 |
4 | This is the return type for the closure.
5 | */
6 | public enum ToSucceedResult {
7 | case succeeded
8 | case failed(reason: String)
9 | }
10 |
11 | /**
12 | A Nimble matcher that takes in a closure for validation.
13 |
14 | Return `.succeeded` when the validation succeeds.
15 | Return `.failed` with a failure reason when the validation fails.
16 | */
17 | public func succeed() -> Predicate<() -> ToSucceedResult> {
18 | return Predicate.define { actualExpression in
19 | let optActual = try actualExpression.evaluate()
20 | guard let actual = optActual else {
21 | return PredicateResult(status: .fail, message: .fail("expected a closure, got "))
22 | }
23 |
24 | switch actual() {
25 | case .succeeded:
26 | return PredicateResult(
27 | bool: true,
28 | message: .expectedCustomValueTo("succeed", "")
29 | )
30 | case .failed(let reason):
31 | return PredicateResult(
32 | bool: false,
33 | message: .expectedCustomValueTo("succeed", " because <\(reason)>")
34 | )
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Nimble.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "NMBExceptionCapture.h"
3 | #import "NMBStringify.h"
4 | #import "DSL.h"
5 |
6 | #import "CwlPreconditionTesting.h"
7 |
8 | FOUNDATION_EXPORT double NimbleVersionNumber;
9 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
10 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Utils/Errors.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // Generic
4 |
5 | internal func setFailureMessageForError(
6 | _ failureMessage: FailureMessage,
7 | postfixMessageVerb: String = "throw",
8 | actualError: Error?,
9 | error: T? = nil,
10 | errorType: T.Type? = nil,
11 | closure: ((T) -> Void)? = nil) {
12 | failureMessage.postfixMessage = "\(postfixMessageVerb) error"
13 |
14 | if let error = error {
15 | failureMessage.postfixMessage += " <\(error)>"
16 | } else if errorType != nil || closure != nil {
17 | failureMessage.postfixMessage += " from type <\(T.self)>"
18 | }
19 | if closure != nil {
20 | failureMessage.postfixMessage += " that satisfies block"
21 | }
22 | if error == nil && errorType == nil && closure == nil {
23 | failureMessage.postfixMessage = "\(postfixMessageVerb) any error"
24 | }
25 |
26 | if let actualError = actualError {
27 | failureMessage.actualValue = "<\(actualError)>"
28 | } else {
29 | failureMessage.actualValue = "no error"
30 | }
31 | }
32 |
33 | internal func errorMatchesExpectedError(
34 | _ actualError: Error,
35 | expectedError: T) -> Bool {
36 | return actualError._domain == expectedError._domain
37 | && actualError._code == expectedError._code
38 | }
39 |
40 | // Non-generic
41 |
42 | internal func setFailureMessageForError(
43 | _ failureMessage: FailureMessage,
44 | actualError: Error?,
45 | closure: ((Error) -> Void)?) {
46 | failureMessage.postfixMessage = "throw error"
47 |
48 | if closure != nil {
49 | failureMessage.postfixMessage += " that satisfies block"
50 | } else {
51 | failureMessage.postfixMessage = "throw any error"
52 | }
53 |
54 | if let actualError = actualError {
55 | failureMessage.actualValue = "<\(actualError)>"
56 | } else {
57 | failureMessage.actualValue = "no error"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Utils/Functional.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | #if !swift(>=4.2)
4 | extension Sequence {
5 | internal func allSatisfy(_ predicate: (Element) throws -> Bool) rethrows -> Bool {
6 | for item in self {
7 | if try !predicate(item) {
8 | return false
9 | }
10 | }
11 | return true
12 | }
13 | }
14 | #endif
15 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Utils/SourceLocation.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // Ideally we would always use `StaticString` as the type for tracking the file name
4 | // that expectations originate from, for consistency with `assert` etc. from the
5 | // stdlib, and because recent versions of the XCTest overlay require `StaticString`
6 | // when calling `XCTFail`. Under the Objective-C runtime (i.e. building on Mac), we
7 | // have to use `String` instead because StaticString can't be generated from Objective-C
8 | #if SWIFT_PACKAGE
9 | public typealias FileString = StaticString
10 | #else
11 | public typealias FileString = String
12 | #endif
13 |
14 | public final class SourceLocation: NSObject {
15 | public let file: FileString
16 | public let line: UInt
17 |
18 | override init() {
19 | file = "Unknown File"
20 | line = 0
21 | }
22 |
23 | init(file: FileString, line: UInt) {
24 | self.file = file
25 | self.line = line
26 | }
27 |
28 | override public var description: String {
29 | return "\(file):\(line)"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface NMBExceptionCapture : NSObject
5 |
6 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally;
7 | - (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock NS_SWIFT_NAME(tryBlock(_:));
8 |
9 | @end
10 |
11 | typedef void(^NMBSourceCallbackBlock)(BOOL successful);
12 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m:
--------------------------------------------------------------------------------
1 | #import "NMBExceptionCapture.h"
2 |
3 | @interface NMBExceptionCapture ()
4 | @property (nonatomic, copy) void(^ _Nullable handler)(NSException * _Nullable);
5 | @property (nonatomic, copy) void(^ _Nullable finally)(void);
6 | @end
7 |
8 | @implementation NMBExceptionCapture
9 |
10 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally {
11 | self = [super init];
12 | if (self) {
13 | self.handler = handler;
14 | self.finally = finally;
15 | }
16 | return self;
17 | }
18 |
19 | - (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock {
20 | @try {
21 | unsafeBlock();
22 | }
23 | @catch (NSException *exception) {
24 | if (self.handler) {
25 | self.handler(exception);
26 | }
27 | }
28 | @finally {
29 | if (self.finally) {
30 | self.finally();
31 | }
32 | }
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.h:
--------------------------------------------------------------------------------
1 | @class NSString;
2 |
3 | /**
4 | * Returns a string appropriate for displaying in test output
5 | * from the provided value.
6 | *
7 | * @param anyObject A value that will show up in a test's output.
8 | *
9 | * @return The string that is returned can be
10 | * customized per type by conforming a type to the `TestOutputStringConvertible`
11 | * protocol. When stringifying a non-`TestOutputStringConvertible` type, this
12 | * function will return the value's debug description and then its
13 | * normal description if available and in that order. Otherwise it
14 | * will return the result of constructing a string from the value.
15 | *
16 | * @see `TestOutputStringConvertible`
17 | */
18 | extern NSString *_Nonnull NMBStringify(id _Nullable anyObject) __attribute__((warn_unused_result));
19 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.m:
--------------------------------------------------------------------------------
1 | #import "NMBStringify.h"
2 |
3 | #if __has_include("Nimble-Swift.h")
4 | #import "Nimble-Swift.h"
5 | #else
6 | #import
7 | #endif
8 |
9 | NSString *_Nonnull NMBStringify(id _Nullable anyObject) {
10 | return [NMBStringer stringify:anyObject];
11 | }
12 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/XCTestObservationCenter+Register.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if __has_include("Nimble-Swift.h")
4 | #import "Nimble-Swift.h"
5 | #else
6 | #import
7 | #endif
8 |
9 | __attribute__((constructor))
10 | static void registerCurrentTestCaseTracker(void) {
11 | [[XCTestObservationCenter sharedTestObservationCenter] addTestObserver:[CurrentTestCaseTracker sharedInstance]];
12 | }
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | ${PODS_DEVELOPMENT_LANGUAGE}
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 0.2.4
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_JPCrop : NSObject
3 | @end
4 | @implementation PodsDummy_JPCrop
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double JPCropVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char JPCropVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/JPCrop
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
5 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
9 | PODS_ROOT = ${SRCROOT}
10 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
12 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
13 | SKIP_INSTALL = YES
14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
15 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop.modulemap:
--------------------------------------------------------------------------------
1 | framework module JPCrop {
2 | umbrella header "JPCrop-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/JPCrop/JPCrop.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/JPCrop
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
5 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
9 | PODS_ROOT = ${SRCROOT}
10 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
12 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
13 | SKIP_INSTALL = YES
14 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
15 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | ${PODS_DEVELOPMENT_LANGUAGE}
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## JPCrop
5 |
6 | Copyright (c) 2020 Rogue24
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 |
27 | ## pop
28 |
29 | BSD License
30 |
31 | For Pop software
32 |
33 | Copyright (c) 2014, Facebook, Inc. All rights reserved.
34 |
35 | Redistribution and use in source and binary forms, with or without modification,
36 | are permitted provided that the following conditions are met:
37 |
38 | * Redistributions of source code must retain the above copyright notice, this
39 | list of conditions and the following disclaimer.
40 |
41 | * Redistributions in binary form must reproduce the above copyright notice,
42 | this list of conditions and the following disclaimer in the documentation
43 | and/or other materials provided with the distribution.
44 |
45 | * Neither the name Facebook nor the names of its contributors may be used to
46 | endorse or promote products derived from this software without specific
47 | prior written permission.
48 |
49 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
50 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
51 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
53 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
54 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
56 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 |
60 | Generated by CocoaPods - https://cocoapods.org
61 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Copyright (c) 2020 Rogue24 <zhoujianping24@hotmail.com>
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 | License
38 | MIT
39 | Title
40 | JPCrop
41 | Type
42 | PSGroupSpecifier
43 |
44 |
45 | FooterText
46 | BSD License
47 |
48 | For Pop software
49 |
50 | Copyright (c) 2014, Facebook, Inc. All rights reserved.
51 |
52 | Redistribution and use in source and binary forms, with or without modification,
53 | are permitted provided that the following conditions are met:
54 |
55 | * Redistributions of source code must retain the above copyright notice, this
56 | list of conditions and the following disclaimer.
57 |
58 | * Redistributions in binary form must reproduce the above copyright notice,
59 | this list of conditions and the following disclaimer in the documentation
60 | and/or other materials provided with the distribution.
61 |
62 | * Neither the name Facebook nor the names of its contributors may be used to
63 | endorse or promote products derived from this software without specific
64 | prior written permission.
65 |
66 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
67 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
68 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
69 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
70 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
71 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
72 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
73 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76 |
77 | License
78 | BSD
79 | Title
80 | pop
81 | Type
82 | PSGroupSpecifier
83 |
84 |
85 | FooterText
86 | Generated by CocoaPods - https://cocoapods.org
87 | Title
88 |
89 | Type
90 | PSGroupSpecifier
91 |
92 |
93 | StringsTable
94 | Acknowledgements
95 | Title
96 | Acknowledgements
97 |
98 |
99 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_JPCrop_Example : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_JPCrop_Example
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double Pods_JPCrop_ExampleVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char Pods_JPCrop_ExampleVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example.debug.xcconfig:
--------------------------------------------------------------------------------
1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/JPCrop" "${PODS_CONFIGURATION_BUILD_DIR}/pop"
4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/JPCrop/JPCrop.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/pop/pop.framework/Headers"
6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks'
7 | LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
8 | OTHER_LDFLAGS = $(inherited) -l"c++" -framework "JPCrop" -framework "pop"
9 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
10 | PODS_BUILD_DIR = ${BUILD_DIR}
11 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
12 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
13 | PODS_ROOT = ${SRCROOT}/Pods
14 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
15 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
16 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_JPCrop_Example {
2 | umbrella header "Pods-JPCrop_Example-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-JPCrop_Example/Pods-JPCrop_Example.release.xcconfig:
--------------------------------------------------------------------------------
1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
2 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/JPCrop" "${PODS_CONFIGURATION_BUILD_DIR}/pop"
4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
5 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/JPCrop/JPCrop.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/pop/pop.framework/Headers"
6 | LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks'
7 | LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
8 | OTHER_LDFLAGS = $(inherited) -l"c++" -framework "JPCrop" -framework "pop"
9 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
10 | PODS_BUILD_DIR = ${BUILD_DIR}
11 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
12 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
13 | PODS_ROOT = ${SRCROOT}/Pods
14 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
15 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
16 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | ${PODS_DEVELOPMENT_LANGUAGE}
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.12
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_pop : NSObject
3 | @end
4 | @implementation PodsDummy_pop
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 | #import "POP.h"
14 | #import "POPAnimatableProperty.h"
15 | #import "POPAnimatablePropertyTypes.h"
16 | #import "POPAnimation.h"
17 | #import "POPAnimationEvent.h"
18 | #import "POPAnimationExtras.h"
19 | #import "POPAnimationTracer.h"
20 | #import "POPAnimator.h"
21 | #import "POPBasicAnimation.h"
22 | #import "POPCustomAnimation.h"
23 | #import "POPDecayAnimation.h"
24 | #import "POPDefines.h"
25 | #import "POPGeometry.h"
26 | #import "POPLayerExtras.h"
27 | #import "POPPropertyAnimation.h"
28 | #import "POPSpringAnimation.h"
29 | #import "POPVector.h"
30 |
31 | FOUNDATION_EXPORT double popVersionNumber;
32 | FOUNDATION_EXPORT const unsigned char popVersionString[];
33 |
34 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_CXX_LANGUAGE_STANDARD = c++11
2 | CLANG_CXX_LIBRARY = libc++
3 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
4 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/pop
5 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
6 | OTHER_LDFLAGS = $(inherited) -l"c++"
7 | PODS_BUILD_DIR = ${BUILD_DIR}
8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
10 | PODS_ROOT = ${SRCROOT}
11 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/pop
12 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
13 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
14 | SKIP_INSTALL = YES
15 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
16 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop.modulemap:
--------------------------------------------------------------------------------
1 | framework module pop {
2 | umbrella header "pop-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/pop/pop.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_CXX_LANGUAGE_STANDARD = c++11
2 | CLANG_CXX_LIBRARY = libc++
3 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
4 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/pop
5 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
6 | OTHER_LDFLAGS = $(inherited) -l"c++"
7 | PODS_BUILD_DIR = ${BUILD_DIR}
8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
10 | PODS_ROOT = ${SRCROOT}
11 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/pop
12 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
13 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
14 | SKIP_INSTALL = YES
15 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
16 |
--------------------------------------------------------------------------------
/Example/Pods/pop/LICENSE:
--------------------------------------------------------------------------------
1 | BSD License
2 |
3 | For Pop software
4 |
5 | Copyright (c) 2014, Facebook, Inc. All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without modification,
8 | are permitted provided that the following conditions are met:
9 |
10 | * Redistributions of source code must retain the above copyright notice, this
11 | list of conditions and the following disclaimer.
12 |
13 | * Redistributions in binary form must reproduce the above copyright notice,
14 | this list of conditions and the following disclaimer in the documentation
15 | and/or other materials provided with the distribution.
16 |
17 | * Neither the name Facebook nor the names of its contributors may be used to
18 | endorse or promote products derived from this software without specific
19 | prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POP.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #ifndef POP_POP_H
11 | #define POP_POP_H
12 |
13 | #import
14 |
15 | #import
16 | #import
17 | #import
18 | #import
19 | #import
20 | #import
21 | #import
22 | #import
23 | #import
24 | #import
25 | #import
26 | #import
27 | #import
28 | #import
29 |
30 | #endif /* POP_POP_H */
31 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAction.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #ifndef POPACTION_H
11 | #define POPACTION_H
12 |
13 | #import
14 |
15 | #import
16 |
17 | #ifdef __cplusplus
18 |
19 | namespace POP {
20 |
21 | /**
22 | @abstract Disables Core Animation actions using RAII.
23 | @discussion The disablement of actions is scoped to the current transaction.
24 | */
25 | class ActionDisabler
26 | {
27 | BOOL state;
28 |
29 | public:
30 | ActionDisabler() POP_NOTHROW
31 | {
32 | state = [CATransaction disableActions];
33 | [CATransaction setDisableActions:YES];
34 | }
35 |
36 | ~ActionDisabler()
37 | {
38 | [CATransaction setDisableActions:state];
39 | }
40 | };
41 |
42 | /**
43 | @abstract Enables Core Animation actions using RAII.
44 | @discussion The enablement of actions is scoped to the current transaction.
45 | */
46 | class ActionEnabler
47 | {
48 | BOOL state;
49 |
50 | public:
51 | ActionEnabler() POP_NOTHROW
52 | {
53 | state = [CATransaction disableActions];
54 | [CATransaction setDisableActions:NO];
55 | }
56 |
57 | ~ActionEnabler()
58 | {
59 | [CATransaction setDisableActions:state];
60 | }
61 | };
62 |
63 | }
64 |
65 | #endif /* __cplusplus */
66 |
67 | #endif /* POPACTION_H */
68 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimatablePropertyTypes.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | typedef void (^POPAnimatablePropertyReadBlock)(id obj, CGFloat values[]);
11 | typedef void (^POPAnimatablePropertyWriteBlock)(id obj, const CGFloat values[]);
12 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationEvent.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | /**
13 | @abstract Enumeraton of animation event types.
14 | */
15 | typedef NS_ENUM(NSUInteger, POPAnimationEventType) {
16 | kPOPAnimationEventPropertyRead = 0,
17 | kPOPAnimationEventPropertyWrite,
18 | kPOPAnimationEventToValueUpdate,
19 | kPOPAnimationEventFromValueUpdate,
20 | kPOPAnimationEventVelocityUpdate,
21 | kPOPAnimationEventBouncinessUpdate,
22 | kPOPAnimationEventSpeedUpdate,
23 | kPOPAnimationEventFrictionUpdate,
24 | kPOPAnimationEventMassUpdate,
25 | kPOPAnimationEventTensionUpdate,
26 | kPOPAnimationEventDidStart,
27 | kPOPAnimationEventDidStop,
28 | kPOPAnimationEventDidReachToValue,
29 | kPOPAnimationEventAutoreversed
30 | };
31 |
32 | /**
33 | @abstract The base animation event class.
34 | */
35 | @interface POPAnimationEvent : NSObject
36 |
37 | /**
38 | @abstract The event type. See {@ref POPAnimationEventType} for possible values.
39 | */
40 | @property (readonly, nonatomic, assign) POPAnimationEventType type;
41 |
42 | /**
43 | @abstract The time of event.
44 | */
45 | @property (readonly, nonatomic, assign) CFTimeInterval time;
46 |
47 | /**
48 | @abstract Optional string describing the animation at time of event.
49 | */
50 | @property (readonly, nonatomic, copy) NSString *animationDescription;
51 |
52 | @end
53 |
54 | /**
55 | @abstract An animation event subclass for recording value and velocity.
56 | */
57 | @interface POPAnimationValueEvent : POPAnimationEvent
58 |
59 | /**
60 | @abstract The value recorded.
61 | */
62 | @property (readonly, nonatomic, strong) id value;
63 |
64 | /**
65 | @abstract The velocity recorded, if any.
66 | */
67 | @property (readonly, nonatomic, strong) id velocity;
68 |
69 | @end
70 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationEvent.mm:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "POPAnimationEvent.h"
11 | #import "POPAnimationEventInternal.h"
12 |
13 | static NSString *stringFromType(POPAnimationEventType aType)
14 | {
15 | switch (aType) {
16 | case kPOPAnimationEventPropertyRead:
17 | return @"read";
18 | case kPOPAnimationEventPropertyWrite:
19 | return @"write";
20 | case kPOPAnimationEventToValueUpdate:
21 | return @"toValue";
22 | case kPOPAnimationEventFromValueUpdate:
23 | return @"fromValue";
24 | case kPOPAnimationEventVelocityUpdate:
25 | return @"velocity";
26 | case kPOPAnimationEventSpeedUpdate:
27 | return @"speed";
28 | case kPOPAnimationEventBouncinessUpdate:
29 | return @"bounciness";
30 | case kPOPAnimationEventFrictionUpdate:
31 | return @"friction";
32 | case kPOPAnimationEventMassUpdate:
33 | return @"mass";
34 | case kPOPAnimationEventTensionUpdate:
35 | return @"tension";
36 | case kPOPAnimationEventDidStart:
37 | return @"didStart";
38 | case kPOPAnimationEventDidStop:
39 | return @"didStop";
40 | case kPOPAnimationEventDidReachToValue:
41 | return @"didReachToValue";
42 | case kPOPAnimationEventAutoreversed:
43 | return @"autoreversed";
44 | default:
45 | return nil;
46 | }
47 | }
48 |
49 | @implementation POPAnimationEvent
50 | @synthesize type = _type;
51 | @synthesize time = _time;
52 | @synthesize animationDescription = _animationDescription;
53 |
54 | - (instancetype)initWithType:(POPAnimationEventType)aType time:(CFTimeInterval)aTime
55 | {
56 | self = [super init];
57 | if (nil != self) {
58 | _type = aType;
59 | _time = aTime;
60 | }
61 | return self;
62 | }
63 |
64 | - (NSString *)description
65 | {
66 | NSMutableString *s = [NSMutableString stringWithFormat:@""];
69 | return s;
70 | }
71 |
72 | // subclass override
73 | - (void)_appendDescription:(NSMutableString *)s
74 | {
75 | if (0 != _animationDescription.length) {
76 | [s appendFormat:@"; animation = %@", _animationDescription];
77 | }
78 | }
79 |
80 | @end
81 |
82 | @implementation POPAnimationValueEvent
83 | @synthesize value = _value;
84 | @synthesize velocity = _velocity;
85 |
86 | - (instancetype)initWithType:(POPAnimationEventType)aType time:(CFTimeInterval)aTime value:(id)aValue
87 | {
88 | self = [self initWithType:aType time:aTime];
89 | if (nil != self) {
90 | _value = aValue;
91 | }
92 | return self;
93 | }
94 |
95 | - (void)_appendDescription:(NSMutableString *)s
96 | {
97 | [super _appendDescription:s];
98 |
99 | if (nil != _value) {
100 | [s appendFormat:@"; value = %@", _value];
101 | }
102 |
103 | if (nil != _velocity) {
104 | [s appendFormat:@"; velocity = %@", _velocity];
105 | }
106 | }
107 |
108 | @end
109 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationEventInternal.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import "POPAnimationEvent.h"
13 |
14 | @interface POPAnimationEvent ()
15 |
16 | /**
17 | @abstract Default initializer.
18 | */
19 | - (instancetype)initWithType:(POPAnimationEventType)type time:(CFTimeInterval)time;
20 |
21 | /**
22 | @abstract Readwrite redefinition of public property.
23 | */
24 | @property (readwrite, nonatomic, copy) NSString *animationDescription;
25 |
26 | @end
27 |
28 | @interface POPAnimationValueEvent ()
29 |
30 | /**
31 | @abstract Default initializer.
32 | */
33 | - (instancetype)initWithType:(POPAnimationEventType)type time:(CFTimeInterval)time value:(id)value;
34 |
35 | /**
36 | @abstract Readwrite redefinition of public property.
37 | */
38 | @property (readwrite, nonatomic, strong) id velocity;
39 |
40 | @end
41 |
42 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationExtras.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import
13 | #import
14 |
15 | /**
16 | @abstract The current drag coefficient.
17 | @discussion A value greater than 1.0 indicates Simulator slow-motion animations are enabled. Defaults to 1.0.
18 | */
19 | extern CGFloat POPAnimationDragCoefficient(void);
20 |
21 | @interface CAAnimation (POPAnimationExtras)
22 |
23 | /**
24 | @abstract Apply the current drag coefficient to animation speed.
25 | @discussion Convenience utility to respect Simulator slow-motion animation settings.
26 | */
27 | - (void)pop_applyDragCoefficient;
28 |
29 | @end
30 |
31 | @interface POPSpringAnimation (POPAnimationExtras)
32 |
33 | /**
34 | @abstract Converts from spring bounciness and speed to tension, friction and mass dynamics values.
35 | */
36 | + (void)convertBounciness:(CGFloat)bounciness speed:(CGFloat)speed toTension:(CGFloat *)outTension friction:(CGFloat *)outFriction mass:(CGFloat *)outMass;
37 |
38 | /**
39 | @abstract Converts from dynamics tension, friction and mass to spring bounciness and speed values.
40 | */
41 | + (void)convertTension:(CGFloat)tension friction:(CGFloat)friction toBounciness:(CGFloat *)outBounciness speed:(CGFloat *)outSpeed;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationPrivate.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #define POP_ANIMATION_FRICTION_FOR_QC_FRICTION(qcFriction) (25.0 + (((qcFriction - 8.0) / 2.0) * (25.0 - 19.0)))
13 | #define POP_ANIMATION_TENSION_FOR_QC_TENSION(qcTension) (194.0 + (((qcTension - 30.0) / 50.0) * (375.0 - 194.0)))
14 |
15 | #define QC_FRICTION_FOR_POP_ANIMATION_FRICTION(fbFriction) (8.0 + 2.0 * ((fbFriction - 25.0)/(25.0 - 19.0)))
16 | #define QC_TENSION_FOR_POP_ANIMATION_TENSION(fbTension) (30.0 + 50.0 * ((fbTension - 194.0)/(375.0 - 194.0)))
17 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationRuntime.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import
13 | #import
14 |
15 | #import "POPAnimatablePropertyTypes.h"
16 | #import "POPVector.h"
17 |
18 | enum POPValueType
19 | {
20 | kPOPValueUnknown = 0,
21 | kPOPValueInteger,
22 | kPOPValueFloat,
23 | kPOPValuePoint,
24 | kPOPValueSize,
25 | kPOPValueRect,
26 | kPOPValueEdgeInsets,
27 | kPOPValueAffineTransform,
28 | kPOPValueTransform,
29 | kPOPValueRange,
30 | kPOPValueColor,
31 | kPOPValueSCNVector3,
32 | kPOPValueSCNVector4,
33 | };
34 |
35 | using namespace POP;
36 |
37 | /**
38 | Returns value type based on objc type description, given list of supported value types and length.
39 | */
40 | extern POPValueType POPSelectValueType(const char *objctype, const POPValueType *types, size_t length);
41 |
42 | /**
43 | Returns value type based on objc object, given a list of supported value types and length.
44 | */
45 | extern POPValueType POPSelectValueType(id obj, const POPValueType *types, size_t length);
46 |
47 | /**
48 | Array of all value types.
49 | */
50 | extern const POPValueType kPOPAnimatableAllTypes[12];
51 |
52 | /**
53 | Array of all value types supported for animation.
54 | */
55 | extern const POPValueType kPOPAnimatableSupportTypes[10];
56 |
57 | /**
58 | Returns a string description of a value type.
59 | */
60 | extern NSString *POPValueTypeToString(POPValueType t);
61 |
62 | /**
63 | Returns a mutable dictionary of weak pointer keys to weak pointer values.
64 | */
65 | extern CFMutableDictionaryRef POPDictionaryCreateMutableWeakPointerToWeakPointer(NSUInteger capacity) CF_RETURNS_RETAINED;
66 |
67 | /**
68 | Returns a mutable dictionary of weak pointer keys to weak pointer values.
69 | */
70 | extern CFMutableDictionaryRef POPDictionaryCreateMutableWeakPointerToStrongObject(NSUInteger capacity) CF_RETURNS_RETAINED;
71 |
72 | /**
73 | Box a vector.
74 | */
75 | extern id POPBox(VectorConstRef vec, POPValueType type, bool force = false);
76 |
77 | /**
78 | Unbox a vector.
79 | */
80 | extern VectorRef POPUnbox(id value, POPValueType &type, NSUInteger &count, bool validate);
81 |
82 | /**
83 | Read object value and return a Vector4r.
84 | */
85 | NS_INLINE Vector4r read_values(POPAnimatablePropertyReadBlock read, id obj, size_t count)
86 | {
87 | Vector4r vec = Vector4r::Zero();
88 | if (0 == count)
89 | return vec;
90 |
91 | read(obj, vec.data());
92 |
93 | return vec;
94 | }
95 |
96 | NS_INLINE NSString *POPStringFromBOOL(BOOL value)
97 | {
98 | return value ? @"YES" : @"NO";
99 | }
100 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationTracer.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import
13 |
14 | @class POPAnimation;
15 |
16 | /**
17 | @abstract Tracer of animation events to facilitate unit testing & debugging.
18 | */
19 | @interface POPAnimationTracer : NSObject
20 |
21 | /**
22 | @abstract Start recording events.
23 | */
24 | - (void)start;
25 |
26 | /**
27 | @abstract Stop recording events.
28 | */
29 | - (void)stop;
30 |
31 | /**
32 | @abstract Resets any recoded events. Continues recording events if already started.
33 | */
34 | - (void)reset;
35 |
36 | /**
37 | @abstract Property representing all recorded events.
38 | @discussion Events are returned in order of occurrence.
39 | */
40 | @property (nonatomic, assign, readonly) NSArray *allEvents;
41 |
42 | /**
43 | @abstract Property representing all recorded write events for convenience.
44 | @discussion Events are returned in order of occurrence.
45 | */
46 | @property (nonatomic, assign, readonly) NSArray *writeEvents;
47 |
48 | /**
49 | @abstract Queries for events of specified type.
50 | @param type The type of event to return.
51 | @returns An array of events of specified type in order of occurrence.
52 | */
53 | - (NSArray *)eventsWithType:(POPAnimationEventType)type;
54 |
55 | /**
56 | @abstract Property indicating whether tracer should automatically log events and reset collection on animation completion.
57 | */
58 | @property (nonatomic, assign) BOOL shouldLogAndResetOnCompletion;
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimationTracerInternal.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import
13 |
14 | @interface POPAnimationTracer (Internal)
15 |
16 | /**
17 | @abstract Designated initializer. Pass the animation being traced.
18 | */
19 | - (instancetype)initWithAnimation:(POPAnimation *)anAnim;
20 |
21 | /**
22 | @abstract Records read value.
23 | */
24 | - (void)readPropertyValue:(id)aValue;
25 |
26 | /**
27 | @abstract Records write value.
28 | */
29 | - (void)writePropertyValue:(id)aValue;
30 |
31 | /**
32 | Records to value update.
33 | */
34 | - (void)updateToValue:(id)aValue;
35 |
36 | /**
37 | @abstract Records from value update.
38 | */
39 | - (void)updateFromValue:(id)aValue;
40 |
41 | /**
42 | @abstract Records from value update.
43 | */
44 | - (void)updateVelocity:(id)aValue;
45 |
46 | /**
47 | @abstract Records bounciness update.
48 | */
49 | - (void)updateBounciness:(float)aFloat;
50 |
51 | /**
52 | @abstract Records speed update.
53 | */
54 | - (void)updateSpeed:(float)aFloat;
55 |
56 | /**
57 | @abstract Records friction update.
58 | */
59 | - (void)updateFriction:(float)aFloat;
60 |
61 | /**
62 | @abstract Records mass update.
63 | */
64 | - (void)updateMass:(float)aFloat;
65 |
66 | /**
67 | @abstract Records tension update.
68 | */
69 | - (void)updateTension:(float)aFloat;
70 |
71 | /**
72 | @abstract Records did add.
73 | */
74 | - (void)didAdd;
75 |
76 | /**
77 | @abstract Records did start.
78 | */
79 | - (void)didStart;
80 |
81 | /**
82 | @abstract Records did stop.
83 | */
84 | - (void)didStop:(BOOL)finished;
85 |
86 | /**
87 | @abstract Records did reach to value.
88 | */
89 | - (void)didReachToValue:(id)aValue;
90 |
91 | /**
92 | @abstract Records when an autoreverse animation takes place.
93 | */
94 | - (void)autoreversed;
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimator.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @protocol POPAnimatorDelegate;
13 |
14 | /**
15 | @abstract The animator class renders animations.
16 | */
17 | @interface POPAnimator : NSObject
18 |
19 | /**
20 | @abstract The shared animator instance.
21 | @discussion Consumers should generally use the shared instance in lieu of creating new instances.
22 | */
23 | + (instancetype)sharedAnimator;
24 |
25 | #if !TARGET_OS_IPHONE
26 | /**
27 | @abstract Allows to select display to bind. Returns nil if failed to create the display link.
28 | */
29 | - (instancetype)initWithDisplayID:(CGDirectDisplayID)displayID;
30 | #endif
31 |
32 | /**
33 | @abstract The optional animator delegate.
34 | */
35 | @property (weak, nonatomic) id delegate;
36 |
37 | /**
38 | @abstract Retrieves the nominal refresh period of a display link. Returns zero if unavailable.
39 | */
40 | @property (readonly, nonatomic) CFTimeInterval refreshPeriod;
41 |
42 | @end
43 |
44 | /**
45 | @abstract The animator delegate.
46 | */
47 | @protocol POPAnimatorDelegate
48 |
49 | /**
50 | @abstract Called on each frame before animation application.
51 | */
52 | - (void)animatorWillAnimate:(POPAnimator *)animator;
53 |
54 | /**
55 | @abstract Called on each frame after animation application.
56 | */
57 | - (void)animatorDidAnimate:(POPAnimator *)animator;
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPAnimatorPrivate.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @class POPAnimation;
13 |
14 | @protocol POPAnimatorObserving
15 | @required
16 |
17 | /**
18 | @abstract Called on each observer after animator has advanced. Core Animation actions are disabled by default.
19 | */
20 | - (void)animatorDidAnimate:(POPAnimator *)animator;
21 |
22 | @end
23 |
24 | @interface POPAnimator ()
25 |
26 | #if !TARGET_OS_IPHONE
27 | /**
28 | Determines whether or not to use a high priority background thread for animation updates. Using a background thread can result in faster, more responsive updates, but may be less compatible. Defaults to YES.
29 | */
30 | + (BOOL)disableBackgroundThread;
31 | + (void)setDisableBackgroundThread:(BOOL)flag;
32 |
33 | /**
34 | Determines the frequency (Hz) of the timer used when no display is available. Defaults to 60Hz.
35 | */
36 | + (uint64_t)displayTimerFrequency;
37 | + (void)setDisplayTimerFrequency:(uint64_t)frequency;
38 | #endif
39 |
40 | /**
41 | Used for externally driven animator instances.
42 | */
43 | @property (assign, nonatomic) BOOL disableDisplayLink;
44 |
45 | /**
46 | Time used when starting animations. Defaults to 0 meaning current media time is used. Exposed for unit testing.
47 | */
48 | @property (assign, nonatomic) CFTimeInterval beginTime;
49 |
50 | /**
51 | Exposed for unit testing.
52 | */
53 | - (void)renderTime:(CFTimeInterval)time;
54 |
55 | /**
56 | Funnel methods for category additions.
57 | */
58 | - (void)addAnimation:(POPAnimation *)anim forObject:(id)obj key:(NSString *)key;
59 | - (void)removeAllAnimationsForObject:(id)obj;
60 | - (void)removeAnimationForObject:(id)obj key:(NSString *)key;
61 | - (NSArray *)animationKeysForObject:(id)obj;
62 | - (POPAnimation *)animationForObject:(id)obj key:(NSString *)key;
63 |
64 | /**
65 | @abstract Add an animator observer. Observer will be notified of each subsequent animator advance until removal.
66 | */
67 | - (void)addObserver:(id)observer;
68 |
69 | /**
70 | @abstract Remove an animator observer.
71 | */
72 | - (void)removeObserver:(id)observer;
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPBasicAnimation.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | /**
13 | @abstract A concrete basic animation class.
14 | @discussion Animation is achieved through interpolation.
15 | */
16 | @interface POPBasicAnimation : POPPropertyAnimation
17 |
18 | /**
19 | @abstract The designated initializer.
20 | @returns An instance of a basic animation.
21 | */
22 | + (instancetype)animation;
23 |
24 | /**
25 | @abstract Convenience initializer that returns an animation with animatable property of name.
26 | @param name The name of the animatable property.
27 | @returns An instance of a basic animation configured with specified animatable property.
28 | */
29 | + (instancetype)animationWithPropertyNamed:(NSString *)name;
30 |
31 | /**
32 | @abstract Convenience constructor.
33 | @returns Returns a basic animation with kCAMediaTimingFunctionDefault timing function.
34 | */
35 | + (instancetype)defaultAnimation;
36 |
37 | /**
38 | @abstract Convenience constructor.
39 | @returns Returns a basic animation with kCAMediaTimingFunctionLinear timing function.
40 | */
41 | + (instancetype)linearAnimation;
42 |
43 | /**
44 | @abstract Convenience constructor.
45 | @returns Returns a basic animation with kCAMediaTimingFunctionEaseIn timing function.
46 | */
47 | + (instancetype)easeInAnimation;
48 |
49 | /**
50 | @abstract Convenience constructor.
51 | @returns Returns a basic animation with kCAMediaTimingFunctionEaseOut timing function.
52 | */
53 | + (instancetype)easeOutAnimation;
54 |
55 | /**
56 | @abstract Convenience constructor.
57 | @returns Returns a basic animation with kCAMediaTimingFunctionEaseInEaseOut timing function.
58 | */
59 | + (instancetype)easeInEaseOutAnimation;
60 |
61 | /**
62 | @abstract The duration in seconds. Defaults to 0.4.
63 | */
64 | @property (assign, nonatomic) CFTimeInterval duration;
65 |
66 | /**
67 | @abstract A timing function defining the pacing of the animation. Defaults to nil indicating pacing according to kCAMediaTimingFunctionDefault.
68 | */
69 | @property (strong, nonatomic) CAMediaTimingFunction *timingFunction;
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPBasicAnimation.mm:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "POPBasicAnimationInternal.h"
11 |
12 | @implementation POPBasicAnimation
13 |
14 | #undef __state
15 | #define __state ((POPBasicAnimationState *)_state)
16 |
17 | #pragma mark - Lifecycle
18 |
19 | + (instancetype)animation
20 | {
21 | return [[self alloc] init];
22 | }
23 |
24 | + (instancetype)animationWithPropertyNamed:(NSString *)aName
25 | {
26 | POPBasicAnimation *anim = [self animation];
27 | anim.property = [POPAnimatableProperty propertyWithName:aName];
28 | return anim;
29 | }
30 |
31 | - (void)_initState
32 | {
33 | _state = new POPBasicAnimationState(self);
34 | }
35 |
36 | + (instancetype)linearAnimation
37 | {
38 | POPBasicAnimation *anim = [self animation];
39 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
40 | return anim;
41 | }
42 |
43 | + (instancetype)easeInAnimation
44 | {
45 | POPBasicAnimation *anim = [self animation];
46 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
47 | return anim;
48 | }
49 |
50 | + (instancetype)easeOutAnimation
51 | {
52 | POPBasicAnimation *anim = [self animation];
53 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
54 | return anim;
55 | }
56 |
57 | + (instancetype)easeInEaseOutAnimation
58 | {
59 | POPBasicAnimation *anim = [self animation];
60 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
61 | return anim;
62 | }
63 |
64 | + (instancetype)defaultAnimation
65 | {
66 | POPBasicAnimation *anim = [self animation];
67 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
68 | return anim;
69 | }
70 |
71 | - (id)init
72 | {
73 | return [self _init];
74 | }
75 |
76 | #pragma mark - Properties
77 |
78 | DEFINE_RW_PROPERTY(POPBasicAnimationState, duration, setDuration:, CFTimeInterval);
79 | DEFINE_RW_PROPERTY_OBJ(POPBasicAnimationState, timingFunction, setTimingFunction:, CAMediaTimingFunction*, __state->updatedTimingFunction(););
80 |
81 | #pragma mark - Utility
82 |
83 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug
84 | {
85 | [super _appendDescription:s debug:debug];
86 | if (__state->duration)
87 | [s appendFormat:@"; duration = %f", __state->duration];
88 | }
89 |
90 | @end
91 |
92 | @implementation POPBasicAnimation (NSCopying)
93 |
94 | - (instancetype)copyWithZone:(NSZone *)zone {
95 |
96 | POPBasicAnimation *copy = [super copyWithZone:zone];
97 |
98 | if (copy) {
99 | copy.duration = self.duration;
100 | copy.timingFunction = self.timingFunction; // not a 'copy', but timing functions are publicly immutable.
101 | }
102 |
103 | return copy;
104 | }
105 |
106 | @end
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPBasicAnimationInternal.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "POPBasicAnimation.h"
11 |
12 | #import "POPPropertyAnimationInternal.h"
13 |
14 | // default animation duration
15 | static CGFloat const kPOPAnimationDurationDefault = 0.4;
16 |
17 | // progress threshold for computing done
18 | static CGFloat const kPOPProgressThreshold = 1e-6;
19 |
20 | static void interpolate(POPValueType valueType, NSUInteger count, const CGFloat *fromVec, const CGFloat *toVec, CGFloat *outVec, CGFloat p)
21 | {
22 | switch (valueType) {
23 | case kPOPValueInteger:
24 | case kPOPValueFloat:
25 | case kPOPValuePoint:
26 | case kPOPValueSize:
27 | case kPOPValueRect:
28 | case kPOPValueEdgeInsets:
29 | case kPOPValueColor:
30 | POPInterpolateVector(count, outVec, fromVec, toVec, p);
31 | break;
32 | default:
33 | NSCAssert(false, @"unhandled type %d", valueType);
34 | break;
35 | }
36 | }
37 |
38 | struct _POPBasicAnimationState : _POPPropertyAnimationState
39 | {
40 | CAMediaTimingFunction *timingFunction;
41 | double timingControlPoints[4];
42 | CFTimeInterval duration;
43 | CFTimeInterval timeProgress;
44 |
45 | _POPBasicAnimationState(id __unsafe_unretained anim) : _POPPropertyAnimationState(anim),
46 | timingFunction(nil),
47 | timingControlPoints{0.},
48 | duration(kPOPAnimationDurationDefault),
49 | timeProgress(0.)
50 | {
51 | type = kPOPAnimationBasic;
52 | }
53 |
54 | bool isDone() {
55 | if (_POPPropertyAnimationState::isDone()) {
56 | return true;
57 | }
58 | return timeProgress + kPOPProgressThreshold >= 1.;
59 | }
60 |
61 | void updatedTimingFunction()
62 | {
63 | float vec[4] = {0.};
64 | [timingFunction getControlPointAtIndex:1 values:&vec[0]];
65 | [timingFunction getControlPointAtIndex:2 values:&vec[2]];
66 | for (NSUInteger idx = 0; idx < POP_ARRAY_COUNT(vec); idx++) {
67 | timingControlPoints[idx] = vec[idx];
68 | }
69 | }
70 |
71 | bool advance(CFTimeInterval time, CFTimeInterval dt, id obj) {
72 | // default timing function
73 | if (!timingFunction) {
74 | ((POPBasicAnimation *)self).timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
75 | }
76 |
77 | // solve for normalized time, aka progress [0, 1]
78 | CGFloat p = 1.0f;
79 | if (duration > 0.0f) {
80 | // cap local time to duration
81 | CFTimeInterval t = MIN(time - startTime, duration) / duration;
82 | p = POPTimingFunctionSolve(timingControlPoints, t, SOLVE_EPS(duration));
83 | timeProgress = t;
84 | } else {
85 | timeProgress = 1.;
86 | }
87 |
88 | // interpolate and advance
89 | interpolate(valueType, valueCount, fromVec->data(), toVec->data(), currentVec->data(), p);
90 | progress = p;
91 | clampCurrentValue();
92 |
93 | return true;
94 | }
95 | };
96 |
97 | typedef struct _POPBasicAnimationState POPBasicAnimationState;
98 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPCGUtils.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #if TARGET_OS_IPHONE
13 | #import
14 | #else
15 | #import
16 | #endif
17 |
18 | #import "POPDefines.h"
19 |
20 | #if SCENEKIT_SDK_AVAILABLE
21 | #import
22 | #endif
23 |
24 | POP_EXTERN_C_BEGIN
25 |
26 | NS_INLINE CGPoint values_to_point(const CGFloat values[])
27 | {
28 | return CGPointMake(values[0], values[1]);
29 | }
30 |
31 | NS_INLINE CGSize values_to_size(const CGFloat values[])
32 | {
33 | return CGSizeMake(values[0], values[1]);
34 | }
35 |
36 | NS_INLINE CGRect values_to_rect(const CGFloat values[])
37 | {
38 | return CGRectMake(values[0], values[1], values[2], values[3]);
39 | }
40 |
41 | #if SCENEKIT_SDK_AVAILABLE
42 | NS_INLINE SCNVector3 values_to_vec3(const CGFloat values[])
43 | {
44 | return SCNVector3Make(values[0], values[1], values[2]);
45 | }
46 |
47 | NS_INLINE SCNVector4 values_to_vec4(const CGFloat values[])
48 | {
49 | return SCNVector4Make(values[0], values[1], values[2], values[3]);
50 | }
51 | #endif
52 |
53 | #if TARGET_OS_IPHONE
54 |
55 | NS_INLINE UIEdgeInsets values_to_edge_insets(const CGFloat values[])
56 | {
57 | return UIEdgeInsetsMake(values[0], values[1], values[2], values[3]);
58 | }
59 |
60 | #endif
61 |
62 | NS_INLINE void values_from_point(CGFloat values[], CGPoint p)
63 | {
64 | values[0] = p.x;
65 | values[1] = p.y;
66 | }
67 |
68 | NS_INLINE void values_from_size(CGFloat values[], CGSize s)
69 | {
70 | values[0] = s.width;
71 | values[1] = s.height;
72 | }
73 |
74 | NS_INLINE void values_from_rect(CGFloat values[], CGRect r)
75 | {
76 | values[0] = r.origin.x;
77 | values[1] = r.origin.y;
78 | values[2] = r.size.width;
79 | values[3] = r.size.height;
80 | }
81 |
82 | #if SCENEKIT_SDK_AVAILABLE
83 | NS_INLINE void values_from_vec3(CGFloat values[], SCNVector3 v)
84 | {
85 | values[0] = v.x;
86 | values[1] = v.y;
87 | values[2] = v.z;
88 | }
89 |
90 | NS_INLINE void values_from_vec4(CGFloat values[], SCNVector4 v)
91 | {
92 | values[0] = v.x;
93 | values[1] = v.y;
94 | values[2] = v.z;
95 | values[3] = v.w;
96 | }
97 | #endif
98 |
99 | #if TARGET_OS_IPHONE
100 |
101 | NS_INLINE void values_from_edge_insets(CGFloat values[], UIEdgeInsets i)
102 | {
103 | values[0] = i.top;
104 | values[1] = i.left;
105 | values[2] = i.bottom;
106 | values[3] = i.right;
107 | }
108 |
109 | #endif
110 |
111 | /**
112 | Takes a CGColorRef and converts it into RGBA components, if necessary.
113 | */
114 | extern void POPCGColorGetRGBAComponents(CGColorRef color, CGFloat components[]);
115 |
116 | /**
117 | Takes RGBA components and returns a CGColorRef.
118 | */
119 | extern CGColorRef POPCGColorRGBACreate(const CGFloat components[]) CF_RETURNS_RETAINED;
120 |
121 | /**
122 | Takes a color reference and returns a CGColor.
123 | */
124 | extern CGColorRef POPCGColorWithColor(id color) CF_RETURNS_NOT_RETAINED;
125 |
126 | #if TARGET_OS_IPHONE
127 |
128 | /**
129 | Takes a UIColor and converts it into RGBA components, if necessary.
130 | */
131 | extern void POPUIColorGetRGBAComponents(UIColor *color, CGFloat components[]);
132 |
133 | /**
134 | Takes RGBA components and returns a UIColor.
135 | */
136 | extern UIColor *POPUIColorRGBACreate(const CGFloat components[]) NS_RETURNS_RETAINED;
137 |
138 | #else
139 |
140 | /**
141 | Takes a NSColor and converts it into RGBA components, if necessary.
142 | */
143 | extern void POPNSColorGetRGBAComponents(NSColor *color, CGFloat components[]);
144 |
145 | /**
146 | Takes RGBA components and returns a NSColor.
147 | */
148 | extern NSColor *POPNSColorRGBACreate(const CGFloat components[]) NS_RETURNS_RETAINED;
149 |
150 | #endif
151 |
152 | POP_EXTERN_C_END
153 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPCustomAnimation.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @class POPCustomAnimation;
13 |
14 | /**
15 | @abstract POPCustomAnimationBlock is the callback block of a custom animation.
16 | @discussion This block will be executed for each animation frame and should update the property or properties being animated based on current timing.
17 | @param target The object being animated. Reference the passed in target to help avoid retain loops.
18 | @param animation The custom animation instance. Use to determine the current and elapsed time since last callback. Reference the passed in animation to help avoid retain loops.
19 | @return Flag indicating whether the animation should continue animating. Return NO to indicate animation is done.
20 | */
21 | typedef BOOL (^POPCustomAnimationBlock)(id target, POPCustomAnimation *animation);
22 |
23 | /**
24 | @abstract POPCustomAnimation is a concrete animation subclass for custom animations.
25 | */
26 | @interface POPCustomAnimation : POPAnimation
27 |
28 | /**
29 | @abstract Creates and returns an initialized custom animation instance.
30 | @discussion This is the designated initializer.
31 | @param block The custom animation callback block. See {@ref POPCustomAnimationBlock}.
32 | @return The initialized custom animation instance.
33 | */
34 | + (instancetype)animationWithBlock:(POPCustomAnimationBlock)block;
35 |
36 | /**
37 | @abstract The current animation time at time of callback.
38 | */
39 | @property (readonly, nonatomic) CFTimeInterval currentTime;
40 |
41 | /**
42 | @abstract The elapsed animation time since last callback.
43 | */
44 | @property (readonly, nonatomic) CFTimeInterval elapsedTime;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPCustomAnimation.mm:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "POPAnimationInternal.h"
11 |
12 | #import "POPCustomAnimation.h"
13 |
14 | @interface POPCustomAnimation ()
15 | @property (nonatomic, copy) POPCustomAnimationBlock animate;
16 | @end
17 |
18 | @implementation POPCustomAnimation
19 | @synthesize currentTime = _currentTime;
20 | @synthesize elapsedTime = _elapsedTime;
21 | @synthesize animate = _animate;
22 |
23 | + (instancetype)animationWithBlock:(BOOL(^)(id target, POPCustomAnimation *))block
24 | {
25 | POPCustomAnimation *b = [[self alloc] _init];
26 | b.animate = block;
27 | return b;
28 | }
29 |
30 | - (id)_init
31 | {
32 | self = [super _init];
33 | if (nil != self) {
34 | _state->type = kPOPAnimationCustom;
35 | }
36 | return self;
37 | }
38 |
39 | - (CFTimeInterval)beginTime
40 | {
41 | POPAnimationState *s = POPAnimationGetState(self);
42 | return s->startTime > 0 ? s->startTime : s->beginTime;
43 | }
44 |
45 | - (BOOL)_advance:(id)object currentTime:(CFTimeInterval)currentTime elapsedTime:(CFTimeInterval)elapsedTime
46 | {
47 | _currentTime = currentTime;
48 | _elapsedTime = elapsedTime;
49 | return _animate(object, self);
50 | }
51 |
52 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug
53 | {
54 | [s appendFormat:@"; elapsedTime = %f; currentTime = %f;", _elapsedTime, _currentTime];
55 | }
56 |
57 | @end
58 |
59 | /**
60 | * Note that only the animate block is copied, but not the current/elapsed times
61 | */
62 | @implementation POPCustomAnimation (NSCopying)
63 |
64 | - (instancetype)copyWithZone:(NSZone *)zone {
65 |
66 | POPCustomAnimation *copy = [super copyWithZone:zone];
67 |
68 | if (copy) {
69 | copy.animate = self.animate;
70 | }
71 |
72 | return copy;
73 | }
74 |
75 | @end
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPDecayAnimation.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | /**
13 | @abstract A concrete decay animation class.
14 | @discussion Animation is achieved through gradual decay of animation value.
15 | */
16 | @interface POPDecayAnimation : POPPropertyAnimation
17 |
18 | /**
19 | @abstract The designated initializer.
20 | @returns An instance of a decay animation.
21 | */
22 | + (instancetype)animation;
23 |
24 | /**
25 | @abstract Convenience initializer that returns an animation with animatable property of name.
26 | @param name The name of the animatable property.
27 | @returns An instance of a decay animation configured with specified animatable property.
28 | */
29 | + (instancetype)animationWithPropertyNamed:(NSString *)name;
30 |
31 | /**
32 | @abstract The current velocity value.
33 | @discussion Set before animation start to account for initial velocity. Expressed in change of value units per second. The only POPValueTypes supported for velocity are: kPOPValuePoint, kPOPValueInteger, kPOPValueFloat, kPOPValueRect, and kPOPValueSize.
34 | */
35 | @property (copy, nonatomic) id velocity;
36 |
37 | /**
38 | @abstract The original velocity value.
39 | @discussion Since the velocity property is modified as the animation progresses, this property stores the original, passed in velocity to support autoreverse and repeatCount.
40 | */
41 | @property (copy, nonatomic, readonly) id originalVelocity;
42 |
43 | /**
44 | @abstract The deceleration factor.
45 | @discussion Values specifies should be in the range [0, 1]. Lower values results in faster deceleration. Defaults to 0.998.
46 | */
47 | @property (assign, nonatomic) CGFloat deceleration;
48 |
49 | /**
50 | @abstract The expected duration.
51 | @discussion Derived based on input velocity and deceleration values.
52 | */
53 | @property (readonly, assign, nonatomic) CFTimeInterval duration;
54 |
55 | /**
56 | The to value is derived based on input velocity and deceleration.
57 | */
58 | - (void)setToValue:(id)toValue NS_UNAVAILABLE;
59 |
60 | /**
61 | @abstract The reversed velocity.
62 | @discussion The reversed velocity based on the originalVelocity when the animation was set up.
63 | */
64 | - (id)reversedVelocity;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPDefines.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #ifndef POP_POPDefines_h
11 | #define POP_POPDefines_h
12 |
13 | #import
14 |
15 | #ifdef __cplusplus
16 | # define POP_EXTERN_C_BEGIN extern "C" {
17 | # define POP_EXTERN_C_END }
18 | #else
19 | # define POP_EXTERN_C_BEGIN
20 | # define POP_EXTERN_C_END
21 | #endif
22 |
23 | #define POP_ARRAY_COUNT(x) sizeof(x) / sizeof(x[0])
24 |
25 | #if defined (__cplusplus) && defined (__GNUC__)
26 | # define POP_NOTHROW __attribute__ ((nothrow))
27 | #else
28 | # define POP_NOTHROW
29 | #endif
30 |
31 | #if defined(POP_USE_SCENEKIT)
32 | # if TARGET_OS_MAC || TARGET_OS_IPHONE
33 | # define SCENEKIT_SDK_AVAILABLE 1
34 | # endif
35 | #endif
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPGeometry.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #if TARGET_OS_IPHONE
13 | #import
14 | #endif
15 |
16 | #if !TARGET_OS_IPHONE
17 |
18 | /** NSValue extensions to support animatable types. */
19 | @interface NSValue (POP)
20 |
21 | /**
22 | @abstract Creates an NSValue given a CGPoint.
23 | */
24 | + (NSValue *)valueWithCGPoint:(CGPoint)point;
25 |
26 | /**
27 | @abstract Creates an NSValue given a CGSize.
28 | */
29 | + (NSValue *)valueWithCGSize:(CGSize)size;
30 |
31 | /**
32 | @abstract Creates an NSValue given a CGRect.
33 | */
34 | + (NSValue *)valueWithCGRect:(CGRect)rect;
35 |
36 | /**
37 | @abstract Creates an NSValue given a CFRange.
38 | */
39 | + (NSValue *)valueWithCFRange:(CFRange)range;
40 |
41 | /**
42 | @abstract Creates an NSValue given a CGAffineTransform.
43 | */
44 | + (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform;
45 |
46 | /**
47 | @abstract Returns the underlying CGPoint value.
48 | */
49 | - (CGPoint)CGPointValue;
50 |
51 | /**
52 | @abstract Returns the underlying CGSize value.
53 | */
54 | - (CGSize)CGSizeValue;
55 |
56 | /**
57 | @abstract Returns the underlying CGRect value.
58 | */
59 | - (CGRect)CGRectValue;
60 |
61 | /**
62 | @abstract Returns the underlying CFRange value.
63 | */
64 | - (CFRange)CFRangeValue;
65 |
66 | /**
67 | @abstract Returns the underlying CGAffineTransform value.
68 | */
69 | - (CGAffineTransform)CGAffineTransformValue;
70 |
71 | @end
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPGeometry.mm:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "POPGeometry.h"
11 |
12 | #if !TARGET_OS_IPHONE
13 | @implementation NSValue (POP)
14 |
15 | + (NSValue *)valueWithCGPoint:(CGPoint)point {
16 | return [NSValue valueWithBytes:&point objCType:@encode(CGPoint)];
17 | }
18 |
19 | + (NSValue *)valueWithCGSize:(CGSize)size {
20 | return [NSValue valueWithBytes:&size objCType:@encode(CGSize)];
21 | }
22 |
23 | + (NSValue *)valueWithCGRect:(CGRect)rect {
24 | return [NSValue valueWithBytes:&rect objCType:@encode(CGRect)];
25 | }
26 |
27 | + (NSValue *)valueWithCFRange:(CFRange)range {
28 | return [NSValue valueWithBytes:&range objCType:@encode(CFRange)];
29 | }
30 |
31 | + (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform
32 | {
33 | return [NSValue valueWithBytes:&transform objCType:@encode(CGAffineTransform)];
34 | }
35 |
36 | - (CGPoint)CGPointValue {
37 | CGPoint result;
38 | [self getValue:&result];
39 | return result;
40 | }
41 |
42 | - (CGSize)CGSizeValue {
43 | CGSize result;
44 | [self getValue:&result];
45 | return result;
46 | }
47 |
48 | - (CGRect)CGRectValue {
49 | CGRect result;
50 | [self getValue:&result];
51 | return result;
52 | }
53 |
54 | - (CFRange)CFRangeValue {
55 | CFRange result;
56 | [self getValue:&result];
57 | return result;
58 | }
59 |
60 | - (CGAffineTransform)CGAffineTransformValue {
61 | CGAffineTransform result;
62 | [self getValue:&result];
63 | return result;
64 | }
65 | @end
66 |
67 | #endif
68 |
69 | #if TARGET_OS_IPHONE
70 | #import "POPDefines.h"
71 |
72 | #if SCENEKIT_SDK_AVAILABLE
73 | #import
74 |
75 | /**
76 | Dirty hacks because iOS is weird and decided to define both SCNVector3's and SCNVector4's objCType as "t". However @encode(SCNVector3) and @encode(SCNVector4) both return the proper definition ("{SCNVector3=fff}" and "{SCNVector4=ffff}" respectively)
77 |
78 | [[NSValue valueWithSCNVector3:SCNVector3Make(0.0, 0.0, 0.0)] objcType] returns "t", whereas it should return "{SCNVector3=fff}".
79 |
80 | *flips table*
81 | */
82 | @implementation NSValue (SceneKitFixes)
83 |
84 | + (NSValue *)valueWithSCNVector3:(SCNVector3)vec3 {
85 | return [NSValue valueWithBytes:&vec3 objCType:@encode(SCNVector3)];
86 | }
87 |
88 | + (NSValue *)valueWithSCNVector4:(SCNVector4)vec4 {
89 | return [NSValue valueWithBytes:&vec4 objCType:@encode(SCNVector4)];
90 | }
91 |
92 | @end
93 | #endif
94 | #endif
95 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPMath.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import
13 |
14 | #import "POPDefines.h"
15 |
16 | NS_INLINE CGFloat sqrtr(CGFloat f)
17 | {
18 | #if CGFLOAT_IS_DOUBLE
19 | return sqrt(f);
20 | #else
21 | return sqrtf(f);
22 | #endif
23 | }
24 |
25 | // round to nearest sub; pass 2.0 to round to every 0.5 (eg: retina pixels)
26 | NS_INLINE CGFloat POPSubRound(CGFloat f, CGFloat sub)
27 | {
28 | return round(f * sub) / sub;
29 | }
30 |
31 | #define MIX(a, b, f) ((a) + (f) * ((b) - (a)))
32 |
33 | // the longer the duration, the higher the necessary precision
34 | #define SOLVE_EPS(dur) (1. / (1000. * (dur)))
35 |
36 | #define _EQLF_(x, y, epsilon) (fabsf ((x) - (y)) < epsilon)
37 |
38 | extern void POPInterpolateVector(NSUInteger count, CGFloat *dst, const CGFloat *from, const CGFloat *to, CGFloat f);
39 |
40 | extern double POPTimingFunctionSolve(const double vec[4], double t, double eps);
41 |
42 | // quadratic mapping of t [0, 1] to [start, end]
43 | extern double POPQuadraticOutInterpolation(double t, double start, double end);
44 |
45 | // normalize value to [0, 1] based on its range [startValue, endValue]
46 | extern double POPNormalize(double value, double startValue, double endValue);
47 |
48 | // project a normalized value [0, 1] to a given range [start, end]
49 | extern double POPProjectNormal(double n, double start, double end);
50 |
51 | // solve a quadratic equation of the form a * x^2 + b * x + c = 0
52 | extern void POPQuadraticSolve(CGFloat a, CGFloat b, CGFloat c, CGFloat &x1, CGFloat &x2);
53 |
54 | // for a given tension return the bouncy 3 friction that produces no bounce
55 | extern double POPBouncy3NoBounce(double tension);
56 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPMath.mm:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "POPMath.h"
11 |
12 | #import "POPAnimationPrivate.h"
13 | #import "UnitBezier.h"
14 |
15 | void POPInterpolateVector(NSUInteger count, CGFloat *dst, const CGFloat *from, const CGFloat *to, CGFloat f)
16 | {
17 | for (NSUInteger idx = 0; idx < count; idx++) {
18 | dst[idx] = MIX(from[idx], to[idx], f);
19 | }
20 | }
21 |
22 | double POPTimingFunctionSolve(const double vec[4], double t, double eps)
23 | {
24 | WebCore::UnitBezier bezier(vec[0], vec[1], vec[2], vec[3]);
25 | return bezier.solve(t, eps);
26 | }
27 |
28 | double POPNormalize(double value, double startValue, double endValue)
29 | {
30 | return (value - startValue) / (endValue - startValue);
31 | }
32 |
33 | double POPProjectNormal(double n, double start, double end)
34 | {
35 | return start + (n * (end - start));
36 | }
37 |
38 | static double linear_interpolation(double t, double start, double end)
39 | {
40 | return t * end + (1.f - t) * start;
41 | }
42 |
43 | double POPQuadraticOutInterpolation(double t, double start, double end)
44 | {
45 | return linear_interpolation(2*t - t*t, start, end);
46 | }
47 |
48 | static double b3_friction1(double x)
49 | {
50 | return (0.0007 * pow(x, 3)) - (0.031 * pow(x, 2)) + 0.64 * x + 1.28;
51 | }
52 |
53 | static double b3_friction2(double x)
54 | {
55 | return (0.000044 * pow(x, 3)) - (0.006 * pow(x, 2)) + 0.36 * x + 2.;
56 | }
57 |
58 | static double b3_friction3(double x)
59 | {
60 | return (0.00000045 * pow(x, 3)) - (0.000332 * pow(x, 2)) + 0.1078 * x + 5.84;
61 | }
62 |
63 | double POPBouncy3NoBounce(double tension)
64 | {
65 | double friction = 0;
66 | if (tension <= 18.) {
67 | friction = b3_friction1(tension);
68 | } else if (tension > 18 && tension <= 44) {
69 | friction = b3_friction2(tension);
70 | } else if (tension > 44) {
71 | friction = b3_friction3(tension);
72 | } else {
73 | assert(false);
74 | }
75 | return friction;
76 | }
77 |
78 | void POPQuadraticSolve(CGFloat a, CGFloat b, CGFloat c, CGFloat &x1, CGFloat &x2)
79 | {
80 | CGFloat discriminant = sqrt(b * b - 4 * a * c);
81 | x1 = (-b + discriminant) / (2 * a);
82 | x2 = (-b - discriminant) / (2 * a);
83 | }
84 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPPropertyAnimation.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 | #import
12 |
13 | /**
14 | @abstract Flags for clamping animation values.
15 | @discussion Animation values can optionally be clamped to avoid overshoot. kPOPAnimationClampStart ensures values are more than fromValue and kPOPAnimationClampEnd ensures values are less than toValue.
16 | */
17 | typedef NS_OPTIONS(NSUInteger, POPAnimationClampFlags)
18 | {
19 | kPOPAnimationClampNone = 0,
20 | kPOPAnimationClampStart = 1UL << 0,
21 | kPOPAnimationClampEnd = 1UL << 1,
22 | kPOPAnimationClampBoth = kPOPAnimationClampStart | kPOPAnimationClampEnd,
23 | };
24 |
25 | /**
26 | @abstract The semi-concrete property animation subclass.
27 | */
28 | @interface POPPropertyAnimation : POPAnimation
29 |
30 | /**
31 | @abstract The property to animate.
32 | */
33 | @property (strong, nonatomic) POPAnimatableProperty *property;
34 |
35 | /**
36 | @abstract The value to animate from.
37 | @discussion The value type should match the property. If unspecified, the value is initialized to the object's current value on animation start.
38 | */
39 | @property (copy, nonatomic) id fromValue;
40 |
41 | /**
42 | @abstract The value to animate to.
43 | @discussion The value type should match the property. If unspecified, the value is initialized to the object's current value on animation start.
44 | */
45 | @property (copy, nonatomic) id toValue;
46 |
47 | /**
48 | @abstract The rounding factor applied to the current animated value.
49 | @discussion Specify 1.0 to animate between integral values. Defaults to 0 meaning no rounding.
50 | */
51 | @property (assign, nonatomic) CGFloat roundingFactor;
52 |
53 | /**
54 | @abstract The clamp mode applied to the current animated value.
55 | @discussion See {@ref POPAnimationClampFlags} for possible values. Defaults to kPOPAnimationClampNone.
56 | */
57 | @property (assign, nonatomic) NSUInteger clampMode;
58 |
59 | /**
60 | @abstract The flag indicating whether values should be "added" each frame, rather than set.
61 | @discussion Addition may be type dependent. Defaults to NO.
62 | */
63 | @property (assign, nonatomic, getter = isAdditive) BOOL additive;
64 |
65 | @end
66 |
67 | @interface POPPropertyAnimation (CustomProperty)
68 |
69 | + (instancetype)animationWithCustomPropertyNamed:(NSString *)name
70 | readBlock:(POPAnimatablePropertyReadBlock)readBlock
71 | writeBlock:(POPAnimatablePropertyWriteBlock)writeBlock;
72 |
73 | + (instancetype)animationWithCustomPropertyReadBlock:(POPAnimatablePropertyReadBlock)readBlock
74 | writeBlock:(POPAnimatablePropertyWriteBlock)writeBlock;
75 |
76 | @end
77 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPSpringAnimation.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | /**
13 | @abstract A concrete spring animation class.
14 | @discussion Animation is achieved through modeling spring dynamics.
15 | */
16 | @interface POPSpringAnimation : POPPropertyAnimation
17 |
18 | /**
19 | @abstract The designated initializer.
20 | @returns An instance of a spring animation.
21 | */
22 | + (instancetype)animation;
23 |
24 | /**
25 | @abstract Convenience initializer that returns an animation with animatable property of name.
26 | @param name The name of the animatable property.
27 | @returns An instance of a spring animation configured with specified animatable property.
28 | */
29 | + (instancetype)animationWithPropertyNamed:(NSString *)name;
30 |
31 | /**
32 | @abstract The current velocity value.
33 | @discussion Set before animation start to account for initial velocity. Expressed in change of value units per second.
34 | */
35 | @property (copy, nonatomic) id velocity;
36 |
37 | /**
38 | @abstract The effective bounciness.
39 | @discussion Use in conjunction with 'springSpeed' to change animation effect. Values are converted into corresponding dynamics constants. Higher values increase spring movement range resulting in more oscillations and springiness. Defined as a value in the range [0, 20]. Defaults to 4.
40 | */
41 | @property (assign, nonatomic) CGFloat springBounciness;
42 |
43 | /**
44 | @abstract The effective speed.
45 | @discussion Use in conjunction with 'springBounciness' to change animation effect. Values are converted into corresponding dynamics constants. Higher values increase the dampening power of the spring resulting in a faster initial velocity and more rapid bounce slowdown. Defined as a value in the range [0, 20]. Defaults to 12.
46 | */
47 | @property (assign, nonatomic) CGFloat springSpeed;
48 |
49 | /**
50 | @abstract The tension used in the dynamics simulation.
51 | @discussion Can be used over bounciness and speed for finer grain tweaking of animation effect.
52 | */
53 | @property (assign, nonatomic) CGFloat dynamicsTension;
54 |
55 | /**
56 | @abstract The friction used in the dynamics simulation.
57 | @discussion Can be used over bounciness and speed for finer grain tweaking of animation effect.
58 | */
59 | @property (assign, nonatomic) CGFloat dynamicsFriction;
60 |
61 | /**
62 | @abstract The mass used in the dynamics simulation.
63 | @discussion Can be used over bounciness and speed for finer grain tweaking of animation effect.
64 | */
65 | @property (assign, nonatomic) CGFloat dynamicsMass;
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/POPSpringAnimationInternal.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2014-present, Facebook, Inc.
3 | All rights reserved.
4 |
5 | This source code is licensed under the BSD-style license found in the
6 | LICENSE file in the root directory of this source tree. An additional grant
7 | of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import "POPAnimationExtras.h"
13 | #import "POPPropertyAnimationInternal.h"
14 |
15 | struct _POPSpringAnimationState : _POPPropertyAnimationState
16 | {
17 | SpringSolver4d *solver;
18 | CGFloat springSpeed;
19 | CGFloat springBounciness; // normalized springiness
20 | CGFloat dynamicsTension; // tension
21 | CGFloat dynamicsFriction; // friction
22 | CGFloat dynamicsMass; // mass
23 |
24 | _POPSpringAnimationState(id __unsafe_unretained anim) : _POPPropertyAnimationState(anim),
25 | solver(nullptr),
26 | springSpeed(12.),
27 | springBounciness(4.),
28 | dynamicsTension(0),
29 | dynamicsFriction(0),
30 | dynamicsMass(0)
31 | {
32 | type = kPOPAnimationSpring;
33 | }
34 |
35 | bool hasConverged()
36 | {
37 | NSUInteger count = valueCount;
38 | if (shouldRound()) {
39 | return vec_equal(previous2Vec, previousVec) && vec_equal(previousVec, toVec);
40 | } else {
41 | if (!previousVec || !previous2Vec)
42 | return false;
43 |
44 | CGFloat t = dynamicsThreshold / 5;
45 |
46 | const CGFloat *toValues = toVec->data();
47 | const CGFloat *previousValues = previousVec->data();
48 | const CGFloat *previous2Values = previous2Vec->data();
49 |
50 | for (NSUInteger idx = 0; idx < count; idx++) {
51 | if ((std::abs(toValues[idx] - previousValues[idx]) >= t) || (std::abs(previous2Values[idx] - previousValues[idx]) >= t)) {
52 | return false;
53 | }
54 | }
55 | return true;
56 | }
57 | }
58 |
59 | bool isDone() {
60 | if (_POPPropertyAnimationState::isDone()) {
61 | return true;
62 | }
63 | return solver->started() && (hasConverged() || solver->hasConverged());
64 | }
65 |
66 | void updatedDynamics()
67 | {
68 | if (NULL != solver) {
69 | solver->setConstants(dynamicsTension, dynamicsFriction, dynamicsMass);
70 | }
71 | }
72 |
73 | void updatedDynamicsThreshold()
74 | {
75 | _POPPropertyAnimationState::updatedDynamicsThreshold();
76 | if (NULL != solver) {
77 | solver->setThreshold(dynamicsThreshold);
78 | }
79 | }
80 |
81 | void updatedBouncinessAndSpeed() {
82 | [POPSpringAnimation convertBounciness:springBounciness speed:springSpeed toTension:&dynamicsTension friction:&dynamicsFriction mass:&dynamicsMass];
83 | updatedDynamics();
84 | }
85 |
86 | bool advance(CFTimeInterval time, CFTimeInterval dt, id obj) {
87 | // advance past not yet initialized animations
88 | if (NULL == currentVec) {
89 | return false;
90 | }
91 |
92 | CFTimeInterval localTime = time - startTime;
93 |
94 | Vector4d value = vector4d(currentVec);
95 | Vector4d toValue = vector4d(toVec);
96 | Vector4d velocity = vector4d(velocityVec);
97 |
98 | SSState4d state;
99 | state.p = toValue - value;
100 |
101 | // the solver assumes a spring of size zero
102 | // flip the velocity from user perspective to solver perspective
103 | state.v = velocity * -1;
104 |
105 | solver->advance(state, localTime, dt);
106 | value = toValue - state.p;
107 |
108 | // flip velocity back to user perspective
109 | velocity = state.v * -1;
110 |
111 | *currentVec = value;
112 |
113 | if (velocityVec) {
114 | *velocityVec = velocity;
115 | }
116 |
117 | clampCurrentValue();
118 |
119 | return true;
120 | }
121 |
122 | virtual void reset(bool all) {
123 | _POPPropertyAnimationState::reset(all);
124 |
125 | if (solver) {
126 | solver->setConstants(dynamicsTension, dynamicsFriction, dynamicsMass);
127 | solver->reset();
128 | }
129 | }
130 | };
131 |
132 | typedef struct _POPSpringAnimationState POPSpringAnimationState;
133 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/WebCore/FloatConversion.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 Apple Inc. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 | * its contributors may be used to endorse or promote products derived
15 | * from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #ifndef FloatConversion_h
30 | #define FloatConversion_h
31 |
32 | #include
33 |
34 | namespace WebCore {
35 |
36 | template
37 | float narrowPrecisionToFloat(T);
38 |
39 | template<>
40 | inline float narrowPrecisionToFloat(double number)
41 | {
42 | return static_cast(number);
43 | }
44 |
45 | template
46 | CGFloat narrowPrecisionToCGFloat(T);
47 |
48 | template<>
49 | inline CGFloat narrowPrecisionToCGFloat(double number)
50 | {
51 | return static_cast(number);
52 | }
53 |
54 | } // namespace WebCore
55 |
56 | #endif // FloatConversion_h
57 |
--------------------------------------------------------------------------------
/Example/Pods/pop/pop/WebCore/UnitBezier.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * 1. Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * 2. Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #ifndef UnitBezier_h
27 | #define UnitBezier_h
28 |
29 | #include
30 |
31 | namespace WebCore {
32 |
33 | struct UnitBezier {
34 | UnitBezier(double p1x, double p1y, double p2x, double p2y)
35 | {
36 | // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
37 | cx = 3.0 * p1x;
38 | bx = 3.0 * (p2x - p1x) - cx;
39 | ax = 1.0 - cx -bx;
40 |
41 | cy = 3.0 * p1y;
42 | by = 3.0 * (p2y - p1y) - cy;
43 | ay = 1.0 - cy - by;
44 | }
45 |
46 | double sampleCurveX(double t)
47 | {
48 | // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
49 | return ((ax * t + bx) * t + cx) * t;
50 | }
51 |
52 | double sampleCurveY(double t)
53 | {
54 | return ((ay * t + by) * t + cy) * t;
55 | }
56 |
57 | double sampleCurveDerivativeX(double t)
58 | {
59 | return (3.0 * ax * t + 2.0 * bx) * t + cx;
60 | }
61 |
62 | // Given an x value, find a parametric value it came from.
63 | double solveCurveX(double x, double epsilon)
64 | {
65 | double t0;
66 | double t1;
67 | double t2;
68 | double x2;
69 | double d2;
70 | int i;
71 |
72 | // First try a few iterations of Newton's method -- normally very fast.
73 | for (t2 = x, i = 0; i < 8; i++) {
74 | x2 = sampleCurveX(t2) - x;
75 | if (fabs (x2) < epsilon)
76 | return t2;
77 | d2 = sampleCurveDerivativeX(t2);
78 | if (fabs(d2) < 1e-6)
79 | break;
80 | t2 = t2 - x2 / d2;
81 | }
82 |
83 | // Fall back to the bisection method for reliability.
84 | t0 = 0.0;
85 | t1 = 1.0;
86 | t2 = x;
87 |
88 | if (t2 < t0)
89 | return t0;
90 | if (t2 > t1)
91 | return t1;
92 |
93 | while (t0 < t1) {
94 | x2 = sampleCurveX(t2);
95 | if (fabs(x2 - x) < epsilon)
96 | return t2;
97 | if (x > x2)
98 | t0 = t2;
99 | else
100 | t1 = t2;
101 | t2 = (t1 - t0) * .5 + t0;
102 | }
103 |
104 | // Failure.
105 | return t2;
106 | }
107 |
108 | double solve(double x, double epsilon)
109 | {
110 | return sampleCurveY(solveCurveX(x, epsilon));
111 | }
112 |
113 | private:
114 | double ax;
115 | double bx;
116 | double cx;
117 |
118 | double ay;
119 | double by;
120 | double cy;
121 | };
122 | }
123 | #endif
124 |
--------------------------------------------------------------------------------
/JPCrop.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod lib lint JPCrop.podspec' to ensure this is a
3 | # valid spec before submitting.
4 | #
5 | # Any lines starting with a # are optional, but their use is encouraged
6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
7 | #
8 |
9 | Pod::Spec.new do |s|
10 | s.name = 'JPCrop'
11 | s.version = '0.2.5'
12 | s.summary = 'A clipping tool that can fine tune the direction of rotation.'
13 |
14 | # This description is used to generate tags and improve search results.
15 | # * Think: What does it do? Why did you write it? What is the focus?
16 | # * Try to keep it short, snappy and to the point.
17 | # * Write the description between the DESC delimiters below.
18 | # * Finally, don't worry about the indent, CocoaPods strips it!
19 |
20 | s.description = <<-DESC
21 | A clipping tool that can fine tune the direction of rotation.
22 | DESC
23 |
24 | s.homepage = 'https://github.com/Rogue24/JPCrop'
25 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
26 | s.license = { :type => 'MIT', :file => 'LICENSE' }
27 | s.author = { 'Rogue24' => 'zhoujianping24@hotmail.com' }
28 | s.source = { :git => 'https://github.com/Rogue24/JPCrop.git', :tag => s.version.to_s }
29 | # s.social_media_url = 'https://twitter.com/'
30 |
31 | s.ios.deployment_target = '11.0'
32 |
33 | s.source_files = 'JPCrop/Classes/**/*'
34 |
35 | s.swift_version = '5.0'
36 |
37 | # s.resource_bundles = {
38 | # 'JPCrop' => ['JPCrop/Assets/*.png']
39 | # }
40 |
41 | # s.public_header_files = 'Pod/Classes/**/*.h'
42 | # s.frameworks = 'UIKit', 'MapKit'
43 | # s.dependency 'AFNetworking', '~> 2.3'
44 | end
45 |
--------------------------------------------------------------------------------
/JPCrop/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/JPCrop/Assets/.gitkeep
--------------------------------------------------------------------------------
/JPCrop/Classes/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rogue24/JPCrop/e5ee9d94eeb4b168bd47be742f8e78ac0f40d15b/JPCrop/Classes/.gitkeep
--------------------------------------------------------------------------------
/JPCrop/Classes/Croper+Crop.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Croper+Crop.swift
3 | // JPCrop
4 | //
5 | // Created by Rogue24 on 2022/3/5.
6 | //
7 |
8 | import UIKit
9 |
10 | extension Croper {
11 | /// 获取修正方向后的图片
12 | func getFixedImageRef() -> CGImage? {
13 | let orientation = image.imageOrientation
14 | let imageRef = image.cgImage
15 | guard orientation != .up, let imageRef else { return imageRef }
16 |
17 | var transform = CGAffineTransform.identity
18 |
19 | switch orientation {
20 | case .down, .downMirrored:
21 | transform = transform.translatedBy(x: image.size.width, y: image.size.height)
22 | transform = transform.rotated(by: .pi)
23 |
24 | case .left, .leftMirrored:
25 | transform = transform.translatedBy(x: image.size.width, y: 0)
26 | transform = transform.rotated(by: .pi / 2)
27 |
28 | case .right, .rightMirrored:
29 | transform = transform.translatedBy(x: 0, y: image.size.height)
30 | transform = transform.rotated(by: -.pi / 2)
31 |
32 | default:
33 | break
34 | }
35 |
36 | switch orientation {
37 | case .upMirrored, .downMirrored:
38 | transform = transform.translatedBy(x: image.size.width, y: 0)
39 | transform = transform.scaledBy(x: -1, y: 1)
40 |
41 | case .leftMirrored, .rightMirrored:
42 | transform = transform.translatedBy(x: image.size.height, y: 0)
43 | transform = transform.scaledBy(x: -1, y: 1)
44 |
45 | default:
46 | break
47 | }
48 |
49 | guard let context = CGContext(data: nil,
50 | width: Int(image.size.width),
51 | height: Int(image.size.height),
52 | bitsPerComponent: imageRef.bitsPerComponent,
53 | bytesPerRow: 0,
54 | space: imageRef.colorSpace ?? CGColorSpaceCreateDeviceRGB(),
55 | bitmapInfo: imageRef.bitmapInfo.rawValue) else {
56 | return imageRef
57 | }
58 |
59 | let drawRect: CGRect
60 | switch orientation {
61 | case .left, .leftMirrored, .right, .rightMirrored:
62 | drawRect = CGRect(x: 0, y: 0, width: image.size.height, height: image.size.width)
63 | default:
64 | drawRect = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
65 | }
66 |
67 | context.concatenate(transform)
68 | context.draw(imageRef, in: drawRect)
69 |
70 | return context.makeImage() ?? imageRef
71 | }
72 |
73 | /// 获取裁剪参数
74 | func getCropFactorSafely() -> CropFactor {
75 | var ratio: CGFloat = 0
76 | var scale: CGFloat = 0
77 | var translate: CGPoint = .zero
78 | var radian: CGFloat = 0
79 | var height: CGFloat = 0
80 |
81 | Self.executeInMainQueue {
82 | ratio = self.cropWHRatio > 0 ? self.cropWHRatio : self.fitCropWHRatio(self.imageWHRatio)
83 | scale = self.scaleValue(self.scrollView.transform) * self.scrollView.zoomScale
84 | translate = self.borderLayer.convert(CGPoint(x: self.cropFrame.origin.x, y: self.cropFrame.maxY), to: self.imageView.layer)
85 | radian = self.actualRadian
86 | height = self.imageView.bounds.height
87 | }
88 |
89 | return CropFactor(cropWHRatio: ratio,
90 | scale: scale,
91 | convertTranslate: translate,
92 | radian: radian,
93 | imageBoundsHeight: height)
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/JPCrop/Classes/Croper+Model.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Croper+Model.swift
3 | // JPCrop_Example
4 | //
5 | // Created by Rogue24 on 2020/12/23.
6 | //
7 |
8 | import UIKit
9 |
10 | // MARK: - 公开模型
11 | public extension Croper {
12 | /// 网格数 - (垂直方向数量, 水平方向数量)
13 | typealias GridCount = (verCount: Int, horCount: Int)
14 |
15 | /// 旋转基准角度:0°/360°、90°、180°、270°
16 | enum OriginAngle: CGFloat {
17 | /// 以 0°/360° 为基准,可旋转范围:`-45° ~ 45°`
18 | case deg0 = 0
19 |
20 | /// 以 90° 为基准,可旋转范围:`45° ~ 135°`
21 | case deg90 = 90
22 |
23 | /// 以 180° 为基准,可旋转范围:`135° ~ 225°`
24 | case deg180 = 180
25 |
26 | /// 以 270° 为基准,可旋转范围:`225° ~ 315°`
27 | case deg270 = 270
28 |
29 | /// 上一个基准角度
30 | var prev: Self {
31 | switch self {
32 | case .deg0: return .deg270
33 | case .deg90: return .deg0
34 | case .deg180: return .deg90
35 | case .deg270: return .deg180
36 | }
37 | }
38 |
39 | /// 下一个基准角度
40 | var next: Self {
41 | switch self {
42 | case .deg0: return .deg90
43 | case .deg90: return .deg180
44 | case .deg180: return .deg270
45 | case .deg270: return .deg0
46 | }
47 | }
48 | }
49 |
50 | /// 初始化配置
51 | struct Configure {
52 | /// 裁剪图片
53 | public let image: UIImage
54 |
55 | /// 裁剪宽高比
56 | public let cropWHRatio: CGFloat
57 |
58 | /// 旋转基准角度:0°/360°、90°、180°、270°
59 | public var originAngle: Croper.OriginAngle
60 |
61 | /// 调整的旋转角度(基于`originAngle`,范围:`-45°` ~ `45°`)
62 | public var angle: CGFloat
63 |
64 | /// 裁剪时的缩放比例
65 | public var zoomScale: CGFloat?
66 |
67 | /// 裁剪时的偏移量
68 | public var contentOffset: CGPoint?
69 |
70 | public init(_ image: UIImage,
71 | cropWHRatio: CGFloat = 0,
72 | originAngle: Croper.OriginAngle = .deg0,
73 | angle: CGFloat = 0,
74 | zoomScale: CGFloat? = nil,
75 | contentOffset: CGPoint? = nil) {
76 | self.image = image
77 | self.cropWHRatio = cropWHRatio
78 | self.originAngle = originAngle
79 | self.angle = angle
80 | self.zoomScale = zoomScale
81 | self.contentOffset = contentOffset
82 | }
83 | }
84 | }
85 |
86 | // MARK: - 私有模型
87 | extension Croper {
88 | struct RotateFactor {
89 | let scale: CGFloat
90 | let transform: CGAffineTransform
91 | let contentInset: UIEdgeInsets
92 | }
93 |
94 | struct DiffFactor {
95 | let factor: RotateFactor
96 | let contentScalePoint: CGPoint
97 | let zoomScale: CGFloat
98 | let imageFrameSize: CGSize
99 | }
100 |
101 | struct CropFactor {
102 | let cropWHRatio: CGFloat
103 | let scale: CGFloat
104 | let convertTranslate: CGPoint
105 | let radian: CGFloat
106 | let imageBoundsHeight: CGFloat
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2020 Rogue24
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JPCrop
2 |
3 | [](https://developer.apple.com/Swift)
4 |
5 | 
6 |
7 | ## Example
8 |
9 | Tool class with high imitation of cutting function of little red book app.
10 | [Juejin Blog](https://juejin.cn/post/6910627272215150600)
11 |
12 | 
13 |
14 | 高仿小红书App裁剪功能的工具:
15 | 1.集成类似小红书基本的裁剪功能(自定义裁剪比例 + 360°任意旋转);
16 | 2.API简单易用;
17 | 3.切换裁剪比例带有动画过渡,不会那么生硬;
18 | 4.可异步可同步裁剪,并且可压缩。
19 |
20 | ## How to use
21 |
22 | Is so easy:
23 |
24 | ### Initialization
25 | ```swift
26 | // 1.Import
27 | import JPCrop
28 |
29 | // 2.Initialize
30 | let frame = CGRect(...
31 | let configure = Croper.Configure(image)
32 | let croper = Croper(frame: frame, configure)
33 |
34 | // 3.Add to superview, done!
35 | view.insertSubview(croper, at: 0)
36 | ```
37 |
38 | ### Rotate
39 | ```swift
40 | /**
41 | * originAngle: Rotation origin angle.
42 | * There are four origins: 0°/360°, 90°, 180°, 270°
43 | * The rotatable angle range of each origin angle is: -45° ~ 45°
44 | */
45 |
46 | // Rotate (Rotatable angle range: Based on the current origin angle -45° ~ 45°)
47 | croper.rotate(angle)
48 |
49 | // Rotate left (originAngle - 90°)
50 | // animated: with animation or not
51 | croper.rotateLeft(animated: true)
52 |
53 | // Rotate right (originAngle + 90°)
54 | // animated: with animation or not
55 | croper.rotateRight(animated: true)
56 |
57 | // Show grid before rotating
58 | // animated: with animation or not
59 | croper.showRotateGrid(animated: true)
60 |
61 | // Hide grid after rotating
62 | // animated: with animation or not
63 | croper.hideRotateGrid(animated: true)
64 | ```
65 |
66 | ### Switch the crop width to height ratio
67 | ```swift
68 | // rotateGridCount: Number of grid in rotation. (ver, hor)
69 | // animated: with animation or not
70 | croper.updateCropWHRatio(3.0 / 4.0, rotateGridCount: (6, 5), animated: true)
71 | ```
72 |
73 | ### Reset
74 | ```swift
75 | // animated: with animation or not
76 | croper.recover(animated: true)
77 | ```
78 |
79 | ### Crop
80 | ```swift
81 | let configure = croper.syncConfigure()
82 |
83 | // 1.Sync crop
84 | let image = croper.crop()
85 | cropDone(image, configure)
86 |
87 | // 2.Async crop: crop in DispatchQueue.global, result back to DispatchQueue.main
88 | croper.asyncCrop {
89 | guard let image = $0 else { return }
90 | cropDone(image, configure)
91 | }
92 |
93 | // PS: You can set the compressionScale to compress the image
94 | ```
95 |
96 | ### More features will be added in the future...
97 |
98 | ## Installation
99 |
100 | JPCrop is available through [CocoaPods](https://cocoapods.org). To install
101 | it, simply add the following line to your Podfile:
102 |
103 | ```ruby
104 | pod 'JPCrop'
105 | ```
106 |
107 | ## Author
108 |
109 | Rogue24, zhoujianping24@hotmail.com
110 |
111 | ## License
112 |
113 | JPCrop is available under the MIT license. See the LICENSE file for more info.
114 |
--------------------------------------------------------------------------------
/_Pods.xcodeproj:
--------------------------------------------------------------------------------
1 | Example/Pods/Pods.xcodeproj
--------------------------------------------------------------------------------