From 32e1d267d1f9053136a2b4d0288d5488eda01e5d Mon Sep 17 00:00:00 2001 From: Darya Rednikina Date: Wed, 20 Mar 2019 15:31:14 +0300 Subject: [PATCH] a lot of changes: still trying to embed coordinators. slowly modfiying channels. added empty card for editing channel --- Cartfile | 4 +- GDproject.xcodeproj/project.pbxproj | 6 ++ GDproject/Base.lproj/Main.storyboard | 102 ++++++++++++++---- .../ News and channels/NewsController.swift | 12 ++- .../TabbarCoordinator.swift | 14 --- .../Coordinators/ChannelsCoordinator.swift | 16 ++- 6 files changed, 113 insertions(+), 41 deletions(-) delete mode 100644 GDproject/Controller/Coordinator tab bar?/TabbarCoordinator.swift diff --git a/Cartfile b/Cartfile index cc276a7..dd68276 100644 --- a/Cartfile +++ b/Cartfile @@ -2,7 +2,7 @@ github "robb/Cartography" github "ivanbruel/MarkdownKit" github "roberthein/TinyConstraints" github "macteo/Marklight" -github "ElaWorkshop/TagListView" github "Alamofire/Alamofire" "5.0.0-beta.2" github "whitesmith/WSTagsField" -github "ReactiveCocoa/ReactiveCocoa" ~> 8.0 \ No newline at end of file +github "ReactiveCocoa/ReactiveCocoa" ~> 8.0 +github "52inc/Pulley" \ No newline at end of file diff --git a/GDproject.xcodeproj/project.pbxproj b/GDproject.xcodeproj/project.pbxproj index e0c4785..f4ab99e 100644 --- a/GDproject.xcodeproj/project.pbxproj +++ b/GDproject.xcodeproj/project.pbxproj @@ -63,6 +63,8 @@ 12F3D6BE2241130000A69214 /* Result.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12F3D6B7224112E800A69214 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12F3D6C02241130200A69214 /* ReactiveSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12F3D6B5224112E000A69214 /* ReactiveSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12F3D6C22241130400A69214 /* ReactiveMapKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12F3D6B3224112D600A69214 /* ReactiveMapKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 12F3D6C92242645800A69214 /* Pulley.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 12F3D6C72242644D00A69214 /* Pulley.framework */; }; + 12F3D6CA2242645800A69214 /* Pulley.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12F3D6C72242644D00A69214 /* Pulley.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -81,6 +83,7 @@ 12F3D6C02241130200A69214 /* ReactiveSwift.framework in Embed Frameworks */, 12F3D6BC224112FD00A69214 /* ReactiveCocoa.framework in Embed Frameworks */, 123AD0E5223C1C4300326173 /* WSTagsField.framework in Embed Frameworks */, + 12F3D6CA2242645800A69214 /* Pulley.framework in Embed Frameworks */, 12E36DC2221441E1006FCDD7 /* MarkdownKit.framework in Embed Frameworks */, ); name = "Embed Frameworks"; @@ -137,6 +140,7 @@ 12F3D6B5224112E000A69214 /* ReactiveSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveSwift.framework; path = Carthage/Build/iOS/ReactiveSwift.framework; sourceTree = ""; }; 12F3D6B7224112E800A69214 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = ""; }; 12F3D6B9224112F500A69214 /* ReactiveCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveCocoa.framework; path = Carthage/Build/iOS/ReactiveCocoa.framework; sourceTree = ""; }; + 12F3D6C72242644D00A69214 /* Pulley.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pulley.framework; path = Carthage/Build/iOS/Pulley.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -147,6 +151,7 @@ 12E36DB522143D54006FCDD7 /* TinyConstraints.framework in Frameworks */, 12F3D6B4224112D600A69214 /* ReactiveMapKit.framework in Frameworks */, 124CC7052221C2BB009DF531 /* Alamofire.framework in Frameworks */, + 12F3D6C92242645800A69214 /* Pulley.framework in Frameworks */, 12F3D6BB224112FD00A69214 /* ReactiveCocoa.framework in Frameworks */, 12F3D6B8224112E900A69214 /* Result.framework in Frameworks */, 12F3D6B6224112E100A69214 /* ReactiveSwift.framework in Frameworks */, @@ -199,6 +204,7 @@ 12E36D8F221424EA006FCDD7 = { isa = PBXGroup; children = ( + 12F3D6C72242644D00A69214 /* Pulley.framework */, 12F3D6B9224112F500A69214 /* ReactiveCocoa.framework */, 12F3D6B7224112E800A69214 /* Result.framework */, 12F3D6B5224112E000A69214 /* ReactiveSwift.framework */, diff --git a/GDproject/Base.lproj/Main.storyboard b/GDproject/Base.lproj/Main.storyboard index f828dc1..ff8cd15 100644 --- a/GDproject/Base.lproj/Main.storyboard +++ b/GDproject/Base.lproj/Main.storyboard @@ -416,6 +416,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -432,26 +471,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -487,6 +506,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GDproject/Controller/ News and channels/NewsController.swift b/GDproject/Controller/ News and channels/NewsController.swift index f829a78..9863f95 100644 --- a/GDproject/Controller/ News and channels/NewsController.swift +++ b/GDproject/Controller/ News and channels/NewsController.swift @@ -21,8 +21,11 @@ protocol UpdateableWithUser: class { } // MARK:- Controller with posts and channels availiable. // Search is availiable within every table (posts and channels). Has button-functionality for boths post and chnnels -class NewsController: UITableViewController, UISearchControllerDelegate, NewPostDelegate, UpdateableWithChannel, DataDelegate +class NewsController: UIViewController, UISearchControllerDelegate, NewPostDelegate, UpdateableWithChannel, DataDelegate { + + var changedChannelName: ((String)->())? + func passData(for row: Int, channel: Model.Channels) { if channel.id == -1{ self.channel = nil @@ -31,6 +34,8 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost } } + @IBOutlet weak var tableView: UITableView! + var dictionary: [Int: Model.Users]? { didSet { @@ -147,9 +152,8 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost self?.posts = $0.posts self?.dictionary = $0.users self?.refreshContr.endRefreshing() - self?.navigationItem.title = "General" + self?.changedChannelName?("General") } - } } @@ -245,7 +249,7 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost var isBannerVisible: Bool = false - override func scrollViewDidScroll(_ scrollView: UIScrollView) { + func scrollViewDidScroll(_ scrollView: UIScrollView) { print(scrollView.contentOffset.y) if scrollView.contentOffset.y >= 50 && !isBannerVisible{ isBannerVisible = true diff --git a/GDproject/Controller/Coordinator tab bar?/TabbarCoordinator.swift b/GDproject/Controller/Coordinator tab bar?/TabbarCoordinator.swift deleted file mode 100644 index c4b7dba..0000000 --- a/GDproject/Controller/Coordinator tab bar?/TabbarCoordinator.swift +++ /dev/null @@ -1,14 +0,0 @@ -import UIKit - -class TabbarCoordinator{ - var window: UIWindow! - - func start(){ - let tabbar = UIStoryboard.tabBarController() - window.rootViewController = tabbar - } - - init(window: UIWindow) { - self.window = window - } -} diff --git a/GDproject/Controller/Coordinators/ChannelsCoordinator.swift b/GDproject/Controller/Coordinators/ChannelsCoordinator.swift index ad5b114..710cc3b 100644 --- a/GDproject/Controller/Coordinators/ChannelsCoordinator.swift +++ b/GDproject/Controller/Coordinators/ChannelsCoordinator.swift @@ -8,6 +8,7 @@ import Foundation import UIKit +import Pulley class ChannelsCoordinator: BaseCoordinator{ private weak var navigationController: UINavigationController? @@ -22,7 +23,20 @@ class ChannelsCoordinator: BaseCoordinator{ private func show() { let storyboard = UIStoryboard(name: "Main", bundle: nil) + let channels = storyboard.instantiateViewController(withIdentifier: channelListControllerId) as! ChannelListController - navigationController?.setViewControllers([channels], animated: false) + + let mainContentVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: newsController) as! NewsController + + let drawerContentVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DrawerContentViewController") + + let pulleyDrawerVC = PulleyViewController(contentViewController: mainContentVC, drawerViewController: drawerContentVC) + + pulleyDrawerVC.initialDrawerPosition = .collapsed + mainContentVC.changedChannelName = { + [weak pulleyDrawerVC] (title) in pulleyDrawerVC?.navigationItem.title = title + } + + navigationController?.setViewControllers([channels,pulleyDrawerVC], animated: false) } }