Skip to content

Refactor PetitionsController to use programmatic UI - #26

Merged
hybridcattt merged 5 commits into
developmentfrom
refactor/petitions
Jun 3, 2020
Merged

Refactor PetitionsController to use programmatic UI#26
hybridcattt merged 5 commits into
developmentfrom
refactor/petitions

Conversation

@Kilo-Loco

Copy link
Copy Markdown
Member

This commit is being used to propose a potential MVC design pattern.

  • ViewController is responsible for utilizing services, handling business logic, and providing the view with data
  • View is responsible for laying out subviews and displaying the data that is provided to it. (Views should be dumb and should not implement any business logic)

PLEASE COMMENT ON THIS PR IF YOU DISAGREE WITH THIS PROPOSAL

@jaywardell

Copy link
Copy Markdown
Member

I am doing something very similar in https://github.com/Say-Their-Name/ios/tree/HomeController-programmatic-Layout. Main difference is I broke out a protocol "ServiceClient" from BaseViewController.

@kingsqd

kingsqd commented Jun 3, 2020

Copy link
Copy Markdown
Contributor

I like the approach. One question, do you think we should rename PetitionUI to be something more general so that it can be re-used by the dontations UI. they seem to be very similar according to the mocks

Comment thread Say Their Names/Source/Controller/Petitions/PetitionsController.swift Outdated
Comment thread Say Their Names/Source/Controller/Petitions/PetitionsUI.swift Outdated
@hybridcattt

Copy link
Copy Markdown
Member

it's middle of the night at @Kilo-Loco 's location, @unnamedd would you like to take over and implement the fixes?

@unnamedd

unnamedd commented Jun 3, 2020

Copy link
Copy Markdown
Contributor

it's middle of the night at @Kilo-Loco 's location, @unnamedd would you like to take over and implement the fixes?

Even if I can do it @hybridcattt, I guess the benefit of the code review is the sharing knowledge. I can do, but then I won't have his opinion about it. I rather wait for him.

@hybridcattt

Copy link
Copy Markdown
Member

Your suggestions are minor and very reasonable so I'm sure @Kilo-Loco would not disagree! This project is collaborative so we just try to do our best to move the project forward and release it as soon as reasonably possible 🙂

@hybridcattt hybridcattt added the please take over This PR is free to be continued by someone else while the author is away label Jun 3, 2020

@hybridcattt hybridcattt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noticed an issue with implementation of PetitionsViewCode. Please have a look 🙏

override func layoutSubviews() {
super.layoutSubviews()

setupSubviews()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

layoutSubviews is called quite often, and the setup needs to happen only once. So it's better to put it in setupSelf method instead

/// The UI for Petitions
final class PetitionsViewCode: UIView {

private lazy var petitionsLabel: UILabel = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
private lazy var petitionsLabel: UILabel = {
private let petitionsLabel: UILabel = {

will work the same, just without the ability to accidentally overwrite the variable 🙂

return label
}()

init() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

init(frame: CGRect) will work exactly the same, allowing to use both init() and init(frame:). It's due to how initializers are inherited, can read more here (though it's a long read) : https://docs.swift.org/swift-book/LanguageGuide/Initialization.html

@hybridcattt hybridcattt removed the please take over This PR is free to be continued by someone else while the author is away label Jun 3, 2020
@hybridcattt
hybridcattt merged commit f59a41d into development Jun 3, 2020
@evilpenguin
evilpenguin deleted the refactor/petitions branch June 6, 2020 16:48
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.

6 participants