git.iko.soy/dashared/GDproject
on master help sign in
Changed preview concept (new vc) and added dialogs bar. Is correctly working in coordinators system. Btw wish General were a channel...
2c1cb56Darya Rednikina
GDproject.xcodeproj/project.pbxproj+16
@@ -19,6 +19,8 @@
19 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */; };
19 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */; };
20 1291BE342221569B009D3F23 /* TabbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */; };
20 1291BE342221569B009D3F23 /* TabbarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */; };
21 1291BE3622218DBF009D3F23 /* LogInCoordinator1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE3522218DBF009D3F23 /* LogInCoordinator1.swift */; };
21 1291BE3622218DBF009D3F23 /* LogInCoordinator1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1291BE3522218DBF009D3F23 /* LogInCoordinator1.swift */; };
22+ 129320042279B4270035C7B3 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129320032279B4270035C7B3 /* MessagesViewController.swift */; };
23+ 129320072279B5690035C7B3 /* MessagesCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129320062279B5690035C7B3 /* MessagesCoordinator.swift */; };
22 12BA4B9B224101A400DF93D7 /* ApplicationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12BA4B9A224101A400DF93D7 /* ApplicationCoordinator.swift */; };
24 12BA4B9B224101A400DF93D7 /* ApplicationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12BA4B9A224101A400DF93D7 /* ApplicationCoordinator.swift */; };
23 12BA4B9D224101E700DF93D7 /* BaseCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12BA4B9C224101E700DF93D7 /* BaseCoordinator.swift */; };
25 12BA4B9D224101E700DF93D7 /* BaseCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12BA4B9C224101E700DF93D7 /* BaseCoordinator.swift */; };
24 12BA4B9F224102B700DF93D7 /* LogInCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12BA4B9E224102B700DF93D7 /* LogInCoordinator.swift */; };
26 12BA4B9F224102B700DF93D7 /* LogInCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12BA4B9E224102B700DF93D7 /* LogInCoordinator.swift */; };
@@ -101,6 +103,8 @@
101 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelsCoordinator.swift; sourceTree = "<group>"; };
103 1291BE2C2221312C009D3F23 /* ChannelsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelsCoordinator.swift; sourceTree = "<group>"; };
102 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarCoordinator.swift; sourceTree = "<group>"; };
104 1291BE332221569B009D3F23 /* TabbarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbarCoordinator.swift; sourceTree = "<group>"; };
103 1291BE3522218DBF009D3F23 /* LogInCoordinator1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInCoordinator1.swift; sourceTree = "<group>"; };
105 1291BE3522218DBF009D3F23 /* LogInCoordinator1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInCoordinator1.swift; sourceTree = "<group>"; };
106+ 129320032279B4270035C7B3 /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = "<group>"; };
107+ 129320062279B5690035C7B3 /* MessagesCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesCoordinator.swift; sourceTree = "<group>"; };
104 12BA4B9A224101A400DF93D7 /* ApplicationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationCoordinator.swift; sourceTree = "<group>"; };
108 12BA4B9A224101A400DF93D7 /* ApplicationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationCoordinator.swift; sourceTree = "<group>"; };
105 12BA4B9C224101E700DF93D7 /* BaseCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCoordinator.swift; sourceTree = "<group>"; };
109 12BA4B9C224101E700DF93D7 /* BaseCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCoordinator.swift; sourceTree = "<group>"; };
106 12BA4B9E224102B700DF93D7 /* LogInCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInCoordinator.swift; sourceTree = "<group>"; };
110 12BA4B9E224102B700DF93D7 /* LogInCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInCoordinator.swift; sourceTree = "<group>"; };
@@ -177,6 +181,7 @@
177 isa = PBXGroup;
181 isa = PBXGroup;
178 children = (
182 children = (
179 12BA4B9A224101A400DF93D7 /* ApplicationCoordinator.swift */,
183 12BA4B9A224101A400DF93D7 /* ApplicationCoordinator.swift */,
184+ 129320062279B5690035C7B3 /* MessagesCoordinator.swift */,
180 12F3D6AF224106F700A69214 /* TabbarController.swift */,
185 12F3D6AF224106F700A69214 /* TabbarController.swift */,
181 12F3D6B12241097B00A69214 /* ProfileCoordinator.swift */,
186 12F3D6B12241097B00A69214 /* ProfileCoordinator.swift */,
182 12BA4B9E224102B700DF93D7 /* LogInCoordinator.swift */,
187 12BA4B9E224102B700DF93D7 /* LogInCoordinator.swift */,
@@ -196,6 +201,14 @@
196 path = "Log In";
201 path = "Log In";
197 sourceTree = "<group>";
202 sourceTree = "<group>";
198 };
203 };
204+ 129320052279B4300035C7B3 /* Messages */ = {
205+ isa = PBXGroup;
206+ children = (
207+ 129320032279B4270035C7B3 /* MessagesViewController.swift */,
208+ );
209+ path = Messages;
210+ sourceTree = "<group>";
211+ };
199 12E36D8F221424EA006FCDD7 = {
212 12E36D8F221424EA006FCDD7 = {
200 isa = PBXGroup;
213 isa = PBXGroup;
201 children = (
214 children = (
@@ -264,6 +277,7 @@
264 isa = PBXGroup;
277 isa = PBXGroup;
265 children = (
278 children = (
266 1291BE32222154C3009D3F23 /* Coordinators */,
279 1291BE32222154C3009D3F23 /* Coordinators */,
280+ 129320052279B4300035C7B3 /* Messages */,
267 1291BE3722218DC4009D3F23 /* Log In */,
281 1291BE3722218DC4009D3F23 /* Log In */,
268 1288B5CC221F0EFE002BE6B1 /* Profile */,
282 1288B5CC221F0EFE002BE6B1 /* Profile */,
269 12E36DD322156519006FCDD7 /* News and channels */,
283 12E36DD322156519006FCDD7 /* News and channels */,
@@ -371,6 +385,7 @@
371 isa = PBXSourcesBuildPhase;
385 isa = PBXSourcesBuildPhase;
372 buildActionMask = 2147483647;
386 buildActionMask = 2147483647;
373 files = (
387 files = (
388+ 129320072279B5690035C7B3 /* MessagesCoordinator.swift in Sources */,
374 124CC7032221C00C009DF531 /* Model.swift in Sources */,
389 124CC7032221C00C009DF531 /* Model.swift in Sources */,
375 12F3D6B0224106F700A69214 /* TabbarController.swift in Sources */,
390 12F3D6B0224106F700A69214 /* TabbarController.swift in Sources */,
376 12E36DD522156559006FCDD7 /* MyStackView.swift in Sources */,
391 12E36DD522156559006FCDD7 /* MyStackView.swift in Sources */,
@@ -391,6 +406,7 @@
391 12BA4B9B224101A400DF93D7 /* ApplicationCoordinator.swift in Sources */,
406 12BA4B9B224101A400DF93D7 /* ApplicationCoordinator.swift in Sources */,
392 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */,
407 1291BE2D2221312D009D3F23 /* ChannelsCoordinator.swift in Sources */,
393 12E36DD122148122006FCDD7 /* FullPostController.swift in Sources */,
408 12E36DD122148122006FCDD7 /* FullPostController.swift in Sources */,
409+ 129320042279B4270035C7B3 /* MessagesViewController.swift in Sources */,
394 1288B5CE221F1158002BE6B1 /* DataStorage.swift in Sources */,
410 1288B5CE221F1158002BE6B1 /* DataStorage.swift in Sources */,
395 12BA4B9F224102B700DF93D7 /* LogInCoordinator.swift in Sources */,
411 12BA4B9F224102B700DF93D7 /* LogInCoordinator.swift in Sources */,
396 12F3D6B22241097B00A69214 /* ProfileCoordinator.swift in Sources */,
412 12F3D6B22241097B00A69214 /* ProfileCoordinator.swift in Sources */,
GDproject/Base.lproj/Main.storyboard+49−6
@@ -11,6 +11,20 @@
11 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
12 </dependencies>
12 </dependencies>
13 <scenes>
13 <scenes>
14+ <!--Item-->
15+ <scene sceneID="bZ2-fw-XBE">
16+ <objects>
17+ <navigationController id="gt4-mD-66Q" sceneMemberID="viewController">
18+ <tabBarItem key="tabBarItem" title="Item" id="ZPm-j1-3dy"/>
19+ <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="XiY-wd-750">
20+ <rect key="frame" x="0.0" y="20" width="375" height="44"/>
21+ <autoresizingMask key="autoresizingMask"/>
22+ </navigationBar>
23+ </navigationController>
24+ <placeholder placeholderIdentifier="IBFirstResponder" id="4yT-77-90q" userLabel="First Responder" sceneMemberID="firstResponder"/>
25+ </objects>
26+ <point key="canvasLocation" x="1089" y="481"/>
27+ </scene>
14 <!--Profile View Controller-->
28 <!--Profile View Controller-->
15 <scene sceneID="rQ6-TM-V7T">
29 <scene sceneID="rQ6-TM-V7T">
16 <objects>
30 <objects>
@@ -131,7 +145,7 @@
131 </viewController>
145 </viewController>
132 <placeholder placeholderIdentifier="IBFirstResponder" id="sap-zV-B7l" userLabel="First Responder" sceneMemberID="firstResponder"/>
146 <placeholder placeholderIdentifier="IBFirstResponder" id="sap-zV-B7l" userLabel="First Responder" sceneMemberID="firstResponder"/>
133 </objects>
147 </objects>
134− <point key="canvasLocation" x="2013.5999999999999" y="957.57121439280365"/>
148+ <point key="canvasLocation" x="1884" y="1216"/>
135 </scene>
149 </scene>
136 <!--Settings View Controller-->
150 <!--Settings View Controller-->
137 <scene sceneID="WVn-Qy-9tO">
151 <scene sceneID="WVn-Qy-9tO">
@@ -168,7 +182,7 @@
168 </tableViewController>
182 </tableViewController>
169 <placeholder placeholderIdentifier="IBFirstResponder" id="xdg-ZK-4Jv" userLabel="First Responder" sceneMemberID="firstResponder"/>
183 <placeholder placeholderIdentifier="IBFirstResponder" id="xdg-ZK-4Jv" userLabel="First Responder" sceneMemberID="firstResponder"/>
170 </objects>
184 </objects>
171− <point key="canvasLocation" x="1986" y="1756"/>
185+ <point key="canvasLocation" x="1980" y="1979"/>
172 </scene>
186 </scene>
173 <!--Invite View Controller-->
187 <!--Invite View Controller-->
174 <scene sceneID="DcO-6Y-Iko">
188 <scene sceneID="DcO-6Y-Iko">
@@ -212,7 +226,7 @@
212 </viewController>
226 </viewController>
213 <placeholder placeholderIdentifier="IBFirstResponder" id="t8a-Sv-mbh" userLabel="First Responder" sceneMemberID="firstResponder"/>
227 <placeholder placeholderIdentifier="IBFirstResponder" id="t8a-Sv-mbh" userLabel="First Responder" sceneMemberID="firstResponder"/>
214 </objects>
228 </objects>
215− <point key="canvasLocation" x="2803" y="1756"/>
229+ <point key="canvasLocation" x="2799" y="1979"/>
216 </scene>
230 </scene>
217 <!--Simplified Channels List-->
231 <!--Simplified Channels List-->
218 <scene sceneID="gAa-jy-vpG">
232 <scene sceneID="gAa-jy-vpG">
@@ -416,9 +430,38 @@
416 </objects>
430 </objects>
417 <point key="canvasLocation" x="3444" y="129.98500749625188"/>
431 <point key="canvasLocation" x="3444" y="129.98500749625188"/>
418 </scene>
432 </scene>
433+ <!--Messages View Controller-->
434+ <scene sceneID="WSW-fr-Vf8">
435+ <objects>
436+ <tableViewController storyboardIdentifier="MessagesViewController" id="KLf-CK-diQ" customClass="MessagesViewController" customModule="GDproject" customModuleProvider="target" sceneMemberID="viewController">
437+ <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="13B-QX-K78">
438+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
439+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
440+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
441+ <prototypes>
442+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="67C-fT-WEV">
443+ <rect key="frame" x="0.0" y="28" width="375" height="44"/>
444+ <autoresizingMask key="autoresizingMask"/>
445+ <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="67C-fT-WEV" id="O3b-Xv-UNk">
446+ <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
447+ <autoresizingMask key="autoresizingMask"/>
448+ </tableViewCellContentView>
449+ </tableViewCell>
450+ </prototypes>
451+ <connections>
452+ <outlet property="dataSource" destination="KLf-CK-diQ" id="LjF-Uw-Xhq"/>
453+ <outlet property="delegate" destination="KLf-CK-diQ" id="yJZ-wH-O3v"/>
454+ </connections>
455+ </tableView>
456+ </tableViewController>
457+ <placeholder placeholderIdentifier="IBFirstResponder" id="fu3-z4-EY7" userLabel="First Responder" sceneMemberID="firstResponder"/>
458+ </objects>
459+ <point key="canvasLocation" x="2798" y="932"/>
460+ </scene>
419 <!--Posts-->
461 <!--Posts-->
420 <scene sceneID="RSd-UJ-34B">
462 <scene sceneID="RSd-UJ-34B">
421 <objects>
463 <objects>
464+ <placeholder placeholderIdentifier="IBFirstResponder" id="POV-5T-jeQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
422 <navigationController storyboardIdentifier="navChannels" automaticallyAdjustsScrollViewInsets="NO" id="NuV-ZG-ld2" sceneMemberID="viewController">
465 <navigationController storyboardIdentifier="navChannels" automaticallyAdjustsScrollViewInsets="NO" id="NuV-ZG-ld2" sceneMemberID="viewController">
423 <tabBarItem key="tabBarItem" title="Posts" image="5" selectedImage="5" id="dH2-sL-YsR"/>
466 <tabBarItem key="tabBarItem" title="Posts" image="5" selectedImage="5" id="dH2-sL-YsR"/>
424 <toolbarItems/>
467 <toolbarItems/>
@@ -428,9 +471,8 @@
428 </navigationBar>
471 </navigationBar>
429 <nil name="viewControllers"/>
472 <nil name="viewControllers"/>
430 </navigationController>
473 </navigationController>
431− <placeholder placeholderIdentifier="IBFirstResponder" id="POV-5T-jeQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
432 </objects>
474 </objects>
433− <point key="canvasLocation" x="1088.8" y="132.68365817091455"/>
475+ <point key="canvasLocation" x="1089" y="-306"/>
434 </scene>
476 </scene>
435 <!--Profile-->
477 <!--Profile-->
436 <scene sceneID="dJj-Hp-Wa9">
478 <scene sceneID="dJj-Hp-Wa9">
@@ -446,7 +488,7 @@
446 </navigationController>
488 </navigationController>
447 <placeholder placeholderIdentifier="IBFirstResponder" id="Fvm-qf-2Ve" userLabel="First Responder" sceneMemberID="firstResponder"/>
489 <placeholder placeholderIdentifier="IBFirstResponder" id="Fvm-qf-2Ve" userLabel="First Responder" sceneMemberID="firstResponder"/>
448 </objects>
490 </objects>
449− <point key="canvasLocation" x="1089" y="958"/>
491+ <point key="canvasLocation" x="1015" y="1216"/>
450 </scene>
492 </scene>
451 <!--Tabbar Controller-->
493 <!--Tabbar Controller-->
452 <scene sceneID="HCR-WO-p7g">
494 <scene sceneID="HCR-WO-p7g">
@@ -460,6 +502,7 @@
460 </tabBar>
502 </tabBar>
461 <connections>
503 <connections>
462 <segue destination="NuV-ZG-ld2" kind="relationship" relationship="viewControllers" id="XuX-8s-fZU"/>
504 <segue destination="NuV-ZG-ld2" kind="relationship" relationship="viewControllers" id="XuX-8s-fZU"/>
505+ <segue destination="gt4-mD-66Q" kind="relationship" relationship="viewControllers" id="QM3-FF-LMu"/>
463 <segue destination="tae-5q-wvT" kind="relationship" relationship="viewControllers" id="wCJ-4N-lfC"/>
506 <segue destination="tae-5q-wvT" kind="relationship" relationship="viewControllers" id="wCJ-4N-lfC"/>
464 </connections>
507 </connections>
465 </tabBarController>
508 </tabBarController>
GDproject/Constants.swift+3
@@ -43,6 +43,9 @@ let newsController = "NewsController"
43/// constant for switching to view controller for log in app
43/// constant for switching to view controller for log in app
44let logInController = "LogInController"
44let logInController = "LogInController"
45
45
46+// constant for getting to messages
47+let messagesViewControllerId = "MessagesViewController"
48+
46
49
47let profileViewController = "ProfileViewController"
50let profileViewController = "ProfileViewController"
48
51
GDproject/Controller/ News and channels/ChannelController.swift+25−5
@@ -33,6 +33,9 @@ class ChannelController: UIViewController, UITableViewDelegate, UITableViewDataS
33
33
34 var activeDataSource: ActiveTable = .people
34 var activeDataSource: ActiveTable = .people
35
35
36+ // func to show preview of the current channel
37+ var onShowingPreview: ((Model.Channels)->())?
38+
36 @IBOutlet weak var viewww: UIView!
39 @IBOutlet weak var viewww: UIView!
37
40
38 @IBOutlet weak var textField: UITextField!
41 @IBOutlet weak var textField: UITextField!
@@ -61,16 +64,33 @@ class ChannelController: UIViewController, UITableViewDelegate, UITableViewDataS
61
64
62 // TODO: update channel
65 // TODO: update channel
63 override func viewWillDisappear(_ animated: Bool) {
66 override func viewWillDisappear(_ animated: Bool) {
67+
68+ defer {
64− super.viewWillDisappear(animated)
69+ super.viewWillDisappear(animated)
70+ }
71+
72+ guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else {
65− if let _ = channel?.id { print("update")
73+ if let _ = channel?.id { print("update")
66− Model.updateChannel(with: channel!)
74+ Model.updateChannel(with: channel!)
67− } else { print("create")
75+ } else { print("create")
68− Model.createChannel(with: channel!)
76+ Model.createChannel(with: channel!)
77+ }
78+ return
79+ }
80+ // nou
81+ }
82+
83+ @objc func showPreview(){
84+ if let channel = channel {
85+ onShowingPreview?(channel)
69 }
86 }
70 }
87 }
71
88
72 func setUpController(){
89 func setUpController(){
73
90
91+ // setting up the preview button for the editing or created channel
92+ navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Preview", style: .done, target: self, action: #selector(showPreview))
93+
74 tableView.delegate = self
94 tableView.delegate = self
75 tableView.dataSource = self
95 tableView.dataSource = self
76 tableView.register(UITableViewCell.self, forCellReuseIdentifier: itemCellId)
96 tableView.register(UITableViewCell.self, forCellReuseIdentifier: itemCellId)
GDproject/Controller/Coordinators/ChannelsCoordinator.swift+18−3
@@ -33,7 +33,7 @@ class ChannelsCoordinator: BaseCoordinator{
33 }
33 }
34
34
35 channels.onEditingModeBegins = { [unowned self] (channel, indexPath) in
35 channels.onEditingModeBegins = { [unowned self] (channel, indexPath) in
36− let vc = self.presentNewsController(with: channel)
36+ let vc = self.presentChannelController(with: channel)
37 self.navigationController?.pushViewController(vc, animated: true)
37 self.navigationController?.pushViewController(vc, animated: true)
38 vc.tabBarController?.tabBar.isHidden = true
38 vc.tabBarController?.tabBar.isHidden = true
39 }
39 }
@@ -42,11 +42,26 @@ class ChannelsCoordinator: BaseCoordinator{
42 navigationController?.setViewControllers([channels, nc], animated: false)
42 navigationController?.setViewControllers([channels, nc], animated: false)
43 }
43 }
44
44
45+ /// Function that presents channel controller
46+ ///
47+ /// - Parameter channel: channel that needs to be displayed
48+ func presentChannelController(with channel: Model.Channels? = nil) -> ChannelController {
49+ let mainContentVC = storyboard.instantiateViewController(withIdentifier: channelControllerId) as! ChannelController
50+
51+ // to show preview we need to instantiate newsController but with different functionality
52+ mainContentVC.onShowingPreview = { [weak mainContentVC, unowned self] ch in
53+ let vc = self.presentNewsController(with: ch, previewMode: true)
54+ mainContentVC?.navigationController?.pushViewController(vc, animated: true)
55+ }
56+ mainContentVC.channel = channel
57+ return mainContentVC
58+ }
59+
45− func presentNewsController(with channel: Model.Channels? = nil) -> NewsController {
60+ func presentNewsController(with channel: Model.Channels? = nil, previewMode: Bool = false) -> NewsController {
46 let mainContentVC = storyboard.instantiateViewController(withIdentifier: newsController) as! NewsController
61 let mainContentVC = storyboard.instantiateViewController(withIdentifier: newsController) as! NewsController
47 mainContentVC.channel = channel
62 mainContentVC.channel = channel
48
63
49− if channel == nil || channel?.id == -1 {
64+ if !previewMode {
50 mainContentVC.news.onFullPost = {
65 mainContentVC.news.onFullPost = {
51 [weak self] (type,post) in
66 [weak self] (type,post) in
52
67
GDproject/Controller/Coordinators/MessagesCoordinator.swiftnew file+32
@@ -0,0 +1,32 @@
1+//
2+// MessagesCoordinator.swift
3+// GDproject
4+//
5+// Created by cstore on 01/05/2019.
6+// Copyright © 2019 drHSE. All rights reserved.
7+//
8+
9+
10+import Foundation
11+import UIKit
12+
13+class MessagesCoordinator: BaseCoordinator {
14+
15+ var didEndSession: (()->())?
16+
17+ let storyboard = UIStoryboard(name: "Main", bundle: nil)
18+ private weak var navigationController: UINavigationController?
19+
20+ init(nc: UINavigationController) {
21+ self.navigationController = nc
22+ }
23+
24+ override func start() {
25+ show()
26+ }
27+
28+ private func show(){
29+ let vc = storyboard.instantiateViewController(withIdentifier: messagesViewControllerId) as! MessagesViewController
30+ navigationController?.viewControllers = [vc]
31+ }
32+}
GDproject/Controller/Coordinators/TabbarController.swift+6−1
@@ -12,6 +12,7 @@ import UIKit
12protocol TabbarView: class {
12protocol TabbarView: class {
13 var onChannelsFlowSelect: ((UINavigationController) -> ())? { get set }
13 var onChannelsFlowSelect: ((UINavigationController) -> ())? { get set }
14 var onProfileFlowSelect: ((UINavigationController) -> ())? { get set }
14 var onProfileFlowSelect: ((UINavigationController) -> ())? { get set }
15+ var onMessagesFlowSelect: ((UINavigationController) -> ())? { get set }
15 var onViewDidLoad: ((UINavigationController) -> ())? { get set }
16 var onViewDidLoad: ((UINavigationController) -> ())? { get set }
16}
17}
17
18
@@ -20,6 +21,8 @@ final class TabbarController: UITabBarController, UITabBarControllerDelegate, Ta
20
21
21 var onChannelsFlowSelect: ((UINavigationController) -> ())?
22 var onChannelsFlowSelect: ((UINavigationController) -> ())?
22 var onProfileFlowSelect: ((UINavigationController) -> ())?
23 var onProfileFlowSelect: ((UINavigationController) -> ())?
24+ var onMessagesFlowSelect: ((UINavigationController) -> ())?
25+
23 var onViewDidLoad: ((UINavigationController) -> ())?
26 var onViewDidLoad: ((UINavigationController) -> ())?
24
27
25 override func viewDidLoad() {
28 override func viewDidLoad() {
@@ -38,8 +41,10 @@ final class TabbarController: UITabBarController, UITabBarControllerDelegate, Ta
38
41
39 if selectedIndex == 0 {
42 if selectedIndex == 0 {
40 onChannelsFlowSelect?(controller)
43 onChannelsFlowSelect?(controller)
41− } else {
44+ } else if selectedIndex == 2 {
42 onProfileFlowSelect?(controller)
45 onProfileFlowSelect?(controller)
46+ } else {
47+ onMessagesFlowSelect?(controller)
43 }
48 }
44 }
49 }
45}
50}
GDproject/Controller/Coordinators/TabbarCoordinator.swift+11
@@ -26,6 +26,7 @@ class TabBarCoordinator: BaseCoordinator {
26 tabbarView.onViewDidLoad = runChannelsFlow()
26 tabbarView.onViewDidLoad = runChannelsFlow()
27 tabbarView.onChannelsFlowSelect = runChannelsFlow()
27 tabbarView.onChannelsFlowSelect = runChannelsFlow()
28 tabbarView.onProfileFlowSelect = runProfileFlow()
28 tabbarView.onProfileFlowSelect = runProfileFlow()
29+ tabbarView.onMessagesFlowSelect = runMessagesFlow()
29 window?.rootViewController = tabbarView as! TabbarController
30 window?.rootViewController = tabbarView as! TabbarController
30 }
31 }
31
32
@@ -40,6 +41,16 @@ class TabBarCoordinator: BaseCoordinator {
40 }
41 }
41 }
42 }
42
43
44+ private func runMessagesFlow() -> ((UINavigationController) -> ()){
45+ return { [unowned self] navController in
46+ if navController.viewControllers.isEmpty == true {
47+ let messagesCoordinator = MessagesCoordinator(nc: navController)
48+ self.addDependency(messagesCoordinator)
49+ messagesCoordinator.start()
50+ }
51+ }
52+ }
53+
43 private func runProfileFlow() -> ((UINavigationController) -> ())
54 private func runProfileFlow() -> ((UINavigationController) -> ())
44 {
55 {
45 return { [unowned self] navController in
56 return { [unowned self] navController in
GDproject/Controller/Messages/MessagesViewController.swiftnew file+90
@@ -0,0 +1,90 @@
1+//
2+// MessagesViewController.swift
3+// GDproject
4+//
5+// Created by cstore on 01/05/2019.
6+// Copyright © 2019 drHSE. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class MessagesViewController: UITableViewController {
12+
13+ override func viewDidLoad() {
14+ super.viewDidLoad()
15+
16+ // Uncomment the following line to preserve selection between presentations
17+ // self.clearsSelectionOnViewWillAppear = false
18+
19+ // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
20+ // self.navigationItem.rightBarButtonItem = self.editButtonItem
21+ }
22+
23+ // MARK: - Table view data source
24+
25+ override func numberOfSections(in tableView: UITableView) -> Int {
26+ // #warning Incomplete implementation, return the number of sections
27+ return 0
28+ }
29+
30+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
31+ // #warning Incomplete implementation, return the number of rows
32+ return 0
33+ }
34+
35+ /*
36+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
37+ let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
38+
39+ // Configure the cell...
40+
41+ return cell
42+ }
43+ */
44+
45+ /*
46+ // Override to support conditional editing of the table view.
47+ override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
48+ // Return false if you do not want the specified item to be editable.
49+ return true
50+ }
51+ */
52+
53+ /*
54+ // Override to support editing the table view.
55+ override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
56+ if editingStyle == .delete {
57+ // Delete the row from the data source
58+ tableView.deleteRows(at: [indexPath], with: .fade)
59+ } else if editingStyle == .insert {
60+ // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
61+ }
62+ }
63+ */
64+
65+ /*
66+ // Override to support rearranging the table view.
67+ override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
68+
69+ }
70+ */
71+
72+ /*
73+ // Override to support conditional rearranging of the table view.
74+ override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
75+ // Return false if you do not want the item to be re-orderable.
76+ return true
77+ }
78+ */
79+
80+ /*
81+ // MARK: - Navigation
82+
83+ // In a storyboard-based application, you will often want to do a little preparation before navigation
84+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
85+ // Get the new view controller using segue.destination.
86+ // Pass the selected object to the new view controller.
87+ }
88+ */
89+
90+}