Updated the Review model in the Feed framework to include the Rating struct.
This commit is contained in:
parent
22a48e1888
commit
908ca1d4c9
@ -1,5 +1,5 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// Review.swift
|
||||
// ReviewsFeed
|
||||
//
|
||||
// Created by Dmitrii Ivanov on 21/07/2020.
|
||||
@ -9,18 +9,30 @@
|
||||
import Foundation
|
||||
|
||||
struct Review {
|
||||
let author: String
|
||||
let version: String
|
||||
let rating: Int
|
||||
let title: String
|
||||
let id: String
|
||||
let content: String
|
||||
|
||||
// MARK: Constants
|
||||
let author: String
|
||||
let comment: String
|
||||
let id: Int
|
||||
let rating: Rating
|
||||
let title: String
|
||||
|
||||
func ratingVersionText() -> String {
|
||||
var stars = ""
|
||||
for _ in 0..<rating {
|
||||
for _ in 0..<rating.stars {
|
||||
stars += "⭐️"
|
||||
}
|
||||
return "\(stars) (ver: \(version))"
|
||||
return "\(stars) (ver: \(rating.appVersion))"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Structs
|
||||
extension Review {
|
||||
struct Rating {
|
||||
|
||||
// MARK: Constants
|
||||
let stars: Int
|
||||
let appVersion: String
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class ReviewCell: UITableViewCell {
|
||||
ratingVersionLabel.text = item.ratingVersionText()
|
||||
authorLabel.text = "from: \(item.author)"
|
||||
titleLabel.text = "\(item.title)"
|
||||
textPreviewLabel.text = "\(item.content)"
|
||||
textPreviewLabel.text = "\(item.comment)"
|
||||
}
|
||||
|
||||
private func setupLabels() {
|
||||
|
@ -53,7 +53,7 @@ class DetailsViewController: UIViewController {
|
||||
titleLabel.numberOfLines = 0
|
||||
titleLabel.font = UIFont.boldSystemFont(ofSize: 22)
|
||||
|
||||
contentLabel.text = review.content
|
||||
contentLabel.text = review.comment
|
||||
contentLabel.numberOfLines = 0
|
||||
|
||||
ratingVersionLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 8).isActive = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user