Skip to content

Commit 9c8b5c6

Browse files
ALFMOB-162: Code review
1 parent ff21723 commit 9c8b5c6

15 files changed

Lines changed: 45 additions & 192 deletions

File tree

Alfie/Alfie/Navigation/Coordinator.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ final class Coordinator: ObservableObject, CoordinatorProtocol {
136136
// MARK: - Product Details
137137

138138
public func openDetails(for productId: String) {
139-
navigationAdapter.push(.productDetails(.id(productId)))
139+
navigationAdapter.push(.productDetails(configuration: .id(productId)))
140140
}
141141

142142
public func openDetails(for product: Product) {
143-
navigationAdapter.push(.productDetails(.product(product)))
143+
navigationAdapter.push(.productDetails(configuration: .product(product)))
144144
}
145145

146146
public func openDetails(for selectedProduct: SelectedProduct) {
147-
navigationAdapter.push(.productDetails(.selectedProduct(selectedProduct)))
147+
navigationAdapter.push(.productDetails(configuration: .selectedProduct(selectedProduct)))
148148
}
149149

150150
// MARK: - Brands

Alfie/Alfie/Navigation/DeepLinking/DeepLinkHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ final class DeepLinkHandler: DeepLinkHandlerProtocol {
8787

8888
case .productDetail(let productId, _, _, _):
8989
// TODO: currently the API does not support fetching a product by the StyleNumber (that is parsed from the URL), just by ProductID, so all requests will return "not found"
90-
target = Screen.productDetails(.id(productId))
90+
target = Screen.productDetails(configuration: .id(productId))
9191

9292
case .webView(let url):
9393
target = Screen.webView(url: url, title: "")

Alfie/Alfie/Navigation/Screen.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum Screen: ScreenProtocol {
1313
case recentSearches
1414
case forceAppUpdate
1515
case debugMenu
16-
case productDetails(_ type: ThemedProductDetailsScreen)
16+
case productDetails(configuration: ProductDetailsConfiguration)
1717
case productListing(configuration: ProductListingScreenConfiguration)
1818
case categoryList(_ categories: [NavigationItem], title: String)
1919

@@ -35,18 +35,18 @@ enum TabScreen: ScreenProtocol {
3535
static let allCases: [TabScreen] = [.home(), .shop(), .wishlist, .bag]
3636
}
3737

38-
enum HomeTabConfig: Equatable, Hashable {
38+
enum HomeTabConfig: Hashable {
3939
case loggedIn(username: String, memberSince: Int)
4040
case loggedOut
4141
}
4242

43-
enum ThemedProductDetailsScreen: Equatable, Hashable {
43+
enum ProductDetailsConfiguration: Hashable {
4444
case id(_ id: String)
4545
case product(_ product: Product)
4646
case selectedProduct(_ selectedProduct: SelectedProduct)
4747
}
4848

49-
struct ProductListingScreenConfiguration: Equatable, Hashable {
49+
struct ProductListingScreenConfiguration: Hashable {
5050
let category: String?
5151
let searchText: String?
5252
let urlQueryParameters: [String: String]?

Alfie/Alfie/Navigation/ViewFactory.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ final class ViewFactory: ViewFactoryProtocol {
124124
case .wishlist:
125125
wishlistView
126126

127-
case .productDetails(let type):
127+
case .productDetails(let configuration):
128128
ProductDetailsView(
129129
viewModel: ProductDetailsViewModel(
130-
productKind: type,
130+
productDetailsConfiguration: configuration,
131131
dependencies: ProductDetailsDependencyContainer(
132132
productService: serviceProvider.productService,
133133
webUrlProvider: serviceProvider.webUrlProvider,

Alfie/Alfie/Views/ProductDetails/ProductDetailsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct ProductDetailsView<ViewModel: ProductDetailsViewModelProtocol>: View {
7373
.writingSize(to: $viewSize)
7474
}
7575
}
76-
.withToolbar(for: .productDetails(.id(viewModel.productId)))
76+
.withToolbar(for: .productDetails(configuration: .id(viewModel.productId)))
7777
.toolbar {
7878
if !viewModel.state.didFail {
7979
ToolbarItem(placement: .principal) {

Alfie/Alfie/Views/ProductDetails/ProductDetailsViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ final class ProductDetailsViewModel: ProductDetailsViewModelProtocol {
8989
}
9090

9191
init(
92-
productKind: ThemedProductDetailsScreen,
92+
productDetailsConfiguration: ProductDetailsConfiguration,
9393
dependencies: ProductDetailsDependencyContainer
9494
) {
9595
self.dependencies = dependencies
9696

97-
switch productKind {
97+
switch productDetailsConfiguration {
9898
case .id(let productId):
9999
self.productId = productId
100100
self.initialSelectedProduct = nil

Alfie/AlfieKit/Sources/Models/Models/Base/Brand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct Brand: Identifiable, Equatable {
3+
public struct Brand: Identifiable, Hashable {
44
/// The ID for the brand
55
public let id: String
66
/// The display name of the brand

Alfie/AlfieKit/Sources/Models/Models/Base/Media.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public enum Media: Equatable, Hashable {
3+
public enum Media: Hashable {
44
case image(MediaImage)
55
case video(MediaVideo)
66

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct MediaImage: Equatable, Hashable {
3+
public struct MediaImage: Hashable {
44
/// A description of the contents of the image for accessibility purposes.
55
public let alt: String?
66
/// The media content type.
@@ -13,16 +13,4 @@ public struct MediaImage: Equatable, Hashable {
1313
self.mediaContentType = mediaContentType
1414
self.url = url
1515
}
16-
17-
public static func == (lhs: MediaImage, rhs: MediaImage) -> Bool {
18-
lhs.alt == rhs.alt
19-
&& lhs.mediaContentType == rhs.mediaContentType
20-
&& lhs.url == rhs.url
21-
}
22-
23-
public func hash(into hasher: inout Hasher) {
24-
hasher.combine(alt)
25-
hasher.combine(mediaContentType)
26-
hasher.combine(url)
27-
}
2816
}
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct MediaVideo: Equatable, Hashable {
3+
public struct MediaVideo: Hashable {
44
/// A description of the contents of the video for accessibility purposes.
55
public let alt: String?
66
/// The media content type.
@@ -16,23 +16,9 @@ public struct MediaVideo: Equatable, Hashable {
1616
self.previewImage = previewImage
1717
self.sources = sources
1818
}
19-
20-
public static func == (lhs: MediaVideo, rhs: MediaVideo) -> Bool {
21-
lhs.alt == rhs.alt
22-
&& lhs.mediaContentType == rhs.mediaContentType
23-
&& lhs.previewImage == rhs.previewImage
24-
&& lhs.sources == rhs.sources
25-
}
26-
27-
public func hash(into hasher: inout Hasher) {
28-
hasher.combine(alt)
29-
hasher.combine(mediaContentType)
30-
hasher.combine(previewImage)
31-
hasher.combine(sources)
32-
}
3319
}
3420

35-
public struct VideoSource: Equatable, Hashable {
21+
public struct VideoSource: Hashable {
3622
public enum VideoFormat: String {
3723
case mp4 = "MP4"
3824
case webm = "WEBM"
@@ -51,16 +37,4 @@ public struct VideoSource: Equatable, Hashable {
5137
self.mimeType = mimeType
5238
self.url = url
5339
}
54-
55-
public static func == (lhs: VideoSource, rhs: VideoSource) -> Bool {
56-
lhs.format == rhs.format
57-
&& lhs.mimeType == rhs.mimeType
58-
&& lhs.url == rhs.url
59-
}
60-
61-
public func hash(into hasher: inout Hasher) {
62-
hasher.combine(format)
63-
hasher.combine(mimeType)
64-
hasher.combine(url)
65-
}
6640
}

0 commit comments

Comments
 (0)