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

Feature/user profile scene viper #89

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

Conversation

roodrigolemos
Copy link

Descrição simples da nova feature

Implement viper on user profile screen.

Checklist:

Coloque um x nas caixas que se aplicam.

  • Não adiciona código duplicado
  • Não contém código comentado
  • Não contém código WIP

Evidências da feature:

Simulator Screen Recording - iPhone 14 Pro - 2022-11-23 at 17 25 04

func fetchUserProfile()
}

protocol UserProfileInteractorOutput: AnyObject {

Choose a reason for hiding this comment

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

Seria bom ter um método pra retornar um erro para a Presenter e apresentar alguma interface de erro na tela.

extension UserProfileInteractor: UserProfileInteractorInput {

func fetchUserProfile() {
service.fetchUserProfile { userProfile in

Choose a reason for hiding this comment

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

Adicionar weak self pra evitar retain cycle

Choose a reason for hiding this comment

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

Também fazer uma verificação da própria instância por meio de guard let self


import UIKit

protocol UserProfilePresenterInput {

Choose a reason for hiding this comment

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

OBS: Esses dois métodos podem estar num protocolo pai da Presenter

}

protocol UserProfilePresenterOutput: AnyObject {
func updateUI(userProfileViewModel: UserProfileViewModel)

Choose a reason for hiding this comment

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

Apagar a propriedade privada userProfileViewModel da Presenter, ou deixá-la internal de modo que a View possa acessá-la e ser apenas notificada pra atualizar a interface por uma função vazia.

private let interactor: UserProfileInteractorInput
private let router: UserProfileRouterInput

private var userProfileViewModel: UserProfileViewModel? {

Choose a reason for hiding this comment

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

Em vez de pegar cada dado da ViewModel dependendo do índice, não é melhor criar um array de chaves e valores e pra cada indexPath, você pega a chave e valor naquele índice e salva na célula?


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .value1, reuseIdentifier: "Cell")
switch indexPath.row {

Choose a reason for hiding this comment

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

let cell = UITableViewCell() cell.textLabel.text = viewModel[indexPath.row].key cell.detailsLabel.text = viewModel[indexPath.row].value return cell

}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3

Choose a reason for hiding this comment

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

Retornar o tamanho do array.

}

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "My account"

Choose a reason for hiding this comment

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

Salvar numa constante na Presenter

}
}

extension UserProfilePresenter: UITableViewDelegate {

Choose a reason for hiding this comment

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

Remover protocolos vazios não implementados

weak var view: UserProfileViewController?

func createModule() {

Choose a reason for hiding this comment

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

Retornar o output do Factory aqui.


}

func navigate() {

Choose a reason for hiding this comment

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

Pode remover este método.

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

Successfully merging this pull request may close these issues.

2 participants