Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature [RM79] Character List View Model #82

Merged
merged 2 commits into from
Aug 19, 2021

Conversation

swg99
Copy link
Contributor

@swg99 swg99 commented Aug 13, 2021

https://github.com/orgs/novoda/projects/1#card-66586073
Built a view model which provides card states to the character list view. A card state factory was also built for utility.

ViewModel provides characterCardStates
Changed from get to load considering function does not return anything
@swg99 swg99 linked an issue Aug 13, 2021 that may be closed by this pull request
Comment on lines +38 to +40
//Image(uiImage: characterCardState.image)
//.resizable()
//.aspectRatio(contentMode: .fit)

Choose a reason for hiding this comment

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

They not to commit commented out code.

Comment on lines +12 to +18
private func getIsAlive(character: Character) -> Bool {
if character.status == "Alive" {
return true
}

return false
}

Choose a reason for hiding this comment

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

If I remember correctly there is also state unknown. is the bool correct choice here?

Comment on lines +20 to +26
private func getFirstEpisode(character: Character) -> String? {
if let firstEpisode = character.episodeURLs.first {
return firstEpisode
}

return nil
}

Choose a reason for hiding this comment

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

If you're returning nil this code doesn't do anything. you could just call character.episodeURLs.first


func loadCardStates() {
characterRepository.getCharacters { characters in
for character in characters {

Choose a reason for hiding this comment

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

What do you think about using .map here

@swg99 swg99 merged commit 2dc1b80 into scottie-main Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BuildCharacterListViewModel
2 participants