Skip to content

Commit

Permalink
feat: Update CharacterDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
xramos committed Apr 8, 2024
1 parent 13e7154 commit f519354
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ import Foundation
struct CharacterDetailLocalization {

let birth = "Birthdate:"
let gender = "Gender:"
let origin = "Origin:"
let alias = "Alias:"
let powers = "Powers:"
let description = "Description:"
}
77 changes: 56 additions & 21 deletions MyComics/MyComics/Scenes/CharacterDetail/CharacterDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,48 +101,83 @@ private extension CharacterDetailView {

titleView(title: viewModel.localization.birth,
value: viewModel.character.birth)
}

titleView(title: viewModel.localization.gender,
value: viewModel.character.getGender())

if !viewModel.character.origin.isEmpty {

titleView(title: viewModel.localization.origin,
value: viewModel.character.origin)
}

if !viewModel.character.aliases.isEmpty {

infoView(title: viewModel.localization.alias,
value: viewModel.character.aliases)
}

if !viewModel.character.getPowers().isEmpty {

infoView(title: viewModel.localization.powers,
value: viewModel.character.getPowers())
}

if !viewModel.character.deck.isEmpty {

Spacer().frame(height: Value.spaceHeight)
infoView(title: viewModel.localization.description,
value: viewModel.character.deck)
}
}
}

func titleView(title: String, value: String) -> some View {

HStack(alignment: .center) {
Group {

VStack(alignment: .leading) {
HStack(alignment: .center) {

Text(title)
.font(.headline)
}

Spacer()

VStack(alignment: .trailing) {
VStack(alignment: .leading) {

Text(title)
.font(.headline)
}

Text(value)
.font(.body)
Spacer()

VStack(alignment: .trailing) {

Text(value)
.font(.body)
}
}

Spacer().frame(height: Value.spaceHeight)
}
}

func infoView(title: String, value: String) -> some View {

HStack(alignment: .center) {
Group {

VStack(alignment: .leading) {

Text(title)
.font(.headline)
HStack(alignment: .center) {

Spacer().frame(height: Value.spaceHeight)
VStack(alignment: .leading) {

Text(title)
.font(.headline)

Spacer().frame(height: Value.spaceHeight)

Text(value)
.font(.body)
}

Text(value)
.font(.body)
Spacer()
}

Spacer()
Spacer().frame(height: Value.spaceHeight)
}
}
}
Expand Down

0 comments on commit f519354

Please sign in to comment.