diff --git a/Rick-and-Morty/Rick And Morty/Views/CharacterCell.swift b/Rick-and-Morty/Rick And Morty/Views/CharacterCell.swift index 56812a5..e1b23ec 100644 --- a/Rick-and-Morty/Rick And Morty/Views/CharacterCell.swift +++ b/Rick-and-Morty/Rick And Morty/Views/CharacterCell.swift @@ -26,7 +26,7 @@ struct CharacterCell: View { VStack(alignment: .leading, spacing: 8) { Text(character.name) - Text(description(for: character)) + description(for: character) } if imagePosition == .right { @@ -39,12 +39,12 @@ struct CharacterCell: View { .buttonStyle(PlainButtonStyle()) } - func description(for character: Character) -> String { + func description(for character: Character) -> Text { if let c = character as? ShortCharacterDescription { - return c.shortDescription + return Text(c.shortDescription) } - return character.description + return Text(character.description) } } diff --git a/Rick-and-Morty/Rick And Morty/Views/CharacterDetailView.swift b/Rick-and-Morty/Rick And Morty/Views/CharacterDetailView.swift index c419143..b922026 100644 --- a/Rick-and-Morty/Rick And Morty/Views/CharacterDetailView.swift +++ b/Rick-and-Morty/Rick And Morty/Views/CharacterDetailView.swift @@ -17,10 +17,14 @@ struct CharacterDetailView: View { .resizable() .scaledToFit() .frame(maxHeight: 200) - HStack { + + VStack(alignment: .leading, spacing: 12) { + if let c = character as? ShortCharacterDescription { + Text(c.shortDescription) + } Text(character.description) - Spacer() } + Spacer() } .padding() @@ -30,7 +34,12 @@ struct CharacterDetailView: View { struct CharacterDetailView_Previews: PreviewProvider { static var previews: some View { - CharacterDetailView(character: ricks[0]) - CharacterDetailView(character: morties[0]) + NavigationView { + CharacterDetailView(character: ricks[0]) + } + NavigationView { + CharacterDetailView(character: morties[2]) + + } } }