This PR contains the work done to show the top 3 words belonging to the filtered reviews in the `FeedListViewController` view controller. Reviewed-on: #12 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
82 lines
1.8 KiB
Swift
82 lines
1.8 KiB
Swift
//
|
|
// FeedItemView.swift
|
|
// ReviewsFeed
|
|
//
|
|
// Created by Javier Cicchelli on 19/03/2024.
|
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import ReviewsUIKit
|
|
import SwiftUI
|
|
|
|
struct FeedItemView: View {
|
|
|
|
// MARK: Constants
|
|
private let item: Review
|
|
|
|
// MARK: Initialisers
|
|
init(_ item: Review) {
|
|
self.item = item
|
|
}
|
|
|
|
// MARK: Body
|
|
var body: some View {
|
|
VStack(
|
|
alignment: .leading,
|
|
spacing: 16
|
|
) {
|
|
FakeLabel(
|
|
systemIcon: .Icon.person,
|
|
title: item.author
|
|
)
|
|
.foregroundColor(.secondary)
|
|
|
|
VStack(spacing: 8) {
|
|
Text(item.title)
|
|
.font(.headline)
|
|
.lineLimit(2)
|
|
.fullWidth()
|
|
|
|
Text(item.comment)
|
|
.font(.body)
|
|
.lineLimit(4)
|
|
.fullWidth()
|
|
}
|
|
.multilineTextAlignment(.leading)
|
|
|
|
HStack(
|
|
alignment: .center,
|
|
spacing: 32
|
|
) {
|
|
StarRating(
|
|
item.rating.stars,
|
|
of: .Rating.total
|
|
)
|
|
|
|
FakeLabel(
|
|
systemIcon: .Icon.info,
|
|
title: item.rating.appVersion
|
|
)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
}
|
|
.padding(.vertical, 8)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Previews
|
|
#Preview("Feed Item") {
|
|
FeedItemView(.init(
|
|
author: "Some author name here...",
|
|
comment: "Some review comment here...",
|
|
id: 0,
|
|
rating: .init(
|
|
stars: 1,
|
|
appVersion: "v1.2.3"
|
|
),
|
|
title: "Some review title here..."
|
|
))
|
|
.padding(.horizontal)
|
|
}
|