Code Monkey home page Code Monkey logo

dailyuniverse's Introduction

DailyUniverse

👷‍♂️🛠 App under construction

iOS App that shows a picture of an astronomical phenomenon and a brief explanation of it everyday.

Daily Universe has three main functionalities:

  • Shows one astronomical picture per day, along with its title and a brief explanation of the phenomenon depicted. These elements are presented in the form of a card.
  • Allows the user to save a card on the app for accessing it later.
  • Allows the user to share the informations in the card on a social media platform.

The data comes from NASA's Astronomy Picture of the Day (APOD) microservice, available as this GitHub repo.

dailyuniverse's People

Contributors

pedrohgmuniz avatar

Stargazers

Sarah Madalena avatar Nillia Sousa avatar Ana Guimarães  avatar  avatar

Watchers

James Cloos avatar  avatar

dailyuniverse's Issues

Refatorar a camada da API

private func makeRequest() {
let url = URL(string: "https://api.nasa.gov/planetary/apod?api_key=wecxoRe6g4DvX2KBDWxsCOQmtQJABHGjilEutoZB")!
let task: URLSessionDataTask = URLSession.shared.dataTask(
with: url,
completionHandler: { (data, response, error) in
print("response: \(String(describing: response))")
print("error: \(String(describing: error))")
guard let responseData = data else { return }
do {
let post = try JSONDecoder().decode(Post.self, from: responseData)
self.post = post
if let url = URL(string: post.hdurl) {
self.makeRequestOfImage(url: url)
}
print("objects returned: \(post)")
} catch let error {
print("error: \(error)")
}
}
)
task.resume()
}

Oie Pedro, assim nessa parte que tu faz de uma forma que pode ficar mais difícil de ler, e que pra mim o ideal seria tu criar uma classe e nela tu tem URLComponents assim:

class API{
    public static func pegaTodosPeople() async -> [People] {
        var urlComponents = URLComponents()
        urlComponents.scheme = "https"
        urlComponents.host = "swapi.dev"
        urlComponents.path = "/api/people/"
        let url: URL = urlComponents.url!
        var urlRequest = URLRequest(url:url)
        
        urlRequest.httpMethod = "GET"
        urlRequest.allHTTPHeaderFields = [   //Consiguracao do Header e o tipo de conteudo
            "Content-Type" : "application/json"
        ]
        do {
            let (data, _) = try await URLSession.shared.data(for: urlRequest)
            // Cria a sessao e faz a requisicao
            let response  = try JSONDecoder().decode(Response.self, from: data)
            let characters = response.results
            // descodifica os dados da requisicao
            return characters
        } catch {
            print(error)
            return []
        }
        
    }

SwiftLint

Oi, Pedro! Tudo bem?

Muito massa teu projeto! Tá bem fácil de ler o código, bem enxuto, mesmo com os comentários. Parabéns!

Uma coisa que eu diria ser super importante pra continuar mantendo os códigos limpos e no padrão é usar SwiftLint. Notei que tu não adicionou no teu projeto, então vou deixar aqui o link com os Docs, beleza? Pra instalar, eu usei o brew, mas tu podes usar qualquer uma das opções que eles dão na documentação. Qualquer dúvida, pode me chamar!

https://github.com/realm/SwiftLint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.