git.iko.soy/dashared/GDproject
on master help sign in
resolved: #11. minor changes
commitf925c61c768a166bc4d9447530fadf55804cdf15 authorDarya Rednikina <rednikina.com@yandex.ru> dateFri 15 Mar 2019, 11:07 (8 years ago) parentbba9114
3 files changed+18−7
GDproject/Controller/ News and channels/FullPostController.swift+10−4 GDproject/Controller/ News and channels/NewsVC.swift+2−2 GDproject/Controller/ News and channels/PostViewCell.swift+6−1
GDproject/Controller/ News and channels/FullPostController.swift+10−4
@@ -12,6 +12,7 @@ import TinyConstraints
1212class FullPostController: UITableViewController {
1313
1414 var post: Model.Posts?
15+ var type: HeaderType = .NONE
1516
1617 override func viewDidLoad() {
1718 super.viewDidLoad()
@@ -96,10 +97,15 @@ class FullPostController: UITableViewController {
9697
9798 cell.fill(with: PostCellData.create(with: post!.body), true, post: post!)
9899
99− cell.onUserDisplay = { [weak self] (id) in
100− let vc = self?.storyboard!.instantiateViewController(withIdentifier: profileViewController) as! ProfileViewController
101− vc.idProfile = id
102− self?.navigationController?.pushViewController(vc, animated: true)
100+ switch type {
101+ case .NEWS:
102+ cell.onUserDisplay = { [weak self] (id) in
103+ let vc = self?.storyboard!.instantiateViewController(withIdentifier: profileViewController) as! ProfileViewController
104+ vc.idProfile = id
105+ self?.navigationController?.pushViewController(vc, animated: true)
106+ }
107+ default:
108+ break
103109 }
104110
105111 cell.selectionStyle = .none
GDproject/Controller/ News and channels/NewsVC.swift+2−2
@@ -27,7 +27,7 @@ struct PostCellData{
2727
2828class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
2929
30− var dataSourse: [Model.Posts] = []{
30+ var dataSourse: [Model.Posts] = [] {
3131 didSet {
3232 cellDataSourse = []
3333 dataSourse.forEach { (item) in
@@ -50,7 +50,7 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
5050 {
5151 tableView.deselectRow(at: indexPath, animated: true)
5252 let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
53−
53+ vc.type = type
5454 vc.post = dataSourse[indexPath.row]
5555 viewController!.navigationController!.pushViewController(vc, animated: true)
5656 }
GDproject/Controller/ News and channels/PostViewCell.swift+6−1
@@ -83,7 +83,12 @@ class PostViewCell: UITableViewCell
8383
8484 nameLabel.setTitle("\(post.user?.firstName ?? "") \(post.user?.lastName ?? "")", for: .normal)
8585 nameLabel.addTarget(self, action: #selector(displayProfile), for: .touchUpInside)
86− fullNameLabel.text = "\(post.authorId)"
86+ if let user = post.user{
87+ fullNameLabel.text = "\(user.firstName) \(user.middleName) \(user.lastName)"
88+ }
89+ else {
90+ fullNameLabel.text = "\(post.authorId)"
91+ }
8792
8893 setUpInStackView(isFullVersoin)
8994 }