Skip to content

Commit

Permalink
refactor the codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuta Akizuki committed Jun 8, 2017
1 parent b95944d commit ff11a2a
Show file tree
Hide file tree
Showing 7 changed files with 710 additions and 517 deletions.
51 changes: 37 additions & 14 deletions Example/FusumaExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ class ViewController: UIViewController, FusumaDelegate {
}

@IBAction func showButtonPressed(_ sender: AnyObject) {

// Show Fusuma
let fusuma = FusumaViewController()

// fusumaCropImage = false

fusuma.delegate = self
fusuma.cropHeightRatio = 0.6
fusuma.defaultMode = .library
fusuma.defaultMode = .library
fusuma.allowMultipleSelection = true
fusumaSavesImage = true

Expand All @@ -45,54 +44,74 @@ class ViewController: UIViewController, FusumaDelegate {

// MARK: FusumaDelegate Protocol
func fusumaImageSelected(_ image: UIImage, source: FusumaMode) {

switch source {

case .camera:

print("Image captured from Camera")

case .library:

print("Image selected from Camera Roll")

default:

print("Image selected")
}

imageView.image = image
}

func fusumaMultipleImageSelected(_ images: [UIImage], source: FusumaMode) {

print("Number of selection images: \(images.count)")

var count: Double = 0

for image in images {
DispatchQueue.main.asyncAfter(deadline: .now() + (3.0 * count), execute: {

DispatchQueue.main.asyncAfter(deadline: .now() + (3.0 * count)) {

self.imageView.image = image
print("w: \(image.size.width) - h: \(image.size.height)")
})
}
count += 1
}
}

func fusumaImageSelected(_ image: UIImage, source: FusumaMode, metaData: ImageMetadata) {

print("Image mediatype: \(metaData.mediaType)")
print("Source image size: \(metaData.pixelWidth)x\(metaData.pixelHeight)")
print("Creation date: \(metaData.creationDate)")
print("Modification date: \(metaData.modificationDate)")
print("Creation date: \(String(describing: metaData.creationDate))")
print("Modification date: \(String(describing: metaData.modificationDate))")
print("Video duration: \(metaData.duration)")
print("Is favourite: \(metaData.isFavourite)")
print("Is hidden: \(metaData.isHidden)")
print("Location: \(metaData.location)")
print("Location: \(String(describing: metaData.location))")
}

func fusumaVideoCompleted(withFileURL fileURL: URL) {

print("video completed and output to file: \(fileURL)")
self.fileUrlLabel.text = "file output to: \(fileURL.absoluteString)"
}

func fusumaDismissedWithImage(_ image: UIImage, source: FusumaMode) {

switch source {

case .camera:

print("Called just after dismissed FusumaViewController using Camera")

case .library:

print("Called just after dismissed FusumaViewController using Camera Roll")

default:

print("Called just after dismissed FusumaViewController")
}
}
Expand All @@ -101,28 +120,32 @@ class ViewController: UIViewController, FusumaDelegate {

print("Camera roll unauthorized")

let alert = UIAlertController(title: "Access Requested", message: "Saving image needs to access your photo album", preferredStyle: .alert)
let alert = UIAlertController(title: "Access Requested",
message: "Saving image needs to access your photo album",
preferredStyle: .alert)

alert.addAction(UIAlertAction(title: "Settings", style: .default, handler: { (action) -> Void in
alert.addAction(UIAlertAction(title: "Settings", style: .default) { (action) -> Void in

if let url = URL(string:UIApplicationOpenSettingsURLString) {

UIApplication.shared.openURL(url)
}

}))
})

alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { (action) -> Void in

}))
})

self.present(alert, animated: true, completion: nil)
}

func fusumaClosed() {

print("Called when the FusumaViewController disappeared")
}

func fusumaWillClosed() {

print("Called when the close button is pressed")
}

Expand Down
2 changes: 1 addition & 1 deletion Fusuma.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Fusuma"
s.version = "1.0.4"
s.version = "1.1.0"
s.summary = "Instagram-like photo browser with a few line of code written in Swift"
s.homepage = "https://github.com/ytakzk/Fusuma"
s.license = 'MIT'
Expand Down
Loading

0 comments on commit ff11a2a

Please sign in to comment.