-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor: ContactUS - View Model / Async await / View Code #26
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
base: main
Are you sure you want to change the base?
Refactor: ContactUS - View Model / Async await / View Code #26
Conversation
| import Foundation | ||
|
|
||
| protocol ContactUSServiceProtocol { | ||
| func fetch() async throws -> Data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch what?
usa um nome mais claro
|
|
||
| protocol ContactUSServiceProtocol { | ||
| func fetch() async throws -> Data | ||
| func send(with parameters: [String: String]) async throws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send what?
usar um nome mais claro tb
| final class ContactUSService: ContactUSServiceProtocol { | ||
| func fetch() async throws -> Data { | ||
| return try await withCheckedThrowingContinuation { continuation in | ||
| AF.shared.request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ja chegou na parte de parar de usar singleton?
se sim, usar GoodNetworkLayer aqui tb
se n me engano o Jorge tem um PR em q ele usou
se n tiver chegado na parte de remover singlton, pode ignorar
|
|
||
| func send(with parameters: [String: String]) async throws { | ||
| return try await withCheckedThrowingContinuation { continuation in | ||
| AF.shared.request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mesmo comentario acima
| import UIKit | ||
|
|
||
| final class ContactUSView: UIView { | ||
| let symbolConfiguration = UIImage.SymbolConfiguration(pointSize: 36) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tem propriedade com essa e outras que poderiam ser privates
| return stackView | ||
| } | ||
|
|
||
| func createCTAStackView() -> UIStackView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oq é CTA?
lembre que não é bom usar siglas (há raras exceções)
| } | ||
|
|
||
| func fetch() async throws { | ||
| guard let data = try? await serivce.fetch() else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dar uma nome melhor para fetch
nao usar try? opcional, já que a funcao dispara erro
fazer protocol para viewModel (se estiver no contexto desse PR)
| } | ||
|
|
||
| func send(parameters: [String: String]) async throws { | ||
| try? await serivce.send(with: parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
melhorar nome e remover try opcional
| enum LuzContactUsFactory { | ||
| static func make() -> UIViewController { | ||
| let service = ContactUSService() | ||
| let viewModel = LuzContactUSViewModel(serivce: service) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service*
| button.backgroundColor = .systemGray4 | ||
| button.layer.cornerRadius = 10 | ||
| button.addTarget( | ||
| contactUSView.chatButton.addTarget( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contactUsView
| dismiss(animated: true) | ||
| } | ||
|
|
||
| func fetch() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
melhorar nome
| guard | ||
| let message = contactUSView.textView.text, message.isEmpty == false | ||
| else { return } | ||
| let email = model?.mail ?? "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colocar email no guard let tb
| "mensagem": message | ||
| ] | ||
|
|
||
| showLoadingView() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esconder loading ao final da Task
ppedroam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code review 1
Separa as responsabilidades e tarefas que estavam faltando: