Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3cc62ef
Showing
20 changed files
with
1,799 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## Build generated | ||
build/ | ||
DerivedData/ | ||
|
||
## Various settings | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata/ | ||
|
||
## Other | ||
*.moved-aside | ||
*.xccheckout | ||
*.xcscmblueprint | ||
*.DS_Store | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output |
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
DragAndDropDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// AppConfig.swift | ||
// DragAndDropDemo | ||
// | ||
// Created by Mario on 26/05/2017. | ||
// Copyright © 2017 Mario. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct AppConfig { | ||
|
||
static var isDragApp: Bool { | ||
|
||
#if IS_DRAG_APP | ||
return true | ||
#endif | ||
|
||
return false | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// AppDelegate.swift | ||
// DragAndDropDemo | ||
// | ||
// Created by Mario on 26/05/2017. | ||
// Copyright © 2017 Mario. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
var window: UIWindow? | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | ||
|
||
SplitViewDragAndDrop.configure(groupIdentifier: "group.com.marioiannotta.draganddropdemo") | ||
|
||
window = UIWindow(frame: UIScreen.main.bounds) | ||
|
||
if AppConfig.isDragApp { | ||
window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DragViewController") | ||
} else { | ||
window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DropViewController") | ||
} | ||
|
||
window?.makeKeyAndVisible() | ||
|
||
return true | ||
|
||
} | ||
|
||
} | ||
|
68 changes: 68 additions & 0 deletions
68
DragAndDropDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// DragViewController.swift | ||
// DragAndDropDemo | ||
// | ||
// Created by Mario on 26/05/2017. | ||
// Copyright © 2017 Mario. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class DragViewController: UIViewController { | ||
|
||
@IBOutlet private var ciaoDraggableView: UIView! | ||
@IBOutlet private var helloDraggableView: UIView! | ||
@IBOutlet private var alohaDraggableView: UIView! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
SplitViewDragAndDrop.handleDrag(viewToDrag: ciaoDraggableView, identifier: "ciao_d&d", dataToTransfer: "Ciao!".data(using: .utf8)) | ||
SplitViewDragAndDrop.handleDrag(viewToDrag: helloDraggableView, identifier: "hello_d&d", dataToTransfer: "Hello!".data(using: .utf8)) | ||
SplitViewDragAndDrop.handleDrag(viewToDrag: alohaDraggableView, identifier: "aloha_d&d", dataToTransfer: "Aloha!".data(using: .utf8)) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// | ||
// DropViewController.swift | ||
// DragAndDropDemo | ||
// | ||
// Created by Mario on 26/05/2017. | ||
// Copyright © 2017 Mario. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class DropViewController: UIViewController { | ||
|
||
@IBOutlet private weak var ciaoTargetImageView: UIImageView! | ||
@IBOutlet private weak var helloTargetImageView: UIImageView! | ||
@IBOutlet private weak var alohaTargetImageView: UIImageView! | ||
|
||
private func presentAlertController(withMessage message: String) { | ||
|
||
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert) | ||
|
||
alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil)) | ||
|
||
present(alertController, animated: true, completion: nil) | ||
|
||
} | ||
|
||
private func draggingBeganAnimation(for view: UIView) { | ||
|
||
UIView.animate(withDuration: 0.3) { | ||
|
||
view.transform = CGAffineTransform(scaleX: 1.2, y: 1.2) | ||
|
||
} | ||
|
||
} | ||
|
||
private func draggingEndedAnimation(for view: UIView) { | ||
|
||
UIView.animate(withDuration: 0.3) { | ||
|
||
view.transform = CGAffineTransform.identity | ||
|
||
} | ||
|
||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
SplitViewDragAndDrop.addDropObserver( | ||
targetView: ciaoTargetImageView, | ||
identifier: "ciao_d&d", | ||
draggingBegan: { frame, draggedViewSnapshotImage, dataTransfered in | ||
|
||
self.draggingBeganAnimation(for: self.ciaoTargetImageView) | ||
|
||
}, | ||
draggingValidation: { frame, draggedViewSnapshotImage, dataTransfered in | ||
|
||
self.draggingEndedAnimation(for: self.ciaoTargetImageView) | ||
|
||
return self.ciaoTargetImageView.windowRelativeFrame.contains(frame) | ||
|
||
}, | ||
completion: { frame, draggedViewSnapshotImage, dataTransfered, isValid in | ||
|
||
if isValid { | ||
self.ciaoTargetImageView.image = draggedViewSnapshotImage | ||
} | ||
|
||
} | ||
) | ||
|
||
SplitViewDragAndDrop.addDropObserver( | ||
targetView: helloTargetImageView, | ||
identifier: "hello_d&d", | ||
draggingBegan: { frame, draggedViewSnapshotImage, dataTransfered in | ||
|
||
self.draggingBeganAnimation(for: self.helloTargetImageView) | ||
|
||
}, | ||
draggingValidation: { frame, draggedViewSnapshotImage, dataTransfered in | ||
|
||
self.draggingEndedAnimation(for: self.helloTargetImageView) | ||
return self.helloTargetImageView.windowRelativeFrame.contains(frame) | ||
|
||
}, | ||
completion: { frame, draggedViewSnapshotImage, dataTransfered, isValid in | ||
|
||
if isValid { | ||
self.helloTargetImageView.image = draggedViewSnapshotImage | ||
} | ||
|
||
} | ||
) | ||
|
||
SplitViewDragAndDrop.addDropObserver( | ||
targetView: alohaTargetImageView, | ||
identifier: "aloha_d&d", | ||
draggingBegan: { frame, draggedViewSnapshotImage, dataTransfered in | ||
|
||
self.draggingBeganAnimation(for: self.alohaTargetImageView) | ||
|
||
}, | ||
draggingValidation: { frame, draggedViewSnapshotImage, dataTransfered in | ||
|
||
self.draggingEndedAnimation(for: self.alohaTargetImageView) | ||
return self.alohaTargetImageView.windowRelativeFrame.contains(frame) | ||
|
||
}, | ||
completion: { frame, draggedViewSnapshotImage, dataTransfered, isValid in | ||
|
||
if isValid { | ||
self.alohaTargetImageView.image = draggedViewSnapshotImage | ||
} | ||
|
||
} | ||
) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="EHf-IW-A2E"> | ||
<objects> | ||
<viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
<layoutGuides> | ||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/> | ||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/> | ||
</layoutGuides> | ||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="53" y="375"/> | ||
</scene> | ||
</scenes> | ||
</document> |
Oops, something went wrong.