Skip to content

Commit

Permalink
Merge pull request #14 from Raizlabs/feature/ateliercw/RIG13-Remove_S…
Browse files Browse the repository at this point in the history
…crollbars

Feature/ateliercw/rig13 remove scrollbars
  • Loading branch information
Michael Skiba authored Dec 8, 2016
2 parents 86f98e6 + 5c816ab commit f0f52ce
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
statement_position:
statement_mode: uncuddled_else

trailing_comma:
mandatory_comma: true

disabled_rules:
- line_length
2 changes: 2 additions & 0 deletions RIGImageGallery/RIGAutoCenteringScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class RIGAutoCenteringScrollView: UIScrollView {

override init(frame: CGRect) {
super.init(frame: frame)
showsVerticalScrollIndicator = false
showsHorizontalScrollIndicator = false
delegate = self
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "1.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "3.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "4.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "5.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "6.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
43 changes: 34 additions & 9 deletions RIGImageGalleryDemo/View Controller/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class ViewController: UIViewController {
view.backgroundColor = .white
navigationItem.title = NSLocalizedString("RIG Image Gallery", comment: "Main screen title")

let galleryButton = UIButton(type: .system)
galleryButton.translatesAutoresizingMaskIntoConstraints = false
galleryButton.addTarget(self, action: #selector(ViewController.showGallery(_:)), for: .touchUpInside)
galleryButton.setTitle(NSLocalizedString("Show Gallery", comment: "Show gallery button title"), for: UIControlState())

let stackView = UIStackView(arrangedSubviews: [galleryButton])
let remoteGalleryButton = UIButton(type: .system)
remoteGalleryButton.addTarget(self, action: #selector(ViewController.showOnlineGallery(_:)), for: .touchUpInside)
remoteGalleryButton.setTitle(NSLocalizedString("Show Online Gallery", comment: "Show gallery button title"), for: .normal)
let localGalleryButton = UIButton(type: .system)
localGalleryButton.setTitle(NSLocalizedString("Show Local Gallery", comment: "Show Local Gallery"), for: .normal)
localGalleryButton.addTarget(self, action: #selector(ViewController.showLocalGallery(_:)), for: .touchUpInside)

let stackView = UIStackView(arrangedSubviews: [remoteGalleryButton, localGalleryButton])
stackView.alignment = .center
stackView.axis = .vertical
stackView.isLayoutMarginsRelativeArrangement = true
Expand All @@ -47,8 +49,8 @@ class ViewController: UIViewController {

private extension ViewController {

@objc func showGallery(_ sender: UIButton) {
let photoViewController = loadImages()
@objc func showOnlineGallery(_ sender: UIButton) {
let photoViewController = prepareRemoteGallery()
photoViewController.dismissHandler = dismissPhotoViewer
photoViewController.actionButtonHandler = actionButtonHandler
photoViewController.actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: nil, action: nil)
Expand All @@ -58,6 +60,16 @@ private extension ViewController {
present(navigationController, animated: true, completion: nil)
}

@objc func showLocalGallery(_ sender: UIButton) {
let photoViewController = prepareLocalGallery()
photoViewController.dismissHandler = dismissPhotoViewer
photoViewController.actionButtonHandler = actionButtonHandler
photoViewController.actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: nil, action: nil)
photoViewController.traitCollectionChangeHandler = traitCollectionChangeHandler
photoViewController.countUpdateHandler = updateCount
let navigationController = navBarWrappedViewController(photoViewController)
present(navigationController, animated: true, completion: nil)
}
}

private extension ViewController {
Expand Down Expand Up @@ -91,7 +103,7 @@ private extension ViewController {
"https://placehold.it/150x350",
].flatMap(URL.init(string:))

func loadImages() -> RIGImageGalleryViewController {
func prepareRemoteGallery() -> RIGImageGalleryViewController {

let urls = type(of: self).urls

Expand All @@ -111,6 +123,19 @@ private extension ViewController {
return rigController
}

func prepareLocalGallery() -> RIGImageGalleryViewController {

let items: [UIImage] = ["1", "2", "3", "4", "5", "6"].flatMap(UIImage.init(named:))

let rigItems = items.map { item in
RIGImageGalleryItem(image: item)
}

let rigController = RIGImageGalleryViewController(images: rigItems)

return rigController
}

func navBarWrappedViewController(_ viewController: UIViewController) -> UINavigationController {
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.navigationBar.barStyle = .blackTranslucent
Expand Down
Binary file modified Resources/rig_demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f0f52ce

Please sign in to comment.