Files
Xaibatsu-Control-Panel/XIONControlPanel/Controllers/MainViewController.swift
T

85 lines
2.4 KiB
Swift
Raw Normal View History

2015-12-30 02:51:22 -08:00
//
// MainViewController.swift
// XIONControlPanel
//
// Created by Charles Magahern on 12/29/15.
// Copyright © 2015 XION. All rights reserved.
//
import UIKit
class MainViewController: UIViewController {
2015-12-30 18:47:13 -08:00
private var _visualizationController: VisualizationViewController = VisualizationViewController()
2015-12-31 15:41:32 -08:00
private var _switchesController: SwitchesViewController = SwitchesViewController()
2015-12-30 18:47:13 -08:00
private var _headerView: HeaderView = HeaderView()
2015-12-30 02:51:22 -08:00
// MARK: Overrides
2015-12-30 02:51:22 -08:00
override func viewDidLoad()
{
super.viewDidLoad()
self.view.backgroundColor = UIColor.blackColor()
2015-12-30 18:47:13 -08:00
self.addChildViewController(_visualizationController)
self.view.addSubview(_visualizationController.view)
2015-12-31 15:41:32 -08:00
self.addChildViewController(_switchesController)
self.view.addSubview(_switchesController.view)
2015-12-30 18:47:13 -08:00
self.view.addSubview(_headerView)
2015-12-30 02:51:22 -08:00
}
override func viewDidLayoutSubviews()
{
super.viewDidLayoutSubviews()
let bounds = self.view.bounds
2015-12-30 18:47:13 -08:00
let headerBounds = CGRect(
x: 0.0,
y: 0.0,
width: bounds.size.width,
height: rint(bounds.size.height / 10.0)
)
let bodyBounds = CGRect(
x: 0.0,
y: CGRectGetMaxY(headerBounds),
width: bounds.size.width,
height: bounds.size.height - headerBounds.size.height
)
_headerView.frame = headerBounds
let visualizationFrame = CGRect(
x: bodyBounds.origin.x,
y: bodyBounds.origin.y,
2015-12-31 15:41:32 -08:00
width: rint(0.6 * bodyBounds.size.width),
2015-12-30 18:47:13 -08:00
height: bodyBounds.size.height
)
_visualizationController.view.frame = visualizationFrame
2015-12-31 15:41:32 -08:00
let switchesControllerFrame = CGRect(
2015-12-30 18:47:13 -08:00
x: CGRectGetMaxX(visualizationFrame),
y: bodyBounds.origin.y,
width: bodyBounds.size.width - visualizationFrame.size.width,
height: bodyBounds.size.height
)
2015-12-31 15:41:32 -08:00
_switchesController.view.frame = switchesControllerFrame
2015-12-30 02:51:22 -08:00
}
2015-12-30 18:47:13 -08:00
override func viewDidAppear(animated: Bool)
{
2015-12-31 10:55:54 -08:00
_headerView.xionLogoView.beginAnimating()
}
2015-12-30 18:47:13 -08:00
override func viewDidDisappear(animated: Bool)
{
2015-12-31 10:55:54 -08:00
_headerView.xionLogoView.stopAnimating()
2015-12-30 18:47:13 -08:00
}
override func prefersStatusBarHidden() -> Bool
{
return true
}
2015-12-30 02:51:22 -08:00
}