implement navbutton to userProfile#75
Conversation
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| setupHierarchy() |
There was a problem hiding this comment.
opa @GusRigor, acha que seria interessante criar uma função chamada setup() onde teria esse dois métodos ? E no caso, dentro do init chamariamos apenas o setup() assim deixaríamos o init mais "limpo" :D
| setupHierarchy() | |
| func setup() { | |
| setupHierarchy() | |
| setupConstraints() | |
| } |
| setupHierarchy() | ||
| setupConstraints() | ||
| } | ||
|
|
There was a problem hiding this comment.
opa, aqui talvez poderiamos colocar o @available(*,unavailable). O que acha ?
| override public func configureView(_ viewModel: ViewModel?) { | ||
| // Configure | ||
| } | ||
|
|
There was a problem hiding this comment.
opa @GusRigor, poderiamos remover esse espaço a mais ?
There was a problem hiding this comment.
É uma prática que eu curto fazer. (Coisa de maluco). A ideia é ter uma linha a mais no começo e no final para fica mais fácil de ver até onde é classe até onde é implementação de função. Me ajuda na hora de bater o olho e ver o código verticalmente.
Mas se quiserem eu tiro.
There was a problem hiding this comment.
Ahhhh boa!! Olha, por mim pode deixar
|
|
||
| import UIKit | ||
|
|
||
| class ProfileButtonView: CodeBaseView<ProfileButtonView.ViewModel> { |
There was a problem hiding this comment.
[QUESTION]
Hmmm, aqui poderia ser final ?
61ebf50 to
3a978c7
Compare
| self.view = homeView | ||
| } | ||
|
|
||
| private func setupProfileImage() { |
There was a problem hiding this comment.
Seria bom implementar esse bar button como uma variável ao invés de uma função.
| struct ViewModel { | ||
| let image: String | ||
|
|
||
| init(image: String) { |
There was a problem hiding this comment.
Como não é public, não precisa do init
| } | ||
|
|
||
| enum Constants { | ||
| static let imageName: String = "avatar-placeholder" |
There was a problem hiding this comment.
Como é um conteúdo variável, pode ser injetado como propriedade
|
|
||
| private lazy var profileButton: UIButton = { | ||
| let button = UIButton() | ||
| button.frame = CGRectMake(.zero, .zero, Constants.imageHeight, Constants.imageWidth) |
There was a problem hiding this comment.
Tentar com intrinsicContentSize em vez do frame.
| let button = UIButton() | ||
| button.frame = CGRectMake(.zero, .zero, Constants.imageHeight, Constants.imageWidth) | ||
| let image = UIImage(named: Constants.imageName) | ||
| if let image = image { |
There was a problem hiding this comment.
Executar esse setup no configureViews
| } | ||
|
|
||
| override public func configureView(_ viewModel: ViewModel?) { | ||
| // Configure |
ProfileButtonView
