git.iko.soy/dashared/GDproject
on master help sign in
changed concept of channels. needs great modifications
commite6e94ee74951dbedd6696ab518f8b639dfac4432 authorDarya Rednikina <rednikina.com@yandex.ru> dateTue 19 Feb 2019, 15:36 (8 years ago) parent3a24fe0
6 files changed+132−155
GDproject.xcodeproj/project.pbxproj−9 GDproject/Controller/News/ChannelsController.swift−35 GDproject/Controller/News/HeaderNewsChannels.swift−54 GDproject/Controller/News/NewsController.swift+82−12 GDproject/Controller/News/NewsVC.swift+48−42 GDproject/Controller/ProfileViewController.swift+2−3
GDproject.xcodeproj/project.pbxproj−9
@@ -29,8 +29,6 @@
2929 12E36DC0221441DB006FCDD7 /* Marklight.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12E36DB222143D4E006FCDD7 /* Marklight.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3030 12E36DC2221441E1006FCDD7 /* MarkdownKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12E36DB022143D47006FCDD7 /* MarkdownKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3131 12E36DC4221441EA006FCDD7 /* Cartography.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 12E36DAE22143D40006FCDD7 /* Cartography.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
32− 12E36DC622144266006FCDD7 /* HeaderNewsChannels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36DC522144266006FCDD7 /* HeaderNewsChannels.swift */; };
33− 12E36DC822144374006FCDD7 /* ChannelsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36DC722144374006FCDD7 /* ChannelsController.swift */; };
3432 12E36DCA22144635006FCDD7 /* NewPostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36DC922144635006FCDD7 /* NewPostViewController.swift */; };
3533 12E36DCC22144725006FCDD7 /* PostViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36DCB22144725006FCDD7 /* PostViewCell.swift */; };
3634 12E36DCE22144756006FCDD7 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12E36DCD22144756006FCDD7 /* Constants.swift */; };
@@ -81,8 +79,6 @@
8179 12E36DB422143D54006FCDD7 /* TinyConstraints.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TinyConstraints.framework; path = Carthage/Build/iOS/TinyConstraints.framework; sourceTree = "<group>"; };
8280 12E36DB62214400A006FCDD7 /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
8381 12E36DB822144016006FCDD7 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
84− 12E36DC522144266006FCDD7 /* HeaderNewsChannels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderNewsChannels.swift; sourceTree = "<group>"; };
85− 12E36DC722144374006FCDD7 /* ChannelsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelsController.swift; sourceTree = "<group>"; };
8682 12E36DC922144635006FCDD7 /* NewPostViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewPostViewController.swift; sourceTree = "<group>"; };
8783 12E36DCB22144725006FCDD7 /* PostViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostViewCell.swift; sourceTree = "<group>"; };
8884 12E36DCD22144756006FCDD7 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
@@ -182,8 +178,6 @@
182178 children = (
183179 12E36DC922144635006FCDD7 /* NewPostViewController.swift */,
184180 12E36DD022148122006FCDD7 /* FullPostController.swift */,
185− 12E36DC522144266006FCDD7 /* HeaderNewsChannels.swift */,
186− 12E36DC722144374006FCDD7 /* ChannelsController.swift */,
187181 12E36D9D221424EA006FCDD7 /* NewsController.swift */,
188182 125BD5802217314A008A3575 /* NewsVC.swift */,
189183 12E36DCB22144725006FCDD7 /* PostViewCell.swift */,
@@ -271,14 +265,12 @@
271265 buildActionMask = 2147483647;
272266 files = (
273267 12E36DD522156559006FCDD7 /* MyStackView.swift in Sources */,
274− 12E36DC822144374006FCDD7 /* ChannelsController.swift in Sources */,
275268 12E36DB922144016006FCDD7 /* User.swift in Sources */,
276269 125BD5812217314A008A3575 /* NewsVC.swift in Sources */,
277270 12E36DB72214400A006FCDD7 /* Post.swift in Sources */,
278271 12DB7FDF221877160096878E /* InviteViewController.swift in Sources */,
279272 12E36DCA22144635006FCDD7 /* NewPostViewController.swift in Sources */,
280273 12E36D9E221424EA006FCDD7 /* NewsController.swift in Sources */,
281− 12E36DC622144266006FCDD7 /* HeaderNewsChannels.swift in Sources */,
282274 12E36DCC22144725006FCDD7 /* PostViewCell.swift in Sources */,
283275 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
284276 12E36DD122148122006FCDD7 /* FullPostController.swift in Sources */,
@@ -289,7 +281,6 @@
289281 12DB7FD722181CD20096878E /* BasicInfoController.swift in Sources */,
290282 12E36DCE22144756006FCDD7 /* Constants.swift in Sources */,
291283 12DB7FDD221872F80096878E /* SettingsViewController.swift in Sources */,
292−
293284 );
294285 runOnlyForDeploymentPostprocessing = 0;
295286 };
GDproject/Controller/News/ChannelsController.swiftdeleted−35
@@ -1,35 +0,0 @@
1−//
2−// PostTable.swift
3−// GDproject
4−//
5−// Created by cstore on 13/02/2019.
6−// Copyright © 2019 drHSE. All rights reserved.
7−//
8−
9−import UIKit
10−
11−class ChannelsController: 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−}
GDproject/Controller/News/HeaderNewsChannels.swiftdeleted−54
@@ -1,54 +0,0 @@
1−//
2−// HeaderNewsChannels.swift
3−// GDproject
4−//
5−// Created by cstore on 13/02/2019.
6−// Copyright © 2019 drHSE. All rights reserved.
7−//
8−
9−import UIKit
10−import TinyConstraints
11−
12−class HeaderNewsChannels: UITableViewCell {
13−
14− weak var tableView: UITableView?
15−
16− weak var vc: NewsController?
17− weak var vcProfile: ProfileViewController?
18−
19−
20− override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
21− super.init(style: style, reuseIdentifier: reuseIdentifier)
22− backgroundColor = .white
23− setUpCell()
24− }
25−
26− required init?(coder aDecoder: NSCoder) {
27− super.init(coder: aDecoder)
28− }
29−
30− func setUpCell(){
31−
32− addSubview(postsChannelsSegment)
33− postsChannelsSegment.selectedSegmentIndex = 0
34− postsChannelsSegment.addTarget(self, action: #selector(changedValue), for: .valueChanged)
35− postsChannelsSegment.edgesToSuperview(insets: .left(16) + .right(16) + .top(8) + .bottom(8))
36− }
37−
38− // Initialize
39− var postsChannelsSegment: UISegmentedControl = UISegmentedControl(items: ["Posts", "Channels"])
40−
41− @objc func changedValue(_ sender: UISegmentedControl) {
42− let index = sender.selectedSegmentIndex
43−
44− switch index {
45− case 0:
46− vc?.setUpNavigationItemsforPosts()
47− case 1:
48− vc?.setUpNavigationItemsForChannels()
49− default:
50− break
51− }
52− }
53−}
54−
GDproject/Controller/News/NewsController.swift+82−12
@@ -8,11 +8,39 @@
88
99import UIKit
1010import TinyConstraints
11+import Cartography
1112
1213// MARK:- Controller with posts and channels availiable.
1314// Search is availiable within every table (posts and channels). Has button-functionality for boths post and chnnels
14−class NewsController: UIViewController
15+class NewsController: UIViewController, UISearchControllerDelegate, UITableViewDelegate, UITableViewDataSource
1516{
17+
18+
19+ 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"]
20+
21+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
22+ return array.count
23+ }
24+
25+
26+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
27+ let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
28+
29+ cell.textLabel?.text = array[indexPath.row]
30+ return cell
31+ }
32+
33+ func presentSearchController(_ searchController: UISearchController) {
34+ print("here")
35+ setUpTableView()
36+ displayTableView() //setup
37+ // this is 0.3
38+ animateTable(some: true)
39+ }
40+
41+ func willDismissSearchController(_ searchController: UISearchController) {
42+ dismissTable()
43+ }
1644
1745 @IBOutlet weak var tableView: UITableView!
1846
@@ -21,24 +49,25 @@ class NewsController: UIViewController
2149 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")]
2250
2351 var news = NewsVC()
24− var channels = ChannelsController()
2552
2653 override func viewDidLoad()
2754 {
2855 super.viewDidLoad()
29− tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
3056 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
57+ tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
58+
59+ //searchController.delegate = self
60+ searchController.obscuresBackgroundDuringPresentation = false
3161
3262 news.dataSourse = dataSourse
3363 news.viewController = self
3464
35− news.type = .NEWS("Posts", "Channels")
3665
3766 tableView.delegate = news
3867 tableView.dataSource = news
3968 tableView.reloadData()
4069
41−
70+ news.type = .NEWS
4271
4372 setUpNavigationItemsforPosts()
4473 searchController.searchBar.placeholder = "Search anything"
@@ -49,8 +78,55 @@ class NewsController: UIViewController
4978 setUpBanner()
5079 }
5180
81+
82+ var facultyTableView = UITableView()
83+
84+ func setUpTableView()
85+ {
86+ facultyTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
87+ facultyTableView.delegate = self
88+ facultyTableView.dataSource = self
89+ let screenSize: CGRect = UIScreen.main.bounds
90+
91+ let screenWidth = screenSize.width
92+ let screenHeight = screenSize.height
93+ facultyTableView.frame = CGRect(x: 0, y: 0, width: Int(screenWidth), height: Int(screenHeight))
94+ }
95+
96+ func displayTableView(){
97+
98+ // the most important line
99+ facultyTableView.translatesAutoresizingMaskIntoConstraints = false
100+ facultyTableView.backgroundColor = UIColor(white: 1, alpha: 1)
101+ view.addSubview(facultyTableView)
102+
103+ facultyTableView.isHidden = true
104+
105+ // now
106+ constrain(facultyTableView, view){
107+ tableView, view in
108+
109+ tableView.top == view.safeAreaLayoutGuide.top
110+ tableView.left == view.left
111+ tableView.right == view.right
112+ tableView.bottom == view.safeAreaLayoutGuide.bottom
113+ }
114+
115+ }
116+
117+ // animation of the table cells
118+ func animateTable(some: Bool){
119+ self.facultyTableView.reloadData()
120+ self.facultyTableView.isHidden = false
121+ }
122+
123+ func dismissTable() {
124+ self.facultyTableView.isHidden = true
125+ }
126+
52127 override func viewWillAppear(_ animated: Bool) {
53128 super.viewWillAppear(animated)
129+ print("hello")
54130 navigationController?.navigationBar.prefersLargeTitles = true
55131 }
56132
@@ -62,13 +138,7 @@ class NewsController: UIViewController
62138 tableView.reloadData()
63139 }
64140
65− func setUpNavigationItemsForChannels(){
66− navigationItem.title = "Channels"
67− navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addChannel))]
68− tableView.delegate = channels
69− tableView.dataSource = channels
70− tableView.reloadData()
71− }
141+ //navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addChannel))]
72142
73143 @objc func writePost(_ barItem: UIBarButtonItem)
74144 {
GDproject/Controller/News/NewsVC.swift+48−42
@@ -16,71 +16,77 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
1616
1717 var viewController: UIViewController?
1818
19+ func numberOfSections(in tableView: UITableView) -> Int {
20+ switch type {
21+ case .NONE:
22+ return 1
23+ default:
24+ return 2
25+ }
26+ }
27+
1928 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
2029 {
2130 tableView.deselectRow(at: indexPath, animated: true)
2231
23− let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
24−
25− vc.post = dataSourse[indexPath.row]
26− viewController!.navigationController!.pushViewController(vc, animated: true)
32+ if indexPath.section == 1 && type == .NEWS || type == .NONE {
33+ let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
34+
35+ vc.post = dataSourse[indexPath.row]
36+ viewController!.navigationController!.pushViewController(vc, animated: true)
37+ }
2738 }
2839
2940 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
30− return dataSourse.count
31− }
32−
33− func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
34− {
35− let cell = tableView.dequeueReusableCell(withIdentifier: postCellId, for: indexPath) as! PostViewCell
36−
37− cell.fill(with: dataSourse[indexPath.row].dataArray, false, post: dataSourse[indexPath.row])
38− cell.selectionStyle = .none
39− return cell
40− }
41−
42− func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
43− return UITableView.automaticDimension
44− }
45−
46− func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
47− return 100.0
48− }
49−
50− func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
5141 switch type {
5242 case .NONE:
53− return 0
43+ return dataSourse.count
5444 default:
55− return 46
45+ switch section {
46+ case 0:
47+ return 1
48+ default:
49+ return dataSourse.count
50+ }
5651 }
5752 }
5853
59− func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
54+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
6055 {
61− let cell = tableView.dequeueReusableCell(withIdentifier: headerNewsChannelsVC) as! HeaderNewsChannels
62−
63− cell.vc = viewController as? NewsController
64− cell.vcProfile = viewController as? ProfileViewController
65−
66− let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 46.0))
67− view.addSubview(cell)
68− cell.edgesToSuperview()
69−
7056 switch type {
7157 case .NONE:
72− return nil
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
7363 default:
74− return view
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+ }
7576 }
7677 }
7778
79+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
80+ return UITableView.automaticDimension
81+ }
82+
83+ func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
84+ return 100.0
85+ }
7886}
7987
8088
8189enum HeaderType {
8290 case NONE
83− case NEWS(String, String)
84− case PROFILE(String, String)
85− case BASIC_INFO(String, String)
91+ case NEWS
8692}
GDproject/Controller/ProfileViewController.swift+2−3
@@ -48,15 +48,14 @@ class ProfileViewController: UIViewController
4848 {
4949 super.viewDidLoad()
5050
51− posts.type = .NONE
52−
5351 posts.dataSourse = [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. comme Aldus PageMaker. 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).")]), Post(dataArray: [.text("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. .")])]
5452
5553 // basicInfo.dataSourse =
5654
5755 posts.viewController = self
56+ posts.type = .NONE
5857
59− tableView.register(HeaderNewsChannels.self, forCellReuseIdentifier: headerNewsChannelsVC)
58+ tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
6059
6160 tableView.register(PostViewCell.self, forCellReuseIdentifier: postCellId)
6261