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

Luizmello/contacts app #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Luizmello/contacts app #1

wants to merge 10 commits into from

Conversation

luizmellodev
Copy link
Collaborator

@luizmellodev luizmellodev commented Jul 1, 2022

Summary

I created an app thats makes an API request presenting a list of users and a user detail navigation. Then I tried removing code smells and simplifying the code. I wasn't able to remove an specific error in the console. The APII has several data (users) coming with different "documentation" (For example, in one user there are results{location {street{name: Street Name}}}, but in others there isn't the street object, it's directly inside the location, which is causing some errors but doesn't affect the application's performance.

I didn't do unit tests for lack of time and for worrying more about turning fetch into async/await.

Items Completed

  • The project builds and runs without any errors or warnings.
    • There are some Errors with API fetch (I tried to solve it but honestly I couldn't)
  • The app runs on a simulator.
  • I've added documentation for my code where necessary.
  • All objects, properties, and methods have clear naming.
  • The app fetches and displays a list of people (users) from the endpoint: https://randomuser.me.
  • A minimum of 10 people are displayed.
  • When displaying a user's detail page, the following are displayed:
    • name
    • photo
    • email
    • phone number
    • address
  • I used async/await for fetching.
  • I created unit tests.

Images/Videos

Users List View User Details View

@luizmellodev luizmellodev added the enhancement New feature or request label Jul 1, 2022
@luizmellodev luizmellodev self-assigned this Jul 1, 2022
Copy link
Contributor

@jonnyholland jonnyholland left a comment

Choose a reason for hiding this comment

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

Overall, it does function as the directions say but there are many areas that need improvement. Specifically, around aesthetics and and simplification. Also, I know you were trying to go above and beyond but taking our image and manipulating it it's appropriate because the splash image (LaunchScreenLogo) doesn't look correct. The golden color is missing within the B. So if it's not correct, we shouldn't use it. Screen Shot 2022-07-02 at 4 28 43 PM

If you read through my comments, you'll see examples of what I had mentioned before in the email about simplifying and cleaning up code. I looked through each file but stopped commenting thoroughly because I realize this is part of a larger discussion we should have. But I wanted to leave some comments you could see some of my feedback. There's a lot that could/should be further simplified and reduced, as well as clarifying naming and overall structure. Those things are not an exact science so they will probably take more time to develop.

But, this is part of the learning process so don't take any of the comments personally. There's many positives too but when we submit code for review, mostly only the negatives get mentioned unfortunately.

let thumbnail: String?
}

struct coordinates: Equatable, Decodable{
Copy link
Contributor

Choose a reason for hiding this comment

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

We should always capitalize objects and keep spacing appropriate.

Suggested change
struct coordinates: Equatable, Decodable{
struct Coordinates: Equatable, Decodable {

let last: String?
}

struct Picture: Equatable, Decodable{
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs spacing

Suggested change
struct Picture: Equatable, Decodable{
struct Picture: Equatable, Decodable {

let longitude: String?
}

struct location: Equatable, Decodable{
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalization and spacing

Suggested change
struct location: Equatable, Decodable{
struct Location: Equatable, Decodable {

let coordinates: coordinates?
}

struct street: Equatable, Decodable{
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalization and spacing

Suggested change
struct street: Equatable, Decodable{
struct Street: Equatable, Decodable {

let picture: Picture
let email: String
let phone: String
let location: location
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let location: location
let location: Location

@State var user: Person
var body: some View {
VStack{
MapView(lat: user.location.coordinates?.latitude, long: user.location.coordinates?.latitude)
Copy link
Contributor

Choose a reason for hiding this comment

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

The maps don't display properly. They seem to not know what to display as the view seems to be in the middle of nowhere.

var body: some View {
AsyncImage(url: URL(string: userImage))
.aspectRatio(contentMode: .fit)
.frame(width: 128, height: 128)
Copy link
Contributor

Choose a reason for hiding this comment

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

To make this reusable, we could remove this so the view that implements it could specify it.

.aspectRatio(contentMode: .fit)
.frame(width: 128, height: 128)
.clipShape(Circle())
.overlay(Circle().stroke(Color.gray, lineWidth: 2))
Copy link
Contributor

Choose a reason for hiding this comment

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

Aesthetically, having the extra circle stroke is a bit confusing.

import SwiftUI
import MapKit

struct MapView: UIViewRepresentable {
Copy link
Contributor

Choose a reason for hiding this comment

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

SwiftUI has a Map object which would be better to use and customize than creating a representable unless we need some specific functionality that the native objects won't give us.


import SwiftUI

struct TestAsync: View {
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't used anywhere in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants