89 lines
2.0 KiB
Swift
89 lines
2.0 KiB
Swift
//
|
|
// FeedItemCell.swift
|
|
// ReviewsFeed
|
|
//
|
|
// Created by Javier Cicchelli on 19/03/2024.
|
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import ReviewsUIKit
|
|
import SwiftUI
|
|
|
|
struct FeedItemCell: 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
|
|
) {
|
|
HStack(
|
|
alignment: .bottom,
|
|
spacing: 8
|
|
) {
|
|
Image(systemName: "person.crop.circle")
|
|
|
|
Text(item.author)
|
|
.font(.subheadline)
|
|
}
|
|
|
|
VStack(spacing: 8) {
|
|
Text(item.title)
|
|
.font(.headline)
|
|
.lineLimit(2)
|
|
.fullWidth()
|
|
|
|
Text(item.comment)
|
|
.font(.body)
|
|
.lineLimit(4)
|
|
.fullWidth()
|
|
}
|
|
.multilineTextAlignment(.leading)
|
|
|
|
HStack(alignment: .bottom) {
|
|
StarRating(
|
|
item.rating.stars,
|
|
of: .Rating.total
|
|
)
|
|
|
|
Spacer()
|
|
|
|
HStack(
|
|
alignment: .bottom,
|
|
spacing: 4
|
|
) {
|
|
Text(item.rating.appVersion)
|
|
|
|
Image(systemName: "iphone.gen3.circle")
|
|
}
|
|
}
|
|
.font(.subheadline)
|
|
}
|
|
.padding(.vertical, 8)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Previews
|
|
#Preview("Feed Item Cell") {
|
|
FeedItemCell(.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)
|
|
}
|