git.iko.soy/dashared/GDproject
on master help sign in
resolved: #11. minor changes
f925c61Darya Rednikina
GDproject/Controller/ News and channels/FullPostController.swift+10−4
@@ -12,6 +12,7 @@ import TinyConstraints
12class FullPostController: UITableViewController {
12class FullPostController: UITableViewController {
13
13
14 var post: Model.Posts?
14 var post: Model.Posts?
15+ var type: HeaderType = .NONE
15
16
16 override func viewDidLoad() {
17 override func viewDidLoad() {
17 super.viewDidLoad()
18 super.viewDidLoad()
@@ -96,10 +97,15 @@ class FullPostController: UITableViewController {
96
97
97 cell.fill(with: PostCellData.create(with: post!.body), true, post: post!)
98 cell.fill(with: PostCellData.create(with: post!.body), true, post: post!)
98
99
100+ switch type {
101+ case .NEWS:
99− cell.onUserDisplay = { [weak self] (id) in
102+ cell.onUserDisplay = { [weak self] (id) in
100− let vc = self?.storyboard!.instantiateViewController(withIdentifier: profileViewController) as! ProfileViewController
103+ let vc = self?.storyboard!.instantiateViewController(withIdentifier: profileViewController) as! ProfileViewController
101− vc.idProfile = id
104+ vc.idProfile = id
102− self?.navigationController?.pushViewController(vc, animated: true)
105+ self?.navigationController?.pushViewController(vc, animated: true)
106+ }
107+ default:
108+ break
103 }
109 }
104
110
105 cell.selectionStyle = .none
111 cell.selectionStyle = .none
GDproject/Controller/ News and channels/NewsVC.swift+2−2
@@ -27,7 +27,7 @@ struct PostCellData{
27
27
28class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
28class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
29
29
30− var dataSourse: [Model.Posts] = []{
30+ var dataSourse: [Model.Posts] = [] {
31 didSet {
31 didSet {
32 cellDataSourse = []
32 cellDataSourse = []
33 dataSourse.forEach { (item) in
33 dataSourse.forEach { (item) in
@@ -50,7 +50,7 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
50 {
50 {
51 tableView.deselectRow(at: indexPath, animated: true)
51 tableView.deselectRow(at: indexPath, animated: true)
52 let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
52 let vc = viewController!.storyboard!.instantiateViewController(withIdentifier: fullPostControllerId) as! FullPostController
53−
53+ vc.type = type
54 vc.post = dataSourse[indexPath.row]
54 vc.post = dataSourse[indexPath.row]
55 viewController!.navigationController!.pushViewController(vc, animated: true)
55 viewController!.navigationController!.pushViewController(vc, animated: true)
56 }
56 }
GDproject/Controller/ News and channels/PostViewCell.swift+6−1
@@ -83,7 +83,12 @@ class PostViewCell: UITableViewCell
83
83
84 nameLabel.setTitle("\(post.user?.firstName ?? "") \(post.user?.lastName ?? "")", for: .normal)
84 nameLabel.setTitle("\(post.user?.firstName ?? "") \(post.user?.lastName ?? "")", for: .normal)
85 nameLabel.addTarget(self, action: #selector(displayProfile), for: .touchUpInside)
85 nameLabel.addTarget(self, action: #selector(displayProfile), for: .touchUpInside)
86+ if let user = post.user{
87+ fullNameLabel.text = "\(user.firstName) \(user.middleName) \(user.lastName)"
88+ }
89+ else {
86− fullNameLabel.text = "\(post.authorId)"
90+ fullNameLabel.text = "\(post.authorId)"
91+ }
87
92
88 setUpInStackView(isFullVersoin)
93 setUpInStackView(isFullVersoin)
89 }
94 }