Skip to content

Commit

Permalink
Merge branch 'enhance-custom-gestures' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jegnux committed Jan 5, 2021
2 parents 1c7ab26 + 98ab0c8 commit 69c25dc
Show file tree
Hide file tree
Showing 29 changed files with 356 additions and 288 deletions.
2 changes: 1 addition & 1 deletion Carthage/Checkouts/RxSwift
Submodule RxSwift updated 560 files
1 change: 1 addition & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use_frameworks!
def commonDependencies
pod 'RxGesture', :path => '../'
pod 'RxSwift', '~> 6.0'
pod 'RxCocoa', '~> 6.0'
end

target 'RxGesture_iOS_Demo' do
Expand Down
3 changes: 2 additions & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PODS:
- RxSwift (6.0.0)

DEPENDENCIES:
- RxCocoa (~> 6.0)
- RxGesture (from `../`)
- RxSwift (~> 6.0)

Expand All @@ -29,6 +30,6 @@ SPEC CHECKSUMS:
RxRelay: 8d593be109c06ea850df027351beba614b012ffb
RxSwift: c14e798c59b9f6e9a2df8fd235602e85cc044295

PODFILE CHECKSUM: 41b5a0f1fcc3d9137e772d5249c15454c63bde88
PODFILE CHECKSUM: d48d39de6335e342c666df2ee12e4efb3d005eb3

COCOAPODS: 1.10.0
32 changes: 16 additions & 16 deletions Example/RxGesture-OSX/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class Step {

let title: String
let code: String
let install: (NSView, NSTextField, AnyObserver<Action>, DisposeBag) -> Void
let install: (NSView, NSTextField, @escaping () -> Void, DisposeBag) -> Void

init(title: String, code: String, install: @escaping (NSView, NSTextField, AnyObserver<Action>, DisposeBag) -> Void) {
init(title: String, code: String, install: @escaping (NSView, NSTextField, @escaping () -> Void, DisposeBag) -> Void) {
self.title = title
self.code = code
self.install = install
Expand Down Expand Up @@ -60,9 +60,9 @@ class MacViewController: NSViewController {
func newIndex(for index: Int, action: Step.Action) -> Int {
switch action {
case .previous:
return index > 0 ? index - 1 : steps.count - 1
return (steps.count + index - 1) % steps.count
case .next:
return index < steps.count - 1 ? index + 1 : 0
return (steps.count + index + 1) % steps.count
}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ class MacViewController: NSViewController {
code.string = step.code

myViewText.stringValue = ""
step.install(myView, myViewText, nextStepObserver.asObserver(), stepBag)
step.install(myView, myViewText, { [nextStepObserver] in nextStepObserver.onNext(.next) }, stepBag)

print("active gestures: \(myView.gestureRecognizers.count)")
}
Expand All @@ -125,7 +125,7 @@ class MacViewController: NSViewController {
.leftClickGesture()
.when(.recognized)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand Down Expand Up @@ -154,7 +154,7 @@ class MacViewController: NSViewController {
}
.when(.recognized)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand All @@ -179,7 +179,7 @@ class MacViewController: NSViewController {
.rightClickGesture()
.when(.recognized)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand All @@ -204,7 +204,7 @@ class MacViewController: NSViewController {
.anyGesture(.leftClick(), .rightClick())
.when(.recognized)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand All @@ -229,7 +229,7 @@ class MacViewController: NSViewController {
.pressGesture()
.when(.began)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand Down Expand Up @@ -276,7 +276,7 @@ class MacViewController: NSViewController {
(.leftClick(), when: .recognized)
)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand Down Expand Up @@ -312,7 +312,7 @@ class MacViewController: NSViewController {
.when(.changed)
.asRotation()
.subscribe(onNext: { rotation in
label.stringValue = String(format: "angle: %.2f", rotation)
label.stringValue = String(format: "%.0fº", rotation * 180 / .pi)
view.layer!.transform = CATransform3DMakeRotation(rotation, 0, 0, 1)
})
.disposed(by: stepBag)
Expand All @@ -323,7 +323,7 @@ class MacViewController: NSViewController {
(.leftClick(), when: .recognized)
)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand Down Expand Up @@ -370,7 +370,7 @@ class MacViewController: NSViewController {
(.leftClick(), when: .recognized)
)
.subscribe(onNext: { _ in
nextStep.onNext(.next)
nextStep()
})
.disposed(by: stepBag)
})
Expand All @@ -380,7 +380,7 @@ class MacViewController: NSViewController {
private extension NSView {

func animateTransform(to transform: CATransform3D) {
let initialTransform = self.layer!.transform
let initialTransform = self.layer?.presentation()?.transform ?? self.layer!.model().transform

let anim = CABasicAnimation(keyPath: "transform")
anim.duration = 0.5
Expand All @@ -391,7 +391,7 @@ private extension NSView {
}

func animateBackgroundColor(to color: NSColor) {
let initialColor = self.layer!.backgroundColor!
let initialColor = self.layer?.presentation()?.backgroundColor ?? self.layer?.model().backgroundColor

let anim = CABasicAnimation(keyPath: "backgroundColor")
anim.duration = 0.5
Expand Down
15 changes: 10 additions & 5 deletions Example/RxGesture.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = GF5CUXMCNW;
DevelopmentTeam = JKFCB4CN7C;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
};
9CBB5C8F1CA3D9C30089E3EA = {
CreatedOnToolsVersion = 7.3;
Expand Down Expand Up @@ -526,13 +527,15 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = GF5CUXMCNW;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = JKFCB4CN7C;
INFOPLIST_FILE = RxGesture/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Wildcard Development";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
Expand All @@ -544,13 +547,15 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = GF5CUXMCNW;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = JKFCB4CN7C;
INFOPLIST_FILE = RxGesture/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Wildcard Development";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
Expand All @@ -569,7 +574,7 @@
INFOPLIST_FILE = "RxGesture-OSX/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "com.underplot.RxGesture-OSX";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.RxGesture-OSX-Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
Expand All @@ -589,7 +594,7 @@
INFOPLIST_FILE = "RxGesture-OSX/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "com.underplot.RxGesture-OSX";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.RxGesture-OSX-Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
Expand Down
43 changes: 29 additions & 14 deletions Example/RxGesture/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,52 @@
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 69c25dc

Please sign in to comment.