git.iko.soy/dashared/GDproject
on master help sign in
slightly impoved channels. only animation in uisearchbar is left
commit13f28783fbdd523194ed172de2cd19cefa031ec6 authorDarya Rednikina <rednikina.com@yandex.ru> dateSat 23 Feb 2019, 17:14 (8 years ago) parent3b1db6e
12 files changed+98−211
GDproject.xcodeproj/project.pbxproj+4−8 GDproject/Base.lproj/Main.storyboard+2−2 GDproject/Controller/ News and channels/ChannelListController.swift+20−7 GDproject/Controller/ News and channels/ChannelsCoordinator.swift+3−1 GDproject/Controller/ News and channels/NewsController.swift+20−108 GDproject/Controller/ News and channels/NewsVC.swift+10−44 GDproject/Controller/Coordinator tab bar?/TabBarController.swift−28 GDproject/Controller/Coordinator tab bar?/TabbarCoordinator.swift+13 GDproject/Controller/Coordinator tab bar?/TabbarView.swift−7 GDproject/Extentions.swift+8 GDproject/Simple model/Channel.swift+8−1 GDproject/Supporting files/AppDelegate.swift+10−5
GDproject.xcodeproj/project.pbxproj+4−8
@@ -14,8 +14,7 @@
1414 125BD5812217314A008A3575 /* NewsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125BD5802217314A008A3575 /* NewsVC.swift */; };
1515 1288B5CE221F1158002BE6B1 /* DataStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1288B5CD221F1158002BE6B1 /* DataStorage.swift */; };
1616 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */; };
17− 1291BE2F222152E1009D3F23 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE2E222152E1009D3F23 /* TabBarController.swift */; };
18− 1291BE312221530D009D3F23 /* TabbarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE302221530D009D3F23 /* TabbarView.swift */; };
17+ 1291BE342221569B009D3F23 /* TabbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */; };
1918 12D7D133221C321600B35452 /* ChannelListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D132221C321600B35452 /* ChannelListController.swift */; };
2019 12D7D135221C42B700B35452 /* ChannelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D134221C42B700B35452 /* ChannelController.swift */; };
2120 12D7D137221D78E800B35452 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12D7D136221D78E800B35452 /* Channel.swift */; };
@@ -74,8 +73,7 @@
7473 125BD5802217314A008A3575 /* NewsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsVC.swift; sourceTree = "<group>"; };
7574 1288B5CD221F1158002BE6B1 /* DataStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStorage.swift; sourceTree = "<group>"; };
7675 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelsCoordinator.swift; sourceTree = "<group>"; };
77− 1291BE2E222152E1009D3F23 /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = "<group>"; };
78− 1291BE302221530D009D3F23 /* TabbarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarView.swift; sourceTree = "<group>"; };
76+ 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarCoordinator.swift; sourceTree = "<group>"; };
7977 12D7D132221C321600B35452 /* ChannelListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelListController.swift; sourceTree = "<group>"; };
8078 12D7D134221C42B700B35452 /* ChannelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelController.swift; sourceTree = "<group>"; };
8179 12D7D136221D78E800B35452 /* Channel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Channel.swift; sourceTree = "<group>"; };
@@ -137,8 +135,7 @@
137135 1291BE32222154C3009D3F23 /* Coordinator tab bar? */ = {
138136 isa = PBXGroup;
139137 children = (
140− 1291BE2E222152E1009D3F23 /* TabBarController.swift */,
141− 1291BE302221530D009D3F23 /* TabbarView.swift */,
138+ 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */,
142139 );
143140 path = "Coordinator tab bar?";
144141 sourceTree = "<group>";
@@ -319,14 +316,13 @@
319316 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */,
320317 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
321318 12D7D133221C321600B35452 /* ChannelListController.swift in Sources */,
322− 1291BE312221530D009D3F23 /* TabbarView.swift in Sources */,
319+ 1291BE342221569B009D3F23 /* TabbarCoordinator.swift in Sources */,
323320 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */,
324321 12E36DD122148122006FCDD7 /* FullPostController.swift in Sources */,
325322 1288B5CE221F1158002BE6B1 /* DataStorage.swift in Sources */,
326323 125BD57D22171D2A008A3575 /* ProfileViewController.swift in Sources */,
327324 12DB7FDB2218590C0096878E /* InfoCell.swift in Sources */,
328325 12DB7FD922181E660096878E /* BasicInfoCell.swift in Sources */,
329− 1291BE2F222152E1009D3F23 /* TabBarController.swift in Sources */,
330326 12D7D135221C42B700B35452 /* ChannelController.swift in Sources */,
331327 12E36D9C221424EA006FCDD7 /* AppDelegate.swift in Sources */,
332328 12DB7FD722181CD20096878E /* BasicInfoController.swift in Sources */,
GDproject/Base.lproj/Main.storyboard+2−2
@@ -407,7 +407,7 @@
407407 <!--Posts-->
408408 <scene sceneID="RSd-UJ-34B">
409409 <objects>
410− <navigationController automaticallyAdjustsScrollViewInsets="NO" id="NuV-ZG-ld2" sceneMemberID="viewController">
410+ <navigationController storyboardIdentifier="navChannels" automaticallyAdjustsScrollViewInsets="NO" id="NuV-ZG-ld2" sceneMemberID="viewController">
411411 <tabBarItem key="tabBarItem" title="Posts" id="dH2-sL-YsR"/>
412412 <toolbarItems/>
413413 <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="6qB-3A-tuL">
@@ -446,7 +446,7 @@
446446 <!--Profile-->
447447 <scene sceneID="dJj-Hp-Wa9">
448448 <objects>
449− <navigationController automaticallyAdjustsScrollViewInsets="NO" id="tae-5q-wvT" sceneMemberID="viewController">
449+ <navigationController storyboardIdentifier="navPosts" automaticallyAdjustsScrollViewInsets="NO" id="tae-5q-wvT" sceneMemberID="viewController">
450450 <tabBarItem key="tabBarItem" title="Profile" id="lYy-LQ-AcR"/>
451451 <toolbarItems/>
452452 <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="q3a-ph-c8V">
GDproject/Controller/ News and channels/ChannelListController.swift+20−7
@@ -23,6 +23,7 @@ class ChannelListController: UITableViewController, DataDelegate {
2323 var filteredDataSource = [Channel]()
2424
2525 var myProtocol: DataDelegate?
26+ var displayingChannel: Channel?
2627
2728 var isFiltering: Bool {
2829 return searchController.isActive && !searchBarIsEmpty()
@@ -51,18 +52,22 @@ class ChannelListController: UITableViewController, DataDelegate {
5152 super.viewDidLoad()
5253 setUpNavigationBar()
5354 navigationItem.title = "Channels"
55+ searchController.searchResultsUpdater = self
5456 searchController.obscuresBackgroundDuringPresentation = false
5557 searchController.searchBar.placeholder = "Search channel"
5658 navigationItem.searchController = searchController
59+ definesPresentationContext = true
5760 }
5861
5962 func setUpNavigationBar(){
63+ navigationController?.navigationItem.largeTitleDisplayMode = .always
6064 navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addChannel))]
6165 }
6266
6367 override func viewWillAppear(_ animated: Bool)
6468 {
6569 super.viewWillAppear(animated)
70+ searchController.isActive = false
6671 tableView.reloadData()
6772 }
6873
@@ -70,15 +75,15 @@ class ChannelListController: UITableViewController, DataDelegate {
7075 {
7176 // insertion
7277 tableView.beginUpdates()
73− ChannelListController.dataSource.insert(Channel(title: "Untitled", subtitle: "No", hashtags: [], people: [], posts: []), at: 0)
74− tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
78+ ChannelListController.dataSource.insert(Channel(title: "Untitled", subtitle: "No", hashtags: [], people: [], posts: []), at: 1)
79+ tableView.insertRows(at: [IndexPath(row: 1, section: 0)], with: .none)
7580 tableView.endUpdates()
7681
77− // editing mode is one automatically
82+ // editing mode is on automatically
7883 let vc = storyboard?.instantiateViewController(withIdentifier: channelControllerId) as! ChannelController
79− vc.index = 0
84+ vc.index = 1
8085 vc.myProtocol = self
81− vc.channel = ChannelListController.dataSource[0]
86+ vc.channel = ChannelListController.dataSource[1]
8287 navigationController?.pushViewController(vc, animated: true)
8388 }
8489
@@ -142,6 +147,10 @@ class ChannelListController: UITableViewController, DataDelegate {
142147
143148
144149 let deleteButton = UITableViewRowAction(style: .normal, title: "Delete") { [weak self] (action, indexPath) in
150+ if (ChannelListController.dataSource[indexPath.row] == self!.displayingChannel!)
151+ {
152+ self?.myProtocol?.passData(for: 0, channel: ChannelListController.dataSource[0])
153+ }
145154 self?.tableView.beginUpdates()
146155 ChannelListController.dataSource.remove(at: indexPath.row)
147156 self?.tableView.deleteRows(at: [indexPath], with: .none)
@@ -157,9 +166,13 @@ class ChannelListController: UITableViewController, DataDelegate {
157166 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
158167 {
159168 if isFiltering {
160− onChannelSelected?(filteredDataSource[indexPath.row])
169+ //onChannelSelected?(filteredDataSource[indexPath.row])
170+ myProtocol?.passData(for: 0, channel: filteredDataSource[indexPath.row])
171+ navigationController?.popViewController(animated: true)
161172 } else {
162− onChannelSelected?(ChannelListController.dataSource[indexPath.row])
173+ myProtocol?.passData(for: 0, channel: ChannelListController.dataSource[indexPath.row])
174+ navigationController?.popViewController(animated: true)
175+ //onChannelSelected?(ChannelListController.dataSource[indexPath.row])
163176 }
164177 }
165178}
GDproject/Controller/ News and channels/ChannelsCoordinator.swift+3−1
@@ -42,8 +42,10 @@ final class ChannelsCoordinator{
4242 controller.onSelectChannel = { [weak self] in
4343 self?.showListOfChannels()
4444 }
45− navigationController?.pushViewController(controller, animated: false)
45+ navigationController?.setViewControllers([controller], animated: false)
46+ //navigationController?.pushViewController(controller, animated: false)
4647 }
48+
4749 // MARK:- update only viewControllers which are depandable on chosen channel
4850 private func updateInterfaces() {
4951 navigationController?.viewControllers.forEach {
GDproject/Controller/ News and channels/NewsController.swift+20−108
@@ -19,8 +19,12 @@ protocol NewPostDelegate {
1919
2020// MARK:- Controller with posts and channels availiable.
2121// Search is availiable within every table (posts and channels). Has button-functionality for boths post and chnnels
22−class NewsController: UITableViewController, UISearchControllerDelegate, NewPostDelegate, UpdateableWithChannel
22+class NewsController: UITableViewController, UISearchControllerDelegate, NewPostDelegate, UpdateableWithChannel, DataDelegate
2323{
24+ func passData(for row: Int, channel: Channel) {
25+ self.channel = channel
26+ }
27+
2428 var channel: Channel?{
2529 didSet{
2630 news.dataSourse = channel?.posts ?? []
@@ -35,120 +39,34 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
3539 news.dataSourse.insert(post, at: 0)
3640 }
3741
38− var array = ["Faculty 1", "Faculty 2","Faculty 3","Faculty 4","Faculty 5","Faculty 6","Faculty 7","Faculty 8","Faculty 9","Faculty 10","Faculty 11","Faculty 12","Faculty 13","Faculty 14","Faculty 15","Faculty 16","Faculty 17","Faculty 18"]
39−
40− override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
41− return array.count
42− }
43−
44−
45− override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
46− let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
47−
48− cell.textLabel?.text = array[indexPath.row]
49− return cell
50− }
51−
52− func presentSearchController(_ searchController: UISearchController) {
53− print("here")
54− setUpTableView()
55− displayTableView() //setup
56− // this is 0.3
57− animateTable(some: true)
58− }
59−
60− func willDismissSearchController(_ searchController: UISearchController) {
61− dismissTable()
62− }
63−
64− //@IBOutlet weak var tableView: UITableView!
65−
6642 var searchController = UISearchController(searchResultsController: nil)
6743
68−
6944 var news = NewsVC()
7045
7146 override func viewDidLoad()
7247 {
7348 super.viewDidLoad()
74−
75− //view.backgroundColor = .white
7649 channel = ChannelListController.dataSource[0]
7750
78− view.addSubview(label)
79− //label.horizontalToSuperview(insets: .left(30) + .right(30))
80− //label.verticalToSuperview()
81−
8251 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
8352 tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
8453
8554 searchController.delegate = self
8655 searchController.obscuresBackgroundDuringPresentation = false
56+ navigationItem.searchController = searchController
57+ definesPresentationContext = true
58+ searchController.searchBar.placeholder = "Search anything"
8759
8860 news.dataSourse = channel!.posts
8961 news.viewController = self
9062
91−
92− tableView.delegate = news
93− tableView.dataSource = news
94− tableView.reloadData()
95−
9663 news.type = .NONE
9764
9865 setUpNavigationItemsforPosts()
99− searchController.searchBar.placeholder = "Search anything"
100−
101− navigationItem.searchController = searchController
102− definesPresentationContext = true
103−
104− setUpBanner()
105− }
106−
107−
108− var facultyTableView = UITableView()
109−
110− func setUpTableView()
111− {
112− facultyTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
113− facultyTableView.delegate = self
114− facultyTableView.dataSource = self
115− let screenSize: CGRect = UIScreen.main.bounds
116−
117− let screenWidth = screenSize.width
118− let screenHeight = screenSize.height
119− facultyTableView.frame = CGRect(x: 0, y: 0, width: Int(screenWidth), height: Int(screenHeight))
120− }
121−
122− func displayTableView(){
123−
124− // the most important line
125− facultyTableView.translatesAutoresizingMaskIntoConstraints = false
126− facultyTableView.backgroundColor = UIColor(white: 1, alpha: 1)
127− view.addSubview(facultyTableView)
128−
129− facultyTableView.isHidden = true
130−
131− // now
132− constrain(facultyTableView, view){
133− tableView, view in
134−
135− tableView.top == view.safeAreaLayoutGuide.top
136− tableView.left == view.left
137− tableView.right == view.right
138− tableView.bottom == view.safeAreaLayoutGuide.bottom
139− }
140−
66+
67+ //setUpBanner()
14168 }
14269
143− // animation of the table cells
144− func animateTable(some: Bool){
145− self.facultyTableView.reloadData()
146− self.facultyTableView.isHidden = false
147− }
148−
149− func dismissTable() {
150− self.facultyTableView.isHidden = true
151− }
15270
15371 let label : UILabel = {
15472 let label = UILabel()
@@ -162,22 +80,14 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
16280
16381 override func viewWillAppear(_ animated: Bool) {
16482 super.viewWillAppear(animated)
165− print("hello")
166− navigationController?.navigationBar.prefersLargeTitles = true
167− if channel!.posts.isEmpty {
168− //tableView.isHidden = true
169− label.isHidden = false
170− } else {
171− label.isHidden = true
172− tableView.isHidden = false
173− tableView.reloadData()
174− }
83+ searchController.isActive = false
84+ // TODO:- display something if no posts are availiable
85+ tableView.reloadData()
17586 }
17687
17788 func setUpNavigationItemsforPosts(){
178− navigationItem.rightBarButtonItems = [
179− UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(self.writePost(_:))),
180− UIBarButtonItem(barButtonSystemItem: .search, target: self, action: #selector(self.showChannels(_:)))]
89+ navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(self.writePost(_:))),UIBarButtonItem(barButtonSystemItem: .search, target: self, action: #selector(self.showChannels(_:)))
90+ ]
18191 tableView.delegate = news
18292 tableView.dataSource = news
18393 tableView.reloadData()
@@ -185,7 +95,10 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
18595
18696 // MARK:- attempt with coordinator
18797 @objc func showChannels(_ barItem: UIBarButtonItem){
188− onSelectChannel?()
98+ let vc = UIStoryboard.makeChannelsListController()
99+ vc.myProtocol = self
100+ vc.displayingChannel = channel
101+ self.navigationController?.pushViewController(vc, animated: true)
189102 }
190103
191104 @objc func writePost(_ barItem: UIBarButtonItem)
@@ -206,8 +119,6 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
206119 navigationController?.pushViewController(vc, animated: false)
207120 }
208121
209−
210−
211122 // for animating the banner
212123 var topConstraint: NSLayoutConstraint?
213124
@@ -227,6 +138,7 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
227138 return label
228139 }()
229140
141+ // MARK:- banner
230142 private func setUpBanner()
231143 {
232144 view.addSubview(bannerView)
GDproject/Controller/ News and channels/NewsVC.swift+10−44
@@ -17,63 +17,29 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
1717 var viewController: UIViewController?
1818
1919 func numberOfSections(in tableView: UITableView) -> Int {
20− return 2
20+ return 1
2121 }
2222
2323 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
2424 {
2525 tableView.deselectRow(at: indexPath, animated: true)
26+ let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
2627
27− if indexPath.section == 1 && type == .NEWS || type == .NONE {
28− let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
29−
30− vc.post = dataSourse[indexPath.row]
31− viewController!.navigationController!.pushViewController(vc, animated: true)
32− }
33− else if indexPath.section == 0 && type == .NEWS{
34− let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: channelListControllerId) as! ChannelListController
35− //vc.myProtocol = viewController as? NewsController
36− viewController!.navigationController!.pushViewController(vc, animated: true)
37− }
28+ vc.post = dataSourse[indexPath.row]
29+ viewController!.navigationController!.pushViewController(vc, animated: true)
3830 }
3931
4032 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
41− switch type {
42− case .NONE:
43− return dataSourse.count
44− default:
45− switch section {
46− case 0:
47− return 1
48− default:
49− return dataSourse.count
50− }
51− }
33+ return dataSourse.count
5234 }
5335
5436 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
5537 {
56− switch type {
57− case .NONE:
58− let cell = tableView.dequeueReusableCell(withIdentifier: postCellId, for: indexPath) as! PostViewCell
59−
60− cell.fill(with: dataSourse[indexPath.row].dataArray, false, post: dataSourse[indexPath.row])
61− cell.selectionStyle = .none
62− return cell
63− default:
64− switch indexPath.section {
65− case 0:
66− let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
67− cell.textLabel?.text = "List of channels"
68− return cell
69− default:
70− let cell = tableView.dequeueReusableCell(withIdentifier: postCellId, for: indexPath) as! PostViewCell
71−
72− cell.fill(with: dataSourse[indexPath.row].dataArray, false, post: dataSourse[indexPath.row])
73− cell.selectionStyle = .none
74− return cell
75− }
76− }
38+ let cell = tableView.dequeueReusableCell(withIdentifier: postCellId, for: indexPath) as! PostViewCell
39+
40+ cell.fill(with: dataSourse[indexPath.row].dataArray, false, post: dataSourse[indexPath.row])
41+ cell.selectionStyle = .none
42+ return cell
7743 }
7844
7945 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
GDproject/Controller/Coordinator tab bar?/TabBarController.swiftdeleted−28
@@ -1,28 +0,0 @@
1−import UIKit
2−
3−final class TabbarController: UITabBarController, UITabBarControllerDelegate, TabbarView {
4−
5− var onItemFlowSelect: ((UINavigationController) -> ())?
6− var onSettingsFlowSelect: ((UINavigationController) -> ())?
7− var onViewDidLoad: ((UINavigationController) -> ())?
8−
9− override func viewDidLoad() {
10− super.viewDidLoad()
11−
12− delegate = self
13− if let controller = customizableViewControllers?.first as? UINavigationController {
14− onViewDidLoad?(controller)
15− }
16− }
17−
18− func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
19− guard let controller = viewControllers?[selectedIndex] as? UINavigationController else { return }
20−
21− if selectedIndex == 0 {
22− onItemFlowSelect?(controller)
23− }
24− else if selectedIndex == 1 {
25− onSettingsFlowSelect?(controller)
26− }
27− }
28−}
GDproject/Controller/Coordinator tab bar?/TabbarCoordinator.swiftnew file+13
@@ -0,0 +1,13 @@
1+import UIKit
2+
3+class TabbarCoordinator{
4+ var window: UIWindow!
5+
6+ func start(){
7+ window.rootViewController = UIStoryboard.tabBarController()
8+ }
9+
10+ init(window: UIWindow) {
11+ self.window = window
12+ }
13+}
GDproject/Controller/Coordinator tab bar?/TabbarView.swiftdeleted−7
@@ -1,7 +0,0 @@
1−import UIKit
2−
3−protocol TabbarView: class {
4− var onItemFlowSelect: ((UINavigationController) -> ())? { get set }
5− var onSettingsFlowSelect: ((UINavigationController) -> ())? { get set }
6− var onViewDidLoad: ((UINavigationController) -> ())? { get set }
7−}
GDproject/Extentions.swift+8
@@ -47,4 +47,12 @@ extension UIStoryboard {
4747 class func makeNewsController() -> NewsController {
4848 return UIStoryboard.userEdit.instantiateViewController(withIdentifier: newsController) as! NewsController
4949 }
50+
51+ class func tabBarController() -> UITabBarController{
52+ return UIStoryboard.userEdit.instantiateViewController(withIdentifier: "TabBar") as! UITabBarController
53+ }
54+
55+ class func navChannels() ->UINavigationController{
56+ return UIStoryboard.userEdit.instantiateViewController(withIdentifier: "navChannels") as! UINavigationController
57+ }
5058}
GDproject/Simple model/Channel.swift+8−1
@@ -8,7 +8,14 @@
88
99import Foundation
1010
11−class Channel {
11+class Channel: Equatable {
12+ static func == (lhs: Channel, rhs: Channel) -> Bool {
13+ return (lhs.title == rhs.title &&
14+ lhs.subtitle == rhs.subtitle &&
15+ lhs.people == rhs.people &&
16+ lhs.hashtags == rhs.hashtags)
17+ }
18+
1219 var title = String()
1320 var subtitle = String()
1421
GDproject/Supporting files/AppDelegate.swift+10−5
@@ -12,19 +12,24 @@ import UIKit
1212class AppDelegate: UIResponder, UIApplicationDelegate {
1313
1414 var coordinator: ChannelsCoordinator!
15+ var tabCoordinator: TabbarCoordinator!
16+
1517 var window: UIWindow?
16− var rootController: UINavigationController {
17− return self.window!.rootViewController as! UINavigationController
18+ var rootController: UINavigationController? {
19+ return self.window!.rootViewController as? UINavigationController
1820 }
1921
2022 private func makeCoordinator(with: UINavigationController) -> ChannelsCoordinator {
21− return ChannelsCoordinator(currentChannel: Channel(title: "example", subtitle: "ex", hashtags: ["none"], people: ["none"], posts: []), navigationController: rootController)
23+ return ChannelsCoordinator(currentChannel: Channel(title: "example", subtitle: "ex", hashtags: ["none"], people: ["none"], posts: []), navigationController: with)
2224 }
2325
2426 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
2527 {
26− coordinator = makeCoordinator(with: rootController)
27− coordinator.start()
28+
29+ // TODO:- determine what to do here: log in or tabbar
30+ tabCoordinator = TabbarCoordinator(window: window!)
31+ tabCoordinator.start()
32+
2833 return true
2934 }
3035