Skip to content

Commit

Permalink
Make camera tab optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruberik committed Jun 2, 2017
1 parent 3e081d7 commit a8db00c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Sources/Gallery/GalleryController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ public class GalleryController: UIViewController, PermissionControllerDelegate {
}

func makePagesController() -> PagesController {
var controllers: [UIViewController] = [imagesController, cameraController]
var controllers: [UIViewController] = [imagesController]
if Config.showsCameraTab {
controllers.append(cameraController)
}
if Config.showsVideoTab {
controllers.append(videosController)
}

let controller = PagesController(controllers: controllers)
controller.selectedIndex = Page.camera.rawValue
if Config.showsCameraTab {
controller.selectedIndex = Page.camera.rawValue
} else {
controller.selectedIndex = Page.images.rawValue
}

return controller
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Utils/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AVFoundation
public struct Config {

public static var showsVideoTab: Bool = true
public static var showsCameraTab: Bool = true

public struct PageIndicator {
public static var backgroundColor: UIColor = UIColor(red: 0, green: 3/255, blue: 10/255, alpha: 1)
Expand Down
11 changes: 9 additions & 2 deletions Sources/Utils/Pages/PagesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,22 @@ class PagesController: UIViewController {
// MARK: - Setup

func setup() {
view.addSubview(pageIndicator)
let usePageIndicator = controllers.count > 1
if usePageIndicator {
view.addSubview(pageIndicator)
}
view.addSubview(scrollView)
scrollView.addSubview(scrollViewContentView)

pageIndicator.g_pinDownward()
pageIndicator.g_pin(height: 40)

scrollView.g_pinUpward()
scrollView.g_pin(on: .bottom, view: pageIndicator, on: .top)
if usePageIndicator {
scrollView.g_pin(on: .bottom, view: pageIndicator, on: .top)
} else {
scrollView.g_pinDownward()
}

scrollViewContentView.g_pinEdges()

Expand Down

0 comments on commit a8db00c

Please sign in to comment.