Integrated the StarRating component from the UI library into the FeedItemCell component in the Feed framework.

This commit is contained in:
Javier Cicchelli 2024-03-20 00:49:40 +01:00
parent 2313afb8c4
commit 32c0ef500d
3 changed files with 33 additions and 8 deletions

View File

@ -0,0 +1,16 @@
//
// Int+Constants.swift
// ReviewsFeed
//
// Created by Javier Cicchelli on 19/03/2024.
// Copyright © 2024 Röck+Cöde. All rights reserved.
//
extension Int {
// MARK: Constants
enum Rating {
static let total: Int = 5
}
}

View File

@ -6,6 +6,7 @@
// Copyright © 2024 Röck+Cöde. All rights reserved.
//
import ReviewsUIKit
import SwiftUI
struct FeedItemCell: View {
@ -48,14 +49,10 @@ struct FeedItemCell: View {
.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")
}
}
StarRating(
item.rating.stars,
of: .Rating.total
)
Spacer()

View File

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
0220ADA32BA90646001E6A9F /* FeedItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0220ADA22BA90646001E6A9F /* FeedItemCell.swift */; };
023AC7FC2BAA3EC10027D064 /* Int+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */; };
02620B8C2BA89C9A00DE7137 /* FeedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */; };
02DC7F9F2BA51793000EEEBE /* ReviewsFeed.h in Headers */ = {isa = PBXBuildFile; fileRef = 02DC7F912BA51793000EEEBE /* ReviewsFeed.h */; settings = {ATTRIBUTES = (Public, ); }; };
02DC7FA22BA51793000EEEBE /* ReviewsFeed.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */; };
@ -48,6 +49,7 @@
/* Begin PBXFileReference section */
0220ADA22BA90646001E6A9F /* FeedItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedItemCell.swift; sourceTree = "<group>"; };
023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+Constants.swift"; sourceTree = "<group>"; };
02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewModel.swift; sourceTree = "<group>"; };
02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReviewsFeed.framework; sourceTree = BUILT_PRODUCTS_DIR; };
02DC7F912BA51793000EEEBE /* ReviewsFeed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReviewsFeed.h; sourceTree = "<group>"; };
@ -91,6 +93,14 @@
path = Cells;
sourceTree = "<group>";
};
023AC7FA2BAA3EB60027D064 /* Extensions */ = {
isa = PBXGroup;
children = (
023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
02620B852BA89BF900DE7137 /* UI */ = {
isa = PBXGroup;
children = (
@ -103,6 +113,7 @@
02620B862BA89C0000DE7137 /* Logic */ = {
isa = PBXGroup;
children = (
023AC7FA2BAA3EB60027D064 /* Extensions */,
02620B8A2BA89C3300DE7137 /* Models */,
02620B872BA89C0700DE7137 /* View Models */,
);
@ -374,6 +385,7 @@
buildActionMask = 2147483647;
files = (
02620B8C2BA89C9A00DE7137 /* FeedViewModel.swift in Sources */,
023AC7FC2BAA3EC10027D064 /* Int+Constants.swift in Sources */,
02DC7FAC2BA51B4C000EEEBE /* FeedItemViewController.swift in Sources */,
0220ADA32BA90646001E6A9F /* FeedItemCell.swift in Sources */,
02DC7FAF2BA51B4C000EEEBE /* Review.swift in Sources */,