-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerViewController.swift
More file actions
97 lines (77 loc) · 3.55 KB
/
ContainerViewController.swift
File metadata and controls
97 lines (77 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// ContainerViewController.swift
// twitterApp
//
// Created by Deepak on 10/4/14.
// Copyright (c) 2014 Deepak. All rights reserved.
//
import UIKit
protocol MentionsViewDelegate {
func MentionsViewRequested(value: Bool) -> Void
}
class ContainerViewController: UIViewController {
@IBOutlet var fakeNavbarView: UIView!
var delegate: MentionsViewDelegate?
@IBOutlet var contentView: UIView!
var viewControllers: [UIViewController] = [TweetsViewController(nibName: nil, bundle: nil)]
var homeTimelineVC: UIViewController?
var profilePageVC: UIViewController?
var storyboard1: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
//var vc = storyboard1.instantiateViewControllerWithIdentifier("TweetsNavigationController") as UIViewController
override func viewDidLoad() {
super.viewDidLoad()
//self.navigationController?.navigationBar.barTintColor = UIColorFromRGB(0x55ACEE)
self.fakeNavbarView.backgroundColor = UIColorFromRGB(0x55ACEE)
self.contentViewXConstraint.constant = 0
var homeTimelineVC = storyboard1.instantiateViewControllerWithIdentifier("TweetsNavigationController") as? UIViewController
self.activeViewController = homeTimelineVC
// Do any additional setup after loading the view.
}
var activeViewController: UIViewController? {
didSet(oldViewControllerOrNil) {
if let oldVC = oldViewControllerOrNil {
oldVC.willMoveToParentViewController(nil)
oldVC.view.removeFromSuperview()
oldVC.removeFromParentViewController()
}
if let newVC = activeViewController {
self.addChildViewController(newVC)
newVC.view.autoresizingMask = .FlexibleWidth | .FlexibleHeight
newVC.view.frame = self.contentView.bounds
self.contentView.addSubview(newVC.view)
newVC.didMoveToParentViewController(self)
}
}
}
@IBOutlet var contentViewXConstraint: NSLayoutConstraint!
@IBOutlet var someButton: UIButton!
@IBOutlet var profileButton: UIButton!
@IBOutlet var mentionsButton: UIButton!
@IBAction func onButtonTap(sender: UIButton) {
if sender == someButton {
NSLog("Some Button");
var homeTimelineVC = storyboard1.instantiateViewControllerWithIdentifier("TweetsNavigationController") as? UIViewController
self.activeViewController = homeTimelineVC
} else if sender == profileButton {
var profilePageVC = storyboard1.instantiateViewControllerWithIdentifier("ProfileNavController") as? UIViewController
self.activeViewController = profilePageVC
} else if sender == mentionsButton {
println("Mentions button pressed")
delegate?.MentionsViewRequested(true)
var profilePageVC = storyboard1.instantiateViewControllerWithIdentifier("ProfileNavController") as? UIViewController
self.activeViewController = profilePageVC
}
UIView.animateWithDuration(0.35, animations: { () -> Void in
self.contentViewXConstraint.constant = 0
self.view.layoutIfNeeded()
})
}
@IBAction func onSwipe(sender: UISwipeGestureRecognizer) {
if sender.state == .Ended {
UIView.animateWithDuration(0.35, animations: { () -> Void in
self.contentViewXConstraint.constant = -160
self.view.layoutIfNeeded()
})
}
}
}