Skip to content

Commit

Permalink
sort pokemons, fix imageview, fix detailview
Browse files Browse the repository at this point in the history
  • Loading branch information
xramos committed May 30, 2022
1 parent 2f14324 commit 4e1f14f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
12 changes: 4 additions & 8 deletions Pokemon/Pokemon/Scenes/Backpack/BackpackViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ class BackpackViewModel: ObservableObject {
state = .loading

pokemons = GetPokemonsUseCase().execute()

// Sort by id
pokemons = pokemons.sorted(by: { $0.id < $1.id })

if pokemons.isEmpty {

state = .empty

} else {

state = .loaded
}
state = pokemons.isEmpty ? .empty : .loaded
}
}
43 changes: 24 additions & 19 deletions Pokemon/Pokemon/Scenes/PokemonDetail/PokemonDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,37 @@ struct PokemonDetailView: View {

var body: some View {

VStack {
GeometryReader { proxy in

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

ImageView(withURL: viewModel.pokemon.url)
Spacer()

VStack(alignment: .leading, spacing: 4) {
VStack {

TitleView(title: viewModel.pokemon.name)
ImageView(withURL: viewModel.pokemon.url)
.frame(width: proxy.size.width * 0.7)

TitleValueView(title: "Weight:", value: "\(viewModel.pokemon.weight)")

TitleValueView(title: "Height: ", value: "\(viewModel.pokemon.height)")

TitleValueView(title: "Experience:", value: "\(viewModel.pokemon.experience)")

TitleValueView(title: "Caught on:", value: "\(viewModel.pokemon.date)")

TitleValueView(title: "Types:", value: "\(viewModel.pokemon.types)")

Spacer().frame(height: 10)
VStack(alignment: .leading, spacing: 4) {

TitleView(title: viewModel.pokemon.name)

TitleValueView(title: "Weight:", value: "\(viewModel.pokemon.weight)")

TitleValueView(title: "Height: ", value: "\(viewModel.pokemon.height)")

TitleValueView(title: "Experience:", value: "\(viewModel.pokemon.experience)")

TitleValueView(title: "Caught on:", value: "\(viewModel.pokemon.date)")

TitleValueView(title: "Types:", value: "\(viewModel.pokemon.types)")
}
.padding(20)
}
.padding([.leading, .trailing, .bottom], 10)
.pokemonBackground()

Spacer()
}
.pokemonBackground()
.padding(.bottom, 20)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Pokemon/Views/ImageView/ImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct ImageView: View {

Image(uiImage: image)
.resizable()
.aspectRatio(contentMode: .fill)
.aspectRatio(contentMode: .fit)

}.onReceive(imageLoader.didChange) { data in

Expand Down

0 comments on commit 4e1f14f

Please sign in to comment.