Skip to content

feature/grand-prix-card-view#10

Open
tmsm1999 wants to merge 3 commits intodevelopfrom
feature/schedule-carousel-component
Open

feature/grand-prix-card-view#10
tmsm1999 wants to merge 3 commits intodevelopfrom
feature/schedule-carousel-component

Conversation

@tmsm1999
Copy link
Owner

No description provided.

@tmsm1999 tmsm1999 self-assigned this Jan 17, 2023
@tmsm1999 tmsm1999 changed the base branch from main to develop January 19, 2023 10:17
@tmsm1999 tmsm1999 changed the title feature/schedule-carousel-component feature/grand-prix-card-view Jan 19, 2023
@tmsm1999 tmsm1999 requested a review from Mteixeira88 January 19, 2023 10:18
Comment on lines +12 to +16
static let eventTitleFont: Self = Font.system(.title3, weight: .bold)
static let eventRoundNumberFont: Self = Font.body.italic()
static let liveSessionTitleFont: Self = Font.body.bold()
static let chevronRightFont: Self = Font.largeTitle
static let liveTextFont: Self = Font.body.bold()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need Font. you can simply have the value 💅


protocol EventStatusBackgroundStylerRepresentable {

var eventStatus: GrandPrixCardViewModel.EventStatus { get }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really a fan of having a Representable consuming another viewModel type 😕, more, in this particular case a Styler should be fully independent to be able to be used everywhere you want, so you have 2 solutions here:

1- Maybe this should be part of the Sessions Model or any other Model that makes sense
2 - Put this inside the EventStatusBackgroundStyler

let id: String // Driver Ticker
let value: Value

enum Value: Comparable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can conform to Int, like that it would be easier to instantiate it when having the results from the API

Suggested change
enum Value: Comparable {
enum Value: Int, Comparable {
case first = 1
case second = 2
case third = 3
....
}
.init(driverTicker: "ALO", value: .init(rawValue: sessionResult.position)) // postion = 1,2,3...

Copy link
Owner Author

@tmsm1999 tmsm1999 Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new property called driverTicker and now the id property is instantiated to UUID().uuidString. We need to review this together to make sure everything is ok.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, whenever you want 🙂

var currentSessionTitle: String? { get }
var currentSessionDetails: String? { get }

var drivers: [DriverResult]? { get }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove the optional from here? 🤔

init(
round: Int,
title: String,
grandPrixDate: String? = .none,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +35 to +42
case .live, .current:
if let title = viewModel.currentSessionTitle, let details = viewModel.currentSessionDetails {
sessionDetailsComponent(title: title, details: details)
}
case .upcoming:
if let details = viewModel.currentSessionDetails {
sessionDetailsComponent(details: details)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case .live, .current:
if let title = viewModel.currentSessionTitle, let details = viewModel.currentSessionDetails {
sessionDetailsComponent(title: title, details: details)
}
case .upcoming:
if let details = viewModel.currentSessionDetails {
sessionDetailsComponent(details: details)
}
case .live, .current, .upcoming:
if let details = viewModel.currentSessionDetails {
sessionDetailsComponent(title: viewModel.eventStatus == .upcoming ? nil : viewModel.currentSessionTitle, details: details)
}

Another way simpler to do this is you probably should fire the title and the details from the enum itself, meaning the enum should be something like

enum Status {
  case live(String, Details)
  case current(String, Details)
  case upcoming(Details)
  case finished([DriverResult])
}

and like this you don't need half of the properties you have inside the VM and you simply use the enum to build your views.

What do you think?

.font(.liveSessionTitleFont)
}

if viewModel.eventStatus == .live || viewModel.eventStatus == .upcoming {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be getting this wrong but this info should come from the main view that uses the function, the function should not have this kind of logic, at least related to the Status that is something already handled in the main view

@Mteixeira88
Copy link
Collaborator

Great work as always keep pushing 👏👏👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants