Skip to content

Feature/user profile scene viper - #89

Open
roodrigolemos wants to merge 3 commits into
devpass-tech:mainfrom
roodrigolemos:feature/userProfileSceneViper
Open

roodrigolemos wants to merge 3 commits into
devpass-tech:mainfrom
roodrigolemos:feature/userProfileSceneViper

Conversation

@roodrigolemos

Copy link
Copy Markdown

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 {

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 {

Copy link
Copy Markdown

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)

Copy link
Copy Markdown

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? {

Copy link
Copy Markdown

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 {

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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"

Copy link
Copy Markdown

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 {

Copy link
Copy Markdown

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() {

Copy link
Copy Markdown

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() {

Copy link
Copy Markdown

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