[Framework] Feed list view in the Feed framework (#9)
This PR contains the work done to provide the existing `FeedViewController` view controller with real life data by integrating the `iTunesService` service into its view model. In addition, the list item cell has been design has been updated, and re-implemented using the `SwiftUI` framework. Reviewed-on: rock-n-code/app-reviews#9 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #9.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// FeedItem.swift
|
||||
// ReviewsFeed
|
||||
//
|
||||
// Created by Javier Cicchelli on 19/03/2024.
|
||||
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct FeedItem: 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) {
|
||||
ForEach(1...5, id: \.self) { index in
|
||||
if #available(iOS 15.0, *) {
|
||||
Image(systemName: "star")
|
||||
.symbolVariant(index <= item.rating.stars ? .fill : .none)
|
||||
} else {
|
||||
Image(systemName: index <= item.rating.stars ? "star.fill" : "star")
|
||||
}
|
||||
}
|
||||
|
||||
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") {
|
||||
FeedItem(.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..."
|
||||
))
|
||||
}
|
||||
Reference in New Issue
Block a user