mirror of
https://github.com/dashared/GDproject.git
synced 2024-11-25 11:43:58 +03:00
fixed news feed updates. added time for posts. have to detect correct time zone
This commit is contained in:
parent
1400778675
commit
78a2ade5f9
@ -37,12 +37,14 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
|
||||
})
|
||||
|
||||
news.dataSourse = newPosts
|
||||
print("and heeeere in dict")
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
var channel: Channel?{
|
||||
didSet{
|
||||
print(channel!.posts.count)
|
||||
navigationItem.title = channel?.title ?? ""
|
||||
}
|
||||
}
|
||||
@ -90,6 +92,7 @@ class NewsController: UITableViewController, UISearchControllerDelegate, NewPost
|
||||
}
|
||||
|
||||
@objc func refreshPostsData( _ ff: UIRefreshControl){
|
||||
print("I am here")
|
||||
Model.getLast { [weak self] (tuple) in
|
||||
self?.channel = tuple.channel
|
||||
self?.dictionary = tuple.users
|
||||
|
@ -29,6 +29,7 @@ class NewsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
|
||||
|
||||
var dataSourse: [Model.Posts] = []{
|
||||
didSet{
|
||||
cellDataSourse = []
|
||||
dataSourse.forEach { (item) in
|
||||
cellDataSourse.append(PostCellData(attributedData: PostCellData.create(with: item.body)))
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class PostViewCell: UITableViewCell
|
||||
return label
|
||||
}()
|
||||
|
||||
let commentsLabel: UILabel = {
|
||||
let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = UIFont.systemFont(ofSize: 12)
|
||||
label.textColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1)
|
||||
@ -84,6 +84,7 @@ class PostViewCell: UITableViewCell
|
||||
nameLabel.setTitle("\(post.user?.firstName ?? "") \(post.user?.lastName ?? "")", for: .normal)
|
||||
nameLabel.addTarget(self, action: #selector(displayProfile), for: .touchUpInside)
|
||||
fullNameLabel.text = "\(post.authorId)"
|
||||
|
||||
setUpInStackView(isFullVersoin)
|
||||
}
|
||||
|
||||
@ -151,10 +152,11 @@ class PostViewCell: UITableViewCell
|
||||
|
||||
stackView.edgesToSuperview(excluding: [.top, .bottom], insets: .left(16) + .right(16))
|
||||
|
||||
let commentsSharesStackView = UIStackView(arrangedSubviews: [ commentsLabel, shareButton])
|
||||
let commentsSharesStackView = UIStackView(arrangedSubviews: [ timeLabel, shareButton])
|
||||
contentView.addSubview(commentsSharesStackView)
|
||||
|
||||
commentsLabel.text = "14.02.19 в 23:00"
|
||||
timeLabel.text = post!.convertDateFormatter()
|
||||
|
||||
commentsSharesStackView.axis = .horizontal
|
||||
commentsSharesStackView.distribution = .equalSpacing
|
||||
commentsSharesStackView.edgesToSuperview(excluding: .top, insets: .bottom(10) + .left(16) + .right(16))
|
||||
|
@ -56,6 +56,21 @@ class Model{
|
||||
self.user = user
|
||||
self.updated = date
|
||||
}
|
||||
|
||||
func convertDateFormatter() -> String
|
||||
{
|
||||
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"//this your string date format
|
||||
dateFormatter.timeZone = NSTimeZone(name: "UTC") as TimeZone!
|
||||
let date = dateFormatter.date(from: updated)
|
||||
|
||||
dateFormatter.dateFormat = "MMM d, yyyy HH:mm" ///this is what you want to convert format
|
||||
dateFormatter.timeZone = NSTimeZone(name: "UTC") as TimeZone!
|
||||
let timeStamp = dateFormatter.string(from: date!)
|
||||
|
||||
return timeStamp
|
||||
}
|
||||
}
|
||||
|
||||
struct Users: Codable{
|
||||
|
Loading…
Reference in New Issue
Block a user