git.iko.soy/dashared/GDproject
on master help sign in
styling of posts and channels improved. added general non-editable channel
478c049Darya Rednikina
GDproject/Base.lproj/Main.storyboard+21−32
@@ -11,37 +11,6 @@
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− <!--News Controller-->
15− <scene sceneID="tne-QT-ifu">
16− <objects>
17− <viewController storyboardIdentifier="NewsController" id="BYZ-38-t0r" customClass="NewsController" customModule="GDproject" customModuleProvider="target" sceneMemberID="viewController">
18− <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
19− <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
20− <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
21− <subviews>
22− <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="bdn-EE-6KU">
23− <rect key="frame" x="0.0" y="116" width="375" height="502"/>
24− <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
25− </tableView>
26− </subviews>
27− <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
28− <constraints>
29− <constraint firstItem="bdn-EE-6KU" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="Mwc-qc-ZfA"/>
30− <constraint firstItem="bdn-EE-6KU" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="dww-F7-g9y"/>
31− <constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="bdn-EE-6KU" secondAttribute="trailing" id="wlT-ZO-QGd"/>
32− <constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="bdn-EE-6KU" secondAttribute="bottom" id="yXX-zW-vb8"/>
33− </constraints>
34− <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
35− </view>
36− <navigationItem key="navigationItem" largeTitleDisplayMode="always" id="caN-kg-RZ4"/>
37− <connections>
38− <outlet property="tableView" destination="bdn-EE-6KU" id="O4Z-at-Hzw"/>
39− </connections>
40− </viewController>
41− <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
42− </objects>
43− <point key="canvasLocation" x="2015.2" y="132.68365817091455"/>
44− </scene>
45 <!--Profile View Controller-->
14 <!--Profile View Controller-->
46 <scene sceneID="rQ6-TM-V7T">
15 <scene sceneID="rQ6-TM-V7T">
47 <objects>
16 <objects>
@@ -447,13 +416,33 @@
447 </navigationBar>
416 </navigationBar>
448 <nil name="viewControllers"/>
417 <nil name="viewControllers"/>
449 <connections>
418 <connections>
450− <segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="ehh-1b-ZGK"/>
419+ <segue destination="Nqc-TI-ueQ" kind="relationship" relationship="rootViewController" id="2BZ-i4-uIE"/>
451 </connections>
420 </connections>
452 </navigationController>
421 </navigationController>
453 <placeholder placeholderIdentifier="IBFirstResponder" id="POV-5T-jeQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
422 <placeholder placeholderIdentifier="IBFirstResponder" id="POV-5T-jeQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
454 </objects>
423 </objects>
455 <point key="canvasLocation" x="1088.8" y="132.68365817091455"/>
424 <point key="canvasLocation" x="1088.8" y="132.68365817091455"/>
456 </scene>
425 </scene>
426+ <!--News Controller-->
427+ <scene sceneID="eR7-97-LRL">
428+ <objects>
429+ <tableViewController storyboardIdentifier="NewsController" id="Nqc-TI-ueQ" customClass="NewsController" customModule="GDproject" customModuleProvider="target" sceneMemberID="viewController">
430+ <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="hwA-SE-xpS">
431+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
432+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
433+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
434+ <color key="sectionIndexBackgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
435+ <connections>
436+ <outlet property="dataSource" destination="Nqc-TI-ueQ" id="bu5-tQ-7lb"/>
437+ <outlet property="delegate" destination="Nqc-TI-ueQ" id="kTM-Be-8qb"/>
438+ </connections>
439+ </tableView>
440+ <navigationItem key="navigationItem" id="b8E-6f-hLM"/>
441+ </tableViewController>
442+ <placeholder placeholderIdentifier="IBFirstResponder" id="c9d-Kh-itI" userLabel="First Responder" sceneMemberID="firstResponder"/>
443+ </objects>
444+ <point key="canvasLocation" x="1880" y="136"/>
445+ </scene>
457 <!--Profile-->
446 <!--Profile-->
458 <scene sceneID="dJj-Hp-Wa9">
447 <scene sceneID="dJj-Hp-Wa9">
459 <objects>
448 <objects>
GDproject/Controller/ News and channels/ChannelListController.swift+8−3
@@ -19,9 +19,8 @@ class ChannelListController: UITableViewController, DataDelegate {
19 // MARK:- filter search controller
19 // MARK:- filter search controller
20
20
21 var filteredDataSource = [Channel]()
21 var filteredDataSource = [Channel]()
22− var myProtocol: DataDelegate?
23
22
24− var generalChannel: Channel = Channel(title: "General", subtitle: "All posts", hashtags: ["All"], people: ["All"], posts: [])
23+ var myProtocol: DataDelegate?
25
24
26 var isFiltering: Bool {
25 var isFiltering: Bool {
27 return searchController.isActive && !searchBarIsEmpty()
26 return searchController.isActive && !searchBarIsEmpty()
@@ -85,6 +84,7 @@ class ChannelListController: UITableViewController, DataDelegate {
85 }
84 }
86
85
87 static var dataSource : [Channel] = [
86 static var dataSource : [Channel] = [
87+ Channel(title: "General", subtitle: "All posts", hashtags: ["All"], people: ["All"], posts: []),
88 Channel(title: "Title", subtitle: "subtitle", hashtags: ["# sad", "# happy"], people: ["Seva", "Andrey"], posts: [Post(dataArray: [.text("Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard.")], from: User(name: "vbogomazova", id: 2, fullName: "Богомазова Вероника Львовна"), date: "14.02.19 в 12:05")]),
88 Channel(title: "Title", subtitle: "subtitle", hashtags: ["# sad", "# happy"], people: ["Seva", "Andrey"], posts: [Post(dataArray: [.text("Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard.")], from: User(name: "vbogomazova", id: 2, fullName: "Богомазова Вероника Львовна"), date: "14.02.19 в 12:05")]),
89 Channel(title: "Title2", subtitle: "subtitle2", hashtags: ["# studyhard", "# university"], people: ["Pasha", "Olya", "Andrey", "Ilya"], posts:
89 Channel(title: "Title2", subtitle: "subtitle2", hashtags: ["# studyhard", "# university"], people: ["Pasha", "Olya", "Andrey", "Ilya"], posts:
90 [
90 [
@@ -121,7 +121,12 @@ class ChannelListController: UITableViewController, DataDelegate {
121
121
122
122
123 override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
123 override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
124+ switch indexPath.row {
125+ case 0:
126+ return false
127+ default:
124− return true
128+ return true
129+ }
125 }
130 }
126
131
127 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
132 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
GDproject/Controller/ News and channels/NewsController.swift+49−15
@@ -17,12 +17,17 @@ protocol NewPostDelegate {
17
17
18// MARK:- Controller with posts and channels availiable.
18// MARK:- Controller with posts and channels availiable.
19// Search is availiable within every table (posts and channels). Has button-functionality for boths post and chnnels
19// Search is availiable within every table (posts and channels). Has button-functionality for boths post and chnnels
20−class NewsController: UIViewController, UISearchControllerDelegate, UITableViewDelegate, UITableViewDataSource, DataDelegate, NewPostDelegate
20+class NewsController: UITableViewController, UISearchControllerDelegate, DataDelegate, NewPostDelegate
21{
21{
22+ var currentChannel: Channel?{
23+ didSet{
24+ news.dataSourse = currentChannel?.posts ?? []
25+ navigationItem.title = currentChannel?.title ?? ""
26+ }
27+ }
22
28
23 func passData(for row: Int, channel: Channel) {
29 func passData(for row: Int, channel: Channel) {
24− news.dataSourse = channel.posts
30+ currentChannel = channel
25− navigationItem.title = channel.title
26 }
31 }
27
32
28 func addPost(post: Post) {
33 func addPost(post: Post) {
@@ -31,12 +36,12 @@ class NewsController: UIViewController, UISearchControllerDelegate, UITableViewD
31
36
32 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"]
37 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"]
33
38
34− func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
39+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
35 return array.count
40 return array.count
36 }
41 }
37
42
38
43
39− func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
44+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
40 let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
45 let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
41
46
42 cell.textLabel?.text = array[indexPath.row]
47 cell.textLabel?.text = array[indexPath.row]
@@ -55,24 +60,31 @@ class NewsController: UIViewController, UISearchControllerDelegate, UITableViewD
55 dismissTable()
60 dismissTable()
56 }
61 }
57
62
58− @IBOutlet weak var tableView: UITableView!
63+ //@IBOutlet weak var tableView: UITableView!
59
64
60 var searchController = UISearchController(searchResultsController: nil)
65 var searchController = UISearchController(searchResultsController: nil)
61−
66+
62− var dataSourse: [Post] = [Post(dataArray: [.text("Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen de polices de texte. Il n'a pas fait que survivre cinq siècles, mais s'est aussi adapté à la bureautique informatique, sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la vente de feuilles Letraset contenant des passages du Lorem Ipsum, et, plus récemment, par son inclusion dans des applications de mise en page de texte, comme Aldus PageMaker. \n On sait depuis longtemps que travailler avec du texte lisible et contenant du sens est source de distractions, et empêche de se concentrer sur la mise en page elle-même. L'avantage du Lorem Ipsum sur un texte générique comme 'Du texte. Du texte. Du texte.' est qu'il possède une distribution de lettres plus ou moins normale, et en tout cas comparable avec celle du français standard. De nombreuses suites logicielles de mise en page ou éditeurs de sites Web ont fait du Lorem Ipsum leur faux texte par défaut, et une recherche pour 'Lorem Ipsum' vous conduira vers de nombreux sites qui n'en sont encore qu'à leur phase de construction. Plusieurs versions sont apparues avec le temps, parfois par accident, souvent intentionnellement (histoire d'y rajouter de petits clins d'oeil, voire des phrases embarassantes).")], from: User(name: "vbogomazova", id: 2, fullName: "Богомазова Вероника Львовна"), date: "14.02.19 в 12:05")]
63
67
64 var news = NewsVC()
68 var news = NewsVC()
65
69
66 override func viewDidLoad()
70 override func viewDidLoad()
67 {
71 {
68 super.viewDidLoad()
72 super.viewDidLoad()
73+
74+ //view.backgroundColor = .white
75+ currentChannel = ChannelListController.dataSource[0]
76+
77+ view.addSubview(label)
78+ //label.horizontalToSuperview(insets: .left(30) + .right(30))
79+ //label.verticalToSuperview()
80+
69 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
81 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
70 tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
82 tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
71
83
72 searchController.delegate = self
84 searchController.delegate = self
73 searchController.obscuresBackgroundDuringPresentation = false
85 searchController.obscuresBackgroundDuringPresentation = false
74
86
75− news.dataSourse = dataSourse
87+ news.dataSourse = currentChannel!.posts
76 news.viewController = self
88 news.viewController = self
77
89
78
90
@@ -80,7 +92,7 @@ class NewsController: UIViewController, UISearchControllerDelegate, UITableViewD
80 tableView.dataSource = news
92 tableView.dataSource = news
81 tableView.reloadData()
93 tableView.reloadData()
82
94
83− news.type = .NEWS
95+ news.type = .NONE
84
96
85 setUpNavigationItemsforPosts()
97 setUpNavigationItemsforPosts()
86 searchController.searchBar.placeholder = "Search anything"
98 searchController.searchBar.placeholder = "Search anything"
@@ -137,22 +149,44 @@ class NewsController: UIViewController, UISearchControllerDelegate, UITableViewD
137 self.facultyTableView.isHidden = true
149 self.facultyTableView.isHidden = true
138 }
150 }
139
151
152+ let label : UILabel = {
153+ let label = UILabel()
154+ label.text = "No posts to display yet!"
155+ label.font = UIFont.systemFont(ofSize: 18)
156+ label.textColor = .black
157+ label.isHidden = true
158+ label.numberOfLines = 0
159+ return label
160+ }()
161+
140 override func viewWillAppear(_ animated: Bool) {
162 override func viewWillAppear(_ animated: Bool) {
141 super.viewWillAppear(animated)
163 super.viewWillAppear(animated)
142 print("hello")
164 print("hello")
143 navigationController?.navigationBar.prefersLargeTitles = true
165 navigationController?.navigationBar.prefersLargeTitles = true
166+ if currentChannel!.posts.isEmpty {
167+ //tableView.isHidden = true
168+ label.isHidden = false
169+ } else {
170+ label.isHidden = true
171+ tableView.isHidden = false
144− tableView.reloadData()
172+ tableView.reloadData()
173+ }
145 }
174 }
146
175
147 func setUpNavigationItemsforPosts(){
176 func setUpNavigationItemsforPosts(){
148− navigationItem.title = "Posts"
177+ navigationItem.rightBarButtonItems = [
149− navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(self.writePost(_:)))]
178+ UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(self.writePost(_:))),
179+ UIBarButtonItem(barButtonSystemItem: .search, target: self, action: #selector(self.showChannels(_:)))]
150 tableView.delegate = news
180 tableView.delegate = news
151 tableView.dataSource = news
181 tableView.dataSource = news
152 tableView.reloadData()
182 tableView.reloadData()
153 }
183 }
154
184
155−
185+ @objc func showChannels(_ barItem: UIBarButtonItem){
186+ let vc = storyboard!.instantiateViewController(withIdentifier: channelListControllerId) as! ChannelListController
187+ vc.myProtocol = self
188+ self.navigationController!.pushViewController(vc, animated: true)
189+ }
156
190
157 @objc func writePost(_ barItem: UIBarButtonItem)
191 @objc func writePost(_ barItem: UIBarButtonItem)
158 {
192 {
@@ -231,7 +265,7 @@ class NewsController: UIViewController, UISearchControllerDelegate, UITableViewD
231
265
232 var isBannerVisible: Bool = false
266 var isBannerVisible: Bool = false
233
267
234− func scrollViewDidScroll(_ scrollView: UIScrollView) {
268+ override func scrollViewDidScroll(_ scrollView: UIScrollView) {
235 print(scrollView.contentOffset.y)
269 print(scrollView.contentOffset.y)
236 if scrollView.contentOffset.y >= 50 && !isBannerVisible{
270 if scrollView.contentOffset.y >= 50 && !isBannerVisible{
237 isBannerVisible = true
271 isBannerVisible = true
GDproject/Controller/ News and channels/NewsVC.swift+1−6
@@ -17,12 +17,7 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
17 var viewController: UIViewController?
17 var viewController: UIViewController?
18
18
19 func numberOfSections(in tableView: UITableView) -> Int {
19 func numberOfSections(in tableView: UITableView) -> Int {
20− switch type {
21− case .NONE:
22− return 1
23− default:
24− return 2
20+ return 2
25− }
26 }
21 }
27
22
28 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
23 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)