Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some more programmatically changes #24

Merged
merged 4 commits into from Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -15,7 +15,16 @@ Written in Swift 3.
Create a `TinyConsoleController`-Instance and pass your App-ViewController as a `rootViewController` parameter.

```swift
TinyConsoleController(rootViewController: MyMainViewController())
let consoleController = TinyConsoleController(rootViewController: MyMainViewController())
```

Set visibility
```swift
// Hide console (default)
consoleController.consoleWindowMode = .collapsed

// Show console
consoleController.consoleWindowMode = .expanded
```

### Actions
Expand Down
8 changes: 7 additions & 1 deletion TinyConsole-Example/AppDelegate.swift
Expand Up @@ -25,7 +25,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
viewController
]

window?.rootViewController = TinyConsoleController(rootViewController: tabBarController)
let consoleController = TinyConsoleController(rootViewController: tabBarController)
// let consoleController = TinyConsoleController(rootViewController: tabBarController, expandedHeight: 300)

// Show a startup
// consoleController.consoleWindowMode = .expanded
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please clean up your code


window?.rootViewController = consoleController
window?.makeKeyAndVisible()

return true
Expand Down
12 changes: 9 additions & 3 deletions TinyConsole/TinyConsoleController.swift
Expand Up @@ -14,7 +14,7 @@ open class TinyConsoleController: UIViewController {
///
/// - collapsed: the console is hidden
/// - expanded: the console is shown
private enum WindowMode {
public enum WindowMode {
case collapsed
case expanded
}
Expand All @@ -35,7 +35,7 @@ open class TinyConsoleController: UIViewController {
}()

private let consoleFrameHeight: CGFloat = 120
private let expandedHeight: CGFloat = 140
private var expandedHeight: CGFloat = 140

private lazy var consoleFrame: CGRect = {

Expand All @@ -45,7 +45,7 @@ open class TinyConsoleController: UIViewController {
return consoleFrame
}()

private var consoleWindowMode: WindowMode = .collapsed {
public var consoleWindowMode: WindowMode = .collapsed {
didSet {
consoleViewHeightConstraint?.isActive = false
consoleViewHeightConstraint?.constant = consoleWindowMode == .collapsed ? 0 : self.expandedHeight
Expand All @@ -59,6 +59,12 @@ open class TinyConsoleController: UIViewController {
super.init(nibName: nil, bundle: nil)
}

public init(rootViewController: UIViewController, expandedHeight: CGFloat) {
self.rootViewController = rootViewController
self.expandedHeight = expandedHeight
super.init(nibName: nil, bundle: nil)
}

required public init?(coder aDecoder: NSCoder) {
assertionFailure("Interface Builder is not supported")
self.rootViewController = UIViewController()
Expand Down