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 [RM75] Character Card #76

Merged
merged 4 commits into from
Aug 12, 2021
Merged

Conversation

swg99
Copy link
Contributor

@swg99 swg99 commented Aug 10, 2021

https://github.com/orgs/novoda/projects/1#card-66556830
Built a character card displaying an image and relevant data about a character.

Instead of using the term "tiles" now using "cards"
@swg99 swg99 requested a review from MiWierzbinski August 10, 2021 13:00
@swg99 swg99 linked an issue Aug 10, 2021 that may be closed by this pull request
Copy link
Contributor

@wrumble wrumble left a comment

Choose a reason for hiding this comment

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

A few duplication comments from me. If its a UI change and its possible for a screen shot id always recommend adding that to the PR description too to help the reviewer :)

Comment on lines 25 to 27
private let cornerRadius: CGFloat = 10
private let noSpacing: CGFloat = 0
private let VSpacing: CGFloat = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

Id probably extract these into their own private constants struct. Something we do on Glovo which i quite like, except they use an enum which i dont like.

private struct Constants {
    let cornerRadius: CGFloat = 10
    let noSpacing: CGFloat = 0
    let VSpacing: CGFloat = 10
}

then id add the other magic numbers dotted around to it too like on line 43, 67 &70

Comment on lines 55 to 59
VStack(alignment: .leading, spacing: noSpacing) {
Text("First seen in:")
.font(.caption)
.foregroundColor(.secondary)
Text(characterCardState.firstEpisode)
Copy link
Contributor

Choose a reason for hiding this comment

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

The duplication here could be extracted to a function. I havent played with SwiftUI to know enough but roughly along the lines of:

func characterDetailsVStack(pretext: String, details: String) -> VStack {
    return VStack(alignment: .leading, spacing: noSpacing) {
                    Text(pretext)
                        .font(.caption)
                        .foregroundColor(.secondary)
                    Text(details)
}

then called:

    characterDetailsVStack(pretext: "Last known location:", details: characterCardState.lastLocation)
    characterDetailsVStack(pretext: "First seen in:", details: characterCardState.firstEpisode)

Copy link
Contributor

Choose a reason for hiding this comment

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

Id maybe even consider putting those strings as constants too, or prep them for localisation 🤷

Comment on lines 77 to 88
VStack {
CharacterCard(characterCardState: CharacterCardState(id: 2, name: "Morty", image: UIImage(named: "morty-image")!, isAlive: true, species: "Human", lastLocation: "Earth", firstEpisode: "Episode 1"))
CharacterCard(characterCardState: CharacterCardState(id: 2, name: "Morty", image: UIImage(named: "morty-image")!, isAlive: false, species: "Human", lastLocation: "Earth", firstEpisode: "Episode 1"))
CharacterCard(characterCardState: CharacterCardState(id: 2, name: "Morty", image: UIImage(named: "morty-image")!, isAlive: true, species: "Human", lastLocation: "Earth", firstEpisode: "Episode 1"))
}
.preferredColorScheme(.light)
VStack {
CharacterCard(characterCardState: CharacterCardState(id: 2, name: "Morty", image: UIImage(named: "morty-image")!, isAlive: true, species: "Human", lastLocation: "Earth", firstEpisode: "Episode 1"))
CharacterCard(characterCardState: CharacterCardState(id: 2, name: "Morty", image: UIImage(named: "morty-image")!, isAlive: false, species: "Human", lastLocation: "Earth", firstEpisode: "Episode 1"))
CharacterCard(characterCardState: CharacterCardState(id: 2, name: "Morty", image: UIImage(named: "morty-image")!, isAlive: true, species: "Human", lastLocation: "Earth", firstEpisode: "Episode 1"))
}
.preferredColorScheme(.dark)
Copy link
Contributor

Choose a reason for hiding this comment

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

Theres duplication here, try and use my above example to see what functions you can create for the VStack and CharacterCard duplications :)

@swg99 swg99 merged commit d095df7 into scottie-main Aug 12, 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.

Build CharacterTile
2 participants