diff --git a/Frameworks/Feed/Bundle/Sources/Logic/Extensions/Int+Constants.swift b/Frameworks/Feed/Bundle/Sources/Logic/Extensions/Int+Constants.swift new file mode 100644 index 0000000..1c6f9b2 --- /dev/null +++ b/Frameworks/Feed/Bundle/Sources/Logic/Extensions/Int+Constants.swift @@ -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 + } + +} diff --git a/Frameworks/Feed/Bundle/Sources/UI/Components/Cells/FeedItemCell.swift b/Frameworks/Feed/Bundle/Sources/UI/Components/Cells/FeedItemCell.swift index 7225169..e37339c 100644 --- a/Frameworks/Feed/Bundle/Sources/UI/Components/Cells/FeedItemCell.swift +++ b/Frameworks/Feed/Bundle/Sources/UI/Components/Cells/FeedItemCell.swift @@ -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() diff --git a/Reviews.xcodeproj/project.pbxproj b/Reviews.xcodeproj/project.pbxproj index 4eadb43..7bcda2a 100644 --- a/Reviews.xcodeproj/project.pbxproj +++ b/Reviews.xcodeproj/project.pbxproj @@ -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 = ""; }; + 023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+Constants.swift"; sourceTree = ""; }; 02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewModel.swift; sourceTree = ""; }; 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 = ""; }; @@ -91,6 +93,14 @@ path = Cells; sourceTree = ""; }; + 023AC7FA2BAA3EB60027D064 /* Extensions */ = { + isa = PBXGroup; + children = ( + 023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */, + ); + path = Extensions; + sourceTree = ""; + }; 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 */,