-
Notifications
You must be signed in to change notification settings - Fork 44
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
implement navbutton to userProfile #75
base: main
Are you sure you want to change the base?
Conversation
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setupHierarchy() |
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.
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() | |
} |
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.
Alterado.
setupHierarchy() | ||
setupConstraints() | ||
} | ||
|
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.
opa, aqui talvez poderiamos colocar o @available(*,unavailable). O que acha ?
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.
Colocado. Faz sentido.
override public func configureView(_ viewModel: ViewModel?) { | ||
// Configure | ||
} | ||
|
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.
opa @GusRigor, poderiamos remover esse espaço a mais ?
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.
É 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhh boa!! Olha, por mim pode deixar
|
||
import UIKit | ||
|
||
class ProfileButtonView: CodeBaseView<ProfileButtonView.ViewModel> { |
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.
[QUESTION]
Hmmm, aqui poderia ser final ?
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.
Faz todo sentido.
61ebf50
to
3a978c7
Compare
@@ -40,4 +41,17 @@ class HomeViewController: UIViewController { | |||
override func loadView() { | |||
self.view = homeView | |||
} | |||
|
|||
private func setupProfileImage() { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Como não é public
, não precisa do init
} | ||
|
||
enum Constants { | ||
static let imageName: String = "avatar-placeholder" |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executar esse setup no configureViews
} | ||
|
||
override public func configureView(_ viewModel: ViewModel?) { | ||
// Configure |
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.
Implementar o setup da view model.
ProfileButtonView